NavBar: Use rotation watcher
am: a98b32cea2
Change-Id: Ia820decbca2535b85ac1bf366bd789ab51be4d73
This commit is contained in:
@@ -54,7 +54,7 @@ import java.io.PrintWriter;
|
|||||||
|
|
||||||
public class NavigationBarView extends LinearLayout {
|
public class NavigationBarView extends LinearLayout {
|
||||||
final static boolean DEBUG = false;
|
final static boolean DEBUG = false;
|
||||||
final static String TAG = "PhoneStatusBar/NavigationBarView";
|
final static String TAG = "StatusBar/NavBarView";
|
||||||
|
|
||||||
// slippery nav bar when everything is disabled, e.g. during setup
|
// slippery nav bar when everything is disabled, e.g. during setup
|
||||||
final static boolean SLIPPERY_WHEN_DISABLED = true;
|
final static boolean SLIPPERY_WHEN_DISABLED = true;
|
||||||
@@ -527,8 +527,8 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
updateCurrentView();
|
updateCurrentView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsReorient() {
|
public boolean needsReorient(int rotation) {
|
||||||
return mCurrentRotation != mDisplay.getRotation();
|
return mCurrentRotation != rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentView() {
|
private void updateCurrentView() {
|
||||||
@@ -567,7 +567,7 @@ public class NavigationBarView extends LinearLayout {
|
|||||||
setMenuVisibility(mShowMenu, true /* force */);
|
setMenuVisibility(mShowMenu, true /* force */);
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "reorient(): rot=" + mDisplay.getRotation());
|
Log.d(TAG, "reorient(): rot=" + mCurrentRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTaskSwitchHelper();
|
updateTaskSwitchHelper();
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.hardware.display.DisplayManager;
|
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
import android.media.MediaMetadata;
|
import android.media.MediaMetadata;
|
||||||
@@ -100,6 +99,7 @@ import android.util.DisplayMetrics;
|
|||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.IRotationWatcher;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -207,7 +207,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||||
DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener,
|
DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener,
|
||||||
HeadsUpManager.OnHeadsUpChangedListener, DisplayManager.DisplayListener {
|
HeadsUpManager.OnHeadsUpChangedListener {
|
||||||
static final String TAG = "PhoneStatusBar";
|
static final String TAG = "PhoneStatusBar";
|
||||||
public static final boolean DEBUG = BaseStatusBar.DEBUG;
|
public static final boolean DEBUG = BaseStatusBar.DEBUG;
|
||||||
public static final boolean SPEW = false;
|
public static final boolean SPEW = false;
|
||||||
@@ -693,8 +693,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mUnlockMethodCache.addListener(this);
|
mUnlockMethodCache.addListener(this);
|
||||||
startKeyguard();
|
startKeyguard();
|
||||||
|
|
||||||
mContext.getSystemService(DisplayManager.class).registerDisplayListener(this, null);
|
|
||||||
|
|
||||||
mDozeServiceHost = new DozeServiceHost();
|
mDozeServiceHost = new DozeServiceHost();
|
||||||
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost);
|
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost);
|
||||||
putComponent(DozeHost.class, mDozeServiceHost);
|
putComponent(DozeHost.class, mDozeServiceHost);
|
||||||
@@ -1411,6 +1409,27 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView);
|
if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView);
|
||||||
if (mNavigationBarView == null) return;
|
if (mNavigationBarView == null) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
WindowManagerGlobal.getWindowManagerService()
|
||||||
|
.watchRotation(new IRotationWatcher.Stub() {
|
||||||
|
@Override
|
||||||
|
public void onRotationChanged(int rotation) throws RemoteException {
|
||||||
|
// We need this to be scheduled as early as possible to beat the redrawing of
|
||||||
|
// window in response to the orientation change.
|
||||||
|
Message msg = Message.obtain(mHandler, () -> {
|
||||||
|
if (mNavigationBarView != null
|
||||||
|
&& mNavigationBarView.needsReorient(rotation)) {
|
||||||
|
repositionNavigationBar();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
msg.setAsynchronous(true);
|
||||||
|
mHandler.sendMessageAtFrontOfQueue(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
|
||||||
prepareNavigationBarView();
|
prepareNavigationBarView();
|
||||||
|
|
||||||
mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
|
mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
|
||||||
@@ -3586,22 +3605,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mNetworkController.onConfigurationChanged();
|
mNetworkController.onConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayAdded(int displayId) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayRemoved(int displayId) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayChanged(int displayId) {
|
|
||||||
if (displayId == Display.DEFAULT_DISPLAY
|
|
||||||
&& mNavigationBarView != null && mNavigationBarView.needsReorient()) {
|
|
||||||
repositionNavigationBar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userSwitched(int newUserId) {
|
public void userSwitched(int newUserId) {
|
||||||
super.userSwitched(newUserId);
|
super.userSwitched(newUserId);
|
||||||
|
|||||||
Reference in New Issue
Block a user