PX30 Android8.1 在设置中添加一个按钮关闭或打开底部导航栏

android03@PowerEdge-R730xd:~/pang/px30_android-8.1/packages/apps/Settings$  git diff
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
old mode 100644
new mode 100755
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index d92d08dfd5..d4d27a6d52 100755
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -3721,4 +3721,7 @@
     <string name="new_device_suggestion_summary" product="tablet" msgid="393751455688210956">"新平板电脑功能导览"</string>
     <string name="new_device_suggestion_summary" product="device" msgid="2939870049868336652">"新设备功能导览"</string>
     <string name="disabled_low_ram_device" msgid="3751578499721173344">"该设备不支持此功能"</string>
+       
+               <!--添加隐藏导航栏-->
+        <string name="hide_nav_title">隐藏导航栏</string>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1fb9592025..b09f1f3e1f 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9117,4 +9117,7 @@
     <string name="hdmi_rotation">HDMI Rotation</string>
     <string name="confirm_dialog_title">Save Confirm</string>
     <string name="confirm_dialog_message">Will cancel it</string>
+       
+       <!--添加隐藏导航栏-->
+        <string name="hide_nav_title">Hide-navigation bar</string>
 </resources>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
old mode 100644
new mode 100755
index ea698bc425..9cf9b5e242
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -63,7 +63,12 @@
     <SwitchPreference
         android:key="auto_rotate"
         android:title="@string/accelerometer_title" />
-
+<!-- 在设置界面中设置一个瘾藏导航栏按钮-->
+    <SwitchPreference
+           android:defaultValue="true" 
+        android:key="hied_nav"
+        android:title="@string/hide_nav_title" />
+       
     <Preference
         android:key="color_mode"
         android:title="@string/color_mode_title"
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
old mode 100644
new mode 100755
index c27c439ded..6c0be84228
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -39,6 +39,7 @@ import com.android.settings.display.ThemePreferenceController;
 import com.android.settings.display.TimeoutPreferenceController;
 import com.android.settings.display.VrDisplayPreferenceController;
 import com.android.settings.display.WallpaperPreferenceController;
+import com.android.settings.display.HideNavPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -52,7 +53,8 @@ public class DisplaySettings extends DashboardFragment {
 
:
packages\apps\Settings\src\com\android\settings\display的HideNavPreferenceController.java
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.android.settings.display;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;

import com.android.settings.DisplaySettings;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
import android.util.Log;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;


public class HideNavPreferenceController extends AbstractPreferenceController implements
        PreferenceControllerMixin, Preference.OnPreferenceChangeListener {

    private final String mAutoBrightnessKey;

    public HideNavPreferenceController(Context context, String key) {
        super(context);
        mAutoBrightnessKey = key;
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public String getPreferenceKey() {
        return mAutoBrightnessKey;
    }

    @Override
    public void updateState(Preference preference) {
      
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        boolean auto = (Boolean) newValue;
	 if(newValue.toString()=="true")
	 {
		  boolean isOk = HideNavUtils.hidenav("wm overscan 0,0,0,0");
		  Log.i("Hied_nav","open"+isOk);
	 }
	 else{
		 boolean isOk = HideNavUtils.hidenav("wm overscan 0,0,0,-48");
		 Log.i("Hied_nav","close"+isOk);
	 }
        return true;
    }
}

你可能感兴趣的:(PX30 Android8.1 在设置中添加一个按钮关闭或打开底部导航栏)