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">
|
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<ImageView
|
<ImageButton
|
||||||
android:id="@+id/favorite"
|
android:id="@+id/favorite"
|
||||||
style="@style/message_view_action_buttons"
|
style="@style/message_view_action_buttons"
|
||||||
android:src="@drawable/btn_star_off_convo_holo_light"
|
android:src="@drawable/btn_star_off_convo_holo_light"
|
||||||
android:contentDescription="@string/favorite_action"
|
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"
|
android:id="@+id/reply"
|
||||||
style="@style/message_view_action_buttons"
|
style="@style/message_view_action_buttons"
|
||||||
android:src="@drawable/ic_reply_holo_dark"
|
android:src="@drawable/ic_reply_holo_dark"
|
||||||
android:contentDescription="@string/reply_action"
|
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"
|
android:id="@+id/more"
|
||||||
style="@android:style/Widget.Holo.ActionButton.Overflow"
|
style="@android:style/Widget.Holo.ActionButton.Overflow"
|
||||||
android:layout_width="48dip"
|
android:layout_width="48dip"
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<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
|
<item
|
||||||
android:id="@+id/reply_all"
|
android:id="@+id/reply_all"
|
||||||
android:title="@string/reply_all_action"
|
android:title="@string/reply_all_action"
|
||||||
|
|
|
@ -1136,6 +1136,11 @@ save attachment.</string>
|
||||||
<!-- General preference: Text zoom. Value is "huge" (+2) [CHAR LIMIT=32] -->
|
<!-- General preference: Text zoom. Value is "huge" (+2) [CHAR LIMIT=32] -->
|
||||||
<string name="general_preference_text_zoom_huge">Huge</string>
|
<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
|
<!-- Settings screen, title used to clear the setting for the list of
|
||||||
senders to automatically show pictures for [CHAR LIMIT=80] -->
|
senders to automatically show pictures for [CHAR LIMIT=80] -->
|
||||||
<string name="general_preferences_clear_trusted_senders_title"
|
<string name="general_preferences_clear_trusted_senders_title"
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
android:key="category_general_preferences"
|
||||||
android:title="@string/category_general_preferences">
|
android:title="@string/category_general_preferences">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
@ -36,6 +37,14 @@
|
||||||
android:entryValues="@array/general_preference_text_zoom_values"
|
android:entryValues="@array/general_preference_text_zoom_values"
|
||||||
android:dialogTitle="@string/general_preference_text_zoom_dialog_title" />
|
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
|
<PreferenceScreen
|
||||||
android:key="clear_trusted_senders"
|
android:key="clear_trusted_senders"
|
||||||
android:title="@string/general_preferences_clear_trusted_senders_title"
|
android:title="@string/general_preferences_clear_trusted_senders_title"
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
||||||
public class Preferences {
|
public class Preferences {
|
||||||
|
|
||||||
// Preferences file
|
// Preferences file
|
||||||
private static final String PREFERENCES_FILE = "AndroidMail.Main";
|
public static final String PREFERENCES_FILE = "AndroidMail.Main";
|
||||||
|
|
||||||
// Preferences field names
|
// Preferences field names
|
||||||
private static final String ACCOUNT_UUIDS = "accountUuids";
|
private static final String ACCOUNT_UUIDS = "accountUuids";
|
||||||
|
@ -64,6 +64,13 @@ public class Preferences {
|
||||||
// "normal" will be the default
|
// "normal" will be the default
|
||||||
public static final int TEXT_ZOOM_DEFAULT = TEXT_ZOOM_NORMAL;
|
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 static Preferences sPreferences;
|
||||||
|
|
||||||
private final SharedPreferences mSharedPreferences;
|
private final SharedPreferences mSharedPreferences;
|
||||||
|
@ -92,6 +99,10 @@ public class Preferences {
|
||||||
return sPreferences;
|
return sPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SharedPreferences getSharedPreferences(Context context) {
|
||||||
|
return getPreferences(context).mSharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getLegacyBackupPreference(Context context) {
|
public static String getLegacyBackupPreference(Context context) {
|
||||||
return getPreferences(context).mSharedPreferences.getString(ACCOUNT_UUIDS, null);
|
return getPreferences(context).mSharedPreferences.getString(ACCOUNT_UUIDS, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.app.Activity;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -32,6 +33,7 @@ import android.widget.PopupMenu;
|
||||||
import android.widget.PopupMenu.OnMenuItemClickListener;
|
import android.widget.PopupMenu.OnMenuItemClickListener;
|
||||||
|
|
||||||
import com.android.email.Email;
|
import com.android.email.Email;
|
||||||
|
import com.android.email.Preferences;
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
import com.android.emailcommon.mail.MeetingInfo;
|
import com.android.emailcommon.mail.MeetingInfo;
|
||||||
import com.android.emailcommon.mail.PackedString;
|
import com.android.emailcommon.mail.PackedString;
|
||||||
|
@ -54,10 +56,9 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
|
|
||||||
private View mReplyButton;
|
private View mReplyButton;
|
||||||
|
|
||||||
/* Nullable - not available on phone. */
|
|
||||||
private View mReplyAllButton;
|
private View mReplyAllButton;
|
||||||
|
|
||||||
/* Nullable - not available on phone. */
|
/* Nullable - not available on phone portrait. */
|
||||||
private View mForwardButton;
|
private View mForwardButton;
|
||||||
|
|
||||||
private View mMoreButton;
|
private View mMoreButton;
|
||||||
|
@ -69,6 +70,12 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
private Drawable mFavoriteIconOn;
|
private Drawable mFavoriteIconOn;
|
||||||
private Drawable mFavoriteIconOff;
|
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. */
|
/** Whether or not the message can be moved from the mailbox it's in. */
|
||||||
private boolean mSupportsMove;
|
private boolean mSupportsMove;
|
||||||
|
|
||||||
|
@ -181,6 +188,24 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
mFavoriteIconOff = res.getDrawable(R.drawable.btn_star_off_convo_holo_light);
|
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
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -188,21 +213,22 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
|
|
||||||
mFavoriteIcon = (ImageView) UiUtilities.getView(view, R.id.favorite);
|
mFavoriteIcon = (ImageView) UiUtilities.getView(view, R.id.favorite);
|
||||||
mReplyButton = UiUtilities.getView(view, R.id.reply);
|
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);
|
mForwardButton = UiUtilities.getViewOrNull(view, R.id.forward);
|
||||||
mMeetingYes = UiUtilities.getView(view, R.id.accept);
|
mMeetingYes = UiUtilities.getView(view, R.id.accept);
|
||||||
mMeetingMaybe = UiUtilities.getView(view, R.id.maybe);
|
mMeetingMaybe = UiUtilities.getView(view, R.id.maybe);
|
||||||
mMeetingNo = UiUtilities.getView(view, R.id.decline);
|
mMeetingNo = UiUtilities.getView(view, R.id.decline);
|
||||||
|
mMoreButton = UiUtilities.getViewOrNull(view, R.id.more);
|
||||||
|
|
||||||
mFavoriteIcon.setOnClickListener(this);
|
mFavoriteIcon.setOnClickListener(this);
|
||||||
mReplyButton.setOnClickListener(this);
|
mReplyButton.setOnClickListener(this);
|
||||||
if (mReplyAllButton != null) {
|
mReplyAllButton.setOnClickListener(this);
|
||||||
mReplyAllButton.setOnClickListener(this);
|
if (mMoreButton != null) {
|
||||||
mForwardButton.setOnClickListener(this);
|
|
||||||
} else {
|
|
||||||
mMoreButton = UiUtilities.getView(view, R.id.more);
|
|
||||||
mMoreButton.setOnClickListener(this);
|
mMoreButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
if (mForwardButton != null) {
|
||||||
|
mForwardButton.setOnClickListener(this);
|
||||||
|
}
|
||||||
mMeetingYes.setOnClickListener(this);
|
mMeetingYes.setOnClickListener(this);
|
||||||
mMeetingMaybe.setOnClickListener(this);
|
mMeetingMaybe.setOnClickListener(this);
|
||||||
mMeetingNo.setOnClickListener(this);
|
mMeetingNo.setOnClickListener(this);
|
||||||
|
@ -224,13 +250,26 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableReplyForwardButtons(boolean enabled) {
|
private void enableReplyForwardButtons(boolean enabled) {
|
||||||
|
mEnableReplyForwardButtons = enabled;
|
||||||
// We don't have disabled button assets, so let's hide them for now
|
// We don't have disabled button assets, so let's hide them for now
|
||||||
final int visibility = enabled ? View.VISIBLE : View.GONE;
|
final int visibility = enabled ? View.VISIBLE : View.GONE;
|
||||||
mReplyButton.setVisibility(visibility);
|
|
||||||
if (mReplyAllButton != null) {
|
// Modify Reply All button only if there's no overflow OR there is
|
||||||
mReplyAllButton.setVisibility(visibility);
|
// 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);
|
mForwardButton.setVisibility(visibility);
|
||||||
} else if (mMoreButton != null) {
|
}
|
||||||
|
if (mMoreButton != null) {
|
||||||
mMoreButton.setVisibility(visibility);
|
mMoreButton.setVisibility(visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,8 +426,12 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
|
|
||||||
case R.id.more: {
|
case R.id.more: {
|
||||||
PopupMenu popup = new PopupMenu(getActivity(), mMoreButton);
|
PopupMenu popup = new PopupMenu(getActivity(), mMoreButton);
|
||||||
|
Menu menu = popup.getMenu();
|
||||||
popup.getMenuInflater().inflate(R.menu.message_header_overflow_menu,
|
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.setOnMenuItemClickListener(this);
|
||||||
popup.show();
|
popup.show();
|
||||||
break;
|
break;
|
||||||
|
@ -402,6 +445,9 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
if (isMessageOpen()) {
|
if (isMessageOpen()) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
case R.id.reply:
|
||||||
|
mCallback.onReply();
|
||||||
|
return true;
|
||||||
case R.id.reply_all:
|
case R.id.reply_all:
|
||||||
mCallback.onReplyAll();
|
mCallback.onReplyAll();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.email.activity.setup;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
@ -26,11 +27,15 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.email.Preferences;
|
import com.android.email.Preferences;
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
|
import com.android.email.activity.UiUtilities;
|
||||||
|
|
||||||
public class GeneralPreferences extends PreferenceFragment implements OnPreferenceChangeListener {
|
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_AUTO_ADVANCE = "auto_advance";
|
||||||
private static final String PREFERENCE_KEY_TEXT_ZOOM = "text_zoom";
|
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 static final String PREFERENCE_KEY_CLEAR_TRUSTED_SENDERS = "clear_trusted_senders";
|
||||||
|
|
||||||
private Preferences mPreferences;
|
private Preferences mPreferences;
|
||||||
|
@ -43,8 +48,16 @@ public class GeneralPreferences extends PreferenceFragment implements OnPreferen
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
getPreferenceManager().setSharedPreferencesName(Preferences.PREFERENCES_FILE);
|
||||||
|
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.general_preferences);
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue