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
|
|
|
*/
|
|
|
|
|
2019-06-30 20:52:33 +00:00
|
|
|
import android.app.Dialog;
|
2019-10-13 09:14:06 +00:00
|
|
|
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;
|
2019-10-19 11:51:16 +00:00
|
|
|
import android.content.res.Configuration;
|
2019-10-13 09:14:06 +00:00
|
|
|
import android.graphics.Bitmap;
|
2020-03-03 13:36:34 +00:00
|
|
|
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;
|
2020-03-03 13:36:34 +00:00
|
|
|
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;
|
2019-10-13 09:14:06 +00:00
|
|
|
import android.widget.ImageView;
|
2019-06-14 17:12:56 +00:00
|
|
|
import android.widget.RadioGroup;
|
2019-10-13 09:14:06 +00:00
|
|
|
import android.widget.SeekBar;
|
2019-05-06 07:10:13 +00:00
|
|
|
import android.widget.Spinner;
|
2020-01-23 16:02:52 +00:00
|
|
|
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;
|
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;
|
2020-03-03 13:36:34 +00:00
|
|
|
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;
|
2020-03-04 12:23:47 +00:00
|
|
|
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;
|
2020-03-04 12:23:47 +00:00
|
|
|
private SwitchCompat swActionbar;
|
|
|
|
|
2019-08-16 17:52:59 +00:00
|
|
|
private SwitchCompat swHighlightUnread;
|
2019-12-30 10:44:09 +00:00
|
|
|
private SwitchCompat swColorStripe;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swAvatars;
|
2020-01-23 16:02:52 +00:00
|
|
|
private TextView tvGravatarsHint;
|
2020-01-17 15:59:29 +00:00
|
|
|
private SwitchCompat swGravatars;
|
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;
|
2019-10-13 09:14:06 +00:00
|
|
|
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;
|
2019-11-18 09:39:32 +00:00
|
|
|
private SwitchCompat swSubjectTop;
|
2019-11-17 19:30:33 +00:00
|
|
|
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;
|
2019-09-09 10:22:50 +00:00
|
|
|
private Spinner spSubjectEllipsize;
|
2020-01-27 16:35:38 +00:00
|
|
|
private SwitchCompat swKeywords;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swFlags;
|
2019-09-27 09:33:07 +00:00
|
|
|
private SwitchCompat swFlagsBackground;
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swPreview;
|
2019-08-12 06:39:43 +00:00
|
|
|
private SwitchCompat swPreviewItalic;
|
2019-10-20 17:35:31 +00:00
|
|
|
private Spinner spPreviewLines;
|
2020-03-23 15:12:34 +00:00
|
|
|
|
2019-05-06 07:10:13 +00:00
|
|
|
private SwitchCompat swAddresses;
|
2020-03-23 15:01:17 +00:00
|
|
|
private SwitchCompat swArchiveTrash;
|
2020-03-23 15:12:34 +00:00
|
|
|
private SwitchCompat swMove;
|
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-09-23 18:13:38 +00:00
|
|
|
private SwitchCompat swTextColor;
|
2020-02-20 15:08:33 +00:00
|
|
|
private SwitchCompat swTextSize;
|
2019-07-10 09:25:23 +00:00
|
|
|
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-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[]{
|
2020-03-04 12:23:47 +00:00
|
|
|
"theme", "startup", "cards", "date", "navbar_colorize", "landscape", "landscape3",
|
2020-03-11 08:25:45 +00:00
|
|
|
"threading", "indentation", "seekbar", "actionbar",
|
2020-03-04 12:23:47 +00:00
|
|
|
"highlight_unread", "color_stripe",
|
2020-01-17 15:59:29 +00:00
|
|
|
"avatars", "gravatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
|
2020-03-23 14:48:13 +00:00
|
|
|
"name_email", "prefer_contact", "distinguish_contacts",
|
2020-03-22 17:43:22 +00:00
|
|
|
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
|
2020-03-23 15:01:17 +00:00
|
|
|
"keywords_header", "flags", "flags_background",
|
|
|
|
"preview", "preview_italic", "preview_lines",
|
2020-03-23 15:12:34 +00:00
|
|
|
"addresses", "button_archive_trash", "button_move",
|
2020-02-20 15:08:33 +00:00
|
|
|
"contrast", "monospaced", "text_color", "text_size",
|
2020-03-23 14:48:13 +00:00
|
|
|
"inline_images", "collapse_quotes", "attachments_alt",
|
|
|
|
"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);
|
2020-03-04 12:23:47 +00:00
|
|
|
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);
|
2020-03-04 12:23:47 +00:00
|
|
|
swIndentation = view.findViewById(R.id.swIndentation);
|
2020-03-11 08:25:45 +00:00
|
|
|
swSeekbar = view.findViewById(R.id.swSeekbar);
|
2020-03-04 12:23:47 +00:00
|
|
|
swActionbar = view.findViewById(R.id.swActionbar);
|
|
|
|
|
2019-08-16 17:52:59 +00:00
|
|
|
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
|
2019-12-30 10:44:09 +00:00
|
|
|
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);
|
2020-01-23 16:02:52 +00:00
|
|
|
tvGravatarsHint = view.findViewById(R.id.tvGravatarsHint);
|
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);
|
2019-10-13 09:14:06 +00:00
|
|
|
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);
|
2019-11-18 09:39:32 +00:00
|
|
|
swSubjectTop = view.findViewById(R.id.swSubjectTop);
|
2019-11-17 19:30:33 +00:00
|
|
|
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);
|
2019-09-09 10:22:50 +00:00
|
|
|
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
|
2020-01-27 16:35:38 +00:00
|
|
|
swKeywords = view.findViewById(R.id.swKeywords);
|
2019-05-06 07:10:13 +00:00
|
|
|
swFlags = view.findViewById(R.id.swFlags);
|
2019-09-27 09:33:07 +00:00
|
|
|
swFlagsBackground = view.findViewById(R.id.swFlagsBackground);
|
2019-05-06 07:10:13 +00:00
|
|
|
swPreview = view.findViewById(R.id.swPreview);
|
2019-08-12 06:39:43 +00:00
|
|
|
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
|
2019-10-20 17:35:31 +00:00
|
|
|
spPreviewLines = view.findViewById(R.id.spPreviewLines);
|
2019-05-06 07:10:13 +00:00
|
|
|
swAddresses = view.findViewById(R.id.swAddresses);
|
2020-03-23 15:01:17 +00:00
|
|
|
swArchiveTrash = view.findViewById(R.id.swArchiveTrash);
|
2020-03-23 15:12:34 +00:00
|
|
|
swMove = view.findViewById(R.id.swMove);
|
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-09-23 18:13:38 +00:00
|
|
|
swTextColor = view.findViewById(R.id.swTextColor);
|
2020-02-20 15:08:33 +00:00
|
|
|
swTextSize = view.findViewById(R.id.swTextSize);
|
2019-07-10 09:25:23 +00:00
|
|
|
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-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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-04 12:23:47 +00:00
|
|
|
swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
2019-05-06 07:10:13 +00:00
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
2020-03-04 12:23:47 +00:00
|
|
|
prefs.edit().putBoolean("date", checked).apply();
|
2019-05-06 07:10:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-04 12:23:47 +00:00
|
|
|
swNavBarColorize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
2019-05-06 07:10:13 +00:00
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
2020-03-04 12:23:47 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-04 12:23:47 +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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-04 12:23:47 +00:00
|
|
|
swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("actionbar", 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-12-30 10:44:09 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-01-23 16:02:52 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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);
|
2020-01-17 15:59:29 +00:00
|
|
|
sbSaturation.setEnabled(checked);
|
|
|
|
sbBrightness.setEnabled(checked);
|
|
|
|
sbThreshold.setEnabled(checked);
|
2019-07-22 08:40:03 +00:00
|
|
|
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();
|
2019-10-13 09:14:06 +00:00
|
|
|
updateColor();
|
2019-05-06 07:10:13 +00:00
|
|
|
ContactInfo.clearCache();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-13 09:14:06 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-11-17 19:30:33 +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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-09 10:22:50 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-01-27 16:35:38 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-27 09:33:07 +00:00
|
|
|
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();
|
2019-08-12 06:39:43 +00:00
|
|
|
swPreviewItalic.setEnabled(checked);
|
2019-10-20 17:35:31 +00:00
|
|
|
spPreviewLines.setEnabled(checked);
|
2019-08-12 06:39:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-20 17:35:31 +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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-23 15:01:17 +00:00
|
|
|
swArchiveTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
2020-03-23 15:12:34 +00:00
|
|
|
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();
|
2020-03-23 15:01:17 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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-09-23 18:13:38 +00:00
|
|
|
swTextColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
2019-07-02 08:54:09 +00:00
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
2019-09-23 18:13:38 +00:00
|
|
|
prefs.edit().putBoolean("text_color", checked).apply();
|
2019-07-02 08:54:09 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-20 15:08:33 +00:00
|
|
|
swTextSize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
prefs.edit().putBoolean("text_size", 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-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-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();
|
2020-03-03 13:36:34 +00:00
|
|
|
|
|
|
|
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());
|
|
|
|
|
2019-10-19 11:51:16 +00:00
|
|
|
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));
|
2020-03-04 12:23:47 +00:00
|
|
|
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));
|
2020-03-04 12:23:47 +00:00
|
|
|
swIndentation.setChecked(prefs.getBoolean("indentation", false));
|
|
|
|
swIndentation.setEnabled(swCards.isChecked());
|
2020-03-11 08:25:45 +00:00
|
|
|
swSeekbar.setChecked(prefs.getBoolean("seekbar", false));
|
2020-03-04 12:23:47 +00:00
|
|
|
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
|
|
|
|
2020-03-08 20:25:20 +00:00
|
|
|
swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", true));
|
2019-12-30 10:44:09 +00:00
|
|
|
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));
|
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-10-14 08:51:58 +00:00
|
|
|
|
2019-10-13 09:14:06 +00:00
|
|
|
sbSaturation.setProgress(prefs.getInt("saturation", 100));
|
2019-10-13 11:54:18 +00:00
|
|
|
sbSaturation.setEnabled(swGeneratedIcons.isChecked());
|
2019-10-13 09:14:06 +00:00
|
|
|
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));
|
2019-11-18 09:39:32 +00:00
|
|
|
swSubjectTop.setChecked(prefs.getBoolean("subject_top", false));
|
|
|
|
|
2019-11-17 19:30:33 +00:00
|
|
|
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));
|
2019-09-09 10:22:50 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-01-27 16:35:38 +00:00
|
|
|
swKeywords.setChecked(prefs.getBoolean("keywords_header", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
swFlags.setChecked(prefs.getBoolean("flags", true));
|
2019-09-27 09:33:07 +00:00
|
|
|
swFlagsBackground.setChecked(prefs.getBoolean("flags_background", false));
|
2019-05-06 07:10:13 +00:00
|
|
|
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-10-20 17:35:31 +00:00
|
|
|
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));
|
2020-03-23 15:12:34 +00:00
|
|
|
swArchiveTrash.setChecked(prefs.getBoolean("button_archive_trash", true));
|
|
|
|
swMove.setChecked(prefs.getBoolean("button_move", true));
|
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-09-23 18:13:38 +00:00
|
|
|
swTextColor.setChecked(prefs.getBoolean("text_color", true));
|
2020-02-20 15:08:33 +00:00
|
|
|
swTextSize.setChecked(prefs.getBoolean("text_size", true));
|
2019-07-10 09:25:23 +00:00
|
|
|
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));
|
2019-10-13 09:14:06 +00:00
|
|
|
|
2020-03-23 14:48:13 +00:00
|
|
|
swAuthentication.setChecked(prefs.getBoolean("authentication", true));
|
|
|
|
|
2019-10-13 09:14:06 +00:00
|
|
|
updateColor();
|
|
|
|
}
|
|
|
|
|
2020-03-03 13:36:34 +00:00
|
|
|
private void setNavigationBarColor(int color) {
|
|
|
|
FragmentActivity activity = getActivity();
|
|
|
|
if (activity == null)
|
|
|
|
return;
|
|
|
|
Window window = activity.getWindow();
|
|
|
|
if (window == null)
|
|
|
|
return;
|
|
|
|
window.setNavigationBarColor(color);
|
|
|
|
}
|
|
|
|
|
2019-10-13 09:14:06 +00:00
|
|
|
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);
|
2019-10-13 09:14:06 +00:00
|
|
|
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-13 09:14:06 +00:00
|
|
|
|
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-13 09:14:06 +00:00
|
|
|
|
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-06-30 20:52:33 +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();
|
|
|
|
|
|
|
|
swReverse.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
|
|
|
checkedId == R.id.rbThemeYellowPurple ||
|
|
|
|
checkedId == R.id.rbThemeRedGreen);
|
|
|
|
swDark.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
|
|
|
checkedId == R.id.rbThemeYellowPurple ||
|
|
|
|
checkedId == R.id.rbThemeRedGreen ||
|
|
|
|
checkedId == R.id.rbThemeGrey);
|
2019-12-30 13:29:16 +00:00
|
|
|
swBlack.setEnabled(checkedId == R.id.rbThemeBlueOrange ||
|
|
|
|
checkedId == R.id.rbThemeYellowPurple ||
|
|
|
|
checkedId == R.id.rbThemeRedGreen);
|
2019-12-28 13:45:10 +00:00
|
|
|
swSystem.setEnabled(swDark.isEnabled());
|
2019-12-27 19:34:07 +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-27 19:34:07 +00:00
|
|
|
boolean system = (swSystem.isEnabled() && swSystem.isChecked());
|
|
|
|
|
|
|
|
swReverse.setEnabled(swReverse.isEnabled() && !system);
|
2019-12-28 08:02:00 +00:00
|
|
|
swDark.setEnabled(swDark.isEnabled() && !system);
|
2019-12-30 13:29:16 +00:00
|
|
|
swBlack.setEnabled(swBlack.isEnabled() && dark);
|
|
|
|
swSystem.setEnabled(swSystem.isEnabled() && !reverse && !dark && !black);
|
2019-12-27 19:34:07 +00:00
|
|
|
}
|
|
|
|
|
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);
|
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);
|
2019-06-30 20:52:33 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-06-30 20:52:33 +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":
|
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":
|
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":
|
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;
|
2019-06-30 20:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2019-12-28 13:45:10 +00:00
|
|
|
prefs.edit().putString("theme", "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)
|
|
|
|
prefs.edit().putString("theme", "yellow_purple_system").apply();
|
|
|
|
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)
|
|
|
|
prefs.edit().putString("theme", "red_green_system").apply();
|
|
|
|
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)
|
2019-06-30 20:52:33 +00:00
|
|
|
.create();
|
|
|
|
}
|
|
|
|
}
|
2019-05-06 07:10:13 +00:00
|
|
|
}
|