diff options
| author | jrior001 <jriordan001@gmail.com> | 2016-12-10 00:16:14 -0500 |
|---|---|---|
| committer | Jason Riordan <jriordan001@gmail.com> | 2017-02-01 22:00:40 -0500 |
| commit | a05d91d231bcd99630ce56f8b7e13148f82d780b (patch) | |
| tree | f8680f64ed1976e3a0d57ffb9ac1fe939b024e0d | |
| parent | c8da10e03bf1c6b184e1b01a8afada13e392f2ad (diff) | |
mofd: remove cmactions, moving to common interface
Change-Id: I5d474b7f1b7886a9ec2cc6081ac17b3ab88c571a
20 files changed, 0 insertions, 1441 deletions
diff --git a/cmactions/Android.mk b/cmactions/Android.mk deleted file mode 100644 index 90e05b0..0000000 --- a/cmactions/Android.mk +++ /dev/null @@ -1,41 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := CMActions -LOCAL_CERTIFICATE := platform -LOCAL_PRIVILEGED_MODULE := true - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-v14-preference \ - android-support-v7-appcompat \ - android-support-v7-preference \ - android-support-v7-recyclerview \ - org.cyanogenmod.platform.internal - -LOCAL_PROGUARD_FLAG_FILES := proguard.flags - -LOCAL_RESOURCE_DIR := \ - $(LOCAL_PATH)/res \ - $(LOCAL_PATH)/../../../../packages/resources/devicesettings/res \ - frameworks/support/v14/preference/res \ - frameworks/support/v7/appcompat/res \ - frameworks/support/v7/preference/res \ - frameworks/support/v7/recyclerview/res - -LOCAL_AAPT_FLAGS := --auto-add-overlay \ - --extra-packages android.support.v14.preference:android.support.v7.appcompat:android.support.v7.preference:android.support.v7.recyclerview - -ifneq ($(INCREMENTAL_BUILDS),) - LOCAL_PROGUARD_ENABLED := disabled - LOCAL_JACK_ENABLED := incremental -endif - -include frameworks/base/packages/SettingsLib/common.mk - -include $(BUILD_PACKAGE) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/cmactions/AndroidManifest.xml b/cmactions/AndroidManifest.xml deleted file mode 100644 index 4f023f8..0000000 --- a/cmactions/AndroidManifest.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.cyanogenmod.settings.device" - android:versionCode="1" - android:versionName="1.0" - android:sharedUserId="android.uid.system" - > - - <uses-permission android:name="android.permission.DEVICE_POWER" /> - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> - <uses-permission android:name="android.permission.VIBRATE" /> - <uses-permission android:name="android.permission.WAKE_LOCK" /> - - <uses-sdk - android:minSdkVersion="23" - android:targetSdkVersion="23" /> - - <application - android:allowBackup="true" - android:label="@string/device_settings_app_name" - android:persistent="true" - android:icon="@mipmap/ic_launcher_settings" - android:theme="@style/CMActions" > - <receiver android:name="com.cyanogenmod.settings.device.BootCompletedReceiver"> - <intent-filter> - <action android:name="android.intent.action.BOOT_COMPLETED" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </receiver> - - <service android:name="ServiceWrapper" android:permission="ServiceWrapper"> - <intent-filter> - <action android:name="ServiceWrapper"/> - </intent-filter> - </service> - - <service android:name="com.cyanogenmod.settings.device.SensorsDozeService" - android:permission="SensorsDozeService"> - </service> - - <!-- stub to ensure its loaded - DO NOT REMOVE --> - <activity android:name=".KeyHandler"/> - - <activity - android:excludeFromRecents="true" - android:name="CMActions" - android:launchMode="singleInstance" - android:screenOrientation="portrait" - android:windowAnimationStyle="@null"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - </intent-filter> - </activity> - - <activity - android:name=".TouchscreenGestureActivity" - android:label="@string/screen_gestures_panel_title"> - <intent-filter> - <action android:name="com.android.settings.action.EXTRA_SETTINGS" /> - </intent-filter> - <meta-data - android:name="com.android.settings.category" - android:value="com.android.settings.category.device" /> - <meta-data - android:name="com.android.settings.icon" - android:resource="@drawable/ic_settings_gestures" /> - </activity> - - </application> - -</manifest> diff --git a/cmactions/proguard.flags b/cmactions/proguard.flags deleted file mode 100644 index 32daf9b..0000000 --- a/cmactions/proguard.flags +++ /dev/null @@ -1,9 +0,0 @@ --keep class org.cyanogenmod.CMActions.* { - *; -} - --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet); -} - --keep class ** extends android.support.v14.preference.PreferenceFragment diff --git a/cmactions/res/drawable/ic_settings_gestures.xml b/cmactions/res/drawable/ic_settings_gestures.xml deleted file mode 100644 index 95cdede..0000000 --- a/cmactions/res/drawable/ic_settings_gestures.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (c) 2015 The CyanogenMod 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. ---> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:viewportWidth="24" - android:viewportHeight="24"> - - <path - android:fillColor="@android:color/white" - android:pathData="M4.7,6.9c0.7-0.7,1.4-1.4,1.7-1.2c0.5,0.2,0,1-0.3,1.5c-0.2,0.4-2.8,3.9-2.8,6.3c0,1.3,0.5,2.3,1.3,3 -c0.7,0.6,1.7,0.7,2.6,0.5c1.1-0.3,1.9-1.4,3-2.8c1.2-1.5,2.8-3.4,4-3.4c1.6,0,1.6,1,1.7,1.8c-3.7,0.6-5.3,3.7-5.3,5.4 -s1.4,3.1,3.2,3.1c1.6,0,4.3-1.3,4.6-6.1H21v-2.5h-2.4c-0.1-1.7-1.1-4.2-4-4.2c-2.2,0-4.1,1.9-4.9,2.8c-0.6,0.7-2,2.5-2.3,2.7 -c-0.2,0.3-0.7,0.8-1.1,0.8c-0.4,0-0.7-0.8-0.4-1.9c0.3-1.1,1.4-2.9,1.8-3.5C8.5,8,9.1,7.2,9.1,5.9C9.1,3.7,7.4,3,6.6,3 -C5.3,3,4.1,4,3.9,4.3C3.5,4.6,3.2,4.9,3,5.2L4.7,6.9z -M13.9,18.6c-0.3,0-0.7-0.3-0.7-0.7c0-0.6,0.7-2.2,2.8-2.8 -C15.8,17.8,14.6,18.6,13.9,18.6z" /> -</vector> diff --git a/cmactions/res/mipmap-xhdpi/ic_launcher_settings.png b/cmactions/res/mipmap-xhdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index fa8c813..0000000 --- a/cmactions/res/mipmap-xhdpi/ic_launcher_settings.png +++ /dev/null diff --git a/cmactions/res/mipmap-xxhdpi/ic_launcher_settings.png b/cmactions/res/mipmap-xxhdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index 3fa69e9..0000000 --- a/cmactions/res/mipmap-xxhdpi/ic_launcher_settings.png +++ /dev/null diff --git a/cmactions/res/mipmap-xxxhdpi/ic_launcher_settings.png b/cmactions/res/mipmap-xxxhdpi/ic_launcher_settings.png Binary files differdeleted file mode 100644 index 72946b7..0000000 --- a/cmactions/res/mipmap-xxxhdpi/ic_launcher_settings.png +++ /dev/null diff --git a/cmactions/res/values/colors.xml b/cmactions/res/values/colors.xml deleted file mode 100644 index c1f38af..0000000 --- a/cmactions/res/values/colors.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2015 The CyanogenMod 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. ---> -<resources> - <!-- Palette colors referenced by top-level themes. --> - <color name="theme_primary">#ff263238</color> - <color name="theme_primary_dark">#ff21272b</color> - <color name="theme_accent">#ff009688</color> -</resources> diff --git a/cmactions/res/values/dimens.xml b/cmactions/res/values/dimens.xml deleted file mode 100644 index 133701d..0000000 --- a/cmactions/res/values/dimens.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2015 The CyanogenMod 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. ---> -<resources> - <!-- ActionBar contentInsetStart --> - <dimen name="actionbar_subsettings_contentInsetStart">72dp</dimen> -</resources> diff --git a/cmactions/res/values/styles.xml b/cmactions/res/values/styles.xml deleted file mode 100644 index c497d8e..0000000 --- a/cmactions/res/values/styles.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2016 The CyanogenMod 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. ---> -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <style name="CMActions" parent="@android:style/Theme.Material.Settings"> - <item name="preferenceTheme">@android:style/Theme.Material.Settings</item> - </style> -</resources> diff --git a/cmactions/res/xml/touchscreen_panel.xml b/cmactions/res/xml/touchscreen_panel.xml deleted file mode 100644 index 5d2b9cc..0000000 --- a/cmactions/res/xml/touchscreen_panel.xml +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2015 The CyanogenMod 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. ---> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - - <PreferenceCategory - android:title="@string/gesture_display_title"> - - <SwitchPreference - android:key="touchscreen_gesture_c" - android:title="@string/touchscreen_c_gesture_title" - android:summary="@string/touchscreen_c_gesture_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_e" - android:title="@string/touchscreen_e_gesture_title" - android:summary="@string/touchscreen_e_gesture_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_s" - android:title="@string/touchscreen_s_gesture_title" - android:summary="@string/touchscreen_s_gesture_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_v" - android:title="@string/touchscreen_v_gesture_title" - android:summary="@string/touchscreen_v_gesture_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_w" - android:title="@string/touchscreen_w_gesture_title" - android:summary="@string/touchscreen_w_gesture_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_z" - android:title="@string/touchscreen_z_gesture_title" - android:summary="@string/touchscreen_z_gesture_summary" /> - - </PreferenceCategory> - - <PreferenceCategory - android:key="ambient_display_key" - android:title="@string/ambient_display_title"> - - <SwitchPreference - android:key="gesture_hand_wave" - android:defaultValue="false" - android:title="@string/hand_wave_gesture_title" - android:summary="@string/hand_wave_gesture_summary" /> - - <SwitchPreference - android:key="gesture_pick_up" - android:defaultValue="false" - android:title="@string/pick_up_gesture_title" - android:summary="@string/pick_up_gesture_summary" /> - - <SwitchPreference - android:key="gesture_pocket" - android:defaultValue="false" - android:title="@string/pocket_gesture_title" - android:summary="@string/pocket_gesture_summary" /> - - </PreferenceCategory> - - <PreferenceCategory - android:title="@string/touchscreen_gesture_extras"> - - <SwitchPreference - android:key="proximity_wake_enable" - android:defaultValue="false" - android:title="@string/proximity_wake_enable_title" - android:summary="@string/proximity_wake_enable_summary" /> - - <SwitchPreference - android:key="touchscreen_gesture_haptic_feedback" - android:persistent="false" - android:title="@string/touchscreen_gesture_haptic_feedback" - android:summary="@string/touchscreen_gesture_haptic_feedback_summary" /> - - </PreferenceCategory> - -</PreferenceScreen> diff --git a/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java b/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java deleted file mode 100644 index b38a0b7..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/BootCompletedReceiver.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -public class BootCompletedReceiver extends BroadcastReceiver { - static final String TAG = "CMActions"; - - @Override - public void onReceive(final Context context, Intent intent) { - Log.d(TAG, "Booting"); - context.startService(new Intent(context, SensorsDozeService.class)); - CMActionsSettings.updateGestureMode(context); - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/CMActionsSettings.java b/cmactions/src/com/cyanogenmod/settings/device/CMActionsSettings.java deleted file mode 100644 index a868565..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/CMActionsSettings.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.util.Log; - -import org.cyanogenmod.internal.util.FileUtils; - -public final class CMActionsSettings { - private static final String TAG = "CMActions"; - - // Proc nodes - private static final String TOUCHSCREEN_GESTURE_MODE_NODE = - "/sys/bus/i2c/devices/i2c-7/7-0038/ftsgesturemode"; - - // Preference keys - public static final String[] ALL_GESTURE_KEYS = { - "touchscreen_gesture_c", - "touchscreen_gesture_e", - "touchscreen_gesture_s", - "touchscreen_gesture_v", - "touchscreen_gesture_w", - "touchscreen_gesture_z", - }; - - // Key Masks - private static final int KEY_MASK_GESTURE_CONTROL = 0x40; - public static final int[] ALL_GESTURE_MASKS = { - 0x04, // c gesture mask - 0x08, // e gesture mask - 0x10, // s gesture mask - 0x01, // v gesture mask - 0x20, // w gesture mask - 0x02, // z gesture mask - }; - - private CMActionsSettings() { - // this class is not supposed to be instantiated - } - - /* Use bitwise logic to set gesture_mode in kernel driver */ - public static void updateGestureMode(Context context) { - int gestureMode = 0; - - // Make sure both arrays are set up correctly - if (ALL_GESTURE_KEYS.length != ALL_GESTURE_MASKS.length) { - Log.w(TAG, "Array lengths do not match!"); - return; - } - - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); - - for (int i = 0; i < ALL_GESTURE_KEYS.length; i++) { - if (sharedPrefs.getBoolean(ALL_GESTURE_KEYS[i], false)) { - gestureMode |= ALL_GESTURE_MASKS[i]; - } - } - - if (gestureMode != 0) - gestureMode |= KEY_MASK_GESTURE_CONTROL; - - Log.d(TAG, "finished gesture mode: " + gestureMode); - FileUtils.writeLine(TOUCHSCREEN_GESTURE_MODE_NODE, String.format("%7s", - Integer.toBinaryString(gestureMode)).replace(' ', '0')); - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/OrientationSensor.java b/cmactions/src/com/cyanogenmod/settings/device/OrientationSensor.java deleted file mode 100644 index 4d32b79..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/OrientationSensor.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.Context; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -public class OrientationSensor implements SensorEventListener { - - public static final int ORIENTATION_UNKNOWN = 0; - public static final int ORIENTATION_FACE_DOWN = 1; - public static final int ORIENTATION_FACE_UP = 2; - public static final int ORIENTATION_VERTICAL = 3; - - private static final int ORIENTATION_DELAY = 60 * 1000; - private static final int ORIENTATION_LATENCY = 0; - private static final float MATH_PI_1_4 = 0.785398F; - private static final float MATH_PI_3_4 = 2.35619F; - - private boolean mEnabled; - private boolean mReady; - private int mState; - private float mGravity[]; - private float mMagnetic[]; - private OrientationListener mOrientationListener; - private Sensor mAccelerometerSensor; - private Sensor mMagneticFieldSensor; - private SensorManager mSensorManager; - - public static interface OrientationListener { - public abstract void onEvent(); - } - - public boolean isFaceDown() { - return mReady && mState == ORIENTATION_FACE_DOWN; - } - - public boolean isFaceUp() { - return mReady && mState == ORIENTATION_FACE_UP; - } - - public boolean isVertical() { - return mReady && mState == ORIENTATION_VERTICAL; - } - - public OrientationSensor(Context context, SensorManager sensorManager, - OrientationListener orientationListener) { - mEnabled = false; - reset(); - mAccelerometerSensor = sensorManager.getDefaultSensor( - Sensor.TYPE_ACCELEROMETER, false); - mMagneticFieldSensor = sensorManager.getDefaultSensor( - Sensor.TYPE_MAGNETIC_FIELD, false); - - mOrientationListener = orientationListener; - mSensorManager = sensorManager; - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - public void onSensorChanged(SensorEvent event) { - if (event.values.length == 0) return; - - switch (event.sensor.getType()) { - case Sensor.TYPE_ACCELEROMETER: - mGravity = event.values; - break; - case Sensor.TYPE_MAGNETIC_FIELD: - mMagnetic = event.values; - break; - default: - break; - } - - if (mGravity != null && mMagnetic != null) { - float[] rotationMatrix = new float[9]; - if (SensorManager.getRotationMatrix(rotationMatrix, new float[9], - mGravity, mMagnetic)) - { - float[] values = new float[3]; - mState = ORIENTATION_UNKNOWN; - SensorManager.getOrientation(rotationMatrix, values); - - // Orientation is flat - if (values[1] > -MATH_PI_1_4 && values[1] < MATH_PI_1_4) { - // Device is face up - if (values[2] > -MATH_PI_1_4 && values[2] < MATH_PI_1_4) { - mState = ORIENTATION_FACE_UP; - } - // Device is face down - else if (values[2] < -MATH_PI_3_4 || values[2] > MATH_PI_3_4) { - mState = ORIENTATION_FACE_DOWN; - } - } - // Orientation is vertical - if (values[1] < -MATH_PI_1_4 || values[1] > MATH_PI_1_4 || - (values[2] > MATH_PI_1_4 && values[2] < MATH_PI_3_4) || - (values[2] > -MATH_PI_3_4 && values[2] < -MATH_PI_1_4)) { - mState = ORIENTATION_VERTICAL; - } - - // Launch an event - mReady = true; - mOrientationListener.onEvent(); - } - } - } - - public void enable() { - if (!mEnabled && mAccelerometerSensor != null && mMagneticFieldSensor != null) { - reset(); - mState = ORIENTATION_UNKNOWN; - mSensorManager.registerListener(this, mAccelerometerSensor, - ORIENTATION_DELAY, ORIENTATION_LATENCY); - mSensorManager.registerListener(this, mMagneticFieldSensor, - ORIENTATION_DELAY, ORIENTATION_LATENCY); - mEnabled = true; - } - } - - public void reset() { - mGravity = null; - mMagnetic = null; - mReady = false; - } - - public void disable() { - if (mEnabled && mAccelerometerSensor != null && mMagneticFieldSensor != null) { - mSensorManager.unregisterListener(this,mAccelerometerSensor); - mSensorManager.unregisterListener(this, mMagneticFieldSensor); - mEnabled = false; - } - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/PickUpSensor.java b/cmactions/src/com/cyanogenmod/settings/device/PickUpSensor.java deleted file mode 100644 index 79e3d9b..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/PickUpSensor.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.Context; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -public class PickUpSensor implements SensorEventListener { - - public static final int PICK_UP_UNKNOWN = 0; - public static final int PICK_UP_FALSE = 1; - public static final int PICK_UP_TRUE = 2; - - private static final int PICKUP_DELAY = 500 * 1000; - private static final int PICKUP_LATENCY = 100 * 1000; - private static final float PICK_UP_SAFEZONE = 5; - private static final float PICK_UP_THRESHOLD = 6; - - private boolean mEnabled; - private boolean mReady; - private int mState; - private Sensor mPickUpSensor; - private PickUpListener mPickUpListener; - private SensorManager mSensorManager; - - public static interface PickUpListener { - public abstract void onEvent(); - public abstract void onInit(); - } - - public boolean isPickedUp() { - return mReady && mState == PICK_UP_TRUE; - } - - public PickUpSensor(Context context, SensorManager sensorManager, - PickUpListener pickUpListener) { - mEnabled = false; - reset(); - mPickUpSensor = sensorManager.getDefaultSensor( - Sensor.TYPE_ACCELEROMETER, false); - - mPickUpListener = pickUpListener; - mSensorManager = sensorManager; - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - public void onSensorChanged(SensorEvent event) { - if (event.values.length == 0) return; - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - // Device is picked-up - if (isPickUpAbove(x, y, PICK_UP_SAFEZONE)) { - if (isPickUpAbove(x, y, PICK_UP_THRESHOLD)) { - if (mState != PICK_UP_TRUE) { - mState = PICK_UP_TRUE; - if (mReady) { - mPickUpListener.onEvent(); - } - } - } - } - // Device is layed down - else if (mState != PICK_UP_FALSE) { - mState = mState = PICK_UP_FALSE; - if (mReady) { - mPickUpListener.onEvent(); - } - } - - // Init the sensor - if (!mReady) { - mReady = true; - mPickUpListener.onInit(); - } - } - - public boolean isPickUpAbove(float x, float y, float threshold) { - return (x < -threshold || x > threshold || y > threshold); - } - - public void enable() { - if (!mEnabled && mPickUpSensor != null) { - reset(); - mSensorManager.registerListener(this, mPickUpSensor, - PICKUP_DELAY, PICKUP_LATENCY); - mEnabled = true; - } - } - - public void reset() { - mReady = false; - mState = PICK_UP_UNKNOWN; - } - - public void disable() { - if (mEnabled && mPickUpSensor != null) { - mSensorManager.unregisterListener(this, mPickUpSensor); - mEnabled = false; - } - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/ProximitySensor.java b/cmactions/src/com/cyanogenmod/settings/device/ProximitySensor.java deleted file mode 100644 index a2ba9e9..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/ProximitySensor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.Context; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -public class ProximitySensor implements SensorEventListener { - - private static final int PROXIMITY_DELAY = 1000 * 1000; - private static final int PROXIMITY_LATENCY = 100 * 1000; - - private boolean mEnabled; - private boolean mReady; - private boolean mState; - private float mMaxRange; - private ProximityListener mProximityListener; - private Sensor mProximitySensor; - private SensorManager mSensorManager; - - public static interface ProximityListener { - public abstract void onEvent(boolean isNear, long timestamp); - public abstract void onInit(boolean isNear, long timestamp); - } - - public ProximitySensor(Context context, SensorManager sensorManager, - ProximityListener proximitylistener) { - mEnabled = false; - reset(); - mProximitySensor = sensorManager.getDefaultSensor( - Sensor.TYPE_PROXIMITY, true); - - mProximityListener = proximitylistener; - mSensorManager = sensorManager; - - if (mProximitySensor != null) { - mMaxRange = mProximitySensor.getMaximumRange(); - } - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - public void onSensorChanged(SensorEvent event) { - if (event.values.length == 0) return; - boolean isNear = (event.values[0] < mMaxRange); - - // Launch an event - if (mState != isNear) { - mState = isNear; - if (mReady) { - mProximityListener.onEvent(mState, event.timestamp); - } - } - - // Init the sensor - if (!mReady) { - mProximityListener.onInit(mState, event.timestamp); - mReady = true; - } - } - - public void enable() { - if (!mEnabled && mProximitySensor != null) { - mSensorManager.registerListener(this, mProximitySensor, - PROXIMITY_DELAY, PROXIMITY_LATENCY); - mEnabled = true; - } - } - - public void reset() { - mReady = false; - mState = false; - } - - public void disable() { - if (mEnabled && mProximitySensor != null) { - mSensorManager.unregisterListener(this, mProximitySensor); - mEnabled = false; - } - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/SensorsDozeService.java b/cmactions/src/com/cyanogenmod/settings/device/SensorsDozeService.java deleted file mode 100644 index 592492f..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/SensorsDozeService.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.hardware.Sensor; -import android.hardware.SensorManager; -import android.media.AudioManager; -import android.os.IBinder; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.os.SystemClock; -import android.os.UserHandle; -import android.os.Vibrator; -import android.preference.PreferenceManager; -import android.provider.Settings; -import android.util.Log; - -import cyanogenmod.providers.CMSettings; - -public class SensorsDozeService extends Service { - - public static final boolean DEBUG = false; - public static final String TAG = "SensorsDozeService"; - - private static final String DOZE_INTENT = "com.android.systemui.doze.pulse"; - - private static final int HANDWAVE_DELTA_NS = 1000 * 1000 * 1000; - private static final int PULSE_MIN_INTERVAL_MS = 5000; - private static final int SENSORS_WAKELOCK_DURATION = 1000; - private static final int VIBRATOR_ACKNOWLEDGE = 40; - - private static final String KEY_GESTURE_HAND_WAVE = "gesture_hand_wave"; - private static final String KEY_GESTURE_PICK_UP = "gesture_pick_up"; - private static final String KEY_GESTURE_POCKET = "gesture_pocket"; - private static final String KEY_PROXIMITY_WAKE = "proximity_wake_enable"; - - private Context mContext; - private OrientationSensor mOrientationSensor; - private PickUpSensor mPickUpSensor; - private PowerManager mPowerManager; - private ProximitySensor mProximitySensor; - private SensorManager mSensorManager; - private WakeLock mSensorsWakeLock; - - private boolean mDozeEnabled; - private boolean mHandwaveDoze; - private boolean mHandwaveGestureEnabled; - private boolean mPickUpDoze; - private boolean mPickUpGestureEnabled; - private boolean mPickUpState; - private boolean mPocketDoze; - private boolean mPocketGestureEnabled; - private boolean mProximityNear; - private boolean mProximityWake; - private boolean mProximityWakeEnabled; - - private long mLastPulseTimestamp = 0; - private long mLastStowedTimestamp = 0; - - private OrientationSensor.OrientationListener mOrientationListener = - new OrientationSensor.OrientationListener() { - public void onEvent() { - setOrientationSensor(false, false); - handleOrientation(); - } - }; - - private PickUpSensor.PickUpListener mPickUpListener = - new PickUpSensor.PickUpListener() { - public void onEvent() { - mPickUpState = mPickUpSensor.isPickedUp(); - handlePickUp(); - } - public void onInit() { - mPickUpState = mPickUpSensor.isPickedUp(); - if (DEBUG) Log.d(TAG, "Pick-up sensor init : " + mPickUpState); - } - }; - - private ProximitySensor.ProximityListener mProximityListener = - new ProximitySensor.ProximityListener() { - public void onEvent(boolean isNear, long timestamp) { - mProximityNear = isNear; - handleProximity(timestamp); - } - public void onInit(boolean isNear, long timestamp) { - if (DEBUG) Log.d(TAG, "Proximity sensor init : " + isNear); - mLastStowedTimestamp = timestamp; - mProximityNear = isNear; - - // Pick-up or Orientation sensor initialization - if (!isEventPending() && !isNear && isPickUpEnabled()) { - setPickUpSensor(true, false); - } - } - }; - - public void onCreate() { - if (DEBUG) Log.d(TAG, "Creating service"); - - super.onCreate(); - mContext = this; - - mPowerManager = (PowerManager) mContext.getSystemService( - Context.POWER_SERVICE); - mSensorManager = (SensorManager) mContext.getSystemService( - Context.SENSOR_SERVICE); - mSensorsWakeLock = mPowerManager.newWakeLock( - PowerManager.PARTIAL_WAKE_LOCK, TAG + "WakeLock"); - - mOrientationSensor = new OrientationSensor(mContext, mSensorManager, - mOrientationListener); - mPickUpSensor = new PickUpSensor(mContext, mSensorManager, - mPickUpListener); - mProximitySensor = new ProximitySensor(mContext, mSensorManager, - mProximityListener); - - SharedPreferences sharedPrefs = PreferenceManager. - getDefaultSharedPreferences(mContext); - loadPreferences(sharedPrefs); - sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener); - } - - public int onStartCommand(Intent intent, int flags, int startId) { - if (DEBUG) Log.d(TAG, "Starting service"); - - IntentFilter intentScreen = new IntentFilter(Intent.ACTION_SCREEN_ON); - intentScreen.addAction(Intent.ACTION_SCREEN_OFF); - mContext.registerReceiver(mScreenStateReceiver, intentScreen); - if (!mPowerManager.isInteractive()) { - onDisplayOff(); - } - - return START_STICKY; - } - - public void onDestroy() { - if (DEBUG) Log.d(TAG, "Destroying service"); - - super.onDestroy(); - setOrientationSensor(false, true); - setPickUpSensor(false, true); - setProximitySensor(false, true); - } - - public IBinder onBind(Intent intent) { - return null; - } - - private void getDozeEnabled() { - boolean enabled = true; - if (android.provider.Settings.Secure.getInt( - mContext.getContentResolver(), Settings.Secure.DOZE_ENABLED, - 1) == 0) { - enabled = false; - } - mDozeEnabled = enabled; - } - - private boolean isDozeEnabled() { - return mDozeEnabled; - } - - private boolean isHandwaveEnabled() { - return mHandwaveGestureEnabled && isDozeEnabled(); - } - - private boolean isPickUpEnabled() { - return mPickUpGestureEnabled && isDozeEnabled(); - } - - private boolean isPocketEnabled() { - return mPocketGestureEnabled && isDozeEnabled(); - } - - private boolean isProximityWakeEnabled() { - return mProximityWakeEnabled; - } - - private boolean isEventPending() { - return mHandwaveDoze || mPickUpDoze || mPocketDoze || mProximityWake; - } - - private void handleProximity(long timestamp) { - long delta = timestamp - mLastStowedTimestamp; - boolean quickWave = delta < HANDWAVE_DELTA_NS; - getDozeEnabled(); - if (DEBUG) Log.d(TAG, "Proximity sensor : isNear " + mProximityNear); - - // Proximity sensor released - if (!mProximityNear) { - mHandwaveDoze = false; - mPickUpDoze = false; - mPocketDoze = false; - mProximityWake = false; - - // Handwave / Pick-up / Pocket gestures activated - if (isHandwaveEnabled() && isPickUpEnabled() && - isPocketEnabled()) { - mHandwaveDoze = quickWave; - mPickUpDoze = !quickWave; - mPocketDoze = !quickWave; - setOrientationSensor(true, false); - } - // Proximity Wake detected - else if (isProximityWakeEnabled() && quickWave) { - mProximityWake = true; - setOrientationSensor(true, false); - } - // Handwave Doze detected - else if (isHandwaveEnabled() && quickWave) { - mHandwaveDoze = true; - setOrientationSensor(true, false); - } - // Pick-up / Pocket Doze detected - else if ((isPickUpEnabled() || isPocketEnabled()) && !quickWave) { - mPickUpDoze = isPickUpEnabled(); - mPocketDoze = isPocketEnabled(); - setOrientationSensor(true, false); - } - // Start the pick-up sensor - else if (isPickUpEnabled()) { - setPickUpSensor(true, false); - } - } - // Proximity sensor stowed - else { - mLastStowedTimestamp = timestamp; - setOrientationSensor(false, false); - setPickUpSensor(false, false); - } - } - - private void handleOrientation() { - if (DEBUG) Log.d(TAG, "Orientation sensor : " + - "FaceDown " + mOrientationSensor.isFaceDown() + - ", FaceUp " + mOrientationSensor.isFaceUp() + - ", Vertical " + mOrientationSensor.isVertical()); - - // Orientation Doze analysis - if (!mProximityNear) { - analyseDoze(); - } - } - - private void handlePickUp() { - getDozeEnabled(); - if (DEBUG) Log.d(TAG, "Pick-up sensor : " + mPickUpState); - - // Pick-up Doze analysis - if (mPickUpState && isPickUpEnabled()) { - mPickUpDoze = true; - launchWakeLock(); - analyseDoze(); - } - // Picked-down - else { - mPickUpDoze = false; - } - } - - private void analyseDoze() { - getDozeEnabled(); - if (DEBUG) - Log.d(TAG, "Doze analysis : HandwaveDoze " + mHandwaveDoze + - ", PickUpDoze " + mPickUpDoze + - ", PocketDoze " + mPocketDoze + - ", ProximityWake " + mProximityWake + - ", PickUpState " + mPickUpState); - - // Handwave Doze launch - if (mHandwaveDoze && !mOrientationSensor.isFaceDown()) { - launchDozePulse(); - } - // Pocket Doze launch - else if (mPickUpDoze && - ((mPickUpState && !mProximityNear) || - (!mPickUpState && mOrientationSensor.isFaceDown()))) { - launchDozePulse(); - } - // Pocket Doze launch - else if (mPocketDoze && mOrientationSensor.isVertical()) { - launchDozePulse(); - } - // Proximity Wake launch - else if (mProximityWake && !mOrientationSensor.isFaceDown()) { - launchDeviceWake(); - } - - // Restore the pick-up sensor - if (!mProximityNear && isPickUpEnabled()) { - setPickUpSensor(true, false); - } - - resetValues(); - return; - } - - private void launchDozePulse() { - long delta; - if (mLastPulseTimestamp != 0) { - delta = SystemClock.elapsedRealtime() - mLastPulseTimestamp; - } else { - delta = PULSE_MIN_INTERVAL_MS; - } - - if (delta >= PULSE_MIN_INTERVAL_MS) { - if (DEBUG) Log.d(TAG, "Doze launch. Time since last : " + delta); - - launchWakeLock(); - launchAcknowledge(); - mLastPulseTimestamp = SystemClock.elapsedRealtime(); - mContext.sendBroadcastAsUser(new Intent(DOZE_INTENT), - UserHandle.ALL); - } - else if (DEBUG) Log.d(TAG, "Doze avoided. Time since last : " + delta); - } - - private void launchDeviceWake() { - if (DEBUG) Log.d(TAG, "Waking device."); - - mSensorsWakeLock.acquire(SENSORS_WAKELOCK_DURATION); - launchAcknowledge(); - mPowerManager.wakeUp(SystemClock.uptimeMillis()); - } - - private void launchWakeLock() { - mSensorsWakeLock.acquire(SENSORS_WAKELOCK_DURATION); - } - - private void launchAcknowledge() { - AudioManager audioManager = (AudioManager) mContext.getSystemService( - Context.AUDIO_SERVICE); - Vibrator vibrator = (Vibrator) mContext.getSystemService( - Context.VIBRATOR_SERVICE); - - boolean enabled = CMSettings.System.getInt(mContext.getContentResolver(), - CMSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, 1) != 0; - - switch (audioManager.getRingerMode()) { - case AudioManager.RINGER_MODE_SILENT: - break; - case AudioManager.RINGER_MODE_VIBRATE: - case AudioManager.RINGER_MODE_NORMAL: - default: - if (enabled) { - vibrator.vibrate(VIBRATOR_ACKNOWLEDGE); - } - break; - } - } - - private void resetValues() { - mHandwaveDoze = false; - mPickUpDoze = false; - mPocketDoze = false; - mProximityWake = false; - } - - private void setOrientationSensor(boolean enabled, boolean reset) { - if (mOrientationSensor == null) return; - - if (reset) { - mOrientationSensor.reset(); - } - if (enabled) { - setPickUpSensor(false, false); - launchWakeLock(); - mOrientationSensor.enable(); - } else { - mOrientationSensor.disable(); - } - } - - private void setPickUpSensor(boolean enabled, boolean reset) { - if (mPickUpSensor == null) return; - - if (reset) { - mPickUpSensor.reset(); - } - if (enabled) { - setOrientationSensor(false, false); - mPickUpSensor.enable(); - } else { - mPickUpSensor.disable(); - } - } - - private void setProximitySensor(boolean enabled, boolean reset) { - if (mProximitySensor == null) return; - - if (reset) { - mProximitySensor.reset(); - } - if (enabled) { - mProximitySensor.enable(); - } else { - mProximitySensor.disable(); - } - } - - private void onDisplayOn() { - if (DEBUG) Log.d(TAG, "Display on"); - - setOrientationSensor(false, true); - setPickUpSensor(false, true); - setProximitySensor(false, true); - } - - private void onDisplayOff() { - if (DEBUG) Log.d(TAG, "Display off"); - - getDozeEnabled(); - mLastPulseTimestamp = 0; - if (isHandwaveEnabled() || isPickUpEnabled() || isPocketEnabled() || - isProximityWakeEnabled()) { - resetValues(); - setOrientationSensor(false, true); - setPickUpSensor(false, true); - setProximitySensor(true, true); - } - } - - private void loadPreferences(SharedPreferences sharedPreferences) { - mHandwaveGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_HAND_WAVE, false); - mPickUpGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_PICK_UP, false); - mPocketGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_POCKET, false); - mProximityWakeEnabled = sharedPreferences.getBoolean( - KEY_PROXIMITY_WAKE, false); - } - - private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { - onDisplayOff(); - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { - onDisplayOn(); - } - } - }; - - private SharedPreferences.OnSharedPreferenceChangeListener mPrefListener = - new SharedPreferences.OnSharedPreferenceChangeListener() { - @Override - public void onSharedPreferenceChanged(SharedPreferences - sharedPreferences, String key) { - if (KEY_GESTURE_HAND_WAVE.equals(key)) { - mHandwaveGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_HAND_WAVE, false); - } else if (KEY_GESTURE_PICK_UP.equals(key)) { - mPickUpGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_PICK_UP, false); - } else if (KEY_GESTURE_POCKET.equals(key)) { - mPocketGestureEnabled = sharedPreferences.getBoolean( - KEY_GESTURE_POCKET, false); - } else if (KEY_PROXIMITY_WAKE.equals(key)) { - mProximityWakeEnabled = sharedPreferences.getBoolean( - KEY_PROXIMITY_WAKE, false); - } - } - }; -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureActivity.java b/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureActivity.java deleted file mode 100644 index 80687d9..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2016 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.app.Fragment; -import android.app.FragmentTransaction; -import android.os.Bundle; - -import com.android.settingslib.drawer.SettingsDrawerActivity; - -public class TouchscreenGestureActivity extends SettingsDrawerActivity { - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - getFragmentManager().beginTransaction().replace(R.id.content_frame, - new TouchscreenGestureFragment()).commit(); - } -} diff --git a/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureFragment.java b/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureFragment.java deleted file mode 100644 index 1430166..0000000 --- a/cmactions/src/com/cyanogenmod/settings/device/TouchscreenGestureFragment.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2015-2016 The CyanogenMod 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.cyanogenmod.settings.device; - -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.support.v14.preference.PreferenceFragment; -import android.support.v14.preference.SwitchPreference; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceCategory; -import android.provider.Settings; -import android.view.ViewGroup; - -import cyanogenmod.providers.CMSettings; - -public class TouchscreenGestureFragment extends PreferenceFragment { - - private static final String CATEGORY_AMBIENT_DISPLAY = "ambient_display_key"; - private static final String KEY_GESTURE_HAND_WAVE = "gesture_hand_wave"; - private static final String KEY_HAPTIC_FEEDBACK = "touchscreen_gesture_haptic_feedback"; - private static final String KEY_PROXIMITY_WAKE = "proximity_wake_enable"; - - private Handler mGestureHandler = new Handler(); - - private SwitchPreference mAmbientDisplayPreference; - private SwitchPreference mHandwavePreference; - private SwitchPreference mProximityWakePreference; - private SwitchPreference mHapticFeedback; - - @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.touchscreen_panel); - - // Ambient Display - PreferenceCategory ambientDisplay = - (PreferenceCategory) findPreference(CATEGORY_AMBIENT_DISPLAY); - ambientDisplay.setEnabled(isDozeEnabled()); - mHandwavePreference = (SwitchPreference) findPreference(KEY_GESTURE_HAND_WAVE); - mHandwavePreference.setOnPreferenceChangeListener(mProxPrefListener); - mProximityWakePreference = (SwitchPreference) findPreference(KEY_PROXIMITY_WAKE); - mProximityWakePreference.setOnPreferenceChangeListener(mProxPrefListener); - mHapticFeedback = (SwitchPreference) findPreference(KEY_HAPTIC_FEEDBACK); - mHapticFeedback.setOnPreferenceChangeListener(mHapticPrefListener); - - // Gestures - for (String gestureKey : CMActionsSettings.ALL_GESTURE_KEYS) { - Preference pref = findPreference(gestureKey); - pref.setOnPreferenceChangeListener(mGesturePrefListener); - } - } - - @Override - public void onResume() { - super.onResume(); - mHapticFeedback.setChecked(CMSettings.System.getInt(getContext().getContentResolver(), - CMSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, 1) != 0); - } - - private boolean isDozeEnabled() { - return Settings.Secure.getInt(getContext().getContentResolver(), - Settings.Secure.DOZE_ENABLED, 1) != 0; - } - - private Preference.OnPreferenceChangeListener mProxPrefListener = - new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - if ((boolean) newValue) { - final String key = preference.getKey(); - if (KEY_GESTURE_HAND_WAVE.equals(key)) { - mProximityWakePreference.setChecked(false); - } else if (KEY_PROXIMITY_WAKE.equals(key)) { - mHandwavePreference.setChecked(false); - } - } - return true; - } - }; - - private Preference.OnPreferenceChangeListener mHapticPrefListener = - new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean value = (Boolean) newValue; - CMSettings.System.putInt(getContext().getContentResolver(), - CMSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, value ? 1 : 0); - return true; - } - }; - - private Preference.OnPreferenceChangeListener mGesturePrefListener = - new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - mGestureHandler.postDelayed(mUpdateGestures, 500); - return true; - } - }; - - private final Runnable mUpdateGestures = new Runnable() { - @Override - public void run() { - CMActionsSettings.updateGestureMode(getContext()); - } - }; -} @@ -110,7 +110,6 @@ ADDITIONAL_DEFAULT_PROPERTIES += ro.dalvik.vm.native.bridge=libhoudini.so # Keyhandler PRODUCT_PACKAGES += \ - CMActions \ com.cyanogenmod.keyhandler # Key layout files |
