|
|
|
@ -16,14 +16,19 @@ package app.fedilab.android.activities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate;
|
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
|
|
|
|
|
import com.vanniktech.emoji.EmojiManager;
|
|
|
|
|
import com.vanniktech.emoji.one.EmojiOneProvider;
|
|
|
|
|
|
|
|
|
|
import app.fedilab.android.R;
|
|
|
|
|
import app.fedilab.android.helper.Helper;
|
|
|
|
|
import app.fedilab.android.helper.ThemeHelper;
|
|
|
|
|
|
|
|
|
@ -38,6 +43,57 @@ public class BaseBarActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
|
String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME));
|
|
|
|
|
//Default automatic switch
|
|
|
|
|
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
|
|
|
|
|
|
|
|
|
|
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
|
|
|
|
switch (currentNightMode) {
|
|
|
|
|
case Configuration.UI_MODE_NIGHT_NO:
|
|
|
|
|
String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT");
|
|
|
|
|
switch (defaultLight) {
|
|
|
|
|
case "LIGHT":
|
|
|
|
|
setTheme(R.style.AppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
case "SOLARIZED_LIGHT":
|
|
|
|
|
setTheme(R.style.SolarizedAppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Configuration.UI_MODE_NIGHT_YES:
|
|
|
|
|
String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK");
|
|
|
|
|
switch (defaultDark) {
|
|
|
|
|
case "DARK":
|
|
|
|
|
setTheme(R.style.AppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
case "SOLARIZED_DARK":
|
|
|
|
|
setTheme(R.style.SolarizedAppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
switch (currentTheme) {
|
|
|
|
|
case "LIGHT":
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
|
|
|
|
setTheme(R.style.AppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
case "DARK":
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
|
|
|
|
setTheme(R.style.AppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
case "SOLARIZED_LIGHT":
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
|
|
|
|
setTheme(R.style.SolarizedAppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
case "SOLARIZED_DARK":
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
|
|
|
|
setTheme(R.style.SolarizedAppThemeBar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
ThemeHelper.adjustFontScale(this, getResources().getConfiguration());
|
|
|
|
|
Helper.setLocale(this);
|
|
|
|
|