diff --git a/QKSMS/src/main/AndroidManifest.xml b/QKSMS/src/main/AndroidManifest.xml index 40d400f7..ea9b0041 100644 --- a/QKSMS/src/main/AndroidManifest.xml +++ b/QKSMS/src/main/AndroidManifest.xml @@ -39,7 +39,7 @@ @@ -66,7 +66,8 @@ + + + + + + + + + + + + + + @@ -124,7 +149,7 @@ @@ -136,7 +161,7 @@ @@ -148,7 +173,7 @@ @@ -160,7 +185,7 @@ @@ -172,7 +197,7 @@ @@ -184,7 +209,7 @@ @@ -196,7 +221,7 @@ @@ -208,7 +233,7 @@ @@ -220,7 +245,7 @@ @@ -232,7 +257,7 @@ @@ -244,7 +269,7 @@ @@ -256,7 +281,7 @@ @@ -268,7 +293,7 @@ @@ -280,7 +305,7 @@ @@ -292,7 +317,7 @@ @@ -304,7 +329,7 @@ @@ -316,7 +341,7 @@ @@ -328,7 +353,7 @@ diff --git a/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java b/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java index d13bcbba..a20a14fd 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/QKSMSAppBase.java @@ -93,6 +93,7 @@ public class QKSMSAppBase extends MultiDexApplication { registerActivityLifecycleCallbacks(new LifecycleHandler()); ThemeManager.init(this); + ThemeManager.migrateIcon(this); // TODO a few versions after 2.7, we can phase this out along with the old alias MmsConfig.init(this); Contact.init(this); DraftCache.init(this); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java b/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java index c18de55c..2ba4e1c4 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java @@ -95,7 +95,8 @@ public enum QKPreference { CONVERSATION_THEME("conversation_theme"), // Storage - COMPOSE_DRAFT("compose_draft", ""); + COMPOSE_DRAFT("compose_draft", ""), + MIGRATED_ICON("migrated_icon", false); private String mKey; private Object mDefaultValue; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java index 26485bfa..1ef3120d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java @@ -326,7 +326,7 @@ public class ThemeManager { LiveViewManager.refreshViews(QKPreference.BACKGROUND); } - public static void setIcon(final QKActivity context) { + public static void setIcon(final QKActivity context, boolean dark) { new QKDialog() .setContext(context) .setTitle(R.string.update_icon_title) @@ -335,50 +335,65 @@ public class ThemeManager { .setPositiveButton(R.string.okay, v -> { PackageManager packageManager = context.getPackageManager(); - String[] colors = { - "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue", - "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", - "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Grey", - "BlueGrey" - }; + String defaultComponent = "com.moez.QKSMS.ui.MainActivity-Default"; + String darkComponent = "com.moez.QKSMS.ui.MainActivity-Dark"; - // Disable all of the color aliases, except for the alias with the current - // color. - String enabledComponent = null; - for (int i = 0; i < colors.length; i++) { - String componentClassName = String.format( - "com.moez.QKSMS.ui.MainActivity-%s", colors[i] - ); - - // Save the enabled component so we can kill the app with this one when - // it's all done. - if (getSwatchColor(mColor) == PALETTE[i]) { - enabledComponent = componentClassName; - - } else { - packageManager.setComponentEnabledSetting( - new ComponentName(context, componentClassName), - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - // Don't kill the app while we're in the loop! This will - // prevent the other component enabled settings from - // changing, i.e. they will all be disabled and the app - // won't show up to the user. - PackageManager.DONT_KILL_APP - ); - } - } + packageManager.setComponentEnabledSetting( + new ComponentName(context, dark ? defaultComponent : darkComponent), + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + // Don't kill the app while we're in the loop! This will + // prevent the other component enabled settings from + // changing, i.e. they will all be disabled and the app + // won't show up to the user. + PackageManager.DONT_KILL_APP + ); // Broadcast an intent to a receiver that will: // 1) enable the last component; and // 2) relaunch QKSMS with the new component name. Intent intent = new Intent(IconColorReceiver.ACTION_ICON_COLOR_CHANGED); - intent.putExtra(IconColorReceiver.EXTRA_COMPONENT_NAME, enabledComponent); + intent.putExtra(IconColorReceiver.EXTRA_COMPONENT_NAME, dark ? darkComponent : defaultComponent); context.sendBroadcast(intent); }) - .setNegativeButton(R.string.cancel, null) + .setCancelOnTouchOutside(false) .show(); } + public static void migrateIcon(Context context) { + PackageManager packageManager = context.getPackageManager(); + + // If we've already migrated to use the MainActivity-Default component, we don't need to do anything + if (mPrefs.getBoolean(QKPreference.MIGRATED_ICON.getKey(), (Boolean) QKPreference.MIGRATED_ICON.getDefaultValue())) { + return; + } + + mPrefs.edit().putBoolean(QKPreference.MIGRATED_ICON.getKey(), true).apply(); + + String[] colors = { + "Red", "Pink", "Purple", "DeepPurple", "Indigo", "Blue", + "LightBlue", "Cyan", "Teal", "Green", "LightGreen", "Lime", + "Yellow", "Amber", "Orange", "DeepOrange", "Brown", "Grey", + "BlueGrey" + }; + + // Disable all of the old components + for (String color : colors) { + String componentClassName = String.format("com.moez.QKSMS.ui.MainActivity-%s", color); + packageManager.setComponentEnabledSetting( + new ComponentName(context, componentClassName), + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP + ); + } + + // Enable the new component + ComponentName componentName = new ComponentName(context, "com.moez.QKSMS.ui.MainActivity-Default"); + packageManager.setComponentEnabledSetting(componentName, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP + ); + } + @ColorInt public static int getBackgroundColor() { return mBackgroundColor; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java index b6ecd335..44190fa3 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java @@ -80,7 +80,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O public static final String CATEGORY_APPEARANCE_SYSTEM_BARS = "pref_key_category_appearance_system_bars"; public static final String THEME = "pref_key_theme"; - public static final String ICON = "pref_key_icon"; + public static final String ICON = "pref_key_icon_dark"; public static final String STATUS_TINT = "pref_key_status_tint"; public static final String NAVIGATION_TINT = "pref_key_navigation_tint"; public static final String BACKGROUND = "pref_key_background"; @@ -410,6 +410,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O case BACKGROUND: ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue)); break; + case ICON: + ThemeManager.setIcon(mContext, (Boolean) newValue); + break; case STATUS_TINT: ThemeManager.setStatusBarTintEnabled(mContext, (Boolean) newValue); break; @@ -537,9 +540,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O case BUBBLES: new BubblePreferenceDialog().setContext(mContext).show(); break; - case ICON: - ThemeManager.setIcon(mContext); - break; case BLOCKED_FUTURE: BlockedNumberDialog.showDialog(mContext); break; diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..401f6945 Binary files /dev/null and b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png deleted file mode 100755 index f61ae596..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_amber.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png deleted file mode 100755 index ca3a1207..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png deleted file mode 100755 index b44a8312..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_blue_grey.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png deleted file mode 100755 index fe0db1cf..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_brown.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png deleted file mode 100755 index 1c5e344d..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_cyan.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png new file mode 100644 index 00000000..dbe76fc7 Binary files /dev/null and b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_dark.png differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png deleted file mode 100755 index c9f6f272..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_orange.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png deleted file mode 100755 index b7718eb1..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_deep_purple.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png deleted file mode 100755 index 21ad10f7..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_green.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png deleted file mode 100755 index 5c774deb..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_grey.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png deleted file mode 100755 index 3208780a..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_indigo.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png deleted file mode 100755 index 00258423..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_blue.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png deleted file mode 100755 index 145cf056..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_light_green.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png deleted file mode 100755 index edee3645..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_lime.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png deleted file mode 100755 index fe6eda7d..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_orange.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png deleted file mode 100755 index 4697e499..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_pink.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png deleted file mode 100755 index a7560cb6..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_purple.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png deleted file mode 100755 index 990c7665..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_red.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png deleted file mode 100755 index 3a6d8b65..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_teal.png and /dev/null differ diff --git a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png b/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png deleted file mode 100755 index 6bc58908..00000000 Binary files a/QKSMS/src/main/res/mipmap-xxxhdpi/ic_launcher_yellow.png and /dev/null differ diff --git a/QKSMS/src/main/res/values/strings.xml b/QKSMS/src/main/res/values/strings.xml index c1b116de..599cd394 100644 --- a/QKSMS/src/main/res/values/strings.xml +++ b/QKSMS/src/main/res/values/strings.xml @@ -125,8 +125,8 @@ Theme color Tap to change theme - Update QKSMS icon color - Update the QKSMS icon to match your theme color + Use dark icon + Use the dark version of the QKSMS icon on your homescreen, to better match your wallpaper Tinted status bar Tinted navigation bar Background color @@ -583,7 +583,7 @@ Update icon color - QKSMS must be restarted when changing the icon color. Restart now? + QKSMS must be restarted when changing the icon color Conversation details Last message date diff --git a/QKSMS/src/main/res/xml/settings.xml b/QKSMS/src/main/res/xml/settings.xml index d4547efe..8f1c50b0 100644 --- a/QKSMS/src/main/res/xml/settings.xml +++ b/QKSMS/src/main/res/xml/settings.xml @@ -4,7 +4,7 @@ android:defaultValue="-16746133" android:key="pref_key_theme" /> + android:key="pref_key_icon_dark" /> diff --git a/QKSMS/src/main/res/xml/settings_appearance.xml b/QKSMS/src/main/res/xml/settings_appearance.xml index 7e38b1c6..3d326e22 100644 --- a/QKSMS/src/main/res/xml/settings_appearance.xml +++ b/QKSMS/src/main/res/xml/settings_appearance.xml @@ -10,12 +10,13 @@ android:layout="@layout/list_item_preference" android:summary="@string/pref_theme_summary_alt" android:title="@string/pref_theme" /> - + android:summary="@string/pref_icon_dark_summary" + android:title="@string/pref_icon_dark" + android:widgetLayout="@layout/view_switch" />