asysbang

 找回密码
 立即注册
查看: 5625|回复: 0
打印 上一主题 下一主题

虚拟按键的一些定制

[复制链接]

513

主题

2

好友

6404

积分

管理员

Rank: 80Rank: 80Rank: 80Rank: 80Rank: 80

最佳新人 活跃会员 热心会员 推广达人 宣传达人 灌水之王 突出贡献 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2015-8-13 18:12:38 |只看该作者 |倒序浏览
由于是pad需要把虚拟按键放在屏幕的左侧 并且增加宽度(其实系统判断中是有放在右侧的,但是左侧时没有的需要自己修改一些计算)

PhoneWindowManager.java中 mNavigationBarHeightForRotation 这个数据里面存储的时宽度(横屏时)

横屏时,虚拟按键宽度,core/res/res/values/dimens.xml  中<dimen name="navigation_bar_width">42dp</dimen>


水平时导航栏默认是在右面的,在beginLayoutLw函数里面判断根据mNavinationBarCanMove和 displayWidth < displayHeight 来判断是否显示在右面

通过修改计算,让导航栏变到左面

--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -281,7 +281,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     WindowState mNavigationBar = null;
     boolean mHasNavigationBar = false;
     boolean mCanHideNavigationBar = false;
-    boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
+    boolean mNavigationBarCanMove = true; // can the navigation bar ever move to the side?
     boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*?
     int[] mNavigationBarHeightForRotation = new int[4];
     int[] mNavigationBarWidthForRotation = new int[4];
@@ -1188,10 +1188,10 @@ resolver.registerContentObserver(Settings.System.getUriFor(
         int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density;

         // Allow the navigation bar to move on small devices (phones).
-        mNavigationBarCanMove = shortSizeDp < 600;
-        if(mHdmiPlugged){
-            mNavigationBarCanMove = false;
-        }
+        //mNavigationBarCanMove = shortSizeDp < 600;
+        //if(mHdmiPlugged){
+        //    mNavigationBarCanMove = false;
+        //}

         mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
         // Allow a system property to override this. Used by the emulator.
@@ -1213,7 +1213,7 @@ resolver.registerContentObserver(Settings.System.getUriFor(
         
   
         if(SystemProperties.getBoolean("ro.platform.has.mbxuimode",false)){
-            mNavigationBarCanMove = false;
+            //mNavigationBarCanMove = false;
             mCanHideNavigationBar = true;
         }

@@ -2843,12 +2843,12 @@ resolver.registerContentObserver(Settings.System.getUriFor(
                     break;
             }
         } else {
-            overscanLeft = 0;
+            overscanLeft = mNavigationBarWidthForRotation[displayRotation];
             overscanTop = 0;
             overscanRight = 0;
             overscanBottom = 0;
         }
-        mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0;
+        mOverscanScreenLeft = mRestrictedOverscanScreenLeft = mNavigationBarWidthForRotation[displayRotation];
         mOverscanScreenTop = mRestrictedOverscanScreenTop = 0;
         mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth;
         mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight;
@@ -2865,7 +2865,7 @@ resolver.registerContentObserver(Settings.System.getUriFor(
         mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth;
         mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight;
         mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft
-                = mCurLeft = mUnrestrictedScreenLeft;
+                = mCurLeft = mUnrestrictedScreenLeft = mNavigationBarWidthForRotation[displayRotation];
         mDockTop = mContentTop = mStableTop = mStableFullscreenTop
                 = mCurTop = mUnrestrictedScreenTop;
         mDockRight = mContentRight = mStableRight = mStableFullscreenRight
@@ -2978,13 +2978,13 @@ resolver.registerContentObserver(Settings.System.getUriFor(
                     // Landscape screen; nav bar goes to the right.
                     int left = displayWidth - overscanRight
                             - mNavigationBarWidthForRotation[displayRotation];
-                    mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
-                    mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
+                    mTmpNavigationFrame.set(0, 0, mNavigationBarWidthForRotation[displayRotation], displayHeight);
+                    mStableRight = mStableFullscreenRight = displayWidth;
                     if (transientNavBarShowing) {
                         mNavigationBarController.setBarShowingLw(true);
                     } else if (navVisible) {
                         mNavigationBarController.setBarShowingLw(true);
-                        mDockRight = mTmpNavigationFrame.left;
+                        mDockRight = displayWidth;
                         mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
                         mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
                     } else {
@@ -2996,7 +2996,7 @@ resolver.registerContentObserver(Settings.System.getUriFor(
                         // If the nav bar is currently requested to be visible,
                         // and not in the process of animating on or off, then
                         // we can tell the app that it is covered by it.
-                        mSystemRight = mTmpNavigationFrame.left;
+                        mSystemRight = displayWidth;
                     }
                 }





屏幕最上面 有wifi图标和时间那个地方时状态栏status_bar.xml
wifi   3g 信号这个图标是通过<include layout="@layout/signal_cluster_view"   引到状态栏的布局里面
在PhoneStatusBar.java中通过
mNetworkController.addSignalCluster(signalCluster);  和 controller和signaliew关联起来的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

Archiver|手机版|aSys-帮 ( 京ICP备13033689号 )

GMT+8, 2024-10-5 20:17 , Processed in 0.045507 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部