Added option to set black background

pull/146/head
M66B 6 years ago
parent 9e0570e694
commit 360c2b68d0

@ -10,7 +10,6 @@ For support on authorizing an account you should consult the documentation of yo
Frequently requested features: Frequently requested features:
* More themes/black theme: the goal is to keep the app as simple as possible, so no more themes will not be added.
* Previewing message text in notification/widget: this is not always possible because the message text is initially not downloaded for larger messages. * Previewing message text in notification/widget: this is not always possible because the message text is initially not downloaded for larger messages.
* Executing filter rules: filter rules should be executed on the server because a battery powered device with possibly an unstable internet connection is not suitable for this. * Executing filter rules: filter rules should be executed on the server because a battery powered device with possibly an unstable internet connection is not suitable for this.
* Widget to read e-mail: widgets do not allow user interaction, so a widget to read e-mail would not be very useful. * Widget to read e-mail: widgets do not allow user interaction, so a widget to read e-mail would not be very useful.

@ -34,10 +34,18 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override @Override
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 = (Helper.isPro(this) ? prefs.getString("theme", "light") : "light"); if (Helper.isPro(this)) {
setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark); String theme = prefs.getString("theme", null);
if ("dark".equals(theme))
setTheme(R.style.AppThemeDark);
else if ("black".equals(theme))
setTheme(R.style.AppThemeBlack);
}
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -71,7 +79,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
Log.i(Helper.TAG, "Preference " + key + "=" + prefs.getAll().get(key)); Log.i(Helper.TAG, "Preference " + key + "=" + prefs.getAll().get(key));
if ("theme".equals(key)) { if ("theme".equals(key)) {
finish(); finish();
startActivity(getIntent()); if (this.getClass().equals(ActivitySetup.class))
startActivity(getIntent());
} else if (!this.getClass().equals(ActivitySetup.class) && ("compact".equals(key) || "debug".equals(key))) } else if (!this.getClass().equals(ActivitySetup.class) && ("compact".equals(key) || "debug".equals(key)))
finish(); finish();
} }

@ -44,6 +44,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
@ -93,6 +94,7 @@ public class FragmentSetup extends FragmentEx {
private Button btnNotifications; private Button btnNotifications;
private ToggleButton tbDarkTheme; private ToggleButton tbDarkTheme;
private CheckBox cbBlackTheme;
private Button btnOptions; private Button btnOptions;
@ -144,6 +146,7 @@ public class FragmentSetup extends FragmentEx {
btnData = view.findViewById(R.id.btnData); btnData = view.findViewById(R.id.btnData);
tbDarkTheme = view.findViewById(R.id.tbDarkTheme); tbDarkTheme = view.findViewById(R.id.tbDarkTheme);
cbBlackTheme = view.findViewById(R.id.cbBlackTheme);
btnOptions = view.findViewById(R.id.btnOptions); btnOptions = view.findViewById(R.id.btnOptions);
// Wire controls // Wire controls
@ -226,9 +229,9 @@ public class FragmentSetup extends FragmentEx {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String theme = prefs.getString("theme", "light"); String theme = prefs.getString("theme", "light");
boolean dark = "dark".equals(theme); boolean light = "light".equals(theme);
tbDarkTheme.setTag(dark); tbDarkTheme.setTag(!light);
tbDarkTheme.setChecked(dark); tbDarkTheme.setChecked(!light);
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) {
@ -247,9 +250,19 @@ public class FragmentSetup extends FragmentEx {
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
} }
cbBlackTheme.setVisibility(tbDarkTheme.isChecked() ? View.VISIBLE : View.GONE);
} }
}); });
cbBlackTheme.setChecked("black".equals(theme));
cbBlackTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
prefs.edit().putString("theme", checked ? "black" : "dark").apply();
}
});
cbBlackTheme.setVisibility(tbDarkTheme.isChecked() ? View.VISIBLE : View.GONE);
btnOptions.setOnClickListener(new View.OnClickListener() { btnOptions.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

@ -228,6 +228,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnNotifications" /> app:layout_constraintTop_toBottomOf="@id/btnNotifications" />
<CheckBox
android:id="@+id/cbBlackTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:text="@string/title_setup_black_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tbDarkTheme" />
<Button <Button
android:id="@+id/btnOptions" android:id="@+id/btnOptions"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -239,6 +249,6 @@
android:text="@string/title_advanced" android:text="@string/title_advanced"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tbDarkTheme" /> app:layout_constraintTop_toBottomOf="@id/cbBlackTheme" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

@ -78,6 +78,7 @@
<string name="title_setup_done">Done</string> <string name="title_setup_done">Done</string>
<string name="title_setup_light_theme">Light theme</string> <string name="title_setup_light_theme">Light theme</string>
<string name="title_setup_dark_theme">Dark theme</string> <string name="title_setup_dark_theme">Dark theme</string>
<string name="title_setup_black_background">Black background</string>
<string name="title_advanced">Advanced options</string> <string name="title_advanced">Advanced options</string>
<string name="title_advanced_enabled">Enabled</string> <string name="title_advanced_enabled">Enabled</string>

@ -51,6 +51,11 @@
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item> <item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
</style> </style>
<style name="AppThemeBlack" parent="AppThemeDark">
<item name="android:windowBackground">@android:color/black</item>
<item name="colorDrawerBackground">@android:color/black</item>
</style>
<style name="Theme.Transparent" parent="Base.Theme.AppCompat"> <style name="Theme.Transparent" parent="Base.Theme.AppCompat">
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item>

Loading…
Cancel
Save