调整diplay size时,虚拟按键一直显示在下方
在这里插入代码片
diff --git a/frameworks/base/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml b/frameworks/base/packages/Syst
old mode 100644
new mode 100755
index b237633..982b935
--- a/frameworks/base/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml
+++ b/frameworks/base/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml
<include android:id="@+id/rot0" layout="@layout/navigation_layout" />
- <include android:id="@+id/rot90" layout="@layout/navigation_layout_rot90" />
+ <include android:id="@+id/rot90" layout="@layout/navigation_layout" />
--git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.ja
old mode 100644
new mode 100755
index 3240489..493485d
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
@@ -86,7 +86,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
Display display = ((WindowManager)
context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Mode displayMode = display.getMode();
- isRot0Landscape = displayMode.getPhysicalWidth() < displayMode.getPhysicalHeight();
+ isRot0Landscape = displayMode.getPhysicalWidth() > displayMode.getPhysicalHeight();
}
private void createInflaters() {
@@ -123,7 +123,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
mRot0 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout, this, false);
mRot0.setId(R.id.rot0);
addView(mRot0);
- mRot90 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout_rot90, this,
+ mRot90 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout, this,
false);
mRot90.setId(R.id.rot90);
addView(mRot90);
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/fra
index e4eaf7b..4b420f0 100755
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -51,7 +51,7 @@ import com.android.systemui.statusbar.policy.DeadZone;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-
+import android.view.Display.Mode;
public class NavigationBarView extends LinearLayout {
final static boolean DEBUG = false;
final static String TAG = "StatusBar/NavBarView";
@@ -72,7 +72,7 @@ public class NavigationBarView extends LinearLayout {
boolean mShowMenu;
int mDisabledFlags = 0;
int mNavigationIconHints = 0;
-
+ private boolean mIsRot0Landscape = true;
private Drawable mBackIcon, mBackLandIcon, mBackAltIcon, mBackAltLandIcon;
private Drawable mBackCarModeIcon, mBackLandCarModeIcon;
private Drawable mBackAltCarModeIcon, mBackAltLandCarModeIcon;
@@ -196,7 +196,11 @@ public class NavigationBarView extends LinearLayout {
mConfiguration = new Configuration();
mConfiguration.updateFrom(context.getResources().getConfiguration());
updateIcons(context, Configuration.EMPTY, mConfiguration);
-
+ Display display = ((WindowManager)
+ context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+ Mode displayMode = display.getMode();
+ mIsRot0Landscape = displayMode.getPhysicalWidth() > displayMode.getPhysicalHeight();
+ Log.v(TAG, "PW=" + displayMode.getPhysicalWidth() + ", PH=" + displayMode.getPhysicalHeight());
mBarTransitions = new NavigationBarTransitions(this);
mButtonDisatchers.put(R.id.back, new ButtonDispatcher(R.id.back));
@@ -540,6 +544,15 @@ public class NavigationBarView extends LinearLayout {
}
void updateRotatedViews() {
+ if (mIsRot0Landscape) {
+ Log.w(TAG, "NBV updateRotatedViews mVertical= true, change rot0 rot90");
+ mRotatedViews[Surface.ROTATION_0] =
+ mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot90);
+ mRotatedViews[Surface.ROTATION_270] =
+ mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot0);
+ updateCurrentView();
+ return;
+ }
mRotatedViews[Surface.ROTATION_0] =
mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
mRotatedViews[Surface.ROTATION_270] =
diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/
index 3e3ebfb..d652d86 100755
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2086,7 +2086,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density;
// Allow the navigation bar to move on non-square small devices (phones).
- mNavigationBarCanMove = width != height && shortSizeDp < 600;
+ mNavigationBarCanMove = width != height && shortSizeDp < 0;
mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);