From b2ddb24dbab66813356f6985ea00d25bcc9c38a7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 20 Jul 2018 03:35:15 +0200 Subject: fab: make icons always white With the new shade of blue, perhaps this simply looks better. I don't like hard coding the color away from the theme, however. --- .../android/activity/ThemeChangeAwareActivity.java | 33 ---------------------- .../android/widget/fab/FloatingActionsMenu.java | 2 +- .../main/res/drawable/ic_action_add_inverse.xml | 9 ------ app/src/main/res/drawable/ic_action_add_white.xml | 9 ++++++ .../main/res/drawable/ic_action_edit_inverse.xml | 9 ------ app/src/main/res/drawable/ic_action_edit_white.xml | 9 ++++++ .../main/res/drawable/ic_action_open_inverse.xml | 9 ------ app/src/main/res/drawable/ic_action_open_white.xml | 9 ++++++ app/src/main/res/layout/tunnel_list_fragment.xml | 4 +-- 9 files changed, 30 insertions(+), 63 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_action_add_inverse.xml create mode 100644 app/src/main/res/drawable/ic_action_add_white.xml delete mode 100644 app/src/main/res/drawable/ic_action_edit_inverse.xml create mode 100644 app/src/main/res/drawable/ic_action_edit_white.xml delete mode 100644 app/src/main/res/drawable/ic_action_open_inverse.xml create mode 100644 app/src/main/res/drawable/ic_action_open_white.xml (limited to 'app/src/main') diff --git a/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java b/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java index d85a0170..de8020f1 100644 --- a/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/ThemeChangeAwareActivity.java @@ -18,37 +18,6 @@ import com.wireguard.android.Application; import java.lang.reflect.Field; public abstract class ThemeChangeAwareActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = "WireGuard/" + ThemeChangeAwareActivity.class.getSimpleName(); - - @Nullable private static Resources lastResources; - private static boolean lastDarkMode; - private static synchronized void invalidateDrawableCache(final Resources resources, final boolean darkMode) { - if (resources == lastResources && darkMode == lastDarkMode) - return; - - try { - Field f; - Object o = resources; - try { - f = o.getClass().getDeclaredField("mResourcesImpl"); - f.setAccessible(true); - o = f.get(o); - } catch (final Exception ignored) { } - f = o.getClass().getDeclaredField("mDrawableCache"); - f.setAccessible(true); - o = f.get(o); - try { - o.getClass().getMethod("onConfigurationChange", int.class).invoke(o, -1); - } catch (final Exception ignored) { - o.getClass().getMethod("clear").invoke(o); - } - } catch (final Exception e) { - Log.e(TAG, "Failed to flush drawable cache", e); - } - - lastResources = resources; - lastDarkMode = darkMode; - } @Override @@ -66,12 +35,10 @@ public abstract class ThemeChangeAwareActivity extends AppCompatActivity impleme @Override public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) { if ("dark_theme".equals(key)) { - final boolean darkMode = sharedPreferences.getBoolean(key, false); AppCompatDelegate.setDefaultNightMode( sharedPreferences.getBoolean(key, false) ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); - invalidateDrawableCache(getResources(), darkMode); recreate(); } } diff --git a/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionsMenu.java b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionsMenu.java index 7ca6d976..e0a335d4 100644 --- a/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionsMenu.java +++ b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionsMenu.java @@ -112,7 +112,7 @@ public class FloatingActionsMenu extends ViewGroup { } private void createAddButton(final Context context) { - final RotatingDrawable rotatingDrawable = new RotatingDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_action_add_inverse, context.getTheme())); + final RotatingDrawable rotatingDrawable = new RotatingDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_action_add_white, context.getTheme())); mRotatingDrawable = rotatingDrawable; final TimeInterpolator interpolator = new OvershootInterpolator(); diff --git a/app/src/main/res/drawable/ic_action_add_inverse.xml b/app/src/main/res/drawable/ic_action_add_inverse.xml deleted file mode 100644 index 571e70e7..00000000 --- a/app/src/main/res/drawable/ic_action_add_inverse.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_action_add_white.xml b/app/src/main/res/drawable/ic_action_add_white.xml new file mode 100644 index 00000000..0706462e --- /dev/null +++ b/app/src/main/res/drawable/ic_action_add_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_action_edit_inverse.xml b/app/src/main/res/drawable/ic_action_edit_inverse.xml deleted file mode 100644 index f1324ffb..00000000 --- a/app/src/main/res/drawable/ic_action_edit_inverse.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_action_edit_white.xml b/app/src/main/res/drawable/ic_action_edit_white.xml new file mode 100644 index 00000000..c1ce5043 --- /dev/null +++ b/app/src/main/res/drawable/ic_action_edit_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_action_open_inverse.xml b/app/src/main/res/drawable/ic_action_open_inverse.xml deleted file mode 100644 index 9836107c..00000000 --- a/app/src/main/res/drawable/ic_action_open_inverse.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_action_open_white.xml b/app/src/main/res/drawable/ic_action_open_white.xml new file mode 100644 index 00000000..74648d14 --- /dev/null +++ b/app/src/main/res/drawable/ic_action_open_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/tunnel_list_fragment.xml b/app/src/main/res/layout/tunnel_list_fragment.xml index 96b13b37..9de4e4d1 100644 --- a/app/src/main/res/layout/tunnel_list_fragment.xml +++ b/app/src/main/res/layout/tunnel_list_fragment.xml @@ -54,7 +54,7 @@ android:layout_height="wrap_content" android:onClick="@{fragment::onRequestCreateConfig}" app:fabSize="mini" - app:srcCompat="@drawable/ic_action_edit_inverse" + app:srcCompat="@drawable/ic_action_edit_white" app:fab_title="@string/create_empty" /> -- cgit v1.2.3