FairEmail/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java

1045 lines
45 KiB
Java
Raw Normal View History

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/>.
2020-01-05 17:32:53 +00:00
Copyright 2018-2020 by Marcel Bokhorst (M66B)
2019-05-06 07:10:13 +00:00
*/
import android.app.Dialog;
import android.content.Context;
2019-12-27 16:11:07 +00:00
import android.content.DialogInterface;
2019-05-06 07:10:13 +00:00
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
2019-12-29 17:36:26 +00:00
import android.net.Uri;
2019-05-06 07:10:13 +00:00
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.view.Window;
2019-05-06 07:10:13 +00:00
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-12-29 17:36:26 +00:00
import android.widget.ImageButton;
import android.widget.ImageView;
2019-06-14 17:12:56 +00:00
import android.widget.RadioGroup;
import android.widget.SeekBar;
2019-05-06 07:10:13 +00:00
import android.widget.Spinner;
import android.widget.TextView;
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;
import androidx.appcompat.app.AlertDialog;
2019-05-06 07:10:13 +00:00
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.FragmentActivity;
2019-09-10 06:53:07 +00:00
import androidx.lifecycle.Lifecycle;
2019-05-06 07:10:13 +00:00
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 swNavBarColorize;
private SwitchCompat swLandscape;
private SwitchCompat swLandscape3;
2019-05-06 07:10:13 +00:00
private SwitchCompat swThreading;
2019-10-12 17:40:30 +00:00
private SwitchCompat swIndentation;
2020-03-11 08:25:45 +00:00
private SwitchCompat swSeekbar;
private SwitchCompat swActionbar;
private SwitchCompat swActionbarColor;
private SwitchCompat swHighlightUnread;
private SwitchCompat swColorStripe;
2019-05-06 07:10:13 +00:00
private SwitchCompat swAvatars;
private TextView tvGravatarsHint;
2020-01-17 15:59:29 +00:00
private SwitchCompat swGravatars;
private SwitchCompat swGeneratedIcons;
2019-05-06 07:10:13 +00:00
private SwitchCompat swIdenticons;
private SwitchCompat swCircular;
private ImageView ivRed;
private ImageView ivGreen;
private ImageView ivBlue;
private SeekBar sbSaturation;
private SeekBar sbBrightness;
2019-10-14 08:51:58 +00:00
private SeekBar sbThreshold;
2019-05-06 07:10:13 +00:00
private SwitchCompat swNameEmail;
2020-02-09 10:37:16 +00:00
private SwitchCompat swPreferContact;
2019-10-03 08:19:27 +00:00
private SwitchCompat swDistinguishContacts;
private SwitchCompat swShowRecipients;
2019-11-18 09:39:32 +00:00
private SwitchCompat swSubjectTop;
private Spinner spFontSizeSender;
private Spinner spFontSizeSubject;
2019-05-06 07:10:13 +00:00
private SwitchCompat swSubjectItalic;
2020-03-22 17:43:22 +00:00
private SwitchCompat swHighlightSubject;
private Spinner spSubjectEllipsize;
private SwitchCompat swKeywords;
2019-05-06 07:10:13 +00:00
private SwitchCompat swFlags;
private SwitchCompat swFlagsBackground;
2019-05-06 07:10:13 +00:00
private SwitchCompat swPreview;
private SwitchCompat swPreviewItalic;
private Spinner spPreviewLines;
2019-05-06 07:10:13 +00:00
private SwitchCompat swAddresses;
private SwitchCompat swArchiveTrash;
private SwitchCompat swMove;
private SwitchCompat swContrast;
2019-05-06 07:10:13 +00:00
private SwitchCompat swMonospaced;
2019-09-23 18:13:38 +00:00
private SwitchCompat swTextColor;
private SwitchCompat swTextSize;
2020-05-03 17:29:02 +00:00
private SwitchCompat swTextAlign;
private SwitchCompat swCollapseQuotes;
2019-09-23 18:13:38 +00:00
private SwitchCompat swImagesInline;
2020-03-22 17:43:22 +00:00
private SwitchCompat swAttachmentsAlt;
2019-05-06 07:10:13 +00:00
2020-04-22 10:10:30 +00:00
private SwitchCompat swParseClasses;
2020-03-23 14:48:13 +00:00
private SwitchCompat swAuthentication;
2019-05-06 12:41:03 +00:00
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "date", "navbar_colorize", "landscape", "landscape3",
"threading", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "color_stripe",
2020-01-17 15:59:29 +00:00
"avatars", "gravatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients",
2020-03-22 17:43:22 +00:00
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"keywords_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses", "button_archive_trash", "button_move",
2020-05-03 17:29:02 +00:00
"contrast", "monospaced", "text_color", "text_size", "text_align",
2020-03-23 14:48:13 +00:00
"inline_images", "collapse_quotes", "attachments_alt",
2020-04-22 10:10:30 +00:00
"parse_classes", "authentication"
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);
swNavBarColorize = view.findViewById(R.id.swNavBarColorize);
swLandscape = view.findViewById(R.id.swLandscape);
swLandscape3 = view.findViewById(R.id.swLandscape3);
2019-05-06 07:10:13 +00:00
swThreading = view.findViewById(R.id.swThreading);
swIndentation = view.findViewById(R.id.swIndentation);
2020-03-11 08:25:45 +00:00
swSeekbar = view.findViewById(R.id.swSeekbar);
swActionbar = view.findViewById(R.id.swActionbar);
swActionbarColor = view.findViewById(R.id.swActionbarColor);
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
swColorStripe = view.findViewById(R.id.swColorStripe);
2019-05-06 07:10:13 +00:00
swAvatars = view.findViewById(R.id.swAvatars);
2020-01-17 15:59:29 +00:00
swGravatars = view.findViewById(R.id.swGravatars);
tvGravatarsHint = view.findViewById(R.id.tvGravatarsHint);
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);
ivRed = view.findViewById(R.id.ivRed);
ivGreen = view.findViewById(R.id.ivGreen);
ivBlue = view.findViewById(R.id.ivBlue);
sbSaturation = view.findViewById(R.id.sbSaturation);
sbBrightness = view.findViewById(R.id.sbBrightness);
2019-10-14 08:51:58 +00:00
sbThreshold = view.findViewById(R.id.sbThreshold);
2019-05-06 07:10:13 +00:00
swNameEmail = view.findViewById(R.id.swNameEmail);
2020-02-09 10:37:16 +00:00
swPreferContact = view.findViewById(R.id.swPreferContact);
2019-10-03 08:19:27 +00:00
swDistinguishContacts = view.findViewById(R.id.swDistinguishContacts);
swShowRecipients = view.findViewById(R.id.swShowRecipients);
2019-11-18 09:39:32 +00:00
swSubjectTop = view.findViewById(R.id.swSubjectTop);
spFontSizeSender = view.findViewById(R.id.spFontSizeSender);
spFontSizeSubject = view.findViewById(R.id.spFontSizeSubject);
2019-05-06 07:10:13 +00:00
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
2020-03-22 17:43:22 +00:00
swHighlightSubject = view.findViewById(R.id.swHighlightSubject);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
swKeywords = view.findViewById(R.id.swKeywords);
2019-05-06 07:10:13 +00:00
swFlags = view.findViewById(R.id.swFlags);
swFlagsBackground = view.findViewById(R.id.swFlagsBackground);
2019-05-06 07:10:13 +00:00
swPreview = view.findViewById(R.id.swPreview);
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
spPreviewLines = view.findViewById(R.id.spPreviewLines);
2019-05-06 07:10:13 +00:00
swAddresses = view.findViewById(R.id.swAddresses);
swArchiveTrash = view.findViewById(R.id.swArchiveTrash);
swMove = view.findViewById(R.id.swMove);
swContrast = view.findViewById(R.id.swContrast);
2019-05-06 07:10:13 +00:00
swMonospaced = view.findViewById(R.id.swMonospaced);
2019-09-23 18:13:38 +00:00
swTextColor = view.findViewById(R.id.swTextColor);
swTextSize = view.findViewById(R.id.swTextSize);
2020-05-03 17:29:02 +00:00
swTextAlign = view.findViewById(R.id.swTextAlign);
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
2019-09-23 18:13:38 +00:00
swImagesInline = view.findViewById(R.id.swImagesInline);
2020-03-22 17:43:22 +00:00
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
2020-04-22 10:10:30 +00:00
swParseClasses = view.findViewById(R.id.swParseClasses);
2020-03-23 14:48:13 +00:00
swAuthentication = view.findViewById(R.id.swAuthentication);
2019-05-06 07:10:13 +00:00
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-10-12 15:16:53 +00:00
new FragmentDialogTheme().show(getParentFragmentManager(), "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-10-20 07:16:45 +00:00
swIndentation.setEnabled(checked);
2019-08-14 10:16:25 +00:00
}
});
swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
2019-05-06 07:10:13 +00:00
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("date", checked).apply();
2019-05-06 07:10:13 +00:00
}
});
swNavBarColorize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
2019-05-06 07:10:13 +00:00
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("navbar_colorize", checked).apply();
setNavigationBarColor(
checked ? Helper.resolveColor(getContext(), R.attr.colorPrimaryDark) : Color.BLACK);
}
});
swLandscape.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("landscape", checked).apply();
swLandscape3.setEnabled(checked);
}
});
swLandscape3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("landscape3", checked).apply();
2019-05-06 07:10:13 +00:00
}
});
2019-10-20 07:16:45 +00:00
swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
2019-10-12 17:40:30 +00:00
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
2019-10-20 07:16:45 +00:00
prefs.edit().putBoolean("threading", checked).apply();
2020-01-01 19:52:23 +00:00
WidgetUnified.updateData(getContext());
2019-10-12 17:40:30 +00:00
}
});
swIndentation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("indentation", checked).apply();
}
});
2020-03-11 08:25:45 +00:00
swSeekbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("seekbar", checked).apply();
}
});
swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("actionbar", checked).apply();
swActionbarColor.setEnabled(checked);
}
});
swActionbarColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("actionbar_color", checked).apply();
}
});
swHighlightUnread.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("highlight_unread", checked).apply();
}
});
swColorStripe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("color_stripe", 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();
}
});
2020-01-17 15:59:29 +00:00
swGravatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("gravatars", checked).apply();
ContactInfo.clearCache();
}
});
tvGravatarsHint.getPaint().setUnderlineText(true);
tvGravatarsHint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(getContext(), Uri.parse(Helper.GRAVATAR_PRIVACY_URI), true);
}
});
swGeneratedIcons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("generated_icons", checked).apply();
swIdenticons.setEnabled(checked);
2020-01-17 15:59:29 +00:00
sbSaturation.setEnabled(checked);
sbBrightness.setEnabled(checked);
sbThreshold.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();
updateColor();
2019-05-06 07:10:13 +00:00
ContactInfo.clearCache();
}
});
sbSaturation.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
prefs.edit().putInt("saturation", progress).apply();
updateColor();
ContactInfo.clearCache();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
sbBrightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
prefs.edit().putInt("brightness", progress).apply();
updateColor();
ContactInfo.clearCache();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
2019-10-14 08:51:58 +00:00
sbThreshold.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
prefs.edit().putInt("threshold", progress).apply();
updateColor();
ContactInfo.clearCache();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
2019-05-06 07:10:13 +00:00
swNameEmail.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("name_email", checked).apply();
}
});
2020-02-09 10:37:16 +00:00
swPreferContact.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("prefer_contact", checked).apply();
}
});
2019-10-03 08:19:27 +00:00
swDistinguishContacts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("distinguish_contacts", checked).apply();
}
});
swShowRecipients.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("show_recipients", checked).apply();
}
});
2019-11-18 09:39:32 +00:00
swSubjectTop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("subject_top", checked).apply();
2020-01-01 19:52:23 +00:00
WidgetUnified.updateData(getContext());
2019-11-18 09:39:32 +00:00
}
});
spFontSizeSender.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.fontSizeValues);
prefs.edit().putInt("font_size_sender", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("font_size_sender").apply();
}
});
spFontSizeSubject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.fontSizeValues);
prefs.edit().putInt("font_size_subject", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("font_size_subject").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();
2020-01-01 19:52:23 +00:00
WidgetUnified.updateData(getContext());
2019-05-06 07:10:13 +00:00
}
});
2020-03-22 17:43:22 +00:00
swHighlightSubject.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("highlight_subject", checked).apply();
}
});
spSubjectEllipsize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String[] values = getResources().getStringArray(R.array.ellipsizeValues);
prefs.edit().putString("subject_ellipsize", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("subject_ellipsize").apply();
}
});
swKeywords.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("keywords_header", checked).apply();
}
});
2019-05-06 07:10:13 +00:00
swFlags.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("flags", checked).apply();
}
});
swFlagsBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("flags_background", checked).apply();
}
});
2019-05-06 07:10:13 +00:00
swPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("preview", checked).apply();
swPreviewItalic.setEnabled(checked);
spPreviewLines.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
}
});
spPreviewLines.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
prefs.edit().putInt("preview_lines", position + 1).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("preview_lines").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();
}
});
swArchiveTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("button_archive_trash", checked).apply();
}
});
swMove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("button_move", checked).apply();
}
});
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-09-23 18:13:38 +00:00
swTextColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
2019-09-23 18:13:38 +00:00
prefs.edit().putBoolean("text_color", checked).apply();
}
});
swTextSize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("text_size", checked).apply();
}
});
2020-05-03 17:29:02 +00:00
swTextAlign.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("text_align", checked).apply();
}
});
swCollapseQuotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("collapse_quotes", checked).apply();
}
});
2019-09-23 18:13:38 +00:00
swImagesInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("inline_images", checked).apply();
}
});
2020-03-22 17:43:22 +00:00
swAttachmentsAlt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("attachments_alt", checked).apply();
}
});
2020-04-22 10:10:30 +00:00
swParseClasses.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("parse_classes", checked).apply();
}
});
2020-03-23 14:48:13 +00:00
swAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("authentication", 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) {
2019-09-10 06:53:07 +00:00
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
setOptions();
2019-05-06 12:41:03 +00:00
}
@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();
setNavigationBarColor(Color.BLACK);
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());
boolean normal = getResources().getConfiguration()
.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
2019-05-06 07:10:13 +00:00
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));
swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false));
swLandscape.setChecked(prefs.getBoolean("landscape", true));
swLandscape.setEnabled(normal);
swLandscape3.setChecked(prefs.getBoolean("landscape3", false));
swLandscape3.setEnabled(normal && swLandscape.isChecked());
2019-05-06 07:10:13 +00:00
swThreading.setChecked(prefs.getBoolean("threading", true));
swIndentation.setChecked(prefs.getBoolean("indentation", false));
swIndentation.setEnabled(swCards.isChecked());
2020-03-11 08:25:45 +00:00
swSeekbar.setChecked(prefs.getBoolean("seekbar", false));
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
swActionbarColor.setChecked(prefs.getBoolean("actionbar_color", false));
swActionbarColor.setEnabled(swActionbar.isChecked());
swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", true));
swColorStripe.setChecked(prefs.getBoolean("color_stripe", true));
2019-05-06 07:10:13 +00:00
swAvatars.setChecked(prefs.getBoolean("avatars", true));
2020-01-17 15:59:29 +00:00
swGravatars.setChecked(prefs.getBoolean("gravatars", false));
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));
2019-05-06 07:10:13 +00:00
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
swIdenticons.setEnabled(swGeneratedIcons.isChecked());
2019-05-06 07:10:13 +00:00
swCircular.setChecked(prefs.getBoolean("circular", true));
2019-10-14 08:51:58 +00:00
sbSaturation.setProgress(prefs.getInt("saturation", 100));
2019-10-13 11:54:18 +00:00
sbSaturation.setEnabled(swGeneratedIcons.isChecked());
sbBrightness.setProgress(prefs.getInt("brightness", 100));
2019-10-13 11:54:18 +00:00
sbBrightness.setEnabled(swGeneratedIcons.isChecked());
2019-10-14 08:51:58 +00:00
sbThreshold.setProgress(prefs.getInt("threshold", 50));
sbThreshold.setEnabled(swGeneratedIcons.isChecked());
2019-08-25 09:14:16 +00:00
swNameEmail.setChecked(prefs.getBoolean("name_email", false));
2020-02-09 10:37:16 +00:00
swPreferContact.setChecked(prefs.getBoolean("prefer_contact", false));
2019-10-03 08:19:27 +00:00
swDistinguishContacts.setChecked(prefs.getBoolean("distinguish_contacts", false));
swShowRecipients.setChecked(prefs.getBoolean("show_recipients", true));
2019-11-18 09:39:32 +00:00
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
int[] fontSizeValues = getResources().getIntArray(R.array.fontSizeValues);
int font_size_sender = prefs.getInt("font_size_sender", -1);
for (int pos = 0; pos < fontSizeValues.length; pos++)
if (fontSizeValues[pos] == font_size_sender) {
spFontSizeSender.setSelection(pos);
break;
}
int font_size_subject = prefs.getInt("font_size_subject", -1);
for (int pos = 0; pos < fontSizeValues.length; pos++)
if (fontSizeValues[pos] == font_size_subject) {
spFontSizeSubject.setSelection(pos);
break;
}
2019-05-06 07:10:13 +00:00
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
2020-03-22 17:43:22 +00:00
swHighlightSubject.setChecked(prefs.getBoolean("highlight_subject", false));
String subject_ellipsize = prefs.getString("subject_ellipsize", "middle");
String[] ellipsizeValues = getResources().getStringArray(R.array.ellipsizeValues);
for (int pos = 0; pos < startupValues.length; pos++)
if (ellipsizeValues[pos].equals(subject_ellipsize)) {
spSubjectEllipsize.setSelection(pos);
break;
}
swKeywords.setChecked(prefs.getBoolean("keywords_header", false));
2019-05-06 07:10:13 +00:00
swFlags.setChecked(prefs.getBoolean("flags", true));
swFlagsBackground.setChecked(prefs.getBoolean("flags_background", false));
2019-05-06 07:10:13 +00:00
swPreview.setChecked(prefs.getBoolean("preview", false));
swPreviewItalic.setChecked(prefs.getBoolean("preview_italic", true));
swPreviewItalic.setEnabled(swPreview.isChecked());
spPreviewLines.setSelection(prefs.getInt("preview_lines", 2) - 1);
spPreviewLines.setEnabled(swPreview.isChecked());
2019-05-06 07:10:13 +00:00
swAddresses.setChecked(prefs.getBoolean("addresses", false));
swArchiveTrash.setChecked(prefs.getBoolean("button_archive_trash", true));
swMove.setChecked(prefs.getBoolean("button_move", true));
swContrast.setChecked(prefs.getBoolean("contrast", false));
2019-05-06 07:10:13 +00:00
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
2019-09-23 18:13:38 +00:00
swTextColor.setChecked(prefs.getBoolean("text_color", true));
swTextSize.setChecked(prefs.getBoolean("text_size", true));
2020-05-03 17:29:02 +00:00
swTextAlign.setChecked(prefs.getBoolean("text_align", true));
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
2019-09-23 18:13:38 +00:00
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
2020-03-22 17:43:22 +00:00
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
2020-04-22 10:10:30 +00:00
swParseClasses.setChecked(prefs.getBoolean("parse_classes", false));
2020-03-23 14:48:13 +00:00
swAuthentication.setChecked(prefs.getBoolean("authentication", true));
updateColor();
}
private void setNavigationBarColor(int color) {
FragmentActivity activity = getActivity();
if (activity == null)
return;
Window window = activity.getWindow();
if (window == null)
return;
window.setNavigationBarColor(color);
}
private void updateColor() {
Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
2019-10-13 11:54:18 +00:00
boolean identicons = prefs.getBoolean("identicons", false);
boolean circular = prefs.getBoolean("circular", true);
int size = Helper.dp2pixels(context, 36);
2019-10-14 11:52:04 +00:00
byte[] ahash = ImageHelper.getHash("abc@example.com");
byte[] bhash = ImageHelper.getHash("bcd@example.com");
byte[] chash = ImageHelper.getHash("cde@example.com");
2019-10-13 11:54:18 +00:00
Integer radius = (circular && !identicons ? null : Helper.dp2pixels(context, 3));
2019-10-14 11:52:04 +00:00
Bitmap red = (identicons
? ImageHelper.generateIdenticon(ahash, 0f, size, 5, context)
: ImageHelper.generateLetterIcon("A", 0f, size, context));
2019-10-13 11:54:18 +00:00
2019-10-14 11:52:04 +00:00
Bitmap green = (identicons
? ImageHelper.generateIdenticon(bhash, 120f, size, 5, context)
: ImageHelper.generateLetterIcon("B", 120f, size, context));
2019-10-13 11:54:18 +00:00
2019-10-14 11:52:04 +00:00
Bitmap blue = (identicons
? ImageHelper.generateIdenticon(chash, 240f, size, 5, context)
: ImageHelper.generateLetterIcon("C", 240f, size, context));
2019-10-14 11:52:04 +00:00
ivRed.setImageBitmap(ImageHelper.makeCircular(red, radius));
ivGreen.setImageBitmap(ImageHelper.makeCircular(green, radius));
ivBlue.setImageBitmap(ImageHelper.makeCircular(blue, radius));
2019-05-06 07:10:13 +00:00
}
2019-09-11 19:43:27 +00:00
public static class FragmentDialogTheme extends FragmentDialogBase {
2019-12-29 17:36:26 +00:00
private ImageButton itten;
2019-12-27 19:34:07 +00:00
private RadioGroup rgTheme;
private SwitchCompat swReverse;
private SwitchCompat swDark;
2019-12-30 13:29:16 +00:00
private SwitchCompat swBlack;
2019-12-27 19:34:07 +00:00
private SwitchCompat swSystem;
private void eval() {
int checkedId = rgTheme.getCheckedRadioButtonId();
2020-04-03 10:13:05 +00:00
boolean colored = (checkedId == R.id.rbThemeBlueOrange ||
2019-12-30 13:29:16 +00:00
checkedId == R.id.rbThemeYellowPurple ||
checkedId == R.id.rbThemeRedGreen);
2020-04-03 10:13:05 +00:00
boolean dark = (colored || checkedId == R.id.rbThemeGrey);
2019-12-27 19:34:07 +00:00
2020-04-03 10:13:05 +00:00
swReverse.setEnabled(colored);
2020-04-03 10:04:50 +00:00
swDark.setEnabled(dark);
2020-04-03 10:13:05 +00:00
swBlack.setEnabled(colored && swDark.isChecked());
2020-04-03 10:04:50 +00:00
swSystem.setEnabled(dark && !swDark.isChecked());
2019-12-27 19:34:07 +00:00
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_theme, null);
2019-12-29 17:36:26 +00:00
itten = dview.findViewById(R.id.itten);
2019-12-27 19:34:07 +00:00
rgTheme = dview.findViewById(R.id.rgTheme);
swReverse = dview.findViewById(R.id.swReverse);
swDark = dview.findViewById(R.id.swDark);
2019-12-30 13:29:16 +00:00
swBlack = dview.findViewById(R.id.swBlack);
2019-12-27 19:34:07 +00:00
swSystem = dview.findViewById(R.id.swSystem);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String theme = prefs.getString("theme", "light");
2019-12-29 17:36:26 +00:00
itten.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("https://en.wikipedia.org/wiki/Johannes_Itten");
Helper.view(getContext(), uri, false);
}
});
2019-12-27 19:34:07 +00:00
swReverse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
eval();
}
});
swDark.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
eval();
}
});
2019-12-30 13:29:16 +00:00
swBlack.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
eval();
}
});
2019-12-27 19:34:07 +00:00
swSystem.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
eval();
}
});
2019-12-27 16:11:07 +00:00
rgTheme.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
2019-12-27 19:34:07 +00:00
eval();
2019-12-27 16:11:07 +00:00
}
});
2019-12-30 13:29:16 +00:00
boolean colored =
(theme.startsWith("orange_blue") ||
theme.startsWith("purple_yellow") ||
theme.startsWith("green_red"));
boolean dark = theme.endsWith("dark");
2019-12-30 14:21:08 +00:00
boolean black = (!"black".equals(theme) && theme.endsWith("black"));
2019-12-30 13:29:16 +00:00
boolean system = theme.endsWith("system");
swReverse.setChecked(colored);
swDark.setChecked(dark || black);
swBlack.setChecked(black);
swSystem.setChecked(system);
2019-12-27 19:34:07 +00:00
switch (theme) {
2019-12-26 15:15:46 +00:00
case "light":
case "dark":
2019-12-27 16:11:07 +00:00
case "system":
2019-12-28 13:45:10 +00:00
case "blue_orange_system":
2019-12-27 16:11:07 +00:00
case "blue_orange_light":
2019-12-26 15:15:46 +00:00
case "blue_orange_dark":
2019-12-30 13:29:16 +00:00
case "blue_orange_black":
2020-04-03 10:04:50 +00:00
case "orange_blue_system":
2019-12-27 17:51:00 +00:00
case "orange_blue_light":
case "orange_blue_dark":
2019-12-30 13:29:16 +00:00
case "orange_blue_black":
2019-12-27 16:11:07 +00:00
rgTheme.check(R.id.rbThemeBlueOrange);
2019-12-26 15:15:46 +00:00
break;
2019-12-28 13:45:10 +00:00
case "yellow_purple_system":
2019-12-27 16:11:07 +00:00
case "yellow_purple_light":
2019-12-26 15:15:46 +00:00
case "yellow_purple_dark":
2019-12-30 13:29:16 +00:00
case "yellow_purple_black":
2020-04-03 10:04:50 +00:00
case "purple_yellow_system":
2019-12-27 17:51:00 +00:00
case "purple_yellow_light":
case "purple_yellow_dark":
2019-12-30 13:29:16 +00:00
case "purple_yellow_black":
2019-12-27 16:11:07 +00:00
rgTheme.check(R.id.rbThemeYellowPurple);
2019-12-26 15:15:46 +00:00
break;
2019-12-28 13:45:10 +00:00
case "red_green_system":
2019-12-27 16:11:07 +00:00
case "red_green_light":
2019-12-26 20:03:38 +00:00
case "red_green_dark":
2019-12-30 13:29:16 +00:00
case "red_green_black":
2020-04-03 10:04:50 +00:00
case "green_red_system":
2019-12-27 17:51:00 +00:00
case "green_red_light":
case "green_red_dark":
2019-12-30 13:29:16 +00:00
case "green_red_black":
2019-12-27 16:11:07 +00:00
rgTheme.check(R.id.rbThemeRedGreen);
2019-12-26 15:15:46 +00:00
break;
2019-12-27 16:11:07 +00:00
case "grey_system":
case "grey_light":
2019-09-09 07:31:55 +00:00
case "grey_dark":
2019-12-27 16:11:07 +00:00
rgTheme.check(R.id.rbThemeGrey);
2019-09-08 15:22:09 +00:00
break;
2019-12-30 14:21:08 +00:00
case "black":
rgTheme.check(R.id.rbThemeBlack);
break;
}
return new AlertDialog.Builder(getContext())
.setView(dview)
2019-12-27 16:11:07 +00:00
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getActivity().getIntent().putExtra("tab", "display");
ContactInfo.clearCache();
2019-12-28 08:02:00 +00:00
boolean reverse = (swReverse.isEnabled() && swReverse.isChecked());
boolean dark = (swDark.isEnabled() && swDark.isChecked());
2019-12-30 13:29:16 +00:00
boolean black = (swBlack.isEnabled() && swBlack.isChecked());
2019-12-28 08:02:00 +00:00
boolean system = (swSystem.isEnabled() && swSystem.isChecked());
2019-12-27 16:11:07 +00:00
switch (rgTheme.getCheckedRadioButtonId()) {
case R.id.rbThemeBlueOrange:
2019-12-28 08:02:00 +00:00
if (system)
2020-04-03 10:04:50 +00:00
prefs.edit().putString("theme",
reverse ? "orange_blue_system" : "blue_orange_system").apply();
2019-12-27 16:11:07 +00:00
else
2019-12-27 17:51:00 +00:00
prefs.edit().putString("theme",
2019-12-28 08:02:00 +00:00
(reverse ? "orange_blue" : "blue_orange") +
2019-12-30 13:29:16 +00:00
(black ? "_black" : dark ? "_dark" : "_light")).apply();
2019-12-27 16:11:07 +00:00
break;
case R.id.rbThemeYellowPurple:
2019-12-28 13:45:10 +00:00
if (system)
2020-04-03 10:04:50 +00:00
prefs.edit().putString("theme",
reverse ? "purple_yellow_system" : "yellow_purple_system").apply();
2019-12-28 13:45:10 +00:00
else
prefs.edit().putString("theme",
(reverse ? "purple_yellow" : "yellow_purple") +
2019-12-30 13:29:16 +00:00
(black ? "_black" : dark ? "_dark" : "_light")).apply();
2019-12-27 16:11:07 +00:00
break;
case R.id.rbThemeRedGreen:
2019-12-28 13:45:10 +00:00
if (system)
2020-04-03 10:04:50 +00:00
prefs.edit().putString("theme",
reverse ? "green_red_system" : "red_green_system").apply();
2019-12-28 13:45:10 +00:00
else
prefs.edit().putString("theme",
(reverse ? "green_red" : "red_green") +
2019-12-30 13:29:16 +00:00
(black ? "_black" : dark ? "_dark" : "_light")).apply();
2019-12-27 16:11:07 +00:00
break;
case R.id.rbThemeGrey:
2019-12-28 08:02:00 +00:00
if (system)
2019-12-27 16:11:07 +00:00
prefs.edit().putString("theme", "grey_system").apply();
else
2019-12-28 08:02:00 +00:00
prefs.edit().putString("theme",
"grey" + (dark ? "_dark" : "_light")).apply();
2019-12-27 16:11:07 +00:00
break;
2019-12-30 14:21:08 +00:00
case R.id.rbThemeBlack:
prefs.edit().putString("theme", "black").apply();
break;
2019-12-27 16:11:07 +00:00
}
}
})
2019-09-12 11:23:32 +00:00
.setNegativeButton(android.R.string.cancel, null)
.create();
}
}
2019-05-06 07:10:13 +00:00
}