Browse Source

Made dark theme a pro feature

main
M66B 6 years ago
parent
commit
18fb7beff5
3 changed files with 13 additions and 6 deletions
  1. +1
    -1
      README.md
  2. +2
    -1
      app/src/main/java/eu/faircode/email/ActivityBase.java
  3. +10
    -4
      app/src/main/java/eu/faircode/email/FragmentSetup.java

+ 1
- 1
README.md View File

@ -26,12 +26,12 @@ Features
* Two way synchronization * Two way synchronization
* Offline storage and operations * Offline storage and operations
* Material design * Material design
* Dark theme
Pro features Pro features
------------ ------------
* Signatures * Signatures
* Dark theme
* Account colors * Account colors
* Standard replies * Standard replies
* Sort on time, unread or starred * Sort on time, unread or starred


+ 2
- 1
app/src/main/java/eu/faircode/email/ActivityBase.java View File

@ -35,7 +35,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME); Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", "light");
boolean pro = prefs.getBoolean("pro", false);
String theme = (pro ? prefs.getString("theme", "light") : "light");
setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark); setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);


+ 10
- 4
app/src/main/java/eu/faircode/email/FragmentSetup.java View File

@ -203,10 +203,16 @@ public class FragmentSetup extends FragmentEx {
tbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { tbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton button, boolean checked) { public void onCheckedChanged(CompoundButton button, boolean checked) {
if (checked != (Boolean) button.getTag()) {
button.setTag(checked);
tbDarkTheme.setChecked(checked);
prefs.edit().putString("theme", checked ? "dark" : "light").apply();
if (prefs.getBoolean("pro", false)) {
if (checked != (Boolean) button.getTag()) {
button.setTag(checked);
tbDarkTheme.setChecked(checked);
prefs.edit().putString("theme", checked ? "dark" : "light").apply();
}
} else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
} }
} }
}); });


Loading…
Cancel
Save