summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpiritCroc <dev@spiritcroc.de>2018-10-09 15:37:32 +0200
committerSpiritCroc <dev@spiritcroc.de>2018-10-09 16:05:48 +0200
commit3031acf1f7363768ba92cc7609cf1b5e693c8fa4 (patch)
treea6ee8396803956e9ccd237a9866d1b4f4de167aa
parent8cf19fbd09df350cf811006ebc090fcf9151153d (diff)
Updater: follow AE themep9.0-los
Change-Id: I73df5ffa50b9b797b01f2ab516b77b797385f6b4
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/values/themes.xml15
-rw-r--r--src/com/aicp/updater/BaseSettingsActivity.java80
-rw-r--r--src/com/aicp/updater/Settings.java3
4 files changed, 96 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9656e6a..cb03660 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -19,7 +19,6 @@
<application android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
- android:theme="@android:style/Theme.DeviceDefault.Settings"
android:icon="@mipmap/ic_launcher">
<service android:name=".Service"
android:directBootAware="true"
diff --git a/res/values/themes.xml b/res/values/themes.xml
new file mode 100644
index 0000000..b042da3
--- /dev/null
+++ b/res/values/themes.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="AppTheme_Default" parent="android:Theme.DeviceDefault.Settings">
+ </style>
+
+ <style name="AppTheme_Light" parent="android:Theme.Material.Light">
+ <!-- White navbar -->
+ <item name="android:navigationBarDividerColor">#1f000000</item>
+ <item name="android:navigationBarColor">@android:color/white</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ </style>
+
+ <style name="AppTheme_Dark" parent="android:Theme.Material">
+ </style>
+</resources>
diff --git a/src/com/aicp/updater/BaseSettingsActivity.java b/src/com/aicp/updater/BaseSettingsActivity.java
new file mode 100644
index 0000000..ff15c2f
--- /dev/null
+++ b/src/com/aicp/updater/BaseSettingsActivity.java
@@ -0,0 +1,80 @@
+package com.aicp.updater;
+
+import android.content.res.TypedArray;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.provider.Settings;
+import android.view.View;
+
+public class BaseSettingsActivity extends PreferenceActivity {
+
+ private int mThemeRes;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ mThemeRes = getThemeRes();
+ setTheme(mThemeRes);
+ super.onCreate(savedInstanceState);
+ fixStatusBarFg();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mThemeRes != getThemeRes()) {
+ recreate();
+ }
+ }
+
+ protected int getThemeRes() {
+ int pref = Settings.System.getInt(getContentResolver(), Settings.System.AE_THEME, 0);
+ switch (pref) {
+ /*
+ case 1:
+ return R.style.AppTheme_DarkAmber;
+ */
+ case 2:
+ case 4:
+ return R.style.AppTheme_Light;
+ case 3:
+ case 5:
+ return R.style.AppTheme_Dark;
+ default:
+ return R.style.AppTheme_Default;
+ }
+ }
+
+ /**
+ * When changing from a theme with light to one with dark status bar, recreating
+ * the activity seems to be not enough to update status bar foreground color,
+ * so it's black on black.
+ * This is a workaround for that, basically adapted from Launcher3's dynamic
+ * status bar color (fg color changing when opening/closing drawer).
+ */
+ private void fixStatusBarFg() {
+ int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
+ int newSystemUiFlags = oldSystemUiFlags;
+ int[] attrs = new int[] {
+ android.R.attr.windowLightStatusBar,
+ android.R.attr.windowLightNavigationBar,
+ };
+ TypedArray ta = getTheme().obtainStyledAttributes(attrs);
+ boolean lightStatusBar = ta.getBoolean(0, false);
+ boolean lightNavigationBar = ta.getBoolean(1, false);
+ ta.recycle();
+ if (lightStatusBar) {
+ newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+ } else {
+ newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ if (lightNavigationBar) {
+ newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
+ } else {
+ newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+
+ if (newSystemUiFlags != oldSystemUiFlags) {
+ getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags);
+ }
+ }
+}
diff --git a/src/com/aicp/updater/Settings.java b/src/com/aicp/updater/Settings.java
index 98aa8c3..499465f 100644
--- a/src/com/aicp/updater/Settings.java
+++ b/src/com/aicp/updater/Settings.java
@@ -12,14 +12,13 @@ import android.os.Bundle;
import android.os.UserManager;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-public class Settings extends PreferenceActivity {
+public class Settings extends BaseSettingsActivity {
private static final int DEFAULT_NETWORK_TYPE = JobInfo.NETWORK_TYPE_UNMETERED;
private static final String KEY_AUTO_UPDATE = "auto_update";
private static final String KEY_AUTO_UPDATE_PROMPT_DOWNLOAD = "auto_update_prompt_download";