mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-29 07:41:17 +00:00
- Now app by default follows system theme for api level 28 and higher, for api level below 28, it fall backs to light theme.
This commit is contained in:
parent
4eccb41c1f
commit
cdf6a69d1f
4 changed files with 7 additions and 3 deletions
|
@ -13,13 +13,14 @@ import com.nutomic.syncthingandroid.service.Constants;
|
||||||
*/
|
*/
|
||||||
public class ThemedAppCompatActivity extends AppCompatActivity {
|
public class ThemedAppCompatActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static final String LIGHT_THEME = "1";
|
private static final String FOLLOW_SYSTEM = "-1";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
// Load theme.
|
// Load theme.
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
Integer prefAppTheme = Integer.parseInt(prefs.getString(Constants.PREF_APP_THEME, LIGHT_THEME));
|
//For api level below 28, Follow system fall backs to light mode
|
||||||
|
Integer prefAppTheme = Integer.parseInt(prefs.getString(Constants.PREF_APP_THEME, FOLLOW_SYSTEM));
|
||||||
AppCompatDelegate.setDefaultNightMode(prefAppTheme);
|
AppCompatDelegate.setDefaultNightMode(prefAppTheme);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="theme_names">
|
<string-array name="theme_names">
|
||||||
|
<item>@string/preference_theme_follow_system</item>
|
||||||
<item>@string/preference_theme_option_light</item>
|
<item>@string/preference_theme_option_light</item>
|
||||||
<item>@string/preference_theme_option_dark</item>
|
<item>@string/preference_theme_option_dark</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="theme_values">
|
<string-array name="theme_values">
|
||||||
|
<item>-1</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
|
@ -380,6 +380,7 @@ Please report any problems you encounter via Github.</string>
|
||||||
<string name="start_into_web_gui_summary">When starting the app, open web GUI instead of the main screen</string>
|
<string name="start_into_web_gui_summary">When starting the app, open web GUI instead of the main screen</string>
|
||||||
|
|
||||||
<string name="preference_theme_title">Theme</string>
|
<string name="preference_theme_title">Theme</string>
|
||||||
|
<string name="preference_theme_follow_system">Follow system</string>
|
||||||
<string name="preference_theme_option_light">Light</string>
|
<string name="preference_theme_option_light">Light</string>
|
||||||
<string name="preference_theme_option_dark">Dark</string>
|
<string name="preference_theme_option_dark">Dark</string>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:title="@string/preference_theme_title"
|
android:title="@string/preference_theme_title"
|
||||||
android:entries="@array/theme_names"
|
android:entries="@array/theme_names"
|
||||||
android:entryValues="@array/theme_values"
|
android:entryValues="@array/theme_values"
|
||||||
android:defaultValue="1"/> <!-- 1 is Light Theme -->
|
android:defaultValue="-1"/> <!-- -1 is Follow System -->
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/category_run_conditions"
|
android:title="@string/category_run_conditions"
|
||||||
|
|
Loading…
Reference in a new issue