CMActions updated

All gestures added & gesture ui updated
This commit is contained in:
Yunus Emre Şeker 2016-10-05 00:24:52 +03:00
parent 46779c8fa1
commit a69af6ca79
17 changed files with 495 additions and 592 deletions

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gesture_action_titles">
<item>Désactivé</item>
<item>Réveiller</item>
<item>Dévérouiller</item>
<item>Lecture/Pause</item>
<item>Piste suivante</item>
<item>Piste précédente</item>
<item>Appareil photo</item>
<item>Lampe de poche</item>
<item>Do Not Disturb Mode</item>
<item>Normal Mode</item>
<item>Mute Mode</item>
</string-array>
<string-array name="gesture_action_values">
<item>disabled</item>
<item>wakeUp</item>
<item>unlock</item>
<item>play</item>
<item>next</item>
<item>prev</item>
<item>camera</item>
<item>flashlight</item>
<item>doNotDisturb</item>
<item>normal</item>
<item>mute</item>
</string-array>
</resources>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2013-2014 The CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
@ -23,30 +22,38 @@
<string name="touchscreen_control_gesture_head">Gestes écran éteint</string>
<string name="touchscreen_control_gesture_title">Activer les Gestes</string>
<string name="gesture_category_title">Gestes disponible</string>
<string name="touchscreen_dtp_gesture_title">Double Tape</string>
<string name="touchscreen_dtp_gesture_summary">Tapez deux fois pour réveiller l\'appareil</string>
<string name="touchscreen_c_gesture_title">Dessinez un \"C\"</string>
<string name="touchscreen_c_gesture_summary">Dessinez un \"C\" pour activer l\'appareil photo</string>
<string name="touchscreen_z_gesture_title">Dessinez un \"Z\"</string>
<string name="touchscreen_z_gesture_summary">Dessinez un \"Z\" pour Lecture/Pause</string>
<string name="touchscreen_ltr_gesture_title">Glissez vers la gauche</string>
<string name="touchscreen_ltr_gesture_summary">Glissez vers la gauche pour Piste Précédente</string>
<string name="touchscreen_gtr_gesture_title">Glissez vers la droite</string>
<string name="touchscreen_gtr_gesture_summary">Glissez vers la droite pour Piste Suivante</string>
<string name="touchscreen_s_gesture_title">Dessinez un \"S\"</string>
<string name="touchscreen_s_gesture_summary">Dessinez un \"S\" pour activer le mode \"Do Not Disturb\"</string>
<string name="touchscreen_w_gesture_title">Dessinez un \"W\"</string>
<string name="touchscreen_w_gesture_summary">Dessinez un \"W\" pour activer le mode \"Normal\"</string>
<string name="touchscreen_m_gesture_title">Dessinez un \"M\"</string>
<string name="touchscreen_m_gesture_summary">Dessinez un \"M\" pour activer le mode \"Silencieux\"</string>
<string name="touchscreen_ydown_gesture_title">Tracez une ligne vers le bas</string>
<string name="touchscreen_ydown_gesture_summary">Tracez une ligne verticale vers le bas pour activer la Torche</string>
<string name="touchscreen_yup_gesture_title">Tracez une ligne vers le haut</string>
<string name="touchscreen_yup_gesture_summary">Tracez une ligne verticale vers le haut pour activer la Torche</string>
<string name="touchscreen_dtp_gesture_title">Double Tape</string>
<string name="touchscreen_x_left_gesture_title">Glissez vers la gauche</string>
<string name="touchscreen_x_right_gesture_title">Glissez vers la droite</string>
<string name="touchscreen_y_down_gesture_title">Tracez une ligne vers le bas</string>
<string name="touchscreen_y_up_gesture_title">Swipe Up</string>
<string name="touchscreen_c_gesture_title">Dessinez \"c\"</string>
<string name="touchscreen_z_gesture_title">Dessinez \"z\"</string>
<string name="touchscreen_s_gesture_title">Dessinez \"s\"</string>
<string name="touchscreen_w_gesture_title">Dessinez \"w\"</string>
<string name="touchscreen_o_gesture_title">Dessinez \"o\"</string>
<string name="touchscreen_v_gesture_title">Dessinez \"v\"</string>
<string name="touchscreen_e_gesture_title">Dessinez \"e\"</string>
<string name="touchscreen_m_gesture_title">Dessinez \"m\"</string>
<!-- haptic feedback -->
<string name="touchscreen_extras">Extras</string>
<string name="haptic_feedback">Retour Haptique</string>
<string name="haptic_feedback_summary">Vibrer quand un geste est détecté</string>
<!-- gesture actions -->
<string name="disabled">Désactivé</string>
<string name="wakeUp">Réveiller</string>
<string name="unlock">Dévérouiller</string>
<string name="play">Lecture/Pause</string>
<string name="next">Piste suivante</string>
<string name="prev">Piste précédente</string>
<string name="camera">Appareil photo</string>
<string name="flashlight">Lampe de poche</string>
<string name="doNotDisturbMode">Do Not Disturb Mode</string>
<string name="normalMode">Normal Mode</string>
<string name="muteMode">Mute Mode</string>
</resources>

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gesture_action_titles">
<item>Выключено</item>
<item>Будить</item>
<item>Разблокировать</item>
<item>Воспризв./Пауза</item>
<item>Следующий Трек</item>
<item>Предыдущий Трек</item>
<item>Запустить камеру</item>
<item>Настройка вспышки</item>
<item>Режим Не беспокоить</item>
<item>Обычный режим</item>
<item>Беззвучный режим</item>
</string-array>
<string-array name="gesture_action_values">
<item>disabled</item>
<item>wakeUp</item>
<item>unlock</item>
<item>play</item>
<item>next</item>
<item>prev</item>
<item>camera</item>
<item>flashlight</item>
<item>doNotDisturb</item>
<item>normal</item>
<item>mute</item>
</string-array>
</resources>

View File

@ -18,35 +18,43 @@
<!-- Gesture shortcuts -->
<string name="screen_gestures_panel_title">Управление жестами</string>
<string name="screen_gestures_panel_summary">Использовать жесты, когда экран выключен</string>
<string name="screen_gestures_panel_summary">Use gestures while the screen is off</string>
<string name="touchscreen_control_gesture_head">Жесты выключенного экрана</string>
<string name="touchscreen_control_gesture_title">Включить управление жестами</string>
<string name="gesture_category_title">Доступные жесты</string>
<string name="touchscreen_dtp_gesture_title">Двойной тап</string>
<string name="touchscreen_dtp_gesture_summary">Пробуждение двойным тапом</string>
<string name="touchscreen_c_gesture_title">Нарисуйте \"C\"</string>
<string name="touchscreen_c_gesture_summary">Нарисуйте \"C\" для активации камеры</string>
<string name="touchscreen_z_gesture_title">Нарисуйте \"Z\"</string>
<string name="touchscreen_z_gesture_summary">Нарисуйте \"Z\" для Воспроизв./Паузы</string>
<string name="touchscreen_ltr_gesture_title">Свайп влево</string>
<string name="touchscreen_ltr_gesture_summary">Свайп влево - предыдущий трек</string>
<string name="touchscreen_gtr_gesture_title">Свайп вправо</string>
<string name="touchscreen_gtr_gesture_summary">Свайп вправо - следующий трек</string>
<string name="touchscreen_s_gesture_title">Нарисуйте \"S\"</string>
<string name="touchscreen_s_gesture_summary">Нарисуйте \"S\" для активации режима \"Не беспокоить\"</string>
<string name="touchscreen_w_gesture_title">Нарисуйте \"W\"</string>
<string name="touchscreen_w_gesture_summary">Нарисуйте \"W\" для активации нормального режима</string>
<string name="touchscreen_m_gesture_title">Нарисуйте \"M\"</string>
<string name="touchscreen_m_gesture_summary">Нарисуйте \"M\" для активации режима \"Без звука\"</string>
<string name="touchscreen_ydown_gesture_title">Нарисуйте черту вниз</string>
<string name="touchscreen_ydown_gesture_summary">Нарисуйте вертикальную черту вниз для активации фонарика</string>
<string name="touchscreen_yup_gesture_title">Нарисуйте черту вверх</string>
<string name="touchscreen_yup_gesture_summary">Нарисуйте вертикальную черту вверх для активации фонарика</string>
<string name="touchscreen_x_left_gesture_title">Музыка</string>
<string name="touchscreen_x_right_gesture_title">Музыка</string>
<string name="touchscreen_y_down_gesture_title">Фонарик</string>
<string name="touchscreen_y_up_gesture_title">Swipe Up</string>
<string name="touchscreen_c_gesture_title">Нарисуйте \"c\"</string>
<string name="touchscreen_z_gesture_title">Нарисуйте \"z\"</string>
<string name="touchscreen_s_gesture_title">Нарисуйте \"s\"</string>
<string name="touchscreen_w_gesture_title">Нарисуйте \"w\"</string>
<string name="touchscreen_o_gesture_title">Нарисуйте \"o\"</string>
<string name="touchscreen_v_gesture_title">Нарисуйте \"v\"</string>
<string name="touchscreen_e_gesture_title">Нарисуйте \"e\"</string>
<string name="touchscreen_m_gesture_title">Нарисуйте \"m\"</string>
<!-- haptic feedback -->
<string name="touchscreen_extras">Дополнительные настройки</string>
<string name="haptic_feedback">Вибрация</string>
<string name="haptic_feedback_summary">Использовать вбирацию при обработке жеста</string>
<!-- gesture actions -->
<string name="disabled">Выключено</string>
<string name="wakeUp">Будить</string>
<string name="unlock">Разблокировать</string>
<string name="play">Воспризв./Пауза</string>
<string name="next">Следующий Трек</string>
<string name="prev">Предыдущий Трек</string>
<string name="camera">Запустить камеру</string>
<string name="flashlight">Настройка вспышки</string>
<string name="doNotDisturbMode">Обычный режим</string>
<string name="normalMode">Обычный режим</string>
<string name="muteMode">Беззвучный режим</string>
</resources>

View File

@ -1,21 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gesture_action_titles">
<item>Disabled</item>
<item>Wake Up</item>
<item>Unlock</item>
<item>Play/Pause</item>
<item>Next Song</item>
<item>Previous Song</item>
<item>Launch Camera</item>
<item>Toggle Flashlight</item>
<item>Do Not Disturb Mode</item>
<item>Normal Mode</item>
<item>Mute Mode</item>
<item>@string/wakeUp</item>
<item>@string/unlock</item>
<item>@string/play</item>
<item>@string/next</item>
<item>@string/prev</item>
<item>@string/camera</item>
<item>@string/flashlight</item>
<item>@string/doNotDisturbMode</item>
<item>@string/normalMode</item>
<item>@string/muteMode</item>
</string-array>
<string-array name="gesture_action_values">
<item>disabled</item>
<item>wakeUp</item>
<item>unlock</item>
<item>play</item>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2013-2014 The CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
@ -16,8 +15,6 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="appName">Gestures</string>
<!-- Gesture shortcuts -->
<string name="screen_gestures_panel_title">Gesture shortcuts</string>
<string name="screen_gestures_panel_summary">Use gestures while the screen is off</string>
@ -25,30 +22,45 @@
<string name="touchscreen_control_gesture_head">Screen Off Gestures</string>
<string name="touchscreen_control_gesture_title">Enable Screen Gestures</string>
<string name="gesture_category_title">Available Gestures</string>
<string name="touchscreen_dtp_gesture_title">Double Tap</string>
<string name="touchscreen_dtp_gesture_summary">Double Tap to Wake-Up device</string>
<string name="touchscreen_c_gesture_title">Draw \"C\"</string>
<string name="touchscreen_c_gesture_summary">Draw a \"C\" to activate Camera</string>
<string name="touchscreen_z_gesture_title">Draw \"Z\"</string>
<string name="touchscreen_z_gesture_summary">Draw an \"Z\" to Play/Pause</string>
<string name="touchscreen_ltr_gesture_title">Swipe Left</string>
<string name="touchscreen_ltr_gesture_summary">Swipe left to Prev Track</string>
<string name="touchscreen_gtr_gesture_title">Swipe Right</string>
<string name="touchscreen_gtr_gesture_summary">Swipe right to Next Track</string>
<string name="touchscreen_s_gesture_title">Draw \"S\"</string>
<string name="touchscreen_s_gesture_summary">Draw a \"S\" to activate \"Do Not Disturb\" Mode</string>
<string name="touchscreen_w_gesture_title">Draw \"W\"</string>
<string name="touchscreen_w_gesture_summary">Draw a \"W\" to activate \"Normal\" Mode</string>
<string name="touchscreen_m_gesture_title">Draw \"M\"</string>
<string name="touchscreen_m_gesture_summary">Draw a \"M\" to activate \"Mute\" Mode</string>
<string name="touchscreen_ydown_gesture_title">Swipe Down</string>
<string name="touchscreen_ydown_gesture_summary">Draw a vertical line down to activate Flashlight</string>
<string name="touchscreen_yup_gesture_title">Swipe Up</string>
<string name="touchscreen_yup_gesture_summary">Draw a vertical line down to activate Flashlight</string>
<string name="touchscreen_x_left_gesture_title">Swipe Left</string>
<string name="touchscreen_x_right_gesture_title">Swipe Right</string>
<string name="touchscreen_y_down_gesture_title">Swipe Down</string>
<string name="touchscreen_y_up_gesture_title">Swipe Up</string>
<string name="touchscreen_c_gesture_title">Draw \"c\"</string>
<string name="touchscreen_z_gesture_title">Draw \"z\"</string>
<string name="touchscreen_s_gesture_title">Draw \"s\"</string>
<string name="touchscreen_w_gesture_title">Draw \"w\"</string>
<string name="touchscreen_o_gesture_title">Draw \"o\"</string>
<string name="touchscreen_v_gesture_title">Draw \"v\"</string>
<string name="touchscreen_e_gesture_title">Draw \"e\"</string>
<string name="touchscreen_m_gesture_title">Draw \"m\"</string>
<!-- unused -->
<!-- &lt; equals to < and &gt; equals to > -->
<string name="touchscreen_v_left_gesture_title">Draw \"&lt;\"</string>
<string name="touchscreen_v_right_gesture_title">Draw \"&gt;\"</string>
<string name="touchscreen_v_down_gesture_title">Draw \"ʌ\"</string>
<!-- haptic feedback -->
<string name="touchscreen_extras">Extras</string>
<string name="haptic_feedback">Haptic feedback</string>
<string name="haptic_feedback_summary">Vibrate when a gesture is detected</string>
<!-- gesture actions -->
<string name="disabled">Disabled</string>
<string name="wakeUp">Wake Up</string>
<string name="unlock">Unlock</string>
<string name="play">Play/Pause</string>
<string name="next">Next Track</string>
<string name="prev">Previous Track</string>
<string name="camera">Launch Camera</string>
<string name="flashlight">Toggle Flashlight</string>
<string name="doNotDisturbMode">Do Not Disturb Mode</string>
<string name="normalMode">Normal Mode</string>
<string name="muteMode">Mute Mode</string>
</resources>

View File

@ -24,41 +24,87 @@
</PreferenceCategory>
<PreferenceCategory
android:dependency="touchscreen_gesture_control"
android:key="category_gestures"
android:title="@string/gesture_category_title">
<ListPreference
android:key="160"
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="wakeUp"
android:key="160_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_dtp_gesture_title" />
<ListPreference
android:key="176"
android:title="@string/touchscreen_ltr_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="prev"
android:key="176_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_x_left_gesture_title" />
<ListPreference
android:key="177"
android:title="@string/touchscreen_gtr_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="next"
android:key="177_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_x_right_gesture_title" />
<ListPreference
android:key="179"
android:title="@string/touchscreen_ydown_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="unlock"
android:key="178_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_y_up_gesture_title" />
<ListPreference
android:key="193"
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="flashlight"
android:key="179_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_y_down_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="camera"
android:key="193_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_c_gesture_title" />
<ListPreference
android:key="202"
android:title="@string/touchscreen_z_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="wakeUp"
android:key="192_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_e_gesture_title" />
<ListPreference
android:key="194"
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="normalMode"
android:key="194_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_w_gesture_title" />
<ListPreference
android:key="195"
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="muteMode"
android:key="195_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_m_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="wakeUp"
android:key="196_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_o_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="muteMode"
android:key="197_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_s_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="wakeUp"
android:key="198_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_v_gesture_title" />
<com.cyanogenmod.settings.device.SwitchPlusPreference
android:defaultValue="doNotDisturbMode"
android:key="202_enabled"
android:summaryOff=" "
android:title="@string/touchscreen_z_gesture_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/touchscreen_extras">

View File

@ -16,8 +16,6 @@
package com.cyanogenmod.settings.device;
import com.cyanogenmod.settings.device.ServiceWrapper.LocalBinder;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@ -27,35 +25,15 @@ import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;
import com.cyanogenmod.settings.device.utils.FileUtils;
public class BootCompletedReceiver extends BroadcastReceiver {
static final String TAG = "CMActions";
private ServiceWrapper mServiceWrapper;
@Override
public void onReceive(final Context context, Intent intent) {
Log.d(TAG, "Booting");
enableComponent(context, TouchscreenGestureSettings.class.getName());
context.startService(new Intent(context, ServiceWrapper.class));
// Set sane default, for whatever reason gesture_mode loads with garbage at boot
FileUtils.writeAsByte(CMActionsSettings.TOUCHSCREEN_GESTURE_MODE_NODE, 256);
}
private ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
LocalBinder binder = (LocalBinder) service;
mServiceWrapper = binder.getService();
mServiceWrapper.start();
}
@Override
public void onServiceDisconnected(ComponentName className) {
mServiceWrapper = null;
}
};
private void enableComponent(Context context, String component) {
ComponentName name = new ComponentName(context, component);
PackageManager pm = context.getPackageManager();

View File

@ -1,44 +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.IntentService;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.util.Log;
import java.util.List;
import java.util.LinkedList;
public class CMActionsService extends IntentService {
private static final String TAG = "CMActions";
private final Context mContext;
public CMActionsService(Context context) {
super("CMActionService");
mContext = context;
Log.d(TAG, "Starting");
CMActionsSettings cmActionsSettings = new CMActionsSettings(context );
}
@Override
protected void onHandleIntent(Intent intent) {
}
}

View File

@ -1,205 +0,0 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
* Copyright (C) 2016 faust93 adaptation for Meizu PRO5 FTS Driver
*
* 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 com.cyanogenmod.settings.device.utils.FileUtils;
public class CMActionsSettings {
private static final String TAG = "CMActions";
// Preference keys
public static final String TOUCHSCREEN_GESTURE_CONTROL_KEY = "touchscreen_gesture_control";
public static final String TOUCHSCREEN_DOUBLETAP_KEY = "160_enabled";
public static final String TOUCHSCREEN_C_GESTURE_KEY = "193_enabled";
public static final String TOUCHSCREEN_Z_GESTURE_KEY = "202_enabled";
public static final String TOUCHSCREEN_LTR_GESTURE_KEY = "176_enabled";
public static final String TOUCHSCREEN_GTR_GESTURE_KEY = "177_enabled";
public static final String TOUCHSCREEN_S_GESTURE_KEY = "s_enabled";
public static final String TOUCHSCREEN_W_GESTURE_KEY = "194_enabled";
public static final String TOUCHSCREEN_M_GESTURE_KEY = "195_enabled";
public static final String TOUCHSCREEN_YDOWN_GESTURE_KEY = "179_enabled";
public static final String TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK =
"touchscreen_gesture_haptic_feedback";
// Proc nodes
public static final String TOUCHSCREEN_GESTURE_MODE_NODE = "/sys/devices/platform/mx-gs/gesture_control";
// Key Masks
public static final int KEY_MASK_DTP_CONTROL = 0x200;
public static final int KEY_MASK_GESTURE_DTP = 0x1000000;
public static final int KEY_MASK_SWIPE_CONTROL = 0x400;
public static final int KEY_MASK_GESTURE_YDOWN = 0x4000000;
public static final int KEY_MASK_GESTURE_LTR = 0x1000000;
public static final int KEY_MASK_GESTURE_GTR = 0x2000000;
public static final int KEY_MASK_GESTURE_CONTROL = 0x300;
public static final int KEY_MASK_GESTURE_C = 0x2000000;
public static final int KEY_MASK_GESTURE_E = 0x4000000;
public static final int KEY_MASK_GESTURE_S = 0x14000000;
public static final int KEY_MASK_GESTURE_V = 0x1000000;
public static final int KEY_MASK_GESTURE_W = 0x8000000;
public static final int KEY_MASK_GESTURE_Z = 0x40000000;
public static final int KEY_MASK_GESTURE_O = 0x80000000;
public static final int KEY_MASK_GESTURE_M = 0x10000000;
public static final int DISABLE_ALL_MASK = 0x100;
public static final int ENABLE_ALL_MASK = 0x1000100;
private static boolean mIsGestureEnabled;
private static boolean mIsGesture_DTP_Enabled;
private static boolean mIsGesture_C_Enabled;
private static boolean mIsGesture_E_Enabled;
private static boolean mIsGesture_S_Enabled;
private static boolean mIsGesture_V_Enabled;
private static boolean mIsGesture_O_Enabled;
private static boolean mIsGesture_M_Enabled;
private static boolean mIsGesture_W_Enabled;
private static boolean mIsGesture_Z_Enabled;
private static boolean mIsGesture_YDOWN_Enabled;
private static boolean mIsGesture_LTR_Enabled;
private static boolean mIsGesture_GTR_Enabled;
private final Context mContext;
private static SharedPreferences.OnSharedPreferenceChangeListener mPrefListener;
public CMActionsSettings(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
loadPreferences(sharedPrefs);
mPrefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
boolean updated = true;
if (TOUCHSCREEN_GESTURE_CONTROL_KEY.equals(key)) {
mIsGestureEnabled = sharedPreferences.getBoolean(TOUCHSCREEN_GESTURE_CONTROL_KEY, false);
Log.d(TAG, "prefChanged: gesture control " + mIsGestureEnabled);
TouchscreenGestureSettings.PrefFragment.gestureCat.setEnabled(areGesturesEnabled());
} else if (TOUCHSCREEN_DOUBLETAP_KEY.equals(key)) {
mIsGesture_DTP_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_DOUBLETAP_KEY, false);
} else if (TOUCHSCREEN_C_GESTURE_KEY.equals(key)) {
mIsGesture_C_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_C_GESTURE_KEY, false);
} else if (TOUCHSCREEN_S_GESTURE_KEY.equals(key)) {
mIsGesture_S_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_S_GESTURE_KEY, false);
} else if (TOUCHSCREEN_W_GESTURE_KEY.equals(key)) {
mIsGesture_W_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_W_GESTURE_KEY, false);
} else if (TOUCHSCREEN_M_GESTURE_KEY.equals(key)) {
mIsGesture_M_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_M_GESTURE_KEY, false);
} else if (TOUCHSCREEN_Z_GESTURE_KEY.equals(key)) {
mIsGesture_Z_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_Z_GESTURE_KEY, false);
} else if (TOUCHSCREEN_YDOWN_GESTURE_KEY.equals(key)) {
mIsGesture_YDOWN_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_YDOWN_GESTURE_KEY, false);
} else if (TOUCHSCREEN_LTR_GESTURE_KEY.equals(key)) {
mIsGesture_LTR_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_LTR_GESTURE_KEY, false);
} else if (TOUCHSCREEN_GTR_GESTURE_KEY.equals(key)) {
mIsGesture_GTR_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_GTR_GESTURE_KEY, false);
} else if (TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK.equals(key)) {
//CMSettings.System.putInt(getContentResolver(),CMSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK, value ? 1 : 0);
final boolean val = sharedPreferences.getBoolean(TOUCHSCREEN_GTR_GESTURE_KEY, false);
} else {
updated = false;
}
if (updated) {
updateGestureMode();
}
}
};
sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
mContext = context;
}
public static boolean areGesturesEnabled() {
Log.d(TAG, "Are gestures enabled:" + mIsGestureEnabled);
return mIsGestureEnabled;
}
public static void loadPreferences(SharedPreferences sharedPreferences) {
mIsGestureEnabled = sharedPreferences.getBoolean(TOUCHSCREEN_GESTURE_CONTROL_KEY, false);
mIsGesture_DTP_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_DOUBLETAP_KEY, false);
mIsGesture_C_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_C_GESTURE_KEY, false);
mIsGesture_S_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_S_GESTURE_KEY, false);
mIsGesture_M_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_M_GESTURE_KEY, false);
mIsGesture_W_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_W_GESTURE_KEY, false);
mIsGesture_Z_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_Z_GESTURE_KEY, false);
mIsGesture_YDOWN_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_YDOWN_GESTURE_KEY, false);
mIsGesture_LTR_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_LTR_GESTURE_KEY, false);
mIsGesture_GTR_Enabled = sharedPreferences.getBoolean(TOUCHSCREEN_GTR_GESTURE_KEY, false);
updateGestureMode();
}
/* Use bitwise logic to set gesture_mode in kernel driver.
Check each if each key is enabled with & operator and KEY_MASK,
if enabled toggle the appropriate bit with ^ XOR operator */
public static void updateGestureMode() {
int gesture_mode = 0;
// TODO Configure gesture control bits for better handling
if (mIsGestureEnabled) {
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_MODE_NODE, ENABLE_ALL_MASK);
// TAP_CTR masking
gesture_mode = (gesture_mode ^ KEY_MASK_DTP_CONTROL);
if (mIsGesture_DTP_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_DTP);
Log.d(TAG, "Gesture mode DoubleTap: " + gesture_mode);
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_MODE_NODE, gesture_mode);
gesture_mode = 0;
// SWIPE_CTR masking
gesture_mode = (gesture_mode ^ KEY_MASK_SWIPE_CONTROL);
if (mIsGesture_YDOWN_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_YDOWN);
if (mIsGesture_LTR_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_LTR);
if (mIsGesture_GTR_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_GTR);
Log.d(TAG, "Gesture mode Swipe: " + gesture_mode);
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_MODE_NODE, gesture_mode);
gesture_mode = 0;
// UNICODE_CTR masking
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_CONTROL);
if (((gesture_mode & KEY_MASK_GESTURE_C) == 1) != mIsGesture_C_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_C);
if (((gesture_mode & KEY_MASK_GESTURE_S) == 1) != mIsGesture_S_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_S);
if (((gesture_mode & KEY_MASK_GESTURE_W) == 1) != mIsGesture_W_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_W);
if (((gesture_mode & KEY_MASK_GESTURE_M) == 1) != mIsGesture_M_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_M);
if (((gesture_mode & KEY_MASK_GESTURE_Z) == 1) != mIsGesture_Z_Enabled)
gesture_mode = (gesture_mode ^ KEY_MASK_GESTURE_Z);
} else {
gesture_mode = DISABLE_ALL_MASK;
}
Log.d(TAG, "finished gesture mode: " + gesture_mode);
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_MODE_NODE, gesture_mode);
}
}

View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
* Copyright (C) 2016 faust93 adaptation for Meizu PRO5 FTS Driver
*
* 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 android.util.SparseIntArray;
import com.cyanogenmod.settings.device.utils.FileUtils;
public class GestureController {
private static final String TAG = GestureController.class.getSimpleName();
public static final String TOUCHSCREEN_GESTURE_CONTROL_NODE = "/sys/devices/platform/mx-gs/gesture_control";
public static final String TOUCHSCREEN_GESTURE_CONTROL_KEY = "touchscreen_gesture_control";
// M2Note gesture keys
public static final int DOUBLE_TAP = 0xA0; //160
public static final int SWIPE_X_LEFT = 0xB0; //176
public static final int SWIPE_X_RIGHT = 0xB1;
public static final int SWIPE_Y_UP = 0xB2;
public static final int SWIPE_Y_DOWN = 0xB3;
public static final int UNICODE_E = 0xC0; // 192
public static final int UNICODE_C = 0xC1;
public static final int UNICODE_W = 0xC2;
public static final int UNICODE_M = 0xC3;
public static final int UNICODE_O = 0xC4;
public static final int UNICODE_S = 0xC5;
public static final int UNICODE_V_UP = 0xC6;
public static final int UNICODE_V_DOWN = 0xC7;
public static final int UNICODE_V_L = 0xC8;
public static final int UNICODE_V_R = 0xC9;
public static final int UNICODE_Z = 0xCA;
public static final int GESTURES_DISABLED_MASK = 0x100;
public static final int GESTURES_ENABLED_MASK = 0x1000100;
// Supported gesture keys and masks
public static SparseIntArray keysToMasks = new SparseIntArray();
static {
keysToMasks.put(DOUBLE_TAP, 0x000100);
keysToMasks.put(SWIPE_X_LEFT, 0x000001);
keysToMasks.put(SWIPE_X_RIGHT, 0x000002);
keysToMasks.put(SWIPE_Y_DOWN, 0x000004);
keysToMasks.put(SWIPE_Y_UP, 0x000008);
keysToMasks.put(UNICODE_E, 0x040000);
keysToMasks.put(UNICODE_C, 0x020000);
keysToMasks.put(UNICODE_M, 0x100000);
keysToMasks.put(UNICODE_O, 0x800000);
keysToMasks.put(UNICODE_S, 0x200000);
keysToMasks.put(UNICODE_V_UP, 0x010000);
keysToMasks.put(UNICODE_W, 0x080000);
keysToMasks.put(UNICODE_Z, 0x400000);
}
private static SharedPreferences.OnSharedPreferenceChangeListener mPrefListener;
public GestureController(final Context context) {
updateGestureControl(context);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
mPrefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updateGestureControl(context);
}
};
sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
}
public static void updateGestureControl(Context context) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
if (sharedPreferences.getBoolean(TOUCHSCREEN_GESTURE_CONTROL_KEY, false)) {
int gestureMask = 0x000000;
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_ENABLED_MASK);
for (int i = 0; i < keysToMasks.size(); i++) {
int key = keysToMasks.keyAt(i);
int mask = keysToMasks.get(key);
if (sharedPreferences.getBoolean(key + "_enabled", false))
gestureMask += mask;
}
byte swipeMask = (byte) (gestureMask & 0xff);
FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{swipeMask, 0, 4, 0});
byte doubleTapMask = (byte) ((gestureMask >> 8) & 0xff);
FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{doubleTapMask, 0, 2, 0});
byte unicodeMask = (byte) ((gestureMask >> 16) & 0xff);
FileUtils.writeByteArray(TOUCHSCREEN_GESTURE_CONTROL_NODE, new byte[]{unicodeMask, 0, 3, 0});
} else {
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_DISABLED_MASK);
}
}
public static void masterSwitch(boolean enabled) {
if (enabled) {
Log.i(TAG, "Gestures enabled");
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_ENABLED_MASK);
} else {
Log.i(TAG, "Gestures disabled");
FileUtils.writeAsByte(TOUCHSCREEN_GESTURE_CONTROL_NODE, GESTURES_DISABLED_MASK);
}
}
}

View File

@ -1,65 +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.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
public class ServiceWrapper extends android.app.Service {
static final String TAG = "CMActions-ServiceWrapper";
private final IBinder mBinder = new LocalBinder();
private CMActionsService mCmActionsService;
public interface ServiceCallback {
void sendResults(int resultCode, Bundle b);
}
public class LocalBinder extends Binder {
ServiceWrapper getService() {
// Return this instance of the service so clients can call public
// methods
return ServiceWrapper.this;
}
}
@Override
public void onCreate() {
Log.i(TAG, "onCreate");
super.onCreate();
mCmActionsService = new CMActionsService(this);
}
@Override
public IBinder onBind(Intent intent) {
Log.i(TAG, "onBind");
return null;
}
public void setCallback(ServiceCallback callback) {
}
public void start() {
Log.i(TAG, "start");
}
public void stop() {
}
}

View File

@ -0,0 +1,125 @@
package com.cyanogenmod.settings.device;
import android.content.Context;
import android.preference.SwitchPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
/**
* Custom preference for handling a switch with a clickable preference area as well
*
* Source: https://gist.github.com/marchold/45e22839eb94aa14dfb5
*/
public class SwitchPlusPreference extends SwitchPreference {
//
// Public interface
//
/**
* Sets listeners for the switch and the background container preference view cell
*
* @param listener A valid SwitchPlusClickListener
*/
public void setSwitchClickListener(SwitchPlusClickListener listener) {
this.listener = listener;
}
private SwitchPlusClickListener listener = null;
/**
* Interface gives callbacks in to both parts of the preference
*/
public interface SwitchPlusClickListener {
/**
* Called when the switch is switched
*
* @param preference
* @param isChecked
*/
public void onCheckedChanged(SwitchPlusPreference preference, boolean isChecked);
/**
* Called when the preference view is clicked
*
* @param view
* @param preference
*/
public void onClick(View view, SwitchPlusPreference preference);
}
public SwitchPlusPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public SwitchPlusPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SwitchPlusPreference(Context context) {
super(context);
}
//
// Internal Functions
//
/**
* Recursively go through view tree until we find an android.widget.Switch
*
* @param view Root view to start searching
* @return A Switch class or null
*/
private Switch findSwitchWidget(View view) {
if (view instanceof Switch) {
return (Switch) view;
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
if (child instanceof ViewGroup) {
Switch result = findSwitchWidget(child);
if (result != null) return result;
}
if (child instanceof Switch) {
return (Switch) child;
}
}
}
return null;
}
//Get a handle on the 2 parts of the switch preference and assign handlers to them
@Override
protected void onBindView(View view) {
super.onBindView(view);
final SwitchPlusPreference that = this;
final Switch switchView = findSwitchWidget(view);
if (switchView != null) {
switchView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null)
listener.onCheckedChanged(that, ((Switch) v).isChecked());
}
});
switchView.setChecked(getSharedPreferences().getBoolean(getKey(), false));
switchView.setFocusable(true);
//switchView.setEnabled(true);
}
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) listener.onClick(v, that);
}
});
}
}

View File

@ -18,63 +18,33 @@ package com.cyanogenmod.settings.device;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TouchscreenGestureSettings extends Activity {
// M2Note gesture codes
public static final int DOUBLE_TAP = 0xA0; //160
public static final int SWIPE_X_LEFT = 0xB0; //176
public static final int SWIPE_X_RIGHT = 0xB1;
public static final int SWIPE_Y_UP = 0xB2;
public static final int SWIPE_Y_DOWN = 0xB3;
public static final int UNICODE_E = 0xC0; // 192
public static final int UNICODE_C = 0xC1;
public static final int UNICODE_W = 0xC2;
public static final int UNICODE_M = 0xC3;
public static final int UNICODE_O = 0xC4;
public static final int UNICODE_S = 0xC5;
public static final int UNICODE_V_UP = 0xC6;
public static final int UNICODE_V_DOWN = 0xC7;
public static final int UNICODE_V_L = 0xC8;
public static final int UNICODE_V_R = 0xC9;
public static final int UNICODE_Z = 0xCA;
private static final int[] supportedGesturesKeys = {
DOUBLE_TAP,
UNICODE_C,
UNICODE_Z,
SWIPE_X_LEFT,
SWIPE_X_RIGHT,
UNICODE_W,
UNICODE_M,
SWIPE_Y_DOWN
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getActionBar();
//actionBar.setTitle(getString(R.string.appName));
actionBar.setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PrefFragment())
.replace(android.R.id.content, new GestureFragment())
.commit();
}
@ -92,11 +62,9 @@ public class TouchscreenGestureSettings extends Activity {
return false;
}
public static class PrefFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
public static class GestureFragment extends PreferenceFragment implements SwitchPlusPreference.SwitchPlusClickListener {
public static final String TAG = PrefFragment.class.getSimpleName();
public static final String CATEGORY_GESTURES = "category_gestures";
public static PreferenceCategory gestureCat;
public static final String TAG = GestureFragment.class.getSimpleName();
private SharedPreferences sharedPrefs;
private String[] actionTitles;
@ -137,44 +105,51 @@ public class TouchscreenGestureSettings extends Activity {
}
actionTitles = actionTitlesList.toArray(new String[actionTitlesList.size()]);
actionValues = actionValuesList.toArray(new String[actionValuesList.size()]);
for (int prefKey : supportedGesturesKeys) {
ListPreference preference = (ListPreference) findPreference(String.valueOf(prefKey));
preference.setEntries(actionTitles);
preference.setEntryValues(actionValues);
preference.setOnPreferenceChangeListener(this);
String prefValue = sharedPrefs.getString(String.valueOf(prefKey), "disabled");
for (int x = 0; x < GestureController.keysToMasks.size(); x++) {
int prefKey = GestureController.keysToMasks.keyAt(x);
SwitchPlusPreference preference = (SwitchPlusPreference) findPreference(String.valueOf(prefKey) + "_enabled");
preference.setSwitchClickListener(this);
String prefValue = sharedPrefs.getString(String.valueOf(prefKey) + "_action", "disabled");
int i = actionValuesList.indexOf(prefValue);
if (i >= 0) {
preference.setSummary(actionTitles[i]);
preference.setValueIndex(i);
if (i >= 0)
preference.setSummaryOn(actionTitles[i]);
else
preference.setSummaryOn(" ");
}
findPreference(GestureController.TOUCHSCREEN_GESTURE_CONTROL_KEY).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
boolean newValue = (boolean) o;
GestureController.masterSwitch(newValue);
return true;
}
}
});
}
@Override
public void onResume() {
super.onResume();
gestureCat = (PreferenceCategory) findPreference(CATEGORY_GESTURES);
if (gestureCat != null) {
gestureCat.setEnabled(CMActionsSettings.areGesturesEnabled());
}
public void onCheckedChanged(SwitchPlusPreference preference, boolean isChecked) {
GestureController.updateGestureControl(getActivity());
}
@Override
public void onStart() {
super.onStart();
}
public void onClick(View view, final SwitchPlusPreference preference) {
if (!preference.isChecked()) return;
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
String newValue = (String) o;
int i = actionValuesList.indexOf(newValue);
if (i >= 0)
preference.setSummary(actionTitles[i]);
sharedPrefs.edit().putBoolean(preference.getKey() + "_enabled",
!"disabled".equals(newValue)).apply();
return true;
String prefValue = sharedPrefs.getString(preference.getKey().replace("_enabled", "_action"), "disabled");
int i = actionValuesList.indexOf(prefValue);
AlertDialog dialog = new AlertDialog.Builder(getActivity()).setSingleChoiceItems(actionTitles, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
preference.setSummaryOn(actionTitles[which]);
sharedPrefs.edit().putString(preference.getKey().replace("_enabled", "_action"),
actionValues[which]).apply();
dialog.dismiss();
}
}).create();
dialog.show();
}
}
}

View File

@ -1,21 +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;
interface UpdatedStateNotifier {
public void updateState();
}

View File

@ -75,6 +75,11 @@ public final class FileUtils {
return true;
}
/**
* Writes the given value as bytes into the given file
*
* @return true on success, false on failure
*/
public static boolean writeAsByte(String fileName, int value) {
byte[] bytes = ByteBuffer.allocate(4).putInt(value).array();
try {
@ -86,7 +91,25 @@ public final class FileUtils {
Log.e(TAG, "Could not write to file " + fileName, e);
return false;
}
return true;
}
/**
* Writes the given byte array into the given file
*
* @return true on success, false on failure
*/
public static boolean writeByteArray(String fileName, byte[] bytes) {
try {
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(bytes);
fos.flush();
fos.close();
} catch (IOException e) {
Log.e(TAG, "Could not write to file " + fileName, e);
return false;
}
return true;
}
}

View File

@ -169,10 +169,10 @@ public class KeyHandler implements DeviceKeyHandler {
@Override
public void handleMessage(Message msg) {
try {
int zenMode = 0;
boolean gestureHandled = true;
int gestureData = (int) msg.obj;
String prefValue = getCMAStringPref(String.valueOf(gestureData));
Log.i(TAG, "Handling gesture: " + gestureData + " action: " + prefValue);
String prefValue = getCMAStringPref(String.valueOf(gestureData) + "_action");
Log.i(TAG, "Handling gesture: " + gestureData + " with action: " + prefValue);
switch (prefValue) {
case "wakeUp":
mPowerManager.wakeUpWithProximityCheck(SystemClock.uptimeMillis());
@ -237,24 +237,23 @@ public class KeyHandler implements DeviceKeyHandler {
mPowerManager.wakeUp(SystemClock.uptimeMillis());
Intent appIntent = mPackageManager.getLaunchIntentForPackage(packageName);
startActivitySafely(appIntent);
} else {
gestureHandled = false;
}
break;
}
doHapticFeedback();
if (gestureHandled)
doHapticFeedback();
} catch (Exception e) {
Log.e(TAG, "Gesture EventHandler", e);
}
}
}
private void setZenMode(int zenMode) {
Global.putInt(mContext.getContentResolver(), Global.ZEN_MODE,
zenMode);
}
public boolean handleKeyEvent(KeyEvent event) {
boolean isHandled = false;
switch (event.getScanCode()) {
case 102: // Home button event
if (event.getAction() == KeyEvent.ACTION_DOWN) {
@ -401,3 +400,4 @@ public class KeyHandler implements DeviceKeyHandler {
return Integer.valueOf(readSingleLine(f));
}
}