赞
踩
一、状态栏的隐藏与显示
SystemUI模块修改文件如下:
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.java
二、导航栏的隐藏与显示
packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
packages/apps/Launcher3/quickstep/src/com/android/quickstep/TouchInteractionService.java
三、Settings模块修改添加开关:
packages/apps/Settings/res/xml/display_settings.xml
packages/apps/Settings/src/com/android/settings/display/status_navi_bar/NaviBarPreferenceController.java
package com.android.settings.display.status_navi_bar; import android.content.Context; import android.content.Intent; import android.os.SystemProperties; import android.preference.Preference; import android.util.Log; import com.android.settings.core.BasePreferenceController; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.TogglePreferenceController; import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnPause; import com.android.settingslib.core.lifecycle.events.OnResume; public class NaviBarPreferenceController extends TogglePreferenceController implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause { private static final String TAG = "NaviBarPreferenceController"; private static final String SYS_PROPERTY_NAVIGATION_BAR = "persist.sys.navigationbar.enable"; private static final String ACTION_HIDE_NAVIGATION_BAR = "com.systemui.navigationbar.hide"; private static final String ACTION_SHOW_NAVIGATION_BAR = "com.systemui.navigationbar.show"; private Context mContext; public NaviBarPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); mContext = context; } @Override public int getAvailabilityStatus() { return BasePreferenceController.AVAILABLE; } @Override public boolean isChecked() { return !SystemProperties.getBoolean(SYS_PROPERTY_NAVIGATION_BAR, false); } @Override public boolean setChecked(boolean isChecked) { Log.d(TAG, "setChecked: " + isChecked); Intent intent = isChecked ? new Intent(ACTION_HIDE_NAVIGATION_BAR) : new Intent(ACTION_SHOW_NAVIGATION_BAR); mContext.sendBroadcast(intent); return true; } @Override public int getSliceHighlightMenuRes() { return NO_RES; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Log.d(TAG, "onPreferenceChange: "+newValue); return true; } @Override public void onPause() { Log.d(TAG, "onPause: "); } @Override public void onResume() { Log.d(TAG, "onResume: "); } }
packages/apps/Settings/src/com/android/settings/display/status_navi_bar/StatusBarPreferenceController.java
package com.android.settings.display.status_navi_bar; import android.content.Context; import android.content.Intent; import android.os.SystemProperties; import android.preference.Preference; import android.util.Log; import com.android.settings.core.BasePreferenceController; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.TogglePreferenceController; import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnPause; import com.android.settingslib.core.lifecycle.events.OnResume; public class StatusBarPreferenceController extends TogglePreferenceController implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause { private static final String TAG = "StatusBarPreferenceController"; private static final String SYS_PROPERTY_STATUS_BAR = "persist.sys.statusbar.enable"; private static final String ACTION_HIDE_STATUS_BAR = "com.systemui.statusbar.hide"; private static final String ACTION_SHOW_STATUS_BAR = "com.systemui.statusbar.show"; private Context mContext; public StatusBarPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); mContext = context; } @Override public int getAvailabilityStatus() { return BasePreferenceController.AVAILABLE; } @Override public boolean isChecked() { return !SystemProperties.getBoolean(SYS_PROPERTY_STATUS_BAR, false); } @Override public boolean setChecked(boolean isChecked) { Log.d(TAG, "setChecked: " + isChecked); Intent intent = isChecked ? new Intent(ACTION_HIDE_STATUS_BAR) : new Intent(ACTION_SHOW_STATUS_BAR); mContext.sendBroadcast(intent); return true; } @Override public int getSliceHighlightMenuRes() { return NO_RES; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Log.d(TAG, "onPreferenceChange: "+newValue); return true; } @Override public void onPause() { Log.d(TAG, "onPause: "); } @Override public void onResume() { Log.d(TAG, "onResume: "); } }
至此,完成了状态栏和导航栏的隐藏与显示
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。