import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.function.Consumer;
public class NavigationBarView extends FrameLayout implements PluginListener<NavGesture> {
final static boolean DEBUG = false;
View[] mRotatedViews = new View[4];
boolean mVertical;
- boolean mScreenOn;
private int mCurrentRotation = -1;
boolean mShowMenu;
mDockedIcon = getDrawable(ctx,
R.drawable.ic_sysbar_docked, R.drawable.ic_sysbar_docked_dark);
}
- if (oldConfig.densityDpi != newConfig.densityDpi) {
+ if (oldConfig.densityDpi != newConfig.densityDpi
+ || oldConfig.getLayoutDirection() != newConfig.getLayoutDirection()) {
mBackIcon = getDrawable(ctx, R.drawable.ic_sysbar_back, R.drawable.ic_sysbar_back_dark);
mBackLandIcon = mBackIcon;
mBackAltIcon = getDrawable(ctx,
super.setLayoutDirection(layoutDirection);
}
- public void notifyScreenOn(boolean screenOn) {
- mScreenOn = screenOn;
+ public void notifyScreenOn() {
setDisabledFlags(mDisabledFlags, true);
}
public void onFinishInflate() {
mNavigationInflaterView = (NavigationBarInflaterView) findViewById(
R.id.navigation_inflater);
- updateRotatedViews();
mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
- DockedStackExistsListener.register(exists -> mHandler.post(() -> {
- mDockedStackExists = exists;
- updateRecentsIcon();
- }));
+ DockedStackExistsListener.register(mDockedListener);
+ updateRotatedViews();
}
- void updateRotatedViews() {
+ private void updateRotatedViews() {
mRotatedViews[Surface.ROTATION_0] =
mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
mRotatedViews[Surface.ROTATION_270] =
mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
-
- updateCurrentView();
}
public boolean needsReorient(int rotation) {
return mCurrentRotation != rotation;
}
- private void updateCurrentView() {
+ private boolean updateCurrentView() {
final int rot = mDisplay.getRotation();
+ if (rot == mCurrentRotation) return false;
for (int i=0; i<4; i++) {
mRotatedViews[i].setVisibility(View.GONE);
}
}
updateLayoutTransitionsEnabled();
mCurrentRotation = rot;
+ return true;
}
private void updateRecentsIcon() {
}
public void reorient() {
- updateCurrentView();
+ if (!updateCurrentView()) {
+ return;
+ }
mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone);
+
((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone);
+
mDeadZone.setDisplayRotation(mCurrentRotation);
// force the low profile & disabled states into compliance
getHomeButton().setVertical(mVertical);
}
- public void onKeyguardOccludedChanged(boolean keyguardOccluded) {
- }
-
private void updateTaskSwitchHelper() {
if (mGestureHelper == null) return;
boolean isRtl = (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
mVertical = newVertical;
//Log.v(TAG, String.format("onSizeChanged: h=%d, w=%d, vert=%s", h, w, mVertical?"y":"n"));
reorient();
+ getHomeButton().setVertical(mVertical);
notifyVerticalChangedListener(newVertical);
}
updateTaskSwitchHelper();
updateIcons(getContext(), mConfiguration, newConfig);
updateRecentsIcon();
- if (uiCarModeChanged || mConfiguration.densityDpi != newConfig.densityDpi) {
+ if (uiCarModeChanged || mConfiguration.densityDpi != newConfig.densityDpi
+ || mConfiguration.getLayoutDirection() != newConfig.getLayoutDirection()) {
// If car mode or density changes, we need to reset the icons.
setNavigationIconHints(mNavigationIconHints, true);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ reorient();
onPluginDisconnected(null); // Create default gesture helper
Dependency.get(PluginManager.class).addPluginListener(this,
NavGesture.class, false /* Only one */);
void onVerticalChanged(boolean isVertical);
}
+ private final Consumer<Boolean> mDockedListener = exists -> mHandler.post(() -> {
+ mDockedStackExists = exists;
+ updateRecentsIcon();
+ });
}