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
* Offline storage and operations
* Material design
* Dark theme
Pro features
------------
* Signatures
* Dark theme
* Account colors
* Standard replies
* 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) {
Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
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);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
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() {
@Override
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