mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
Added option to set black background
This commit is contained in:
1
FAQ.md
1
FAQ.md
@@ -10,7 +10,6 @@ For support on authorizing an account you should consult the documentation of yo
|
||||
|
||||
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.
|
||||
* 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.
|
||||
|
||||
@@ -34,10 +34,18 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String theme = (Helper.isPro(this) ? prefs.getString("theme", "light") : "light");
|
||||
setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark);
|
||||
if (Helper.isPro(this)) {
|
||||
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);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -71,7 +79,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
Log.i(Helper.TAG, "Preference " + key + "=" + prefs.getAll().get(key));
|
||||
if ("theme".equals(key)) {
|
||||
finish();
|
||||
startActivity(getIntent());
|
||||
if (this.getClass().equals(ActivitySetup.class))
|
||||
startActivity(getIntent());
|
||||
} else if (!this.getClass().equals(ActivitySetup.class) && ("compact".equals(key) || "debug".equals(key)))
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
@@ -93,6 +94,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
private Button btnNotifications;
|
||||
|
||||
private ToggleButton tbDarkTheme;
|
||||
private CheckBox cbBlackTheme;
|
||||
|
||||
private Button btnOptions;
|
||||
|
||||
@@ -144,6 +146,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
btnData = view.findViewById(R.id.btnData);
|
||||
|
||||
tbDarkTheme = view.findViewById(R.id.tbDarkTheme);
|
||||
cbBlackTheme = view.findViewById(R.id.cbBlackTheme);
|
||||
btnOptions = view.findViewById(R.id.btnOptions);
|
||||
|
||||
// Wire controls
|
||||
@@ -226,9 +229,9 @@ public class FragmentSetup extends FragmentEx {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
String theme = prefs.getString("theme", "light");
|
||||
boolean dark = "dark".equals(theme);
|
||||
tbDarkTheme.setTag(dark);
|
||||
tbDarkTheme.setChecked(dark);
|
||||
boolean light = "light".equals(theme);
|
||||
tbDarkTheme.setTag(!light);
|
||||
tbDarkTheme.setChecked(!light);
|
||||
tbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton button, boolean checked) {
|
||||
@@ -247,9 +250,19 @@ public class FragmentSetup extends FragmentEx {
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
@@ -228,6 +228,16 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
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
|
||||
android:id="@+id/btnOptions"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
@@ -239,6 +249,6 @@
|
||||
android:text="@string/title_advanced"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tbDarkTheme" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlackTheme" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
@@ -78,6 +78,7 @@
|
||||
<string name="title_setup_done">Done</string>
|
||||
<string name="title_setup_light_theme">Light 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_enabled">Enabled</string>
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
<item name="android:buttonStyleToggle">@style/buttonStyleToggle</item>
|
||||
</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">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
||||
Reference in New Issue
Block a user