diff --git a/res/drawable/activities_icon.png b/res/drawable/activities_icon.png new file mode 100644 index 0000000..abd62e2 Binary files /dev/null and b/res/drawable/activities_icon.png differ diff --git a/res/drawable/fab_accent.xml b/res/drawable/fab_accent.xml new file mode 100644 index 0000000..0294cc0 --- /dev/null +++ b/res/drawable/fab_accent.xml @@ -0,0 +1,4 @@ + + + + diff --git a/res/layout/custom_action_item.xml b/res/layout/custom_action_item.xml new file mode 100644 index 0000000..f67cbad --- /dev/null +++ b/res/layout/custom_action_item.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index f6a02b1..13b0807 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -596,4 +596,8 @@ Button backlight touch Button backlight will only appear when buttons are pressed rather than on all the time. Timeout still impacts this feature. + + Hardware navigation buttons + Disable hardware buttons + diff --git a/res/xml/cherish_settings_button.xml b/res/xml/cherish_settings_button.xml index 904c889..b342095 100644 --- a/res/xml/cherish_settings_button.xml +++ b/res/xml/cherish_settings_button.xml @@ -18,6 +18,13 @@ android:title="@string/button_title" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> + + + + + diff --git a/src/com/cherish/settings/fragments/ButtonSettings.java b/src/com/cherish/settings/fragments/ButtonSettings.java index f9bd602..925aa77 100644 --- a/src/com/cherish/settings/fragments/ButtonSettings.java +++ b/src/com/cherish/settings/fragments/ButtonSettings.java @@ -36,8 +36,6 @@ import androidx.preference.SwitchPreference; import android.provider.Settings; import android.widget.Toast; import com.android.settings.R; - -import com.android.settings.SettingsPreferenceFragment; import com.cherish.settings.preferences.SystemSettingSwitchPreference; import com.cherish.settings.preferences.SecureSettingSwitchPreference; import com.android.internal.logging.nano.MetricsProto; @@ -59,10 +57,12 @@ import android.provider.SearchIndexableResource; import java.util.ArrayList; import java.util.List; @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) -public class ButtonSettings extends SettingsPreferenceFragment implements - Preference.OnPreferenceChangeListener { +public class ButtonSettings extends ActionFragment implements OnPreferenceChangeListener { + + private static final String HWKEY_DISABLE = "hardware_keys_disable"; // category keys + private static final String CATEGORY_HWKEY = "hardware_keys"; private static final String CATEGORY_BACK = "back_key"; private static final String CATEGORY_HOME = "home_key"; private static final String CATEGORY_MENU = "menu_key"; @@ -87,6 +87,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private static final String TORCH_POWER_BUTTON_GESTURE = "torch_power_button_gesture"; + private SwitchPreference mHwKeyDisable; private ListPreference mTorchPowerButton; private CustomSeekBarPreference mButtonTimoutBar; private CustomSeekBarPreference mManualButtonBrightness; @@ -100,6 +101,22 @@ public class ButtonSettings extends SettingsPreferenceFragment implements final Resources res = getResources(); final ContentResolver resolver = getActivity().getContentResolver(); final PreferenceScreen prefScreen = getPreferenceScreen(); + + final boolean needsNavbar = ActionUtils.hasNavbarByDefault(getActivity()); + final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen + .findPreference(CATEGORY_HWKEY); + int keysDisabled = 0; + if (!needsNavbar) { + mHwKeyDisable = (SwitchPreference) findPreference(HWKEY_DISABLE); + keysDisabled = Settings.System.getIntForUser(getContentResolver(), + Settings.System.HARDWARE_KEYS_DISABLE, 0, + UserHandle.USER_CURRENT); + mHwKeyDisable.setChecked(keysDisabled != 0); + mHwKeyDisable.setOnPreferenceChangeListener(this); + } else { + prefScreen.removePreference(hwkeyCat); + } + // bits for hardware keys present on device final int deviceKeys = getResources().getInteger( com.android.internal.R.integer.config_deviceHardwareKeys); @@ -143,8 +160,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements } // let super know we can load ActionPreferences onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.HWKEYS)); - - // screen off torch + + // load preferences first + setActionPreferencesEnabled(keysDisabled == 0); + + // screen off torch mTorchPowerButton = (ListPreference) findPreference(TORCH_POWER_BUTTON_GESTURE); int mTorchPowerButtonValue = Settings.System.getInt(resolver, Settings.System.TORCH_POWER_BUTTON_GESTURE, 0); @@ -189,6 +209,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements Settings.System.putInt(resolver, Settings.System.TORCH_POWER_BUTTON_GESTURE, mTorchPowerButtonValue); return true; + } else if (preference == mHwKeyDisable) { + boolean value = (Boolean) newValue; + Settings.System.putInt(getContentResolver(), Settings.System.HARDWARE_KEYS_DISABLE, + value ? 1 : 0); + setActionPreferencesEnabled(!value); } else if (preference == mButtonTimoutBar) { int buttonTimeout = (Integer) newValue; Settings.System.putInt(getContentResolver(), @@ -216,7 +241,26 @@ public class ButtonSettings extends SettingsPreferenceFragment implements /** * For Search. */ - public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider(R.xml.cherish_settings_button); + + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + + @Override + public List getXmlResourcesToIndex(Context context, + boolean enabled) { + ArrayList result = + new ArrayList(); + SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.cherish_settings_button; + result.add(sir); + return result; + } + + @Override + public List getNonIndexableKeys(Context context) { + List keys = super.getNonIndexableKeys(context); + return keys; + } + }; } \ No newline at end of file