|
|
|
@ -19,6 +19,7 @@ package eu.faircode.email;
|
|
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
@ -35,7 +36,9 @@ import android.widget.Spinner;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
|
import androidx.appcompat.widget.SwitchCompat;
|
|
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
|
|
|
|
|
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
|
|
|
@ -97,7 +100,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|
|
|
|
btnTheme.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
onSelectTheme();
|
|
|
|
|
new FragmentDialogTheme().show(getFragmentManager(), "setup:theme");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -256,7 +259,39 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|
|
|
|
editor.apply();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onSelectTheme() {
|
|
|
|
|
private void setOptions() {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
|
|
boolean compact = prefs.getBoolean("compact", false);
|
|
|
|
|
|
|
|
|
|
String startup = prefs.getString("startup", "unified");
|
|
|
|
|
String[] startupValues = getResources().getStringArray(R.array.startupValues);
|
|
|
|
|
for (int pos = 0; pos < startupValues.length; pos++)
|
|
|
|
|
if (startupValues[pos].equals(startup)) {
|
|
|
|
|
spStartup.setSelection(pos);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swDate.setChecked(prefs.getBoolean("date", true));
|
|
|
|
|
swThreading.setChecked(prefs.getBoolean("threading", true));
|
|
|
|
|
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
|
|
|
|
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
|
|
|
|
swCircular.setChecked(prefs.getBoolean("circular", true));
|
|
|
|
|
swNameEmail.setChecked(prefs.getBoolean("name_email", !compact));
|
|
|
|
|
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
|
|
|
|
|
swFlags.setChecked(prefs.getBoolean("flags", true));
|
|
|
|
|
swPreview.setChecked(prefs.getBoolean("preview", false));
|
|
|
|
|
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
|
|
|
|
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
|
|
|
|
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
|
|
|
|
swImages.setChecked(prefs.getBoolean("autoimages", false));
|
|
|
|
|
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FragmentDialogTheme extends DialogFragment {
|
|
|
|
|
@NonNull
|
|
|
|
|
@Override
|
|
|
|
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_theme, null);
|
|
|
|
|
final RadioGroup rgTheme = dview.findViewById(R.id.rgTheme);
|
|
|
|
|
|
|
|
|
@ -299,37 +334,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
|
return new AlertDialog.Builder(getContext())
|
|
|
|
|
.setView(dview)
|
|
|
|
|
.show();
|
|
|
|
|
.create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setOptions() {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
|
|
boolean compact = prefs.getBoolean("compact", false);
|
|
|
|
|
|
|
|
|
|
String startup = prefs.getString("startup", "unified");
|
|
|
|
|
String[] startupValues = getResources().getStringArray(R.array.startupValues);
|
|
|
|
|
for (int pos = 0; pos < startupValues.length; pos++)
|
|
|
|
|
if (startupValues[pos].equals(startup)) {
|
|
|
|
|
spStartup.setSelection(pos);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
swDate.setChecked(prefs.getBoolean("date", true));
|
|
|
|
|
swThreading.setChecked(prefs.getBoolean("threading", true));
|
|
|
|
|
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
|
|
|
|
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
|
|
|
|
swCircular.setChecked(prefs.getBoolean("circular", true));
|
|
|
|
|
swNameEmail.setChecked(prefs.getBoolean("name_email", !compact));
|
|
|
|
|
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
|
|
|
|
|
swFlags.setChecked(prefs.getBoolean("flags", true));
|
|
|
|
|
swPreview.setChecked(prefs.getBoolean("preview", false));
|
|
|
|
|
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
|
|
|
|
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
|
|
|
|
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
|
|
|
|
swImages.setChecked(prefs.getBoolean("autoimages", false));
|
|
|
|
|
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|