1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Move message view theme setting from message view menu to global prefs

by default.

The message view theme isn't something the user is likely to change on a
regular basis, so we don't need to clutter the message view menu with
this setting. The menu item can still be enabled for those who want it.
This commit is contained in:
Danny Baumann 2013-02-06 09:47:16 +01:00 committed by cketti
parent 7714bc3cfa
commit 2ea0961006
7 changed files with 108 additions and 20 deletions

View File

@ -808,6 +808,7 @@ Um Fehler zu melden, neue Funktionen vorzuschlagen oder Fragen zu stellen, besuc
<string name="account_settings_signature__location_label">Position der Signatur</string>
<string name="account_settings_signature__location_before_quoted_text">Vor zitierter Nachricht</string>
<string name="account_settings_signature__location_after_quoted_text">Nach zitierter Nachricht</string>
<string name="setting_theme_global">Anwendungsdesign verwenden</string>
<string name="setting_theme_dark">Dunkel</string>
<string name="setting_theme_light">Hell</string>
<string name="display_preferences">Anzeige</string>
@ -821,8 +822,13 @@ Um Fehler zu melden, neue Funktionen vorzuschlagen oder Fragen zu stellen, besuc
<string name="messageview_preferences">Nachrichten</string>
<string name="folderlist_preferences">Ordnerliste</string>
<string name="settings_theme_label">Design</string>
<string name="settings_message_theme_label">Nachrichten-Design</string>
<string name="settings_language_label">Sprache</string>
<string name="settings_message_theme_selection_label">Festes Nachrichten-Design</string>
<string name="settings_message_theme_selection_summary_off">Nachrichten-Design während des Ansehens der Nachricht auswählen</string>
<string name="settings_message_theme_selection_summary_on">Immer das ausgewählte Nachrichten-Design verwenden</string>
<string name="settings_messageview_mobile_layout_label">Einfaches Layout</string>
<string name="settings_messageview_mobile_layout_summary">HTML-Nachrichten für kleine Displays optimieren</string>

View File

@ -502,6 +502,18 @@
<item>dark</item>
</string-array>
<string-array name="settings_message_theme_entries">
<item>@string/setting_theme_light</item>
<item>@string/setting_theme_dark</item>
<item>@string/setting_theme_global</item>
</string-array>
<string-array name="settings_message_theme_values">
<item>light</item>
<item>dark</item>
<item>global</item>
</string-array>
<!-- Note: If you change this make sure the code in Prefs.java is still working -->
<string-array name="background_ops_entries">
<item>@string/background_ops_enabled</item>

View File

@ -817,6 +817,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="account_settings_signature__location_label">Signature position</string>
<string name="account_settings_signature__location_before_quoted_text">Before quoted message</string>
<string name="account_settings_signature__location_after_quoted_text">After quoted message</string>
<string name="setting_theme_global">Use app theme</string>
<string name="setting_theme_dark">Dark</string>
<string name="setting_theme_light">Light</string>
<string name="display_preferences">Display</string>
@ -830,8 +831,13 @@ Please submit bug reports, contribute new features and ask questions at
<string name="messageview_preferences">Messages</string>
<string name="folderlist_preferences">Folder lists</string>
<string name="settings_theme_label">Theme</string>
<string name="settings_message_theme_label">Message view theme</string>
<string name="settings_language_label">Language</string>
<string name="settings_message_theme_selection_label">Fixed message theme</string>
<string name="settings_message_theme_selection_summary_off">Select the messsge view theme while viewing the message</string>
<string name="settings_message_theme_selection_summary_on">Use a fixed message view theme</string>
<string name="settings_messageview_mobile_layout_label">Condensed layout</string>
<string name="settings_messageview_mobile_layout_summary">Reformat HTML messages for smaller screens</string>

View File

@ -49,6 +49,22 @@
android:entryValues="@array/settings_theme_values"
android:dialogTitle="@string/settings_theme_label" />
<CheckBoxPreference
android:persistent="false"
android:key="fixedMessageViewTheme"
android:title="@string/settings_message_theme_selection_label"
android:summaryOff="@string/settings_message_theme_selection_summary_off"
android:summaryOn="@string/settings_message_theme_selection_summary_on" />
<ListPreference
android:persistent="false"
android:dependency="fixedMessageViewTheme"
android:key="messageViewTheme"
android:title="@string/settings_message_theme_label"
android:entries="@array/settings_message_theme_entries"
android:entryValues="@array/settings_message_theme_values"
android:dialogTitle="@string/settings_message_theme_label" />
<Preference
android:persistent="false"
android:key="font_size"

View File

@ -46,6 +46,7 @@ import com.fsck.k9.service.StorageGoneReceiver;
public class K9 extends Application {
public static final int THEME_LIGHT = 0;
public static final int THEME_DARK = 1;
public static final int THEME_GLOBAL = 2;
/**
* Components that are interested in knowing when the K9 instance is
@ -99,7 +100,8 @@ public class K9 extends Application {
private static String language = "";
private static int theme = THEME_LIGHT;
private static int messageViewTheme = THEME_LIGHT;
private static int messageViewTheme = THEME_GLOBAL;
private static boolean useFixedMessageTheme = true;
private static final FontSizes fontSizes = new FontSizes();
@ -524,6 +526,7 @@ public class K9 extends Application {
editor.putString("language", language);
editor.putInt("theme", theme);
editor.putInt("messageViewTheme", messageViewTheme);
editor.putBoolean("fixedMessageViewTheme", useFixedMessageTheme);
editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround);
editor.putBoolean("confirmDelete", mConfirmDelete);
@ -777,7 +780,8 @@ public class K9 extends Application {
}
K9.setK9Theme(theme);
K9.setK9MessageViewTheme(sprefs.getInt("messageViewTheme", THEME_LIGHT));
K9.setK9MessageViewThemeSetting(sprefs.getInt("messageViewTheme", THEME_GLOBAL));
K9.setUseFixedMessageViewTheme(sprefs.getBoolean("fixedMessageViewTheme", true));
}
private void maybeSetupStrictMode() {
@ -836,8 +840,8 @@ public class K9 extends Application {
language = nlanguage;
}
public static int getK9ThemeResourceId(int theme) {
return (theme == THEME_LIGHT) ? R.style.Theme_K9_Light : R.style.Theme_K9_Dark;
public static int getK9ThemeResourceId(int themeId) {
return (themeId == THEME_LIGHT) ? R.style.Theme_K9_Light : R.style.Theme_K9_Dark;
}
public static int getK9ThemeResourceId() {
@ -845,6 +849,10 @@ public class K9 extends Application {
}
public static int getK9MessageViewTheme() {
return messageViewTheme == THEME_GLOBAL ? theme : messageViewTheme;
}
public static int getK9MessageViewThemeSetting() {
return messageViewTheme;
}
@ -853,13 +861,25 @@ public class K9 extends Application {
}
public static void setK9Theme(int ntheme) {
assert ntheme != THEME_GLOBAL;
theme = ntheme;
}
public static void setK9MessageViewTheme(int nMessageViewTheme) {
public static void setK9MessageViewThemeSetting(int nMessageViewTheme) {
messageViewTheme = nMessageViewTheme;
}
public static boolean useFixedMessageViewTheme() {
return useFixedMessageTheme;
}
public static void setUseFixedMessageViewTheme(boolean useFixed) {
useFixedMessageTheme = useFixed;
if (!useFixedMessageTheme && messageViewTheme == THEME_GLOBAL) {
messageViewTheme = theme;
}
}
public static BACKGROUND_OPS getBackgroundOps() {
return backgroundOps;
}

View File

@ -955,14 +955,19 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
next.setEnabled(canDoNext);
next.getIcon().setAlpha(canDoNext ? 255 : 127);
}
// Set title of menu item to switch to dark/light theme
MenuItem toggleTheme = menu.findItem(R.id.toggle_message_view_theme);
if (K9.getK9MessageViewTheme() == K9.THEME_DARK) {
toggleTheme.setTitle(R.string.message_view_theme_action_light);
if (K9.useFixedMessageViewTheme()) {
toggleTheme.setVisible(false);
} else {
toggleTheme.setTitle(R.string.message_view_theme_action_dark);
// Set title of menu item to switch to dark/light theme
if (K9.getK9MessageViewTheme() == K9.THEME_DARK) {
toggleTheme.setTitle(R.string.message_view_theme_action_light);
} else {
toggleTheme.setTitle(R.string.message_view_theme_action_dark);
}
toggleTheme.setVisible(true);
}
toggleTheme.setVisible(true);
// Set title of menu item to toggle the read state of the currently displayed message
if (mMessageViewFragment.isMessageRead()) {
@ -1417,9 +1422,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
private void onToggleTheme() {
if (K9.getK9MessageViewTheme() == K9.THEME_DARK) {
K9.setK9MessageViewTheme(K9.THEME_LIGHT);
K9.setK9MessageViewThemeSetting(K9.THEME_LIGHT);
} else {
K9.setK9MessageViewTheme(K9.THEME_DARK);
K9.setK9MessageViewThemeSetting(K9.THEME_DARK);
}
new Thread(new Runnable() {

View File

@ -18,6 +18,7 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.text.TextUtils;
import android.widget.Toast;
import com.fsck.k9.Account;
@ -52,6 +53,8 @@ public class Prefs extends K9PreferenceActivity {
*/
private static final String PREFERENCE_LANGUAGE = "language";
private static final String PREFERENCE_THEME = "theme";
private static final String PREFERENCE_MESSAGE_VIEW_THEME = "messageViewTheme";
private static final String PREFERENCE_FIXED_MESSAGE_THEME = "fixedMessageViewTheme";
private static final String PREFERENCE_FONT_SIZE = "font_size";
private static final String PREFERENCE_DATE_FORMAT = "dateFormat";
private static final String PREFERENCE_ANIMATIONS = "animations";
@ -101,6 +104,8 @@ public class Prefs extends K9PreferenceActivity {
private ListPreference mLanguage;
private ListPreference mTheme;
private CheckBoxPreference mFixedMessageTheme;
private ListPreference mMessageTheme;
private ListPreference mDateFormat;
private CheckBoxPreference mAnimations;
private CheckBoxPreference mGestures;
@ -170,8 +175,11 @@ public class Prefs extends K9PreferenceActivity {
entryVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY),
entryValueVector.toArray(EMPTY_CHAR_SEQUENCE_ARRAY));
final String theme = (K9.getK9Theme() == K9.THEME_DARK) ? "dark" : "light";
mTheme = setupListPreference(PREFERENCE_THEME, theme);
mTheme = setupListPreference(PREFERENCE_THEME, themeIdToName(K9.getK9Theme()));
mFixedMessageTheme = (CheckBoxPreference) findPreference(PREFERENCE_FIXED_MESSAGE_THEME);
mFixedMessageTheme.setChecked(K9.useFixedMessageViewTheme());
mMessageTheme = setupListPreference(PREFERENCE_MESSAGE_VIEW_THEME,
themeIdToName(K9.getK9MessageViewThemeSetting()));
findPreference(PREFERENCE_FONT_SIZE).setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@ -434,17 +442,32 @@ public class Prefs extends K9PreferenceActivity {
mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues());
}
private static String themeIdToName(int theme) {
switch (theme) {
case K9.THEME_DARK: return "dark";
case K9.THEME_GLOBAL: return "global";
default: return "light";
}
}
private static int themeNameToId(String theme) {
if (TextUtils.equals(theme, "dark")) {
return K9.THEME_DARK;
} else if (TextUtils.equals(theme, "global")) {
return K9.THEME_GLOBAL;
} else {
return K9.THEME_LIGHT;
}
}
private void saveSettings() {
SharedPreferences preferences = Preferences.getPreferences(this).getPreferences();
K9.setK9Language(mLanguage.getValue());
int newTheme = mTheme.getValue().equals("dark") ? K9.THEME_DARK : K9.THEME_LIGHT;
if (K9.getK9Theme() != newTheme) {
// Reset the message view theme when the app theme changes
K9.setK9MessageViewTheme(newTheme);
}
K9.setK9Theme(newTheme);
K9.setK9Theme(themeNameToId(mTheme.getValue()));
K9.setUseFixedMessageViewTheme(mFixedMessageTheme.isChecked());
K9.setK9MessageViewThemeSetting(themeNameToId(mMessageTheme.getValue()));
K9.setAnimations(mAnimations.isChecked());
K9.setGesturesEnabled(mGestures.isChecked());