summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-11-15 15:25:51 -0500
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:28 -0700
commitbcd2b57276599e21009f4a180575001650915176 (patch)
tree0878e445339270190ce1ff98be119aba71d231a2
parent5719bbe75399c6efeb1b8c3407afea455e0baa9c (diff)
downloadpackages_apps_Settings-bcd2b57276599e21009f4a180575001650915176.zip
packages_apps_Settings-bcd2b57276599e21009f4a180575001650915176.tar.gz
packages_apps_Settings-bcd2b57276599e21009f4a180575001650915176.tar.bz2
Settings: add "advanced" menu to Display/TapToWake
Forward TapToWake from CM11 Contains Commits: Author: Ricardo Cerqueira<cyanogenmod@cerqueira.org> DisplaySettings: Add hardware-framework support for tap-to-wake Since we have tap-to-sleep globally, might as well support the wake gesture as a standalone thing through the HAF. Place it in "Display". Change-Id: I6facc2334ff9e80077581c54c428476594e91528 Author: Roman Birg <roman@cyngn.com> Settings: set proper default value for tap to wake The first time the display_settings.xml file gets inflated, the PreferenceManager takes the defaultValue and persists it in the default shared preferences file. When we read the double tap to wake preference, we assume it has a default value of true, which it uses until the user enters Display Settings for the first time. At that point, the default value is persisted, and every boot after will use the default value in display_settings.xml. Remove the default defined in the XML file. Change-Id: I0989dd73b6b3c42ff8649bc17eebf4e191293ee4 Change-Id: I271390aa7bfc56811dcf6fff7e1d05c76c4bfa48
-rw-r--r--Android.mk2
-rw-r--r--AndroidManifest.xml8
-rw-r--r--res/values/cm_strings.xml7
-rw-r--r--res/xml/display_settings.xml7
-rw-r--r--src/com/android/settings/DisplaySettings.java49
-rw-r--r--src/com/android/settings/cyanogenmod/BootReceiver.java2
6 files changed, 75 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index ccfe64d..8c25641 100644
--- a/Android.mk
+++ b/Android.mk
@@ -31,6 +31,8 @@ include frameworks/opt/setupwizard/navigationbar/common.mk
include frameworks/opt/setupwizard/library/common.mk
include frameworks/base/packages/SettingsLib/common.mk
+LOCAL_JAVA_LIBRARIES += org.cyanogenmod.hardware
+
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8c09426..17eb93d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -95,6 +95,8 @@
android:usesCleartextTraffic="false">
<!-- Settings -->
+ <uses-library android:name="org.cyanogenmod.hardware"
+ android:required="false" />
<activity android:name="Settings"
android:taskAffinity="com.android.settings"
@@ -2509,6 +2511,12 @@
</intent-filter>
</receiver>
+ <receiver android:name=".cyanogenmod.BootReceiver" android:enabled="true">$
+ <intent-filter android:priority="2147483647">$
+ <action android:name="android.intent.action.BOOT_COMPLETED" />$
+ </intent-filter>$
+ </receiver>
+
<!-- Watch for ContactsContract.Profile changes and update the user's photo. -->
<receiver android:name=".users.ProfileUpdateReceiver">
<intent-filter>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 9894eca..8ec4213 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -398,4 +398,11 @@
<string name="navigation_ring_title">Navigation ring targets</string>
<string name="navigation_ring_message">Tap the edit icon to open the navigation ring for editing.\n\nSelect a target to configure its behavior.\n\nTap the check mark icon to save your changes, or restore to reset the settings to defaults.</string>
+
+ <!--- Advanced Settings -->
+ <string name="advanced_settings">Advanced settings</string>
+ <string name="advanced_settings_summary">Enable more settings options</string>
+
+ <!--- Tap To Wake -->
+ <string name="double_tap_to_wake_title">Double-tap to wake</string>
</resources>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index e04d818..66aaac6 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -97,5 +97,12 @@
android:title="@string/wifi_display_settings_title"
settings:keywords="@string/keywords_display_cast_screen"
android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
+ <PreferenceScreen
+ android:key="advanced_display_prefs"
+ android:title="@string/advanced_settings">
+ <SwitchPreference
+ android:key="double_tap_wake_gesture"
+ android:title="@string/double_tap_to_wake_title" />
+ </PreferenceScreen>
</PreferenceScreen>
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 0e2c77c..1cbb3af 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -39,6 +39,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
@@ -48,6 +49,7 @@ import android.os.SystemProperties;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.provider.SearchIndexableResource;
@@ -59,6 +61,7 @@ import java.util.ArrayList;
import java.util.List;
import com.android.settings.Utils;
+import org.cyanogenmod.hardware.TapToWake;
public class DisplaySettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, OnPreferenceClickListener, Indexable {
@@ -76,6 +79,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
private static final String KEY_AUTO_ROTATE = "auto_rotate";
private static final String KEY_NIGHT_MODE = "night_mode";
+ private static final String KEY_TAP_TO_WAKE = "double_tap_wake_gesture";
+
+ private static final String CATEGORY_ADVANCED = "advanced_display_prefs";
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
@@ -90,6 +96,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private SwitchPreference mDozePreference;
private SwitchPreference mTapToWakePreference;
private SwitchPreference mAutoBrightnessPreference;
+ private SwitchPreference mTapToWake;
@Override
protected int getMetricsCategory() {
@@ -197,6 +204,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
mNightModePreference.setValue(String.valueOf(currentNightMode));
mNightModePreference.setOnPreferenceChangeListener(this);
}
+ PreferenceScreen advancedPrefs = (PreferenceScreen) findPreference(CATEGORY_ADVANCED);
+
+ mTapToWake = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
+ if (!isTapToWakeSupported()) {
+ advancedPrefs.removePreference(mTapToWake);
+ mTapToWake = null;
+ }
}
private static boolean allowAllRotations(Context context) {
@@ -318,6 +332,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
@Override
public void onResume() {
super.onResume();
+
+ if (mTapToWake != null) {
+ mTapToWake.setChecked(TapToWake.isEnabled());
+ }
+
updateState();
}
@@ -372,6 +391,15 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
}
+ private static boolean isTapToWakeSupported() {
+ try {
+ return TapToWake.isSupported();
+ } catch (NoClassDefFoundError e) {
+ // Hardware abstraction framework not installed
+ return false;
+ }
+ }
+
public void writeFontSizePreference(Object objValue) {
try {
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
@@ -383,6 +411,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ if (preference == mTapToWake) {
+ return TapToWake.setEnabled(mTapToWake.isChecked());
+ }
+
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@@ -449,6 +481,23 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
return R.string.help_uri_display;
}
+ /**
+ * Restore the properties associated with this preference on boot
+ @param ctx A valid context
+ */
+ public static void restore(Context ctx) {
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
+ if (isTapToWakeSupported()) {
+ final boolean enabled = prefs.getBoolean(KEY_TAP_TO_WAKE,
+ TapToWake.isEnabled());
+ if (!TapToWake.setEnabled(enabled)) {
+ Log.e(TAG, "Failed to restore tap-to-wake settings.");
+ } else {
+ Log.d(TAG, "Tap-to-wake settings restored.");
+ }
+ }
+ }
+
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/cyanogenmod/BootReceiver.java b/src/com/android/settings/cyanogenmod/BootReceiver.java
index c809b7f..18213d7 100644
--- a/src/com/android/settings/cyanogenmod/BootReceiver.java
+++ b/src/com/android/settings/cyanogenmod/BootReceiver.java
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.android.settings.ButtonSettings;
+import com.android.settings.DisplaySettings;
public class BootReceiver extends BroadcastReceiver {
@@ -28,6 +29,7 @@ public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context ctx, Intent intent) {
/* Restore the hardware tunable values */
+ DisplaySettings.restore(ctx);
ButtonSettings.restoreKeyDisabler(ctx);
}
}