diff options
author | John Spurlock <jspurlock@google.com> | 2013-08-10 06:52:28 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2013-08-13 13:18:14 -0400 |
commit | 34e13d90eda9bfda7a70998d190a95c88aa3d3d1 (patch) | |
tree | 07899960bd361f8afe27f26928f2d82d19d16457 /packages/SystemUI | |
parent | 43e56c4a911c8d192b3e8cc1c6de664e8755cb73 (diff) | |
download | frameworks_base-34e13d90eda9bfda7a70998d190a95c88aa3d3d1.zip frameworks_base-34e13d90eda9bfda7a70998d190a95c88aa3d3d1.tar.gz frameworks_base-34e13d90eda9bfda7a70998d190a95c88aa3d3d1.tar.bz2 |
Update transient navigation confirmation logic.
Show the confirmation toast when hiding the transient
navigation bar only the first time per app, per reboot.
Hitting the power key while the transient nav is hidden
is taken as a signal of possible user confusion, so reshow
the prompt the next time.
This requires the confirmation prompt to live in policy
(not sysui). It arguably should have been here in the first
place, since the transient bar state/policy was here, and
sysui should not have not been able to fail to display
the prompt correctly.
Also take this opportunity to remove a hack wrt positioning
the confirmation properly while the nav bar is transitioning.
Toasts now support LAYOUT_HIDE_NAVIGATION if applied to the
toast's view.
Bug: 10246225
Change-Id: Ieb6355e4ca975c0758918a39e3c2ec13da81c7f4
Diffstat (limited to 'packages/SystemUI')
5 files changed, 1 insertions, 132 deletions
diff --git a/packages/SystemUI/res/values-land/refs.xml b/packages/SystemUI/res/values-land/refs.xml deleted file mode 100644 index 62fb77d..0000000 --- a/packages/SystemUI/res/values-land/refs.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Copyright (c) 2013, 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. -*/ ---> -<resources> - <item type="string" name="hiding_navigation_confirmation_message">@string/hiding_navigation_confirmation_message_long</item> -</resources> diff --git a/packages/SystemUI/res/values-sw600dp-port/refs.xml b/packages/SystemUI/res/values-sw600dp-port/refs.xml deleted file mode 100644 index 62fb77d..0000000 --- a/packages/SystemUI/res/values-sw600dp-port/refs.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Copyright (c) 2013, 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. -*/ ---> -<resources> - <item type="string" name="hiding_navigation_confirmation_message">@string/hiding_navigation_confirmation_message_long</item> -</resources> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 33a85c3..eec8177 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -503,10 +503,4 @@ <string name="status_bar_help_title">Notifications appear here</string> <!-- Body of help text shown when the notification panel is pulled down for the very first time. [CHAR LIMIT=NONE] --> <string name="status_bar_help_text">Access them anytime by swiping down.\nSwipe down again for system controls.</string> - - <!-- Toast bar message when hiding the navigation bar --> - <string name="hiding_navigation_confirmation_message">Swipe edge of screen to reveal bar</string> - - <!-- Longer version of toast bar message when hiding the navigation bar (if room) --> - <string name="hiding_navigation_confirmation_message_long">Swipe from edge of screen to reveal system bar</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index c914a34..0a09a52 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -57,7 +57,6 @@ import android.view.Gravity; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; -import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewPropertyAnimator; @@ -72,7 +71,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; -import android.widget.Toast; + import com.android.internal.statusbar.StatusBarIcon; import com.android.systemui.EventLogTags; import com.android.systemui.R; @@ -129,8 +128,6 @@ public class PhoneStatusBar extends BaseStatusBar { private static final int STATUS_OR_NAV_TRANSIENT = View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT; - private static final int TRANSIENT_NAV_HIDING = - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_ALLOW_TRANSIENT; private static final long AUTOHIDE_TIMEOUT_MS = 3000; private static final float TRANSPARENT_ALPHA = 0.7f; @@ -314,37 +311,6 @@ public class PhoneStatusBar extends BaseStatusBar { } }; - private Toast mHidingNavigationConfirmation; - private boolean mHidingNavigationConfirmationDismissed; - - private final View.OnTouchListener mDismissHidingNavigationConfirmationOnTouchOutside = - new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) { - dismissHidingNavigationConfirmation(); - } - return false; - } - }; - - private final Runnable mHidingNavigationConfirmationAction = new Runnable() { - @Override - public void run() { - if (mHidingNavigationConfirmation != null) { - final boolean isGloballyConfirmed = Prefs.read(mContext) - .getBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, false); - if (!isGloballyConfirmed) { - // user pressed button, consider this a confirmation - Prefs.edit(mContext) - .putBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, true) - .apply(); - } - dismissHidingNavigationConfirmation(); - } - } - }; - private boolean mAutohideSuspended; private final Runnable mAutohide = new Runnable() { @@ -1955,16 +1921,6 @@ public class PhoneStatusBar extends BaseStatusBar { } } - // update hiding navigation confirmation - if (mNavigationBarView != null) { - boolean oldShowConfirm = (oldVal & TRANSIENT_NAV_HIDING) == TRANSIENT_NAV_HIDING; - boolean newShowConfirm = (newVal & TRANSIENT_NAV_HIDING) == TRANSIENT_NAV_HIDING; - if (!oldShowConfirm && newShowConfirm) { - mHidingNavigationConfirmationDismissed = false; - } - setHidingNavigationConfirmationVisible(newShowConfirm); - } - // send updated sysui visibility to window manager notifyUiVisibilityChanged(mSystemUiVisibility); } @@ -1987,45 +1943,6 @@ public class PhoneStatusBar extends BaseStatusBar { : BAR_MODE_NORMAL; } - private void dismissHidingNavigationConfirmation() { - if (mHidingNavigationConfirmation != null) { - mHidingNavigationConfirmationDismissed = true; - mHidingNavigationConfirmation.cancel(); - mHidingNavigationConfirmation = null; - } - } - - private void setHidingNavigationConfirmationVisible(boolean visible) { - if (DEBUG) Log.d(TAG, "setHidingNavigationConfirmationVisible " + visible); - if (visible && - mHidingNavigationConfirmation == null && !mHidingNavigationConfirmationDismissed) { - // create the confirmation toast bar - int msg = R.string.hiding_navigation_confirmation_message; - mHidingNavigationConfirmation = Toast.makeBar(mContext, msg, Toast.LENGTH_INFINITE) - .setAction(com.android.internal.R.string.ok, - mHidingNavigationConfirmationAction); - View v = mHidingNavigationConfirmation.getView(); - v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); - boolean isGloballyConfirmed = Prefs.read(mContext) - .getBoolean(Prefs.HIDING_NAVIGATION_CONFIRMED, false); - if (isGloballyConfirmed) { - // dismiss on outside touch if globally confirmed - v.setOnTouchListener(mDismissHidingNavigationConfirmationOnTouchOutside); - } - // position at the bottom like normal toasts, but use top gravity - // to avoid jumping around when showing/hiding the nav bar - v.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); - int offsetY = mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.toast_y_offset); - mHidingNavigationConfirmation.setGravity(Gravity.TOP, - 0, mCurrentDisplaySize.y - v.getMeasuredHeight() / 2 - offsetY); - // show the confirmation - mHidingNavigationConfirmation.show(); - } else if (!visible) { - dismissHidingNavigationConfirmation(); - } - } - @Override public void resumeAutohide() { if (mAutohideSuspended) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java index 3d51f20..16a92ea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Prefs.java @@ -25,8 +25,6 @@ public class Prefs { public static final String SHOWN_COMPAT_MODE_HELP = "shown_compat_mode_help"; public static final String SHOWN_QUICK_SETTINGS_HELP = "shown_quick_settings_help"; - public static final String HIDING_NAVIGATION_CONFIRMED = "hiding_navigation_confirmed"; - public static SharedPreferences read(Context context) { return context.getSharedPreferences(Prefs.SHARED_PREFS_NAME, Context.MODE_PRIVATE); } |