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:
@@ -592,10 +592,6 @@
|
||||
<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>
|
||||
<string name="screen_off_animation_crt">CRT</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>
|
||||
|
||||
@@ -18,17 +18,52 @@
|
||||
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
|
||||
android:key="volume_category"
|
||||
android:title="@string/volume_category">
|
||||
|
||||
<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"
|
||||
@@ -41,11 +76,16 @@
|
||||
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
|
||||
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
|
||||
|
||||
@@ -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) {
|
||||
@@ -183,6 +200,16 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
|
||||
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,
|
||||
Settings.System.BUTTON_BACKLIGHT_TIMEOUT, 0);
|
||||
@@ -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,26 +244,47 @@ 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 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 false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user