- 添加系统默认键值
xml
复制代码
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -212,4 +212,7 @@
<!-- Default for Settings.Secure.NFC_PAYMENT_COMPONENT -->
<string name="def_nfc_payment_component"></string>
+
+ <!--mh.modify 20190602 navigationbar switch.-->
+ <integer name="switch_navigation_bar">0</integer>
java
复制代码
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2646,6 +2646,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED,
R.bool.def_device_provisioned);
+
+ //mh.mmi add navbar 20190602
+ loadIntegerSetting(stmt, "switch_navigation_bar",R.integer.switch_navigation_bar);
- 设置中添加开关
xml
复制代码
+++ b/packages/apps/Settings/res/values-zh-rCN/strings.xml
@@ -2880,4 +2880,6 @@
<string name="write_settings_description" msgid="6868293938839954623">"此权限允许应用修改系统设置。"</string>
<string name="write_settings_on" msgid="8230580416068832239">"允许"</string>
<string name="write_settings_off" msgid="5156104383386336233">"不允许"</string>
+ <string name="switch_navigationbarview">虚拟键开关</string>
</resources>
diff --git a/packages/apps/Settings/res/values/strings.xml b/packages/apps/Settings/res/values/strings.xml
old mode 100644
new mode 100755
index ad5ca8cbf3..d4474ab5bc
+++ b/packages/apps/Settings/res/values/strings.xml
@@ -6998,4 +6998,6 @@
<string name="write_settings_on">Yes</string>
<!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->
<string name="write_settings_off">No</string>
+ <string name="switch_navigationbarview">Navigation key switch</string>
xml
复制代码
+++ b/packages/apps/Settings/res/xml/accessibility_settings.xml
@@ -36,6 +36,12 @@
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title"/>
+
+ <!-- mh.mmi -->
+ <SwitchPreference
+ android:key="switch_navigationbarview"
+ android:title="@string/switch_navigationbarview"
+ android:persistent="false"/>
java
复制代码
+++ b/packages/apps/Settings/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -187,6 +187,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
private PreferenceCategory mServicesCategory;
private PreferenceCategory mSystemsCategory;
+ private SwitchPreference mToggleNavBarPreference;//mh.mmi
private SwitchPreference mToggleLargeTextPreference;
private SwitchPreference mToggleHighTextContrastPreference;
private SwitchPreference mTogglePowerButtonEndsCallPreference;
@@ -304,9 +305,20 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
handleDisplayMagnificationPreferenceScreenClick();
return true;
}
+ //mh.mmi add navbar switch. 20190602
+ else if (mToggleNavBarPreference == preference) {
+ handleToggleNavBarPreferenceClick();
+ }
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
+ ///mh.mmi add navbar switch. 20190602
+ private void handleToggleNavBarPreferenceClick() {
+ Settings.Global.putInt(getContentResolver(),
+ "switch_navigation_bar",
+ mToggleNavBarPreference.isChecked() ? 1 : 0);
+ }
+
private void handleToggleLargeTextPreferenceClick() {
/** M: MTK fix fonts problem @{ */
float fontScale = LARGE_FONT_SCALE;
@@ -380,6 +392,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
+ // mh.mmi add navbar switch. 20190602
+ mToggleNavBarPreference =
+ (SwitchPreference) findPreference("switch_navigationbarview");
+
// Large text.
mToggleLargeTextPreference =
(SwitchPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
@@ -580,6 +596,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
}
updateFontScale = mLargeFontScaleTablet;
}
+
+ ///mh.mmi add navbar switch. 20190602
+ mToggleNavBarPreference.setChecked(Settings.Global.getInt(getContentResolver(),
+ "switch_navigation_bar", 0) == 1);
mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == updateFontScale);
/** @} */
- 监听数据库变化
java
复制代码
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -668,6 +668,43 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mScreenPinningRequest = new ScreenPinningRequest(mContext);
}
+
+ ///mh.modify start 2019.6.2
+ class NavBarChangeContentObserver extends ContentObserver{
+
+ public NavBarChangeContentObserver() {
+ super(new Handler());
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ super.onChange(selfChange);
+ boolean isShownav = Settings.Global.getInt(mContext.getContentResolver(), "switch_navigation_bar", 0) != 0;
+ android.util.Log.d("mh.log", "isShownav:"+isShownav);
+ if (isShownav) {
+ if (mNavigationBarView == null) {
+ addNarBar();
+ }
+ if (mNavigationBarView != null) {
+ checkBarMode(MODE_TRANSLUCENT, mNavigationBarWindowState, mNavigationBarView.getBarTransitions(), false);
+ }
+ } else {
+ if (mNavigationBarView != null) {
+ mWindowManager.removeView(mNavigationBarView);
+ mNavigationBarView = null;
+ }
+ }
+ }
+ }
+ private void addNarBar() {
+ if (mNavigationBarView == null) {
+ mNavigationBarView = (NavigationBarView) View.inflate(mContext, R.layout.navigation_bar, null);
+ mNavigationBarView.setDisabledFlags(mDisabled1);
+ mNavigationBarView.setBar(this);
+ prepareNavigationBarView();
+ }
+ mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
+ }
+
+ ///mh.modify end 2019.6.2
@@ -1246,7 +1248,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// For small-screen devices (read: phones) that lack hardware navigation buttons
private void addNavigationBar() {
if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView);
- if (mNavigationBarView == null) return;
+ if (mNavigationBarView == null) {
+ Settings.Global.putInt(mContext.getContentResolver(), "switch_navigation_bar", 0);
+ return;
+ }
prepareNavigationBarView();
// ================================================================================
// Constructing the view
@@ -698,6 +735,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
mStatusBarView.setBar(this);
+ ///mh.mmi add navbar 20190602
+ NavBarChangeContentObserver mNavContentObserver = new NavBarChangeContentObserver();
+ mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor("switch_navigation_bar"),true,mNavContentObserver);
PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
mStatusBarView.setPanelHolder(holder);