LineageParts: Initial bring up of buttons settings
* Make use of the new information architecture for the Settings app
and place the status bar settings into System category.
* Set intent priority to a value between those that Google uses for
"Languages & input" and the one we use for "System profiles" entry
in order to place our preference in between those two.
* Use empty summary so that the title is centered vertically,
matching "Developer options" and "Reset" entries.
* Use new helpers in SDK and update for moved hardware key configs.
* Minor things left disabled for now:
- Button brightness settings (left out for a sepparate change)
- OneHand feature (still missing rework in the frameworks)
- Power menu actions (requires a huge revamp)
Change-Id: I6f3caea2cecf57e1d1df537d56186acf0c16f12b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f6bc086..8fd484f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -129,31 +129,24 @@
</activity-alias>
-->
- <!-- Button settings (dashboard) -->
- <!--
+ <!-- Button settings (System category) -->
<activity-alias
android:name=".input.ButtonSettings"
android:label="@string/button_pref_title"
+ android:icon="@drawable/ic_settings_buttons"
android:targetActivity="PartsActivity">
- <intent-filter android:priority="1">
- <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
+ <intent-filter android:priority="256">
+ <action android:name="org.lineageos.lineageparts.action.SETTINGS" />
<action android:name="org.lineageos.lineageparts.BUTTON_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="com.android.settings.category"
- android:value="com.android.settings.category.device" />
+ android:value="com.android.settings.category.ia.system" />
<meta-data
- android:name="com.android.settings.icon"
- android:resource="@drawable/ic_settings_buttons" />
- <meta-data
- android:name="org.lineageos.settings.summary.receiver"
- android:value="org.lineageos.lineageparts.PartsUpdater" />
- <meta-data
- android:name="org.lineageos.settings.summary.key"
- android:value="button_settings" />
+ android:name="com.android.settings.summary"
+ android:value="@string/summary_empty" />
</activity-alias>
- -->
<!--
<activity android:name=".gestures.KeyHandler" />
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index b790078..d880d12 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -62,8 +62,10 @@
<item>@string/hardware_keys_action_sleep</item>
<item>@string/hardware_keys_action_last_app</item>
<item>@string/hardware_keys_action_split_screen</item>
+ <!--
<item>@string/hardware_keys_action_single_handed_left</item>
<item>@string/hardware_keys_action_single_handed_right</item>
+ -->
</string-array>
<string-array name="hardware_keys_action_values" translatable="false">
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index 37661bb..ee94d37 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -71,10 +71,12 @@
android:key="power_key"
android:title="@string/hardware_keys_power_key_title" >
+ <!--
<PreferenceScreen
android:key="power_menu"
android:title="@string/power_menu_title"
android:fragment="org.lineageos.lineageparts.input.PowerMenuActions" />
+ -->
<SwitchPreference
android:key="power_end_call"
diff --git a/src/org/lineageos/lineageparts/input/ButtonSettings.java b/src/org/lineageos/lineageparts/input/ButtonSettings.java
index 3256733..155b683 100644
--- a/src/org/lineageos/lineageparts/input/ButtonSettings.java
+++ b/src/org/lineageos/lineageparts/input/ButtonSettings.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod project
+ * Copyright (C) 2017 The LineageOS project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,12 +48,13 @@
import org.lineageos.internal.util.QSUtils;
import org.lineageos.internal.util.ScreenType;
+import static org.lineageos.internal.util.DeviceKeysConstants.*;
+
import java.util.List;
import lineageos.hardware.LineageHardwareManager;
import lineageos.providers.LineageSettings;
-/*
public class ButtonSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "SystemSettings";
@@ -91,45 +93,6 @@
private static final String CATEGORY_BACKLIGHT = "key_backlight";
private static final String CATEGORY_NAVBAR = "navigation_bar_category";
- // Available custom actions to perform on a key press.
- // Must match values for KEY_HOME_LONG_PRESS_ACTION in:
- // frameworks/base/core/java/android/provider/Settings.java
- private enum Action {
- NOTHING,
- MENU,
- APP_SWITCH,
- SEARCH,
- VOICE_SEARCH,
- IN_APP_SEARCH,
- LAUNCH_CAMERA,
- SLEEP,
- LAST_APP,
- SPLIT_SCREEN,
- SINGLE_HAND_LEFT,
- SINGLE_HAND_RIGHT;
-
- public static Action fromIntSafe(int id) {
- if (id < NOTHING.ordinal() || id > Action.values().length) {
- return NOTHING;
- }
- return Action.values()[id];
- }
-
- public static Action fromSettings(ContentResolver cr, String setting, Action def) {
- return fromIntSafe(LineageSettings.System.getInt(cr, setting, def.ordinal()));
- }
- }
-
- // Masks for checking presence of hardware keys.
- // Must match values in frameworks/base/core/res/res/values/config.xml
- public static final int KEY_MASK_HOME = 0x01;
- public static final int KEY_MASK_BACK = 0x02;
- public static final int KEY_MASK_MENU = 0x04;
- public static final int KEY_MASK_ASSIST = 0x08;
- public static final int KEY_MASK_APP_SWITCH = 0x10;
- public static final int KEY_MASK_CAMERA = 0x20;
- public static final int KEY_MASK_VOLUME = 0x40;
-
private ListPreference mHomeLongPressAction;
private ListPreference mHomeDoubleTapAction;
private ListPreference mMenuPressAction;
@@ -167,10 +130,10 @@
final ContentResolver resolver = getActivity().getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
- final int deviceKeys = getResources().getInteger(
- com.android.internal.R.integer.config_deviceHardwareKeys);
- final int deviceWakeKeys = getResources().getInteger(
- com.android.internal.R.integer.config_deviceHardwareWakeKeys);
+ final int deviceKeys = res.getInteger(
+ org.lineageos.platform.internal.R.integer.config_deviceHardwareKeys);
+ final int deviceWakeKeys = res.getInteger(
+ org.lineageos.platform.internal.R.integer.config_deviceHardwareWakeKeys);
final boolean hasPowerKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER);
final boolean hasHomeKey = (deviceKeys & KEY_MASK_HOME) != 0;
@@ -229,9 +192,9 @@
mNavigationPreferencesCat = (PreferenceCategory) findPreference(CATEGORY_NAVBAR);
Action defaultHomeLongPressAction = Action.fromIntSafe(res.getInteger(
- com.android.internal.R.integer.config_longPressOnHomeBehavior));
+ org.lineageos.platform.internal.R.integer.config_longPressOnHomeBehavior));
Action defaultHomeDoubleTapAction = Action.fromIntSafe(res.getInteger(
- com.android.internal.R.integer.config_doubleTapOnHomeBehavior));
+ org.lineageos.platform.internal.R.integer.config_doubleTapOnHomeBehavior));
Action homeLongPressAction = Action.fromSettings(resolver,
LineageSettings.System.KEY_HOME_LONG_PRESS_ACTION,
defaultHomeLongPressAction);
@@ -384,7 +347,7 @@
prefScreen.removePreference(mCameraWakeScreen);
}
// Only show 'Camera sleep on release' if the device has a focus key
- if (res.getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) {
+ if (res.getBoolean(org.lineageos.platform.internal.R.bool.config_singleStageCameraKey)) {
prefScreen.removePreference(mCameraSleepOnRelease);
}
} else {
@@ -434,18 +397,21 @@
Log.e(TAG, "Error getting navigation bar status");
}
+ /*
final ButtonBacklightBrightness backlight =
(ButtonBacklightBrightness) findPreference(KEY_BUTTON_BACKLIGHT);
if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported()) {
prefScreen.removePreference(backlight);
}
+ */
if (mCameraWakeScreen != null) {
if (mCameraSleepOnRelease != null && !getResources().getBoolean(
- com.android.internal.R.bool.config_singleStageCameraKey)) {
+ org.lineageos.platform.internal.R.bool.config_singleStageCameraKey)) {
mCameraSleepOnRelease.setDependency(LineageSettings.System.CAMERA_WAKE_SCREEN);
}
}
+
mVolumeWakeScreen = (SwitchPreference) findPreference(LineageSettings.System.VOLUME_WAKE_SCREEN);
mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
@@ -573,7 +539,6 @@
final PreferenceScreen prefScreen = getPreferenceScreen();
/* Disable hw-key options if they're disabled */
- /*
final PreferenceCategory homeCategory =
(PreferenceCategory) prefScreen.findPreference(CATEGORY_HOME);
final PreferenceCategory backCategory =
@@ -584,8 +549,10 @@
(PreferenceCategory) prefScreen.findPreference(CATEGORY_ASSIST);
final PreferenceCategory appSwitchCategory =
(PreferenceCategory) prefScreen.findPreference(CATEGORY_APPSWITCH);
+ /*
final ButtonBacklightBrightness backlight =
(ButtonBacklightBrightness) prefScreen.findPreference(KEY_BUTTON_BACKLIGHT);
+ */
/* Toggle backlight control depending on navbar state, force it to
off if enabling */
@@ -594,9 +561,9 @@
backlight.setEnabled(!navbarEnabled);
backlight.updateSummary();
}
+ */
/* Toggle hardkey control availability depending on navbar state */
- /*
if (homeCategory != null) {
homeCategory.setEnabled(!navbarEnabled);
}
@@ -682,4 +649,3 @@
: LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR_DO_NOTHING));
}
}
-*/
diff --git a/src/org/lineageos/lineageparts/utils/DeviceUtils.java b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
index 312f909..4bd3434 100644
--- a/src/org/lineageos/lineageparts/utils/DeviceUtils.java
+++ b/src/org/lineageos/lineageparts/utils/DeviceUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod project
+ * Copyright (C) 2017 The LineageOS project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,20 +32,16 @@
import android.text.TextUtils;
import android.view.Surface;
-/*
-import org.lineageos.lineageparts.input.ButtonSettings;
-*/
+import static org.lineageos.internal.util.DeviceKeysConstants.*;
public class DeviceUtils {
/* returns whether the device has volume rocker or not. */
- /*
public static boolean hasVolumeRocker(Context context) {
final int deviceKeys = context.getResources().getInteger(
- com.android.internal.R.integer.config_deviceHardwareKeys);
- return (deviceKeys & ButtonSettings.KEY_MASK_VOLUME) != 0;
+ org.lineageos.platform.internal.R.integer.config_deviceHardwareKeys);
+ return (deviceKeys & KEY_MASK_VOLUME) != 0;
}
- */
public static boolean isPackageInstalled(Context context, String pkg, boolean ignoreState) {
if (pkg != null) {