Add setting for ReplyAll
Also show/hide the right icon and item in overflow menu depending on setting Bug: 5298445 Change-Id: I950025cab0aeb57d18769b137eeca418d581c5f9
This commit is contained in:
parent
b0f52fdc1d
commit
bfbf0dd853
|
@ -15,19 +15,33 @@
|
|||
-->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/favorite"
|
||||
style="@style/message_view_action_buttons"
|
||||
android:src="@drawable/btn_star_off_convo_holo_light"
|
||||
android:contentDescription="@string/favorite_action"
|
||||
/>
|
||||
<ImageView
|
||||
<!-- Either reply or replyall will be set to gone in code depending on setting -->
|
||||
<ImageButton
|
||||
android:id="@+id/reply"
|
||||
style="@style/message_view_action_buttons"
|
||||
android:src="@drawable/ic_reply_holo_dark"
|
||||
android:contentDescription="@string/reply_action"
|
||||
/>
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/reply_all"
|
||||
style="@style/message_view_action_buttons"
|
||||
android:src="@drawable/ic_reply_all_holo_dark"
|
||||
android:contentDescription="@string/reply_all_action"
|
||||
/>
|
||||
<View
|
||||
android:id="@+id/more_separator"
|
||||
android:layout_width="1dip"
|
||||
android:layout_height="24dip"
|
||||
android:layout_margin="3dip"
|
||||
android:background="#ddd"
|
||||
/>
|
||||
<ImageButton
|
||||
android:id="@+id/more"
|
||||
style="@android:style/Widget.Holo.ActionButton.Overflow"
|
||||
android:layout_width="48dip"
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Reply or replyall may be removed in code depending on setting and layout -->
|
||||
<item
|
||||
android:id="@+id/reply"
|
||||
android:title="@string/reply_action"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/reply_all"
|
||||
android:title="@string/reply_all_action"
|
||||
|
|
|
@ -1136,6 +1136,11 @@ save attachment.</string>
|
|||
<!-- General preference: Text zoom. Value is "huge" (+2) [CHAR LIMIT=32] -->
|
||||
<string name="general_preference_text_zoom_huge">Huge</string>
|
||||
|
||||
<!-- Settings screen, Reply to all default setting title [CHAR LIMIT=30] -->
|
||||
<string name="general_preference_reply_all_label">Reply all</string>
|
||||
<!-- Settings screen, Reply to all default setting summary [CHAR LIMIT=70] -->
|
||||
<string name="general_preference_reply_all_summary">Make \'Reply all\' the default for responding to messages</string>
|
||||
|
||||
<!-- Settings screen, title used to clear the setting for the list of
|
||||
senders to automatically show pictures for [CHAR LIMIT=80] -->
|
||||
<string name="general_preferences_clear_trusted_senders_title"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="category_general_preferences"
|
||||
android:title="@string/category_general_preferences">
|
||||
|
||||
<ListPreference
|
||||
|
@ -36,6 +37,14 @@
|
|||
android:entryValues="@array/general_preference_text_zoom_values"
|
||||
android:dialogTitle="@string/general_preference_text_zoom_dialog_title" />
|
||||
|
||||
<!-- This may be removed in GeneralPreferences.java -->
|
||||
<CheckBoxPreference
|
||||
android:key="reply_all"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/general_preference_reply_all_label"
|
||||
android:summary="@string/general_preference_reply_all_summary" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="clear_trusted_senders"
|
||||
android:title="@string/general_preferences_clear_trusted_senders_title"
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
|||
public class Preferences {
|
||||
|
||||
// Preferences file
|
||||
private static final String PREFERENCES_FILE = "AndroidMail.Main";
|
||||
public static final String PREFERENCES_FILE = "AndroidMail.Main";
|
||||
|
||||
// Preferences field names
|
||||
private static final String ACCOUNT_UUIDS = "accountUuids";
|
||||
|
@ -64,6 +64,13 @@ public class Preferences {
|
|||
// "normal" will be the default
|
||||
public static final int TEXT_ZOOM_DEFAULT = TEXT_ZOOM_NORMAL;
|
||||
|
||||
// Starting something new here:
|
||||
// REPLY_ALL is saved by the framework (CheckBoxPreference's parent, Preference).
|
||||
// i.e. android:persistent=true in general_preferences.xml
|
||||
public static final String REPLY_ALL = "reply_all";
|
||||
// Reply All Default - when changing this, be sure to update general_preferences.xml
|
||||
public static final boolean REPLY_ALL_DEFAULT = false;
|
||||
|
||||
private static Preferences sPreferences;
|
||||
|
||||
private final SharedPreferences mSharedPreferences;
|
||||
|
@ -92,6 +99,10 @@ public class Preferences {
|
|||
return sPreferences;
|
||||
}
|
||||
|
||||
public static SharedPreferences getSharedPreferences(Context context) {
|
||||
return getPreferences(context).mSharedPreferences;
|
||||
}
|
||||
|
||||
public static String getLegacyBackupPreference(Context context) {
|
||||
return getPreferences(context).mSharedPreferences.getString(ACCOUNT_UUIDS, null);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.app.Activity;
|
|||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -32,6 +33,7 @@ import android.widget.PopupMenu;
|
|||
import android.widget.PopupMenu.OnMenuItemClickListener;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.mail.MeetingInfo;
|
||||
import com.android.emailcommon.mail.PackedString;
|
||||
|
@ -54,10 +56,9 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
|
||||
private View mReplyButton;
|
||||
|
||||
/* Nullable - not available on phone. */
|
||||
private View mReplyAllButton;
|
||||
|
||||
/* Nullable - not available on phone. */
|
||||
/* Nullable - not available on phone portrait. */
|
||||
private View mForwardButton;
|
||||
|
||||
private View mMoreButton;
|
||||
|
@ -69,6 +70,12 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
private Drawable mFavoriteIconOn;
|
||||
private Drawable mFavoriteIconOff;
|
||||
|
||||
/** Default to ReplyAll if true. Otherwise Reply. */
|
||||
boolean mDefaultReplyAll;
|
||||
|
||||
/** Whether or not to enable Reply/ReplyAll and Forward buttons */
|
||||
boolean mEnableReplyForwardButtons;
|
||||
|
||||
/** Whether or not the message can be moved from the mailbox it's in. */
|
||||
private boolean mSupportsMove;
|
||||
|
||||
|
@ -181,6 +188,24 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
mFavoriteIconOff = res.getDrawable(R.drawable.btn_star_off_convo_holo_light);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mMoreButton != null) {
|
||||
mDefaultReplyAll = Preferences.getSharedPreferences(mContext).getBoolean(
|
||||
Preferences.REPLY_ALL, Preferences.REPLY_ALL_DEFAULT);
|
||||
|
||||
int replyVisibility = View.GONE;
|
||||
int replyAllVisibility = View.GONE;
|
||||
if (mEnableReplyForwardButtons) {
|
||||
replyVisibility = mDefaultReplyAll ? View.GONE : View.VISIBLE;
|
||||
replyAllVisibility = mDefaultReplyAll ? View.VISIBLE : View.GONE;
|
||||
}
|
||||
mReplyButton.setVisibility(replyVisibility);
|
||||
mReplyAllButton.setVisibility(replyAllVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -188,21 +213,22 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
|
||||
mFavoriteIcon = (ImageView) UiUtilities.getView(view, R.id.favorite);
|
||||
mReplyButton = UiUtilities.getView(view, R.id.reply);
|
||||
mReplyAllButton = UiUtilities.getViewOrNull(view, R.id.reply_all);
|
||||
mReplyAllButton = UiUtilities.getView(view, R.id.reply_all);
|
||||
mForwardButton = UiUtilities.getViewOrNull(view, R.id.forward);
|
||||
mMeetingYes = UiUtilities.getView(view, R.id.accept);
|
||||
mMeetingMaybe = UiUtilities.getView(view, R.id.maybe);
|
||||
mMeetingNo = UiUtilities.getView(view, R.id.decline);
|
||||
mMoreButton = UiUtilities.getViewOrNull(view, R.id.more);
|
||||
|
||||
mFavoriteIcon.setOnClickListener(this);
|
||||
mReplyButton.setOnClickListener(this);
|
||||
if (mReplyAllButton != null) {
|
||||
mReplyAllButton.setOnClickListener(this);
|
||||
mForwardButton.setOnClickListener(this);
|
||||
} else {
|
||||
mMoreButton = UiUtilities.getView(view, R.id.more);
|
||||
mReplyAllButton.setOnClickListener(this);
|
||||
if (mMoreButton != null) {
|
||||
mMoreButton.setOnClickListener(this);
|
||||
}
|
||||
if (mForwardButton != null) {
|
||||
mForwardButton.setOnClickListener(this);
|
||||
}
|
||||
mMeetingYes.setOnClickListener(this);
|
||||
mMeetingMaybe.setOnClickListener(this);
|
||||
mMeetingNo.setOnClickListener(this);
|
||||
|
@ -224,13 +250,26 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
}
|
||||
|
||||
private void enableReplyForwardButtons(boolean enabled) {
|
||||
mEnableReplyForwardButtons = enabled;
|
||||
// We don't have disabled button assets, so let's hide them for now
|
||||
final int visibility = enabled ? View.VISIBLE : View.GONE;
|
||||
mReplyButton.setVisibility(visibility);
|
||||
if (mReplyAllButton != null) {
|
||||
mReplyAllButton.setVisibility(visibility);
|
||||
|
||||
// Modify Reply All button only if there's no overflow OR there is
|
||||
// overflow but default is to show the Reply All button
|
||||
if (mMoreButton == null || mDefaultReplyAll) {
|
||||
UiUtilities.setVisibilitySafe(mReplyAllButton, visibility);
|
||||
}
|
||||
|
||||
// Modify Reply button only if there's no overflow OR there is
|
||||
// overflow but default is to show the Reply button
|
||||
if (mMoreButton == null || !mDefaultReplyAll) {
|
||||
UiUtilities.setVisibilitySafe(mReplyButton, visibility);
|
||||
}
|
||||
|
||||
if (mForwardButton != null) {
|
||||
mForwardButton.setVisibility(visibility);
|
||||
} else if (mMoreButton != null) {
|
||||
}
|
||||
if (mMoreButton != null) {
|
||||
mMoreButton.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
@ -387,8 +426,12 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
|
||||
case R.id.more: {
|
||||
PopupMenu popup = new PopupMenu(getActivity(), mMoreButton);
|
||||
Menu menu = popup.getMenu();
|
||||
popup.getMenuInflater().inflate(R.menu.message_header_overflow_menu,
|
||||
popup.getMenu());
|
||||
menu);
|
||||
|
||||
// Remove Reply if ReplyAll icon is visible or vice versa
|
||||
menu.removeItem(mDefaultReplyAll ? R.id.reply_all : R.id.reply);
|
||||
popup.setOnMenuItemClickListener(this);
|
||||
popup.show();
|
||||
break;
|
||||
|
@ -402,6 +445,9 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (isMessageOpen()) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.reply:
|
||||
mCallback.onReply();
|
||||
return true;
|
||||
case R.id.reply_all:
|
||||
mCallback.onReplyAll();
|
||||
return true;
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.email.activity.setup;
|
|||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
@ -26,11 +27,15 @@ import android.widget.Toast;
|
|||
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
import com.android.email.activity.UiUtilities;
|
||||
|
||||
public class GeneralPreferences extends PreferenceFragment implements OnPreferenceChangeListener {
|
||||
|
||||
private static final String PREFERENCE_CATEGORY_KEY = "category_general_preferences";
|
||||
|
||||
private static final String PREFERENCE_KEY_AUTO_ADVANCE = "auto_advance";
|
||||
private static final String PREFERENCE_KEY_TEXT_ZOOM = "text_zoom";
|
||||
private static final String PREFERENCE_KEY_REPLY_ALL = Preferences.REPLY_ALL;
|
||||
private static final String PREFERENCE_KEY_CLEAR_TRUSTED_SENDERS = "clear_trusted_senders";
|
||||
|
||||
private Preferences mPreferences;
|
||||
|
@ -43,8 +48,16 @@ public class GeneralPreferences extends PreferenceFragment implements OnPreferen
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getPreferenceManager().setSharedPreferencesName(Preferences.PREFERENCES_FILE);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.general_preferences);
|
||||
|
||||
if (UiUtilities.useTwoPane(getActivity())) {
|
||||
// "Reply All" should only be shown on phones
|
||||
PreferenceCategory pc = (PreferenceCategory) findPreference(PREFERENCE_CATEGORY_KEY);
|
||||
pc.removePreference(findPreference(PREFERENCE_KEY_REPLY_ALL));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue