2019-05-06 07:10:13 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
|
|
|
*/
|
|
|
|
|
2019-06-30 20:52:33 +00:00
|
|
|
import android.app.Dialog;
|
2019-05-06 07:10:13 +00:00
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.LayoutInflater;
|
2019-05-06 12:41:03 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2019-05-06 07:10:13 +00:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.AdapterView;
|
2019-06-14 17:12:56 +00:00
|
|
|
import android.widget.Button;
|
2019-05-06 07:10:13 +00:00
|
|
|
import android.widget.CompoundButton;
|
2019-06-14 17:12:56 +00:00
|
|
|
import android.widget.RadioGroup;
|
2019-05-06 07:10:13 +00:00
|
|
|
import android.widget.Spinner;
|
2019-07-14 10:32:32 +00:00
|
|
|
import android.widget.Toast;
|
2019-05-06 07:10:13 +00:00
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2019-06-30 20:52:33 +00:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2019-05-06 07:10:13 +00:00
|
|
|
import androidx.appcompat.widget.SwitchCompat;
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
2019-05-06 12:41:03 +00:00
|
|
|
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
2019-06-14 17:12:56 +00:00
|
|
|
private Button btnTheme;
|
2019-05-06 07:10:13 +00:00
|
|
|
private Spinner spStartup;
|
2019-08-14 10:16:25 +00:00
|
|
|
private SwitchCompat swCards;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swDate;
|
|
|
|
private SwitchCompat swThreading;
|
2019-08-16 17:52:59 +00:00
|
|
|
private SwitchCompat swHighlightUnread;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swAvatars;
|
2019-07-22 08:40:03 +00:00
|
|
|
private SwitchCompat swGeneratedIcons;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swIdenticons;
|
|
|
|
private SwitchCompat swCircular;
|
|
|
|
private SwitchCompat swNameEmail;
|
2019-08-22 10:50:13 +00:00
|
|
|
private SwitchCompat swSubjectTop;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swSubjectItalic;
|
|
|
|
private SwitchCompat swFlags;
|
|
|
|
private SwitchCompat swPreview;
|
2019-08-12 06:39:43 +00:00
|
|
|
private SwitchCompat swPreviewItalic;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swAddresses;
|
2019-05-17 18:07:08 +00:00
|
|
|
private SwitchCompat swAttachmentsAlt;
|
2019-07-10 09:25:23 +00:00
|
|
|
|
2019-07-09 06:09:20 +00:00
|
|
|
private SwitchCompat swContrast;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swMonospaced;
|
2019-07-22 10:04:13 +00:00
|
|
|
private SwitchCompat swImagesInline;
|
2019-07-10 09:25:23 +00:00
|
|
|
private SwitchCompat swCollapseQuotes;
|
2019-07-08 12:51:36 +00:00
|
|
|
private SwitchCompat swRemoteContent;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swActionbar;
|
|
|
|
|
2019-05-06 12:41:03 +00:00
|
|
|
private final static String[] RESET_OPTIONS = new String[]{
|
2019-08-22 10:50:13 +00:00
|
|
|
"theme", "startup", "cards", "date", "threading", "highlight_unread",
|
|
|
|
"avatars", "generated_icons", "identicons", "circular", "name_email", "subject_top", "subject_italic",
|
2019-08-12 06:39:43 +00:00
|
|
|
"flags", "preview", "preview_italic", "addresses", "attachments_alt",
|
2019-09-01 20:33:32 +00:00
|
|
|
"contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "actionbar",
|
2019-05-06 12:41:03 +00:00
|
|
|
};
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
@Override
|
|
|
|
@Nullable
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
2019-06-12 14:15:46 +00:00
|
|
|
setSubtitle(R.string.title_setup);
|
2019-05-06 12:41:03 +00:00
|
|
|
setHasOptionsMenu(true);
|
2019-05-06 07:10:13 +00:00
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_options_display, container, false);
|
|
|
|
|
|
|
|
// Get controls
|
|
|
|
|
2019-06-14 17:12:56 +00:00
|
|
|
btnTheme = view.findViewById(R.id.btnTheme);
|
2019-05-06 07:10:13 +00:00
|
|
|
spStartup = view.findViewById(R.id.spStartup);
|
2019-08-14 10:16:25 +00:00
|
|
|
swCards = view.findViewById(R.id.swCards);
|
2019-05-06 07:10:13 +00:00
|
|
|
swDate = view.findViewById(R.id.swDate);
|
|
|
|
swThreading = view.findViewById(R.id.swThreading);
|
2019-08-16 17:52:59 +00:00
|
|
|
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
|
2019-05-06 07:10:13 +00:00
|
|
|
swAvatars = view.findViewById(R.id.swAvatars);
|
2019-07-22 08:40:03 +00:00
|
|
|
swGeneratedIcons = view.findViewById(R.id.swGeneratedIcons);
|
2019-05-06 07:10:13 +00:00
|
|
|
swIdenticons = view.findViewById(R.id.swIdenticons);
|
|
|
|
swCircular = view.findViewById(R.id.swCircular);
|
|
|
|
swNameEmail = view.findViewById(R.id.swNameEmail);
|
2019-08-22 10:50:13 +00:00
|
|
|
swSubjectTop = view.findViewById(R.id.swSubjectTop);
|
2019-05-06 07:10:13 +00:00
|
|
|
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
|
|
|
|
swFlags = view.findViewById(R.id.swFlags);
|
|
|
|
swPreview = view.findViewById(R.id.swPreview);
|
2019-08-12 06:39:43 +00:00
|
|
|
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
|
2019-05-06 07:10:13 +00:00
|
|
|
swAddresses = view.findViewById(R.id.swAddresses);
|
2019-05-17 18:07:08 +00:00
|
|
|
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
|
2019-07-09 06:09:20 +00:00
|
|
|
swContrast = view.findViewById(R.id.swContrast);
|
2019-05-06 07:10:13 +00:00
|
|
|
swMonospaced = view.findViewById(R.id.swMonospaced);
|
2019-07-22 10:04:13 +00:00
|
|
|
swImagesInline = view.findViewById(R.id.swImagesInline);
|
2019-07-10 09:25:23 +00:00
|
|
|
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
|
2019-07-08 12:51:36 +00:00
|
|
|
swRemoteContent = view.findViewById(R.id.swRemoteContent);
|
2019-05-06 07:10:13 +00:00
|
|
|
swActionbar = view.findViewById(R.id.swActionbar);
|
|
|
|
|
2019-05-06 13:30:30 +00:00
|
|
|
setOptions();
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
// Wire controls
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
2019-06-14 17:12:56 +00:00
|
|
|
btnTheme.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2019-06-30 20:52:33 +00:00
|
|
|
new FragmentDialogTheme().show(getFragmentManager(), "setup:theme");
|
2019-06-14 17:12:56 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
spStartup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
@Override
|
|
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
|
|
|
String[] values = getResources().getStringArray(R.array.startupValues);
|
|
|
|
prefs.edit().putString("startup", values[position]).apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
prefs.edit().remove("startup").apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-14 10:16:25 +00:00
|
|
|
swCards.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("cards", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("date", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("threading", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-16 17:52:59 +00:00
|
|
|
swHighlightUnread.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("highlight_unread", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("avatars", checked).apply();
|
|
|
|
ContactInfo.clearCache();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-22 08:40:03 +00:00
|
|
|
swGeneratedIcons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("generated_icons", checked).apply();
|
|
|
|
swIdenticons.setEnabled(checked);
|
|
|
|
ContactInfo.clearCache();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swIdenticons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("identicons", checked).apply();
|
|
|
|
ContactInfo.clearCache();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swCircular.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("circular", checked).apply();
|
|
|
|
ContactInfo.clearCache();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swNameEmail.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("name_email", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-22 10:50:13 +00:00
|
|
|
swSubjectTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("subject_top", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swSubjectItalic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("subject_italic", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swFlags.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("flags", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("preview", checked).apply();
|
2019-08-12 06:39:43 +00:00
|
|
|
swPreviewItalic.setEnabled(checked);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swPreviewItalic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("preview_italic", checked).apply();
|
2019-05-06 07:10:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
swAddresses.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("addresses", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-17 18:07:08 +00:00
|
|
|
swAttachmentsAlt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("attachments_alt", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-09 06:09:20 +00:00
|
|
|
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("contrast", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swMonospaced.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("monospaced", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-22 10:04:13 +00:00
|
|
|
swImagesInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
2019-07-02 08:54:09 +00:00
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("inline_images", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-10 09:25:23 +00:00
|
|
|
swCollapseQuotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("collapse_quotes", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-08 12:51:36 +00:00
|
|
|
swRemoteContent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("autocontent", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("actionbar", checked).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-06 12:41:03 +00:00
|
|
|
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2019-05-06 12:41:03 +00:00
|
|
|
@Override
|
|
|
|
public void onDestroyView() {
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
|
|
|
|
super.onDestroyView();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
|
|
|
setOptions();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
inflater.inflate(R.menu.menu_options, menu);
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.menu_default:
|
|
|
|
onMenuDefault();
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onMenuDefault() {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
for (String option : RESET_OPTIONS)
|
|
|
|
editor.remove(option);
|
|
|
|
editor.apply();
|
2019-07-14 10:32:32 +00:00
|
|
|
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
|
2019-05-06 12:41:03 +00:00
|
|
|
}
|
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
private void setOptions() {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-14 10:16:25 +00:00
|
|
|
swCards.setChecked(prefs.getBoolean("cards", true));
|
2019-05-06 07:10:13 +00:00
|
|
|
swDate.setChecked(prefs.getBoolean("date", true));
|
|
|
|
swThreading.setChecked(prefs.getBoolean("threading", true));
|
2019-08-16 17:52:59 +00:00
|
|
|
swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
2019-07-22 08:40:03 +00:00
|
|
|
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));
|
2019-05-06 07:10:13 +00:00
|
|
|
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
2019-07-22 08:40:03 +00:00
|
|
|
swIdenticons.setEnabled(swGeneratedIcons.isChecked());
|
2019-05-06 07:10:13 +00:00
|
|
|
swCircular.setChecked(prefs.getBoolean("circular", true));
|
2019-08-25 09:14:16 +00:00
|
|
|
swNameEmail.setChecked(prefs.getBoolean("name_email", false));
|
2019-08-22 10:50:13 +00:00
|
|
|
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
|
|
|
|
swFlags.setChecked(prefs.getBoolean("flags", true));
|
|
|
|
swPreview.setChecked(prefs.getBoolean("preview", false));
|
2019-08-12 06:39:43 +00:00
|
|
|
swPreviewItalic.setChecked(prefs.getBoolean("preview_italic", true));
|
|
|
|
swPreviewItalic.setEnabled(swPreview.isChecked());
|
2019-05-06 07:10:13 +00:00
|
|
|
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
2019-05-17 18:07:08 +00:00
|
|
|
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
2019-07-09 06:09:20 +00:00
|
|
|
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
2019-08-24 17:50:28 +00:00
|
|
|
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
|
2019-07-10 09:25:23 +00:00
|
|
|
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
|
2019-07-08 12:51:36 +00:00
|
|
|
swRemoteContent.setChecked(prefs.getBoolean("autocontent", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
|
|
|
}
|
2019-06-30 20:52:33 +00:00
|
|
|
|
2019-08-04 07:22:53 +00:00
|
|
|
public static class FragmentDialogTheme extends FragmentDialogEx {
|
2019-06-30 20:52:33 +00:00
|
|
|
@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);
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
|
|
|
|
switch (theme) {
|
|
|
|
case "dark":
|
|
|
|
rgTheme.check(R.id.rbThemeDark);
|
|
|
|
break;
|
|
|
|
case "black":
|
|
|
|
rgTheme.check(R.id.rbThemeBlack);
|
|
|
|
break;
|
2019-09-09 07:31:55 +00:00
|
|
|
case "grey_light":
|
|
|
|
rgTheme.check(R.id.rbThemeGreyLight);
|
|
|
|
break;
|
|
|
|
case "grey_dark":
|
|
|
|
rgTheme.check(R.id.rbThemeGreyDark);
|
2019-09-08 15:22:09 +00:00
|
|
|
break;
|
2019-06-30 20:52:33 +00:00
|
|
|
case "system":
|
|
|
|
rgTheme.check(R.id.rbThemeSystem);
|
|
|
|
break;
|
2019-09-09 09:40:14 +00:00
|
|
|
case "grey_system":
|
|
|
|
rgTheme.check(R.id.rbThemeGreySystem);
|
|
|
|
break;
|
2019-06-30 20:52:33 +00:00
|
|
|
default:
|
|
|
|
rgTheme.check(R.id.rbThemeLight);
|
|
|
|
}
|
|
|
|
|
|
|
|
rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
|
getActivity().getIntent().putExtra("tab", "display");
|
|
|
|
|
|
|
|
switch (checkedId) {
|
|
|
|
case R.id.rbThemeLight:
|
|
|
|
prefs.edit().putString("theme", "light").apply();
|
|
|
|
break;
|
|
|
|
case R.id.rbThemeDark:
|
|
|
|
prefs.edit().putString("theme", "dark").apply();
|
|
|
|
break;
|
|
|
|
case R.id.rbThemeBlack:
|
|
|
|
prefs.edit().putString("theme", "black").apply();
|
|
|
|
break;
|
2019-09-09 07:31:55 +00:00
|
|
|
case R.id.rbThemeGreyLight:
|
|
|
|
prefs.edit().putString("theme", "grey_light").apply();
|
|
|
|
break;
|
|
|
|
case R.id.rbThemeGreyDark:
|
|
|
|
prefs.edit().putString("theme", "grey_dark").apply();
|
2019-09-08 15:22:09 +00:00
|
|
|
break;
|
2019-06-30 20:52:33 +00:00
|
|
|
case R.id.rbThemeSystem:
|
|
|
|
prefs.edit().putString("theme", "system").apply();
|
|
|
|
break;
|
2019-09-09 09:40:14 +00:00
|
|
|
case R.id.rbThemeGreySystem:
|
|
|
|
prefs.edit().putString("theme", "grey_system").apply();
|
|
|
|
break;
|
2019-06-30 20:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return new AlertDialog.Builder(getContext())
|
|
|
|
.setView(dview)
|
|
|
|
.create();
|
|
|
|
}
|
|
|
|
}
|
2019-05-06 07:10:13 +00:00
|
|
|
}
|