diff options
author | John Spurlock <jspurlock@google.com> | 2013-08-13 20:02:46 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2013-08-13 20:32:28 -0400 |
commit | 4cf6a948f9998204d2bfdceebae89954b2b4ae7e (patch) | |
tree | 9b05475a7385c321b344e69c4be2acbcd2f99d16 /policy | |
parent | e932e30eadb5978591316ffe3d21d60604c0cd91 (diff) | |
download | frameworks_base-4cf6a948f9998204d2bfdceebae89954b2b4ae7e.zip frameworks_base-4cf6a948f9998204d2bfdceebae89954b2b4ae7e.tar.gz frameworks_base-4cf6a948f9998204d2bfdceebae89954b2b4ae7e.tar.bz2 |
Delay transient navigation confirmation prompt.
Ensure the nav bar is hidden, then wait about the same amount
of time before showing the prompt.
Bug:10312565
Change-Id: Ifbbbc55edf2e40844296e3e96fcc5b491f1b246f
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 2 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/TransientNavigationConfirmation.java | 85 |
2 files changed, 54 insertions, 33 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 952dfda..9da4357 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -943,7 +943,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } }); - mTransientNavigationConfirmation = new TransientNavigationConfirmation(mContext, mHandler); + mTransientNavigationConfirmation = new TransientNavigationConfirmation(mContext); mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); diff --git a/policy/src/com/android/internal/policy/impl/TransientNavigationConfirmation.java b/policy/src/com/android/internal/policy/impl/TransientNavigationConfirmation.java index bd5bd80..3c4f092 100644 --- a/policy/src/com/android/internal/policy/impl/TransientNavigationConfirmation.java +++ b/policy/src/com/android/internal/policy/impl/TransientNavigationConfirmation.java @@ -18,9 +18,13 @@ package com.android.internal.policy.impl; import android.content.Context; import android.os.Handler; +import android.os.Message; import android.util.ArraySet; import android.util.Slog; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.AnimationUtils; import android.widget.Toast; import com.android.internal.R; @@ -30,29 +34,26 @@ import com.android.internal.R; * is hidden. */ public class TransientNavigationConfirmation { - private final String TAG = "TransientNavigationConfirmation"; - private final boolean DEBUG = false; + private static final String TAG = "TransientNavigationConfirmation"; + private static final boolean DEBUG = false; private final Context mContext; - private final Handler mHandler; + private final H mHandler; private final ArraySet<String> mConfirmedUserPackages = new ArraySet<String>(); - - private final Runnable mHandleDismiss = new Runnable() { - @Override - public void run() { - if (mToast != null) { - mToast.cancel(); - mToast = null; - } - } - }; + private final long mShowDelayMs; private Toast mToast; private String mLastUserPackage; - public TransientNavigationConfirmation(Context context, Handler handler) { + public TransientNavigationConfirmation(Context context) { mContext = context; - mHandler = handler; + mHandler = new H(); + mShowDelayMs = getNavBarExitDuration() * 3; + } + + private long getNavBarExitDuration() { + Animation exit = AnimationUtils.loadAnimation(mContext, R.anim.dock_bottom_exit); + return exit != null ? exit.getDuration() : 0; } public void transientNavigationChanged(int userId, String pkg, boolean isNavTransient) { @@ -60,16 +61,17 @@ public class TransientNavigationConfirmation { return; } String userPkg = userId + ":" + pkg; + mHandler.removeMessages(H.SHOW); if (isNavTransient) { mLastUserPackage = userPkg; if (!mConfirmedUserPackages.contains(userPkg)) { if (DEBUG) Slog.d(TAG, "Showing transient navigation confirmation for " + userPkg); - mHandler.post(handleShowConfirmation(userPkg)); + mHandler.sendMessageDelayed(mHandler.obtainMessage(H.SHOW, userPkg), mShowDelayMs); } } else { mLastUserPackage = null; if (DEBUG) Slog.d(TAG, "Hiding transient navigation confirmation for " + userPkg); - mHandler.post(mHandleDismiss); + mHandler.sendEmptyMessage(H.HIDE); } } @@ -80,22 +82,24 @@ public class TransientNavigationConfirmation { } } - private Runnable handleShowConfirmation(final String userPkg) { - return new Runnable() { - @Override - public void run() { - // create the confirmation toast bar - final int msg = R.string.transient_navigation_confirmation; - mToast = Toast.makeBar(mContext, msg, Toast.LENGTH_INFINITE); - mToast.setAction(R.string.ok, confirmAction(userPkg)); + private void handleHide() { + if (mToast != null) { + mToast.cancel(); + mToast = null; + } + } - // we will be hiding the nav bar, so layout as if it's already hidden - mToast.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); + private void handleShow(String userPkg) { + // create the confirmation toast bar + final int msg = R.string.transient_navigation_confirmation; + mToast = Toast.makeBar(mContext, msg, Toast.LENGTH_INFINITE); + mToast.setAction(R.string.ok, confirmAction(userPkg)); - // show the confirmation - mToast.show(); - } - }; + // we will be hiding the nav bar, so layout as if it's already hidden + mToast.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); + + // show the confirmation + mToast.show(); } private Runnable confirmAction(final String userPkg) { @@ -103,8 +107,25 @@ public class TransientNavigationConfirmation { @Override public void run() { mConfirmedUserPackages.add(userPkg); - mHandleDismiss.run(); + handleHide(); } }; } + + private final class H extends Handler { + private static final int SHOW = 0; + private static final int HIDE = 1; + + @Override + public void handleMessage(Message msg) { + switch(msg.what) { + case SHOW: + handleShow((String)msg.obj); + break; + case HIDE: + handleHide(); + break; + } + } + } } |