Methods Summary |
---|
private void | adjustExtraKeyGravity(android.view.View navBar, boolean isLayoutRtl)
View menu = navBar.findViewById(R.id.menu);
View imeSwitcher = navBar.findViewById(R.id.ime_switcher);
if (menu != null) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) menu.getLayoutParams();
lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP;
menu.setLayoutParams(lp);
}
if (imeSwitcher != null) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imeSwitcher.getLayoutParams();
lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP;
imeSwitcher.setLayoutParams(lp);
}
|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
pw.println("NavigationBarView {");
final Rect r = new Rect();
final Point size = new Point();
mDisplay.getRealSize(size);
pw.println(String.format(" this: " + PhoneStatusBar.viewInfo(this)
+ " " + visibilityToString(getVisibility())));
getWindowVisibleDisplayFrame(r);
final boolean offscreen = r.right > size.x || r.bottom > size.y;
pw.println(" window: "
+ r.toShortString()
+ " " + visibilityToString(getWindowVisibility())
+ (offscreen ? " OFFSCREEN!" : ""));
pw.println(String.format(" mCurrentView: id=%s (%dx%d) %s",
getResourceName(mCurrentView.getId()),
mCurrentView.getWidth(), mCurrentView.getHeight(),
visibilityToString(mCurrentView.getVisibility())));
pw.println(String.format(" disabled=0x%08x vertical=%s menu=%s",
mDisabledFlags,
mVertical ? "true" : "false",
mShowMenu ? "true" : "false"));
dumpButton(pw, "back", getBackButton());
dumpButton(pw, "home", getHomeButton());
dumpButton(pw, "rcnt", getRecentsButton());
dumpButton(pw, "menu", getMenuButton());
pw.println(" }");
|
private static void | dumpButton(java.io.PrintWriter pw, java.lang.String caption, android.view.View button)
pw.print(" " + caption + ": ");
if (button == null) {
pw.print("null");
} else {
pw.print(PhoneStatusBar.viewInfo(button)
+ " " + visibilityToString(button.getVisibility())
+ " alpha=" + button.getAlpha()
);
if (button instanceof KeyButtonView) {
pw.print(" drawingAlpha=" + ((KeyButtonView)button).getDrawingAlpha());
pw.print(" quiescentAlpha=" + ((KeyButtonView)button).getQuiescentAlpha());
}
}
pw.println();
|
public android.view.View | getBackButton()
return mCurrentView.findViewById(R.id.back);
|
public BarTransitions | getBarTransitions()
return mBarTransitions;
|
public android.view.View | getCurrentView()
return mCurrentView;
|
public android.view.View | getHomeButton()
return mCurrentView.findViewById(R.id.home);
|
private void | getIcons(android.content.res.Resources res)
mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back);
mBackLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_land);
mBackAltIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime);
mBackAltLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime);
mRecentIcon = res.getDrawable(R.drawable.ic_sysbar_recent);
mRecentLandIcon = res.getDrawable(R.drawable.ic_sysbar_recent_land);
|
public android.view.View | getImeSwitchButton()
return mCurrentView.findViewById(R.id.ime_switcher);
|
public android.view.View | getMenuButton()
return mCurrentView.findViewById(R.id.menu);
|
public android.view.View | getRecentsButton()
return mCurrentView.findViewById(R.id.recent_apps);
|
private java.lang.String | getResourceName(int resId)
if (resId != 0) {
final android.content.res.Resources res = getContext().getResources();
try {
return res.getResourceName(resId);
} catch (android.content.res.Resources.NotFoundException ex) {
return "(unknown)";
}
} else {
return "(null)";
}
|
private boolean | inLockTask()
try {
return ActivityManagerNative.getDefault().isInLockTaskMode();
} catch (RemoteException e) {
return false;
}
|
private void | initDownStates(android.view.MotionEvent ev)
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mDelegateIntercepted = false;
}
|
public boolean | isVertical()
return mVertical;
|
public void | notifyScreenOn(boolean screenOn)
mScreenOn = screenOn;
setDisabledFlags(mDisabledFlags, true);
|
private void | notifyVerticalChangedListener(boolean newVertical)
if (mOnVerticalChangedListener != null) {
mOnVerticalChangedListener.onVerticalChanged(newVertical);
}
|
protected void | onConfigurationChanged(android.content.res.Configuration newConfig)
super.onConfigurationChanged(newConfig);
updateRTLOrder();
updateTaskSwitchHelper();
|
public void | onFinishInflate()
mRotatedViews[Surface.ROTATION_0] =
mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
mCurrentView = mRotatedViews[Surface.ROTATION_0];
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
updateRTLOrder();
|
public boolean | onInterceptTouchEvent(android.view.MotionEvent event)
initDownStates(event);
boolean intercept = mTaskSwitchHelper.onInterceptTouchEvent(event);
if (!intercept) {
mDelegateIntercepted = mDelegateHelper.onInterceptTouchEvent(event);
intercept = mDelegateIntercepted;
} else {
MotionEvent cancelEvent = MotionEvent.obtain(event);
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
mDelegateHelper.onInterceptTouchEvent(cancelEvent);
cancelEvent.recycle();
}
return intercept;
|
protected void | onLayout(boolean changed, int l, int t, int r, int b)
super.onLayout(changed, l, t, r, b);
mDelegateHelper.setInitialTouchRegion(getHomeButton(), getBackButton(), getRecentsButton());
|
protected void | onSizeChanged(int w, int h, int oldw, int oldh)
if (DEBUG) Log.d(TAG, String.format(
"onSizeChanged: (%dx%d) old: (%dx%d)", w, h, oldw, oldh));
final boolean newVertical = w > 0 && h > w;
if (newVertical != mVertical) {
mVertical = newVertical;
//Log.v(TAG, String.format("onSizeChanged: h=%d, w=%d, vert=%s", h, w, mVertical?"y":"n"));
reorient();
notifyVerticalChangedListener(newVertical);
}
postCheckForInvalidLayout("sizeChanged");
super.onSizeChanged(w, h, oldw, oldh);
|
public boolean | onTouchEvent(android.view.MotionEvent event)
initDownStates(event);
if (!mDelegateIntercepted && mTaskSwitchHelper.onTouchEvent(event)) {
return true;
}
if (mDeadZone != null && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
mDeadZone.poke(event);
}
if (mDelegateHelper != null && mDelegateIntercepted) {
boolean ret = mDelegateHelper.onInterceptTouchEvent(event);
if (ret) return true;
}
return super.onTouchEvent(event);
|
private void | postCheckForInvalidLayout(java.lang.String how)
mHandler.obtainMessage(MSG_CHECK_INVALID_LAYOUT, 0, 0, how).sendToTarget();
|
public void | reorient()
final int rot = mDisplay.getRotation();
for (int i=0; i<4; i++) {
mRotatedViews[i].setVisibility(View.GONE);
}
mCurrentView = mRotatedViews[rot];
mCurrentView.setVisibility(View.VISIBLE);
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
// force the low profile & disabled states into compliance
mBarTransitions.init(mVertical);
setDisabledFlags(mDisabledFlags, true /* force */);
setMenuVisibility(mShowMenu, true /* force */);
if (DEBUG) {
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
}
// swap to x coordinate if orientation is not in vertical
if (mDelegateHelper != null) {
mDelegateHelper.setSwapXY(mVertical);
}
updateTaskSwitchHelper();
setNavigationIconHints(mNavigationIconHints, true);
|
public void | setBar(com.android.systemui.statusbar.BaseStatusBar phoneStatusBar)
mTaskSwitchHelper.setBar(phoneStatusBar);
mDelegateHelper.setBar(phoneStatusBar);
|
public void | setDelegateView(android.view.View view)
mDelegateHelper.setDelegateView(view);
|
public void | setDisabledFlags(int disabledFlags)
setDisabledFlags(disabledFlags, false);
|
public void | setDisabledFlags(int disabledFlags, boolean force)
if (!force && mDisabledFlags == disabledFlags) return;
mDisabledFlags = disabledFlags;
final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
&& ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);
if (SLIPPERY_WHEN_DISABLED) {
setSlippery(disableHome && disableRecent && disableBack && disableSearch);
}
ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
if (navButtons != null) {
LayoutTransition lt = navButtons.getLayoutTransition();
if (lt != null) {
if (!lt.getTransitionListeners().contains(mTransitionListener)) {
lt.addTransitionListener(mTransitionListener);
}
if (!mScreenOn && mCurrentView != null) {
lt.disableTransitionType(
LayoutTransition.CHANGE_APPEARING |
LayoutTransition.CHANGE_DISAPPEARING |
LayoutTransition.APPEARING |
LayoutTransition.DISAPPEARING);
}
}
}
if (inLockTask() && disableRecent && !disableHome) {
// Don't hide recents when in lock task, it is used for exiting.
// Unless home is hidden, then in DPM locked mode and no exit available.
disableRecent = false;
}
getBackButton() .setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
getHomeButton() .setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);
mBarTransitions.applyBackButtonQuiescentAlpha(mBarTransitions.getMode(), true /*animate*/);
|
public void | setLayoutDirection(int layoutDirection)
getIcons(getContext().getResources());
super.setLayoutDirection(layoutDirection);
|
public void | setMenuVisibility(boolean show)
setMenuVisibility(show, false);
|
public void | setMenuVisibility(boolean show, boolean force)
if (!force && mShowMenu == show) return;
mShowMenu = show;
// Only show Menu if IME switcher not shown.
final boolean shouldShow = mShowMenu &&
((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) == 0);
getMenuButton().setVisibility(shouldShow ? View.VISIBLE : View.INVISIBLE);
|
public void | setNavigationIconHints(int hints)
setNavigationIconHints(hints, false);
|
public void | setNavigationIconHints(int hints, boolean force)
if (!force && hints == mNavigationIconHints) return;
final boolean backAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
if ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0 && !backAlt) {
mTransitionListener.onBackAltCleared();
}
if (DEBUG) {
android.widget.Toast.makeText(getContext(),
"Navigation icon hints = " + hints,
500).show();
}
mNavigationIconHints = hints;
((ImageView)getBackButton()).setImageDrawable(backAlt
? (mVertical ? mBackAltLandIcon : mBackAltIcon)
: (mVertical ? mBackLandIcon : mBackIcon));
((ImageView)getRecentsButton()).setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon);
final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
// Update menu button in case the IME state has changed.
setMenuVisibility(mShowMenu, true);
setDisabledFlags(mDisabledFlags, true);
|
public void | setOnVerticalChangedListener(com.android.systemui.statusbar.phone.NavigationBarView$OnVerticalChangedListener onVerticalChangedListener)
mOnVerticalChangedListener = onVerticalChangedListener;
notifyVerticalChangedListener(mVertical);
|
public void | setSlippery(boolean newSlippery)
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
if (lp != null) {
boolean oldSlippery = (lp.flags & WindowManager.LayoutParams.FLAG_SLIPPERY) != 0;
if (!oldSlippery && newSlippery) {
lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY;
} else if (oldSlippery && !newSlippery) {
lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY;
} else {
return;
}
WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
wm.updateViewLayout(this, lp);
}
|
private void | setVisibleOrGone(android.view.View view, boolean visible)
if (view != null) {
view.setVisibility(visible ? VISIBLE : GONE);
}
|
private void | swapChildrenOrderIfVertical(android.view.View group)Swaps the children order of a LinearLayout if it's orientation is Vertical
if (group instanceof LinearLayout) {
LinearLayout linearLayout = (LinearLayout) group;
if (linearLayout.getOrientation() == VERTICAL) {
int childCount = linearLayout.getChildCount();
ArrayList<View> childList = new ArrayList<>(childCount);
for (int i = 0; i < childCount; i++) {
childList.add(linearLayout.getChildAt(i));
}
linearLayout.removeAllViews();
for (int i = childCount - 1; i >= 0; i--) {
linearLayout.addView(childList.get(i));
}
}
}
|
private void | updateRTLOrder()In landscape, the LinearLayout is not auto mirrored since it is vertical. Therefore we
have to do it manually
boolean isLayoutRtl = getResources().getConfiguration()
.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
if (mIsLayoutRtl != isLayoutRtl) {
// We swap all children of the 90 and 270 degree layouts, since they are vertical
View rotation90 = mRotatedViews[Surface.ROTATION_90];
swapChildrenOrderIfVertical(rotation90.findViewById(R.id.nav_buttons));
adjustExtraKeyGravity(rotation90, isLayoutRtl);
View rotation270 = mRotatedViews[Surface.ROTATION_270];
if (rotation90 != rotation270) {
swapChildrenOrderIfVertical(rotation270.findViewById(R.id.nav_buttons));
adjustExtraKeyGravity(rotation270, isLayoutRtl);
}
mIsLayoutRtl = isLayoutRtl;
}
|
private void | updateTaskSwitchHelper()
boolean isRtl = (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
mTaskSwitchHelper.setBarState(mVertical, isRtl);
|
private static java.lang.String | visibilityToString(int vis)
switch (vis) {
case View.INVISIBLE:
return "INVISIBLE";
case View.GONE:
return "GONE";
default:
return "VISIBLE";
}
|