Implement General Preferences
- Removed the place holder setting - Added "auto-advance" setting, which has "newer", "older" (original behavior, default) and "message list" - Strings were copied from Gmail This CL has preference change only (i.e. the setting isn't used yet). The actual implementation will come later. Change-Id: I9f90a723c67e066fdc536a73490101817a127933
This commit is contained in:
parent
6a461a9d46
commit
0f52e546ef
@ -4,9 +4,9 @@
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -18,9 +18,9 @@
|
||||
|
||||
<!-- Do not change any of the values in this array without checking/changing -->
|
||||
<!-- related values in: AccountSetupBasics.java & AccountSetupOptions.java -->
|
||||
|
||||
|
||||
<!-- In particular, 15 minutes is hardcoded as the default for new accounts. -->
|
||||
|
||||
|
||||
<string-array name="account_settings_check_frequency_entries">
|
||||
<item>@string/account_setup_options_mail_check_frequency_never</item>
|
||||
<item>@string/account_setup_options_mail_check_frequency_5min</item>
|
||||
@ -36,10 +36,10 @@
|
||||
<item>10</item>
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>60</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- The arrays that are presented to push-enabled accounts -->
|
||||
<string-array name="account_settings_check_frequency_entries_push">
|
||||
<item>@string/account_setup_options_mail_check_frequency_push</item>
|
||||
@ -58,9 +58,9 @@
|
||||
<item>10</item>
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>60</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Mail sync window sizes for EAS accounts -->
|
||||
<!-- Note, "all" (value 6) is not presented in UI. -->
|
||||
<string-array name="account_settings_mail_window_entries">
|
||||
@ -98,6 +98,26 @@
|
||||
<item>never</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Auto-advance options (DO NOT change the order. Code assumes this order)-->
|
||||
<string-array name="general_preference_auto_advance_entries">
|
||||
<!-- Move to newer -->
|
||||
<item>@string/general_preference_auto_advance_newer</item>
|
||||
<!-- Move to older -->
|
||||
<item>@string/general_preference_auto_advance_older</item>
|
||||
<!-- Move to message list -->
|
||||
<item>@string/general_preference_auto_advance_message_list</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Auto-advance option values (DO NOT change the order. Code assumes this order)-->
|
||||
<string-array translatable="false" name="general_preference_auto_advance_values">
|
||||
<!-- Move to newer -->
|
||||
<item>newer</item>
|
||||
<!-- Move to older -->
|
||||
<item>older</item>
|
||||
<!-- Move to message list -->
|
||||
<item>list</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Arrays "mailbox_display_names" and "mailbox_display_icons" MUST match the order
|
||||
of the types of mailboxes defined in EmailContent -->
|
||||
<string-array name="mailbox_display_names" translatable="false">
|
||||
|
@ -775,10 +775,32 @@
|
||||
<string name="header_label_general_preferences">Email Preferences</string>
|
||||
<!-- First category in general preferences -->
|
||||
<string name="category_general_preferences">Application Preferences</string>
|
||||
<!-- STOPSHIP remove this fake preference -->
|
||||
<string name="title_fix_all_bugs_preference" translatable="false">Fix All Bugs</string>
|
||||
<!-- STOPSHIP remove this fake preference -->
|
||||
<string name="summary_fix_all_bugs_preference" translatable="false">Cheaper than beer</string>
|
||||
|
||||
<!-- General preference: Label of the setting for the direction to move to
|
||||
when deleting the current message.
|
||||
Options contain "newer message","older message", etc. [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_auto_advance_label">Auto-advance</string>
|
||||
<!-- General preference: Description of the setting for the direction to move to
|
||||
when deleting the current message.
|
||||
Options contain "newer message","older message", etc. [CHAR LIMIT=64] -->
|
||||
<string name="general_preference_auto_advance_summary">
|
||||
Select which screen to show after you delete a message</string>
|
||||
<!-- General preference: Title of the dialog box containing options for setting for
|
||||
the direction to move to when deleting the current message.
|
||||
Options contain "newer message","older message", etc. [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_auto_advance_dialog_title">Advance to</string>
|
||||
<!-- General preference: Option for the setting for
|
||||
the direction to move to when deleting the current message.
|
||||
This option is for "move to the newer message" [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_auto_advance_newer">Newer message</string>
|
||||
<!-- General preference: Option for the setting for
|
||||
the direction to move to when deleting the current message.
|
||||
This option is for "move to the older message" [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_auto_advance_older">Older message</string>
|
||||
<!-- General preference: Option for the setting for
|
||||
the direction to move to when deleting the current message.
|
||||
This option is for "move back to the message list" [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_auto_advance_message_list">Message list</string>
|
||||
|
||||
<!--
|
||||
Strings for temporary UI
|
||||
|
@ -22,11 +22,13 @@
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_general_preferences">
|
||||
|
||||
<!-- STOPSHIP remove this fake preference -->
|
||||
<CheckBoxPreference
|
||||
android:key="fix_all_bugs_preference"
|
||||
android:title="@string/title_fix_all_bugs_preference"
|
||||
android:summary="@string/summary_fix_all_bugs_preference" />
|
||||
<ListPreference
|
||||
android:key="auto_advance"
|
||||
android:title="@string/general_preference_auto_advance_label"
|
||||
android:summary="@string/general_preference_auto_advance_summary"
|
||||
android:entries="@array/general_preference_auto_advance_entries"
|
||||
android:entryValues="@array/general_preference_auto_advance_values"
|
||||
android:dialogTitle="@string/general_preference_auto_advance_dialog_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -36,6 +36,13 @@ public class Preferences {
|
||||
private static final String ENABLE_EXCHANGE_FILE_LOGGING = "enableExchangeFileLogging";
|
||||
private static final String DEVICE_UID = "deviceUID";
|
||||
private static final String ONE_TIME_INITIALIZATION_PROGRESS = "oneTimeInitializationProgress";
|
||||
private static final String AUTO_ADVANCE_DIRECTION = "autoAdvance";
|
||||
|
||||
public static final int AUTO_ADVANCE_NEWER = 0;
|
||||
public static final int AUTO_ADVANCE_OLDER = 1;
|
||||
public static final int AUTO_ADVANCE_MESSAGE_LIST = 2;
|
||||
// "move to older" was the behavior on older versions.
|
||||
public static final int AUTO_ADVANCE_DEFAULT = AUTO_ADVANCE_OLDER;
|
||||
|
||||
private static Preferences sPreferences;
|
||||
|
||||
@ -178,6 +185,14 @@ public class Preferences {
|
||||
mSharedPreferences.edit().putInt(ONE_TIME_INITIALIZATION_PROGRESS, progress).commit();
|
||||
}
|
||||
|
||||
public int getAutoAdvanceDirection() {
|
||||
return mSharedPreferences.getInt(AUTO_ADVANCE_DIRECTION, AUTO_ADVANCE_DEFAULT);
|
||||
}
|
||||
|
||||
public void setAutoAdvanceDirection(int direction) {
|
||||
mSharedPreferences.edit().putInt(AUTO_ADVANCE_DIRECTION, direction).commit();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,8 @@ public class MessageListXL extends Activity implements View.OnClickListener,
|
||||
// the delete triggers mCursorObserver in MessageOrderManager.
|
||||
// first move to older/newer before the actual delete
|
||||
long messageIdToDelete = mFragmentManager.getMessageId();
|
||||
if (!moveToOlder()) moveToNewer();
|
||||
|
||||
if (!moveToOlder()) moveToNewer(); // TODO use "auto-advance" preference
|
||||
ActivityHelper.deleteMessage(this, messageIdToDelete);
|
||||
// If this was the last message, moveToOlder/Newer didn't move the current position.
|
||||
// MessageOrderManager detects the current message is gone, and we go back to the message
|
||||
|
@ -180,7 +180,7 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
|
||||
// the delete triggers mCursorObserver in MessageOrderManager.
|
||||
// first move to older/newer before the actual delete
|
||||
long messageIdToDelete = mMessageId;
|
||||
boolean moved = moveToOlder() || moveToNewer();
|
||||
boolean moved = moveToOlder() || moveToNewer(); // TODO use "auto-advance" preference
|
||||
ActivityHelper.deleteMessage(this, messageIdToDelete);
|
||||
if (!moved) {
|
||||
// this generates a benign warning "Duplicate finish request" because
|
||||
|
@ -320,7 +320,7 @@ public class AccountSettingsXL extends PreferenceActivity implements OnClickList
|
||||
mAppPreferencesHeader.summary = null;
|
||||
mAppPreferencesHeader.iconRes = 0;
|
||||
mAppPreferencesHeader.icon = null;
|
||||
mAppPreferencesHeader.fragment = GeneralPreferences.getCanonicalName();
|
||||
mAppPreferencesHeader.fragment = GeneralPreferences.class.getCanonicalName();
|
||||
mAppPreferencesHeader.fragmentArguments = null;
|
||||
}
|
||||
return mAppPreferencesHeader;
|
||||
@ -609,26 +609,6 @@ public class AccountSettingsXL extends PreferenceActivity implements OnClickList
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Placeholder for app-wide preferences
|
||||
* STOPSHIP - make this real
|
||||
*/
|
||||
public static class GeneralPreferences extends PreferenceFragment {
|
||||
|
||||
/** STOPSHIP - this is hardcoded for now because getCanonicalName() doesn't return $ */
|
||||
public static String getCanonicalName() {
|
||||
return "com.android.email.activity.setup.AccountSettingsXL$GeneralPreferences";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.general_preferences);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog fragment to show "exit with unsaved changes?" dialog
|
||||
*/
|
||||
|
63
src/com/android/email/activity/setup/GeneralPreferences.java
Normal file
63
src/com/android/email/activity/setup/GeneralPreferences.java
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.email.activity.setup;
|
||||
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
public class GeneralPreferences extends PreferenceFragment {
|
||||
|
||||
private static final String PREFERENCE_AUTO_ADVANCE= "auto_advance";
|
||||
|
||||
private Preferences mPreferences;
|
||||
private ListPreference mAutoAdvance;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.general_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
loadSettings();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
mPreferences = Preferences.getPreferences(getActivity());
|
||||
mAutoAdvance = (ListPreference) findPreference(PREFERENCE_AUTO_ADVANCE);
|
||||
mAutoAdvance.setValueIndex(mPreferences.getAutoAdvanceDirection());
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
mPreferences.setAutoAdvanceDirection(
|
||||
mAutoAdvance.findIndexOfValue(mAutoAdvance.getValue()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user