From 5b67026507e032fca84f5c0c6b2bb7b826eb435c Mon Sep 17 00:00:00 2001 From: Hovn Date: Sun, 17 Jul 2022 13:50:50 +0800 Subject: [PATCH] Optimize code --- .../nekosms/app/SettingsFragment.java | 20 ++----------------- .../main/res/{xml => xml-v25}/shortcuts.xml | 0 .../settings_notifications.xml} | 9 ++++++++- 3 files changed, 10 insertions(+), 19 deletions(-) rename app/src/main/res/{xml => xml-v25}/shortcuts.xml (100%) rename app/src/main/res/{xml/settings_notifications_v26.xml => xml-v26/settings_notifications.xml} (58%) diff --git a/app/src/main/java/com/crossbowffs/nekosms/app/SettingsFragment.java b/app/src/main/java/com/crossbowffs/nekosms/app/SettingsFragment.java index 9c01374..4bbf0a2 100644 --- a/app/src/main/java/com/crossbowffs/nekosms/app/SettingsFragment.java +++ b/app/src/main/java/com/crossbowffs/nekosms/app/SettingsFragment.java @@ -1,11 +1,9 @@ package com.crossbowffs.nekosms.app; -import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; -import android.provider.Settings; + import com.crossbowffs.nekosms.BuildConfig; import com.crossbowffs.nekosms.R; import com.crossbowffs.nekosms.consts.PreferenceConsts; @@ -27,21 +25,7 @@ public void onCreate(Bundle savedInstanceState) { } // Notification settings - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - addPreferencesFromResource(R.xml.settings_notifications_v26); - Preference settingsPreference = findPreference(PreferenceConsts.KEY_NOTIFICATIONS_OPEN_SETTINGS); - settingsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); - intent.putExtra(Settings.EXTRA_APP_PACKAGE, NEKOSMS_PACKAGE); - startActivity(intent); - return true; - } - }); - } else { - addPreferencesFromResource(R.xml.settings_notifications); - } + addPreferencesFromResource(R.xml.settings_notifications); } @Override diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml-v25/shortcuts.xml similarity index 100% rename from app/src/main/res/xml/shortcuts.xml rename to app/src/main/res/xml-v25/shortcuts.xml diff --git a/app/src/main/res/xml/settings_notifications_v26.xml b/app/src/main/res/xml-v26/settings_notifications.xml similarity index 58% rename from app/src/main/res/xml/settings_notifications_v26.xml rename to app/src/main/res/xml-v26/settings_notifications.xml index 9cf8954..7ba45d7 100644 --- a/app/src/main/res/xml/settings_notifications_v26.xml +++ b/app/src/main/res/xml-v26/settings_notifications.xml @@ -4,6 +4,13 @@ + android:summary="@string/pref_notifications_open_settings_summary"> + + + +