Navbar: Add navbar layout custom

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>

Navbar: Add navbar layout preference

Change-Id: Id092c83daa490f29e04bc5b88e52508b1dc53f9c
Signed-off-by: SagarMakhar <sagarmakhar@gmail.com>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>

Navbar: Add navbar arrow keys switch

Change-Id: I9e15f7737559b169e3f58d70999779a1e7109577
Signed-off-by: SagarMakhar <sagarmakhar@gmail.com>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Alex
2022-03-27 11:37:53 +07:00
committed by Hưng Phan
parent 4d53fbb8d2
commit 9b1b715f48
4 changed files with 213 additions and 52 deletions

View File

@@ -591,10 +591,6 @@
<string name="button_timeout_title">Backlight timeout</string>
<string name="button_backlight_on_touch_only_title">Button backlight touch</string>
<string name="button_backlight_on_touch_only_summary">Button backlight will only appear when buttons are pressed rather than on all the time. Timeout still impacts this feature.</string>
<!-- Hardware keys -->
<string name="hardware_keys_category">Hardware navigation buttons</string>
<string name="hardware_keys_disable_title">Disable hardware buttons</string>
<!-- Screen off animation -->
<string name="screen_off_animation_title">Screen off animation</string>
@@ -722,4 +718,35 @@
<string name="system_black_theme_title">Use black theme</string>
<string name="system_black_theme_summary">Force black background colors</string>
<!-- Volume rocker gestures -->
<string name="volume_skiptrack_screen_title">Skip music tracks</string>
<!-- Navigation bar -->
<string name="navigation_title">Navigatie</string>
<string name="navigation_bar_category">Navigation bar</string>
<string name="navigation_bar_title">On-screen navigation bar</string>
<string name="navigation_bar_summary">Enable on-screen navigation keys</string>
<string name="navigation_bar_layout_title">Layout</string>
<string name="navigation_bar_layout_summary">Customize the layout of the navigation bar</string>
<string name="navigation_bar_arrow_keys_title">Show arrow keys while typing</string>
<string name="navigation_bar_arrow_keys_summary">Display left and right cursor buttons in navigation bar while typing</string>
<string name="navigation_bar_help_text">These settings mainly relate to the 3-button navigation bar. If you use gesture navigation and want to customize it, e.g. hide the gesture handle, please visit: Settings > System > Gestures.</string>
<string name="nav_bar_tuner_title">Navigation bar tuner</string>
<string name="nav_bar_tuner_summary">Change nav bar layout</string>
<string name="navbar_layout_title">Layout</string>
<string name="navbar_layout_normal">Normal</string>
<string name="navbar_layout_compact">Compact</string>
<string name="navbar_layout_leftleaning">Left-leaning</string>
<string name="navbar_layout_rightleaning">Right-leaning</string>
<string name="system_navigation_summary">Choose which system navigation style to use</string>
<!-- HW keys -->
<string name="hardware_keys_title">Buttons</string>
<string name="hardware_keys_category">Hardware navigation buttons</string>
<string name="hardware_keys_disable_title">Disable hardware buttons</string>
<string name="hardware_keys_disable_summary">Use the device hardware keys for navigation</string>
<!-- NavBar Inverse -->
<string name="navigation_bar_inverse_title">Invert 3 button navigation bar</string>
</resources>

View File

@@ -18,18 +18,53 @@
android:title="@string/button_title"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<PreferenceCategory android:key="hardware_keys"
android:title="@string/hardware_keys_category">
<SwitchPreference
android:key="navbar_visibility"
android:title="@string/navigation_bar_title"
android:summary="@string/navigation_bar_summary" />
<PreferenceCategory
android:key="navigation_keys"
android:title="@string/navigation_title"
android:dependency="navbar_visibility">
<Preference
android:key="gesture_system_navigation_input_summary"
android:title="@string/system_navigation_title"
android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController"
settings:keywords="@string/keywords_system_navigation" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="navigation_bar_menu_arrow_keys"
android:title="@string/navigation_bar_arrow_keys_title"
android:summary="@string/navigation_bar_arrow_keys_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="navigation_bar_inverse"
android:title="@string/navigation_bar_inverse_title"
android:defaultValue="0"
settings:controller="com.cherish.settings.fragments.NavBarInversePreferenceController" />
<com.android.settingslib.widget.FooterPreference
android:key="navigation_bar_footer_preference"
android:selectable="false"
android:title="@string/navigation_bar_help_text" />
<SwitchPreference android:key="hardware_keys_disable"
android:title="@string/hardware_keys_disable_title" />
</PreferenceCategory>
<PreferenceCategory
<PreferenceCategory
android:key="volume_category"
android:title="@string/volume_category">
<com.cherish.settings.preferences.SystemSettingSwitchPreference
<Preference
android:key="vol_steps"
android:title="@string/volume_steps_fragment_title"
android:summary="@string/volume_steps_summary"
android:fragment="com.cherish.settings.fragments.VolumeStepsFragment" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="swap_volume_buttons"
android:title="@string/swap_volume_buttons_title"
android:summary="@string/swap_volume_buttons_summary"
@@ -40,22 +75,27 @@
android:summary="@string/volume_rocker_wake_summary"
android:title="@string/volume_rocker_wake_title"
android:defaultValue="false" />
<Preference
android:key="vol_steps"
android:title="@string/volume_steps_fragment_title"
android:summary="@string/volume_steps_summary"
android:fragment="com.cherish.settings.fragments.VolumeStepsFragment" />
</PreferenceCategory>
<PreferenceCategory
<PreferenceCategory
android:key="hardware_keys"
android:title="@string/hardware_keys_category">
<SwitchPreference
android:key="hardware_keys_disable"
android:title="@string/hardware_keys_disable_title" />
</PreferenceCategory>
<PreferenceCategory
android:key="button_backlight_options_category"
android:title="@string/button_backlight_options_category" >
android:title="@string/button_backlight_options_category">
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="button_backlight_enable"
android:title="@string/button_backlight_enable_title"
android:defaultValue="true"/>
android:defaultValue="true" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="custom_button_use_screen_brightness"
@@ -89,123 +129,123 @@
android:dependency="button_backlight_enable" />
</PreferenceCategory>
<PreferenceCategory
<PreferenceCategory
android:key="back_key"
android:title="@string/hardware_keys_back_key_title" >
<com.cherish.settings.preferences.ActionPreference
android:title="@string/hardware_keys_back_key_title">
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_back_single_tap"
android:summary="@string/hardware_keys_single_tap_summary"
android:title="@string/hardware_keys_single_tap_title" >
android:title="@string/hardware_keys_single_tap_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_back_long_press"
android:summary="@string/hardware_keys_long_press_summary"
android:title="@string/hardware_keys_long_press_title" >
android:title="@string/hardware_keys_long_press_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_back_double_tap"
android:summary="@string/hardware_keys_double_tap_summary"
android:title="@string/hardware_keys_double_tap_title" >
android:title="@string/hardware_keys_double_tap_title">
</com.cherish.settings.preferences.ActionPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="home_key"
android:title="@string/hardware_keys_home_key_title" >
<com.cherish.settings.preferences.ActionPreference
android:title="@string/hardware_keys_home_key_title">
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_home_single_tap"
android:summary="@string/hardware_keys_single_tap_summary"
android:title="@string/hardware_keys_single_tap_title" >
android:title="@string/hardware_keys_single_tap_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_home_long_press"
android:summary="@string/hardware_keys_long_press_summary"
android:title="@string/hardware_keys_long_press_title" >
android:title="@string/hardware_keys_long_press_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_home_double_tap"
android:summary="@string/hardware_keys_double_tap_summary"
android:title="@string/hardware_keys_double_tap_title" >
android:title="@string/hardware_keys_double_tap_title">
</com.cherish.settings.preferences.ActionPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="app_switch_key"
android:title="@string/hardware_keys_appswitch_key_title" >
android:title="@string/hardware_keys_appswitch_key_title">
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_overview_single_tap"
android:summary="@string/hardware_keys_single_tap_summary"
android:title="@string/hardware_keys_single_tap_title" >
android:title="@string/hardware_keys_single_tap_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_overview_long_press"
android:summary="@string/hardware_keys_long_press_summary"
android:title="@string/hardware_keys_long_press_title" >
android:title="@string/hardware_keys_long_press_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_overview_double_tap"
android:summary="@string/hardware_keys_double_tap_summary"
android:title="@string/hardware_keys_double_tap_title" >
android:title="@string/hardware_keys_double_tap_title">
</com.cherish.settings.preferences.ActionPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="menu_key"
android:title="@string/hardware_keys_menu_key_title" >
android:title="@string/hardware_keys_menu_key_title">
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_menu_single_tap"
android:summary="@string/hardware_keys_single_tap_summary"
android:title="@string/hardware_keys_single_tap_title" >
android:title="@string/hardware_keys_single_tap_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_menu_long_press"
android:summary="@string/hardware_keys_long_press_summary"
android:title="@string/hardware_keys_long_press_title" >
android:title="@string/hardware_keys_long_press_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_menu_double_tap"
android:summary="@string/hardware_keys_double_tap_summary"
android:title="@string/hardware_keys_double_tap_title" >
android:title="@string/hardware_keys_double_tap_title">
</com.cherish.settings.preferences.ActionPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="assist_key"
android:title="@string/hardware_keys_assist_key_title" >
android:title="@string/hardware_keys_assist_key_title">
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_assist_single_tap"
android:summary="@string/hardware_keys_single_tap_summary"
android:title="@string/hardware_keys_single_tap_title" >
android:title="@string/hardware_keys_single_tap_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_assist_long_press"
android:summary="@string/hardware_keys_long_press_summary"
android:title="@string/hardware_keys_long_press_title" >
android:title="@string/hardware_keys_long_press_title">
</com.cherish.settings.preferences.ActionPreference>
<com.cherish.settings.preferences.ActionPreference
android:key="hwkeys_button_assist_double_tap"
android:summary="@string/hardware_keys_double_tap_summary"
android:title="@string/hardware_keys_double_tap_title" >
android:title="@string/hardware_keys_double_tap_title">
</com.cherish.settings.preferences.ActionPreference>
</PreferenceCategory>

View File

@@ -38,7 +38,9 @@ import android.widget.Toast;
import com.android.settings.R;
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
import com.cherish.settings.preferences.SecureSettingSwitchPreference;
import com.android.internal.cherish.hardware.LineageHardwareManager;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.util.cherish.CherishUtils;
import com.android.settings.SettingsPreferenceFragment;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.Utils;
@@ -56,10 +58,18 @@ import android.provider.SearchIndexableResource;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class ButtonSettings extends ActionFragment implements OnPreferenceChangeListener {
private static final String HWKEY_DISABLE = "hardware_keys_disable";
private static final String NAVBAR_VISIBILITY = "navbar_visibility";
private static final String KEY_LAYOUT_SETTINGS = "layout_settings";
private static final String KEY_NAVIGATION_BAR_ARROWS = "navigation_bar_menu_arrow_keys";
// category keys
private static final String CATEGORY_HWKEY = "hardware_keys";
@@ -92,6 +102,13 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
private CustomSeekBarPreference mButtonTimoutBar;
private CustomSeekBarPreference mManualButtonBrightness;
private PreferenceCategory mButtonBackLightCategory;
private SwitchPreference mNavbarVisibility;
private Preference mLayoutSettings;
private SystemSettingSwitchPreference mNavigationArrows;
private boolean mIsNavSwitchingMode = false;
private Handler mHandler;
@Override
public void onCreate(Bundle icicle) {
@@ -182,6 +199,16 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
mManualButtonBrightness.setMax(pm.getMaximumScreenBrightnessSetting());
mManualButtonBrightness.setValue(currentBrightness);
mManualButtonBrightness.setOnPreferenceChangeListener(this);
mNavbarVisibility = (SwitchPreference) findPreference(NAVBAR_VISIBILITY);
boolean showing = Settings.System.getIntForUser(resolver,
Settings.System.FORCE_SHOW_NAVBAR,
CherishUtils.hasNavbarByDefault(getActivity()) ? 1 : 0, UserHandle.USER_CURRENT) != 0;
mNavbarVisibility.setChecked(showing);
mNavbarVisibility.setOnPreferenceChangeListener(this);
mHandler = new Handler();
mButtonTimoutBar = (CustomSeekBarPreference) findPreference(KEY_BUTTON_TIMEOUT);
int currentTimeout = Settings.System.getInt(resolver,
@@ -197,6 +224,10 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
if (!enableBacklightOptions) {
prefScreen.removePreference(mButtonBackLightCategory);
}
mLayoutSettings = (Preference) findPreference(KEY_LAYOUT_SETTINGS);
mNavigationArrows = (SystemSettingSwitchPreference) findPreference(KEY_NAVIGATION_BAR_ARROWS);
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -213,19 +244,35 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
boolean value = (Boolean) newValue;
Settings.System.putInt(getContentResolver(), Settings.System.HARDWARE_KEYS_DISABLE,
value ? 1 : 0);
setActionPreferencesEnabled(!value);
return true;
} else if (preference == mButtonTimoutBar) {
int buttonTimeout = (Integer) newValue;
Settings.System.putInt(getContentResolver(),
Settings.System.BUTTON_BACKLIGHT_TIMEOUT, buttonTimeout);
return true;
} else if (preference == mManualButtonBrightness) {
int buttonBrightness = (Integer) newValue;
Settings.System.putInt(getContentResolver(),
Settings.System.CUSTOM_BUTTON_BRIGHTNESS, buttonBrightness);
} else {
return false;
return true;
} else if (preference == mNavbarVisibility) {
if (mIsNavSwitchingMode) {
return false;
}
mIsNavSwitchingMode = true;
boolean showing = ((Boolean)newValue);
Settings.System.putIntForUser(resolver, Settings.System.FORCE_SHOW_NAVBAR,
showing ? 1 : 0, UserHandle.USER_CURRENT);
mNavbarVisibility.setChecked(showing);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mIsNavSwitchingMode = false;
}
}, 1500);
return true;
}
return true;
return false;
}
@Override
@@ -233,6 +280,11 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
}
private static boolean isKeyDisablerSupported(Context context) {
final LineageHardwareManager hardware = LineageHardwareManager.getInstance(context);
return hardware.isSupported(LineageHardwareManager.FEATURE_KEY_DISABLE);
}
@Override
protected boolean usesExtendedActionsList() {
return true;

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 AOSP-Krypton 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.cherish.settings.fragments
import android.content.Context
import android.os.UserHandle
import android.provider.Settings
import com.cherish.settings.CherishBasePreferenceController
class NavBarInversePreferenceController(
context: Context,
key: String,
): CherishBasePreferenceController(context, key) {
override fun getAvailabilityStatus(): Int {
val threeButtonMode = Settings.Secure.getIntForUser(
mContext.contentResolver,
Settings.Secure.NAVIGATION_MODE,
0,
UserHandle.USER_CURRENT,
) == 0
return if (threeButtonMode)
AVAILABLE
else
DISABLED_DEPENDENT_SETTING
}
}