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:
@@ -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;
|
||||
|
||||
@@ -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