summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJin Cao <jinyan@google.com>2014-08-09 00:20:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-08 22:57:22 +0000
commit094986e3c824d705909af10464954532c377adc3 (patch)
tree4652c9083529b59c60607adbb8251bad7a111bec /src
parent79314245229c5f87160da15690661ac93b019734 (diff)
parentd23f6d1cd1dd8248cba755bf91c5355a31fbb885 (diff)
downloadandroid_packages_apps_UnifiedEmail-094986e3c824d705909af10464954532c377adc3.tar.gz
android_packages_apps_UnifiedEmail-094986e3c824d705909af10464954532c377adc3.tar.bz2
android_packages_apps_UnifiedEmail-094986e3c824d705909af10464954532c377adc3.zip
Merge "[KBNav] Support peeking the focused conversation" into ub-gmail-ur14-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/mail/ui/AbstractActivityController.java4
-rw-r--r--src/com/android/mail/ui/ConversationListCallbacks.java6
-rw-r--r--src/com/android/mail/ui/ConversationListFragment.java38
-rw-r--r--src/com/android/mail/ui/OnePaneController.java5
-rw-r--r--src/com/android/mail/ui/TwoPaneController.java15
5 files changed, 65 insertions, 3 deletions
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index 6e4ee8ff6..f6727d38a 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -2461,6 +2461,10 @@ public abstract class AbstractActivityController implements ActivityController,
* onLoadFinished(Loader, Cursor) on any callback.
*/
protected void showConversation(Conversation conversation) {
+ showConversation(conversation, true /* markAsRead */);
+ }
+
+ protected void showConversation(Conversation conversation, boolean markAsRead) {
if (conversation != null) {
Utils.sConvLoadTimer.start();
}
diff --git a/src/com/android/mail/ui/ConversationListCallbacks.java b/src/com/android/mail/ui/ConversationListCallbacks.java
index 23f2873aa..c58a36794 100644
--- a/src/com/android/mail/ui/ConversationListCallbacks.java
+++ b/src/com/android/mail/ui/ConversationListCallbacks.java
@@ -40,6 +40,12 @@ public interface ConversationListCallbacks {
void onConversationSelected(Conversation conversation, boolean inLoaderCallbacks);
/**
+ * Possibly show the conversation provided here depending on implementation.
+ * Used mainly by two-pane landscape mode when we are navigating with the keyboard.
+ */
+ void onConversationFocused(Conversation conversation);
+
+ /**
* Called whenever CAB mode has been entered via long press or selecting a sender image.
*/
void onCabModeEntered();
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index 15a562b7b..84d46c3b9 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -28,6 +28,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -68,12 +69,14 @@ import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.List;
+import static android.view.View.OnKeyListener;
+
/**
* The conversation list UI component.
*/
public final class ConversationListFragment extends ListFragment implements
OnItemLongClickListener, ModeChangeListener, ListItemSwipedListener, OnRefreshListener,
- SwipeListener {
+ SwipeListener, OnKeyListener {
/** Key used to pass data to {@link ConversationListFragment}. */
private static final String CONVERSATION_LIST_KEY = "conversation-list";
/** Key used to keep track of the scroll state of the list. */
@@ -451,6 +454,7 @@ public final class ConversationListFragment extends ListFragment implements
mListView.enableSwipe(mAccount.supportsCapability(AccountCapabilities.UNDO));
mListView.setListItemSwipedListener(this);
mListView.setSwipeListener(this);
+ mListView.setOnKeyListener(this);
// enable animateOnLayout (equivalent of setLayoutTransition) only for >=JB (b/14302062)
if (Utils.isRunningJellybeanOrLater()) {
@@ -581,6 +585,10 @@ public final class ConversationListFragment extends ListFragment implements
*/
@Override
public void onListItemClick(ListView l, View view, int position, long id) {
+ onListItemSelected(view, position);
+ }
+
+ private void onListItemSelected(View view, int position) {
if (view instanceof ToggleableItem) {
final boolean showSenderImage =
(mAccount.settings.convListIcon == ConversationListIcon.SENDER_IMAGE);
@@ -608,6 +616,34 @@ public final class ConversationListFragment extends ListFragment implements
}
@Override
+ public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
+ SwipeableListView list = (SwipeableListView) view;
+ // Don't need to handle ENTER because it's auto-handled as a "click".
+ if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
+ if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
+ onListItemSelected(list.getSelectedView(), list.getSelectedItemPosition());
+ }
+ return true;
+ } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
+ if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
+ final int position = list.getSelectedItemPosition();
+ final ConversationCursor cursor =
+ (ConversationCursor) getAnimatedAdapter().getItem(position);
+
+ if (cursor != null) {
+ final Conversation conv = cursor.getConversation();
+ mCallbacks.onConversationFocused(conv);
+ } else {
+ LogUtils.e(LOG_TAG,
+ "unable to find conv at cursor pos=%s cursor=%s getPositionOffset=%s",
+ position, cursor, getAnimatedAdapter().getPositionOffset(position));
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
public void onResume() {
super.onResume();
diff --git a/src/com/android/mail/ui/OnePaneController.java b/src/com/android/mail/ui/OnePaneController.java
index 1e71b1186..0d83572c6 100644
--- a/src/com/android/mail/ui/OnePaneController.java
+++ b/src/com/android/mail/ui/OnePaneController.java
@@ -265,6 +265,11 @@ public final class OnePaneController extends AbstractActivityController {
}
@Override
+ public void onConversationFocused(Conversation conversation) {
+ // Do nothing
+ }
+
+ @Override
public void showWaitForInitialization() {
super.showWaitForInitialization();
replaceFragment(getWaitFragment(), FragmentTransaction.TRANSIT_FRAGMENT_OPEN, TAG_WAIT,
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index 0c9b0f1ba..781efa3d4 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -70,6 +70,8 @@ public final class TwoPaneController extends AbstractActivityController implemen
*/
private boolean mSavedMiscellaneousView = false;
+ private boolean mIsTabletLandscape;
+
public TwoPaneController(MailActivity activity, ViewMode viewMode) {
super(activity, viewMode);
}
@@ -152,6 +154,7 @@ public final class TwoPaneController extends AbstractActivityController implemen
}
mLayout.setController(this, Intent.ACTION_SEARCH.equals(mActivity.getIntent().getAction()));
mActivity.getWindow().setBackgroundDrawable(null);
+ mIsTabletLandscape = !mActivity.getResources().getBoolean(R.bool.list_collapsible);
final FolderListFragment flf = getFolderListFragment();
flf.setMiniDrawerEnabled(true);
@@ -336,8 +339,8 @@ public final class TwoPaneController extends AbstractActivityController implemen
}
@Override
- protected void showConversation(Conversation conversation) {
- super.showConversation(conversation);
+ protected void showConversation(Conversation conversation, boolean markAsRead) {
+ super.showConversation(conversation, markAsRead);
// 2-pane can ignore inLoaderCallbacks because it doesn't use
// FragmentManager.popBackStack().
@@ -363,6 +366,7 @@ public final class TwoPaneController extends AbstractActivityController implemen
// When a mode change is required, wait for onConversationVisibilityChanged(), the signal
// that the mode change animation has finished, before rendering the conversation.
mConversationToShow = conversation;
+ mCurrentConversationJustPeeking = !markAsRead;
final int mode = mViewMode.getMode();
LogUtils.i(LOG_TAG, "IN TPC.showConv, oldMode=%s conv=%s", mode, mConversationToShow);
@@ -380,6 +384,13 @@ public final class TwoPaneController extends AbstractActivityController implemen
}
@Override
+ public void onConversationFocused(Conversation conversation) {
+ if (mIsTabletLandscape) {
+ showConversation(conversation, false /* markAsRead */);
+ }
+ }
+
+ @Override
public void setCurrentConversation(Conversation conversation) {
// Order is important! We want to calculate different *before* the superclass changes
// mCurrentConversation, so before super.setCurrentConversation().