Unify general settings
Make Email GeneralPreferences subclass GeneralPrefsFragment. Only contains a minimum of code to strip out archive-related prefs, which are not relevant to the current state of Email back-ends. (These actions could be relevant for Gmail IMAP extensions if support is added for them) b/9566150 Change-Id: Ie8e26379ed504c7d96c2a2f8e1c843bbe0582cc7
This commit is contained in:
parent
2a5dac19e7
commit
6f747eb776
@ -1,62 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- App-wide preferences -->
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="confirm-delete"
|
|
||||||
android:persistent="true"
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:title="@string/general_preference_confirm_delete_label" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="confirm-send"
|
|
||||||
android:persistent="true"
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:title="@string/general_preference_confirm_send_label" />
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="auto-advance-mode-widget"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/auto_advance_label"
|
|
||||||
android:summary="@string/auto_advance_summary"
|
|
||||||
android:entries="@array/prefEntries_autoAdvance"
|
|
||||||
android:entryValues="@array/prefValues_autoAdvance"
|
|
||||||
android:dialogTitle="@string/auto_advance_help_title" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="conversation-list-sender-image"
|
|
||||||
android:persistent="true"
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:title="@string/preference_sender_image_title"
|
|
||||||
android:summary="@string/preference_sender_image_description" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="default-reply-all"
|
|
||||||
android:persistent="true"
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:title="@string/preferences_default_reply_all_title"
|
|
||||||
android:summary="@string/preferences_default_reply_all_summary" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="conversation-list-swipe"
|
|
||||||
android:persistent="true"
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:title="@string/preference_swipe_title_delete"
|
|
||||||
android:summary="@string/preference_swipe_description" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@ -16,87 +16,32 @@
|
|||||||
|
|
||||||
package com.android.email.activity.setup;
|
package com.android.email.activity.setup;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceFragment;
|
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import com.android.email.R;
|
import com.android.mail.preferences.MailPrefs.PreferenceKeys;
|
||||||
import com.android.email.provider.EmailProvider;
|
import com.android.mail.ui.settings.GeneralPrefsFragment;
|
||||||
import com.android.mail.preferences.MailPrefs;
|
|
||||||
import com.android.mail.ui.settings.ClearPictureApprovalsDialogFragment;
|
|
||||||
|
|
||||||
public class GeneralPreferences extends PreferenceFragment implements
|
public class GeneralPreferences extends GeneralPrefsFragment {
|
||||||
OnPreferenceChangeListener {
|
|
||||||
|
|
||||||
private static final String AUTO_ADVANCE_MODE_WIDGET = "auto-advance-mode-widget";
|
public GeneralPreferences() {}
|
||||||
|
|
||||||
private MailPrefs mMailPrefs;
|
|
||||||
private ListPreference mAutoAdvance;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
mMailPrefs = MailPrefs.get(getActivity());
|
final PreferenceScreen ps = getPreferenceScreen();
|
||||||
getPreferenceManager().setSharedPreferencesName(mMailPrefs.getSharedPreferencesName());
|
final Preference removalAction = findPreference(PreferenceKeys.REMOVAL_ACTION);
|
||||||
|
if (removalAction != null) {
|
||||||
// Load the preferences from an XML resource
|
ps.removePreference(removalAction);
|
||||||
addPreferencesFromResource(R.xml.general_preferences);
|
|
||||||
}
|
}
|
||||||
|
final Preference confirmArchive = findPreference(PreferenceKeys.CONFIRM_ARCHIVE);
|
||||||
@Override
|
final PreferenceGroup removalGroup =
|
||||||
public void onResume() {
|
(PreferenceGroup) findPreference(REMOVAL_ACTIONS_GROUP);
|
||||||
loadSettings();
|
if (confirmArchive != null) {
|
||||||
super.onResume();
|
removalGroup.removePreference(confirmArchive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
String key = preference.getKey();
|
|
||||||
// Indicate we need to send notifications to UI
|
|
||||||
if (AUTO_ADVANCE_MODE_WIDGET.equals(key)) {
|
|
||||||
mMailPrefs.setAutoAdvanceMode(mAutoAdvance.findIndexOfValue((String) newValue) + 1);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSettings() {
|
|
||||||
mAutoAdvance = (ListPreference) findPreference(AUTO_ADVANCE_MODE_WIDGET);
|
|
||||||
mAutoAdvance.setValueIndex(mMailPrefs.getAutoAdvanceMode() - 1);
|
|
||||||
mAutoAdvance.setOnPreferenceChangeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
menu.clear();
|
|
||||||
inflater.inflate(R.menu.general_prefs_fragment_menu, menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.clear_picture_approvals_menu_item:
|
|
||||||
clearDisplayImages();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearDisplayImages() {
|
|
||||||
final ClearPictureApprovalsDialogFragment fragment =
|
|
||||||
ClearPictureApprovalsDialogFragment.newInstance();
|
|
||||||
fragment.show(getActivity().getFragmentManager(),
|
|
||||||
ClearPictureApprovalsDialogFragment.FRAGMENT_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user