diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
index e6ca9986..04f2f646 100644
--- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java
@@ -64,15 +64,8 @@ public abstract class BaseActivity extends AppCompatActivity {
/* There isn't presently a way to globally change the theme of a whole application at
* runtime, just individual activities. So, each activity has to set its theme before any
* views are created. */
- String[] themeFlavorPair = preferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT).split(":");
- String appTheme = themeFlavorPair[0], themeFlavorPreference = themeFlavorPair[2];
-
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme));
-
- String flavor = preferences.getString("appThemeFlavor", ThemeUtils.THEME_FLAVOR_DEFAULT);
- if (flavor.equals(ThemeUtils.THEME_FLAVOR_DEFAULT))
- flavor = themeFlavorPreference;
- ThemeUtils.setAppNightMode(flavor);
+ String theme = preferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT);
+ ThemeUtils.setAppNightMode(theme);
int style;
switch(preferences.getString("statusTextSize", "medium")) {
diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt
index f50565f2..e668b56f 100644
--- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt
@@ -64,16 +64,8 @@ class LoginActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
preferences = PreferenceManager.getDefaultSharedPreferences(this)
- val themeFlavorPair = preferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT)!!.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
- val appTheme = themeFlavorPair[0]
- val themeFlavorPreference = themeFlavorPair[2]
-
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme))
-
- var flavor = preferences.getString("appThemeFlavor", ThemeUtils.THEME_FLAVOR_DEFAULT)
- if (flavor == ThemeUtils.THEME_FLAVOR_DEFAULT)
- flavor = themeFlavorPreference
- ThemeUtils.setAppNightMode(flavor)
+ val theme = preferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT)
+ ThemeUtils.setAppNightMode(theme)
setContentView(R.layout.activity_login)
diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
index 057edd0d..df7ccd67 100644
--- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
@@ -27,7 +27,6 @@ import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.keylesspalace.tusky.fragment.PreferencesFragment;
-import com.keylesspalace.tusky.util.ResourcesUtils;
import com.keylesspalace.tusky.util.ThemeUtils;
public class PreferencesActivity extends BaseActivity
@@ -59,7 +58,6 @@ public class PreferencesActivity extends BaseActivity
actionBar.setDisplayShowHomeEnabled(true);
}
-
preferences.registerOnSharedPreferenceChangeListener(this);
if(savedInstanceState == null) {
@@ -71,28 +69,6 @@ public class PreferencesActivity extends BaseActivity
}
showFragment(currentPreferences, currentTitle);
- PreferencesFragment preferencesFragment = (PreferencesFragment)getFragmentManager().findFragmentById(R.id.fragment_container);
- String[] themeFlavorPair = preferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT).split(":");
- String appTheme = themeFlavorPair[0], themeFlavorMode = themeFlavorPair[1], themeFlavorPreference = themeFlavorPair[2];
-
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme));
-
- if (preferencesFragment.findPreference("appThemeFlavor") != null) {
- boolean lockFlavor = themeFlavorMode.equals(ThemeUtils.THEME_MODE_ONLY);
- preferencesFragment.findPreference("appThemeFlavor").setEnabled(!lockFlavor);
- }
-
- String flavor = preferences.getString("appThemeFlavor", ThemeUtils.THEME_FLAVOR_DEFAULT);
- if (flavor.equals(ThemeUtils.THEME_FLAVOR_DEFAULT)) {
- flavor = themeFlavorPreference;
-
- preferences.edit()
- .putString("appThemeFlavor", flavor)
- .apply();
- }
-
- // Set theme based on preference
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme));
}
public void showFragment(@XmlRes int preferenceId, @StringRes int title) {
@@ -128,32 +104,10 @@ public class PreferencesActivity extends BaseActivity
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key) {
case "appTheme": {
- String[] themeFlavorPair = sharedPreferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT).split(":");
- String appTheme = themeFlavorPair[0];
-
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme));
-
- sharedPreferences.edit()
- .remove("appThemeFlavor")
- .apply();
- }
- case "appThemeFlavor": {
- String[] themeFlavorPair = sharedPreferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT).split(":");
- String appTheme = themeFlavorPair[0], themeFlavorPreference = themeFlavorPair[2];
-
- setTheme(ResourcesUtils.getResourceIdentifier(this, "style", appTheme));
-
- String flavor = sharedPreferences.getString("appThemeFlavor", ThemeUtils.THEME_FLAVOR_DEFAULT);
- if (flavor.equals(ThemeUtils.THEME_FLAVOR_DEFAULT)) {
- flavor = themeFlavorPreference;
-
- sharedPreferences.edit()
- .putString("appThemeFlavor", flavor)
- .apply();
- }
- ThemeUtils.setAppNightMode(flavor);
-
+ String theme = sharedPreferences.getString("appTheme", TuskyApplication.APP_THEME_DEFAULT);
+ ThemeUtils.setAppNightMode(theme);
restartActivitiesOnExit = true;
+
// recreate() could be used instead, but it doesn't have an animation B).
Intent intent = getIntent();
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -163,7 +117,6 @@ public class PreferencesActivity extends BaseActivity
startActivity(intent);
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
- break;
}
case "statusTextSize": {
restartActivitiesOnExit = true;
diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java
index 47efb83d..7c2ae988 100644
--- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java
+++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java
@@ -28,10 +28,11 @@ import com.jakewharton.picasso.OkHttp3Downloader;
import com.keylesspalace.tusky.db.AccountManager;
import com.keylesspalace.tusky.db.AppDatabase;
import com.keylesspalace.tusky.util.OkHttpUtils;
+import com.keylesspalace.tusky.util.ThemeUtils;
import com.squareup.picasso.Picasso;
public class TuskyApplication extends Application {
- public static final String APP_THEME_DEFAULT = "AppTheme:prefer:night";
+ public static final String APP_THEME_DEFAULT = ThemeUtils.THEME_NIGHT;
private static AppDatabase db;
private static AccountManager accountManager;
diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java
index 7281f4f4..f2c1a250 100644
--- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java
+++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java
@@ -37,12 +37,9 @@ import com.keylesspalace.tusky.TuskyApplication;
* the ability to do so is not supported in resource files.
*/
public class ThemeUtils {
- public static final String THEME_MODE_PREFER = "prefer";
- public static final String THEME_MODE_ONLY = "only";
- public static final String THEME_FLAVOR_NIGHT = "night";
- public static final String THEME_FLAVOR_DAY = "day";
- public static final String THEME_FLAVOR_AUTO = "auto";
- public static final String THEME_FLAVOR_DEFAULT = "preferred";
+ public static final String THEME_NIGHT = "night";
+ public static final String THEME_DAY = "day";
+ public static final String THEME_AUTO = "auto";
public static Drawable getDrawable(Context context, @AttrRes int attribute,
@DrawableRes int fallbackDrawable) {
@@ -94,20 +91,19 @@ public class ThemeUtils {
drawable.setColorFilter(getColor(context, attribute), PorterDuff.Mode.SRC_IN);
}
- public static boolean setAppNightMode(String flavor) {
+ public static void setAppNightMode(String flavor) {
int mode;
switch (flavor) {
- case THEME_FLAVOR_AUTO:
- mode = UiModeManager.MODE_NIGHT_AUTO;
- break;
- case THEME_FLAVOR_NIGHT:
+ default:
+ case THEME_NIGHT:
mode = UiModeManager.MODE_NIGHT_YES;
break;
- case THEME_FLAVOR_DAY:
+ case THEME_DAY:
mode = UiModeManager.MODE_NIGHT_NO;
break;
- default:
- return false;
+ case THEME_AUTO:
+ mode = UiModeManager.MODE_NIGHT_AUTO;
+ break;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -116,6 +112,5 @@ public class ThemeUtils {
AppCompatDelegate.setDefaultNightMode(mode);
}
- return true;
}
}
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index f1395ccf..870d264f 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -185,14 +185,6 @@
Motyw
- Odmiana motywu
-
- - Pora dnia
- - Noc
- - Dzień
-
-
-
Przeglądarka
Używaj niestandardowych kart Chrome
Ukryj przycisk śledzenia podczas przewijania
diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml
index fb234eb7..1b03dc9d 100644
--- a/app/src/main/res/values-v27/styles.xml
+++ b/app/src/main/res/values-v27/styles.xml
@@ -7,10 +7,4 @@
- @color/status_divider_light
-
-
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index 080fb870..aea818fe 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -31,13 +31,9 @@
- - AppTheme:prefer:night
- - Remin:only:day
-
-
-
- - auto
- night
- day
+ - auto
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a6409922..69afd0df 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -172,15 +172,9 @@
App Theme
- - Tusky
- - Remin
-
-
- Theme flavor
-
- - Sunset/Sunrise
- - Night
- - Day
+ - Dark
+ - Light
+ - Automatic at sunset
Browser
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 192ce0db..53a7dd81 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -105,14 +105,6 @@
-
-
-
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 0eb9fbd4..aabfe321 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -12,13 +12,6 @@
android:summary="%s"
android:title="@string/pref_title_app_theme" />
-
-