1. 隐藏状态栏以及导航栏
diff --git a/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 30613bc..7c42abc 100644 --- a/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3434,6 +3434,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mRemoteInputController = new RemoteInputController(mStatusBarWindowManager, mHeadsUpManager); mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight()); + mStatusBarView.setVisibility(View.GONE); } // called by makeStatusbar and also by PhoneStatusBarView
2. 在设置->显示栏中 增加 显示导航栏 开关
diff --git a/android/device/softwinner/a40-p1/overlay/packages/apps/Settings/res/xml/display_settings.xml b/android/device/softwinner/a40-p1/overlay/packages/apps/Settings/res/xml/display_settings.xml index 80d03cc..ce5356e 100755 --- a/android/device/softwinner/a40-p1/overlay/packages/apps/Settings/res/xml/display_settings.xml +++ b/android/device/softwinner/a40-p1/overlay/packages/apps/Settings/res/xml/display_settings.xml @@ -116,6 +116,12 @@ android:summary="%s" android:title="@string/display_vr_pref_title" /> + <SwitchPreference + android:key="show_nav" + android:title="@string/whether_shownav" + android:summary="@string/whether_shownav" /> + + <PreferenceCategory android:key="hdmi_setting" android:title="@string/hdmi_setting"> @@ -136,33 +142,7 @@ android:key="hdmi_height_scale" android:title="@string/hdmi_height_scale" android:layout="@layout/preference_iconless_slider" /> - </PreferenceCategory> - - <PreferenceCategory android:key="smart_color_setting" - android:title="@string/smart_color"> - - <SwitchPreference - android:key="smart_color" - android:title="@string/smart_color" - android:summary="@string/smart_color_summary" /> - - <SwitchPreference - android:key="smart_color_demo" - android:title="@string/brightness_demo" - android:summary="@string/brightness_demo_summary" /> - </PreferenceCategory> - - <PreferenceCategory android:key="intelligent_backlight_setting" - android:title="@string/intelligent_backlight"> - - <SwitchPreference - android:key="intelligent_backlight" - android:title="@string/intelligent_backlight" /> - <SwitchPreference - android:key="intelligent_backlight_demo" - android:title="@string/brightness_demo" - android:summary="@string/brightness_demo_summary" /> </PreferenceCategory> </PreferenceScreen> diff --git a/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml index d010bc5..d8ec69c 100755 --- a/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml +++ b/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml @@ -242,5 +242,7 @@ <integer name="def_hdmi_hscaler">90</integer> <integer name="def_vga_output_mode">888</integer> - <!-- end added by zhongzhiwen --> + + <string name="def_show_nav_bar">false</string> + <!-- end added by zhongzhiwen --> </resources> diff --git a/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 5e34361..ada7cd6 100755 --- a/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -2363,6 +2363,8 @@ class DatabaseHelper extends SQLiteOpenHelper { R.bool.def_dim_screen); loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, R.integer.def_screen_off_timeout); + loadStringSetting(stmt, "show_navigation_bar", + R.string.def_show_nav_bar); // Set default cdma DTMF type loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0); diff --git a/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 7c42abc..781ce7f 100644 --- a/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -723,6 +723,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mScreenPinningRequest = new ScreenPinningRequest(mContext); mFalsingManager = FalsingManager.getInstance(mContext); + + String isShownav = Settings.System.getString(mContext.getContentResolver(),"show_navigation_bar"); + if ("false".equals(isShownav)) { + mWindowManager.removeView(mNavigationBarView); + } } protected void createIconController() { @@ -787,9 +792,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, try { boolean showNav = mWindowManagerService.hasNavigationBar(); if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav); + if (showNav) { createNavigationBarView(context); } + } catch (RemoteException ex) { // no window manager? good luck with that } @@ -1012,6 +1019,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, // Private API call to make the shadows look better for Recents ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f)); + return mStatusBarView; } @@ -3678,7 +3686,27 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, mUserSetupObserver, mCurrentUserId); - } + mContentObserver = new SettingsValueChangeContentObserver(); + mContext.getContentResolver().registerContentObserver( + Settings.System.getUriFor("show_navigation_bar"),true, mContentObserver); + } + +private SettingsValueChangeContentObserver mContentObserver; +class SettingsValueChangeContentObserver extends ContentObserver { + public SettingsValueChangeContentObserver() { + super(new Handler()); + } + @Override + public void onChange(boolean selfChange) { + super.onChange(selfChange); + String isShownav = Settings.System.getString(mContext.getContentResolver(),"show_navigation_bar"); + if ("true".equals(isShownav)) { + mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); + } else { + mWindowManager.removeView(mNavigationBarView); + } + } +} /** * Reload some of our resources when the configuration changes. diff --git a/android/packages/apps/Settings/res/values-zh-rCN/custom.xml b/android/packages/apps/Settings/res/values-zh-rCN/custom.xml index 48f8352..3de5ff8 100755 --- a/android/packages/apps/Settings/res/values-zh-rCN/custom.xml +++ b/android/packages/apps/Settings/res/values-zh-rCN/custom.xml @@ -29,7 +29,8 @@ <string name="smart_color">丽色系统</string> <string name="smart_color_summary">丽色系统用于玩游戏,观看视频图片,效果更佳</string> <string name="intelligent_backlight">智能背光</string> - <string name="brightness_demo">演示模式</string> + <string name="whether_shownav">"显示导航栏"</string> + <string name="brightness_demo">演示模式</string> <string name="brightness_demo_summary">只对半个屏幕有效,便于看出效果</string> <!-- display settings end --> diff --git a/android/packages/apps/Settings/res/values/custom.xml b/android/packages/apps/Settings/res/values/custom.xml index 6b4ad1b..aca7000 100755 --- a/android/packages/apps/Settings/res/values/custom.xml +++ b/android/packages/apps/Settings/res/values/custom.xml @@ -45,7 +45,8 @@ <string name="smart_color">Smart color</string> <string name="smart_color_summary">It is better for playing games and video and picture.</string> <string name="intelligent_backlight">Intelligent backlight</string> - <string name="brightness_demo">Demo mode</string> + <string name="whether_shownav">"whether show nav"</string> + <string name="brightness_demo">Demo mode</string> <string name="brightness_demo_summary">Only half of the screen is effective, in order to show the effect easily.</string> <!-- display settings end --> diff --git a/android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java b/android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java index bf041c1..ac5bb68 100644 --- a/android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java +++ b/android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java @@ -122,6 +122,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private SwitchPreference mSmartColorDemoPreference; private SwitchPreference mIntelligentBacklightPreference; private SwitchPreference mIntelligentBacklightDemoPreference; + private SwitchPreference mshowNavPreference; @Override protected int getMetricsCategory() { @@ -135,8 +136,18 @@ public class DisplaySettings extends SettingsPreferenceFragment implements final ContentResolver resolver = activity.getContentResolver(); addPreferencesFromResource(R.xml.display_settings); - - mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER); + + mshowNavPreference = (SwitchPreference) findPreference("show_nav"); + if (mshowNavPreference != null) { + // 显示之前的设置 + String isShownav = Settings.System.getString(getContentResolver(),"show_navigation_bar"); + mshowNavPreference.setChecked("true".equals(isShownav) ? true : false); + mshowNavPreference.setOnPreferenceChangeListener(this); + } else { + removePreference("show_navigation_bar"); + } + + mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER); if (mScreenSaverPreference != null && getResources().getBoolean( com.android.internal.R.bool.config_dreamsSupported) == false) { @@ -497,6 +508,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements Log.e(TAG, "could not persist screen timeout setting", e); } } + if (preference == mshowNavPreference) { + boolean auto = (Boolean) objValue; + Settings.System.putString(getContentResolver(),"show_navigation_bar",String.valueOf(auto)); + } if (preference == mAutoBrightnessPreference) { boolean auto = (Boolean) objValue; Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,