sanders: Apply more LineageOS rebrand
* CMActions: Move to Lineage SDK * CMActions -> LineageActions Since history is going to be killed anyway: * Move related stuff under "actions" or "doze" packages, make every class role clear * Rename misleading TouchscreenGesture* to Actions* Also add original-package for preferences migration Signed-off-by: jhenrique09 <jhenrique09.mcz@hotmail.com> (cherry picked from commit 99c39df834c26edfc066e8ad2088a55e5a858166)
This commit is contained in:
@@ -5,7 +5,7 @@ LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := CMActions
|
||||
LOCAL_PACKAGE_NAME := LineageActions
|
||||
LOCAL_CERTIFICATE := platform
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
|
||||
@@ -13,7 +13,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-v14-preference \
|
||||
android-support-v7-appcompat \
|
||||
android-support-v7-preference \
|
||||
android-support-v7-recyclerview
|
||||
android-support-v7-recyclerview \
|
||||
org.lineageos.platform.internal
|
||||
|
||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cyanogenmod.settings.device"
|
||||
package="org.lineageos.settings.device"
|
||||
android:sharedUserId="android.uid.system"
|
||||
>
|
||||
|
||||
<original-package android:name="com.cyanogenmod.settings.device" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
@@ -16,7 +18,7 @@
|
||||
android:label="@string/device_settings_app_name"
|
||||
android:persistent="true">
|
||||
|
||||
<receiver android:name="com.cyanogenmod.settings.device.BootCompletedReceiver">
|
||||
<receiver android:name="org.lineageos.settings.device.BootCompletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
@@ -32,18 +34,17 @@
|
||||
<activity
|
||||
android:name=".DozePreferenceActivity"
|
||||
android:label="@string/ambient_display_title"
|
||||
android:theme="@style/CMActions">
|
||||
android:theme="@style/LineageActions">
|
||||
<intent-filter>
|
||||
<action android:name="org.cyanogenmod.settings.device.DOZE_SETTINGS" />
|
||||
<action android:name="org.lineageos.settings.device.DOZE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".TouchscreenGesturePreferenceActivity"
|
||||
android:label="@string/moto_actions_title"
|
||||
android:summary="@string/moto_actions_summary"
|
||||
android:theme="@style/CMActions">
|
||||
android:name=".ActionsPreferenceActivity"
|
||||
android:label="@string/screen_gestures_panel_title"
|
||||
android:theme="@style/LineageActions">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.EXTRA_SETTINGS" />
|
||||
</intent-filter>
|
||||
@@ -1,4 +1,4 @@
|
||||
-keep class org.cyanogenmod.CMActions.* {
|
||||
-keep class org.lineageos.LineageActions.* {
|
||||
*;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<style name="CMActions" parent="@android:style/Theme.DeviceDefault.Settings">
|
||||
<style name="LineageActions" parent="@android:style/Theme.DeviceDefault.Settings">
|
||||
<item name="preferenceTheme">@style/SettingsPreference</item>
|
||||
</style>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:key="ambient_display_key"
|
||||
android:title="@string/ambient_display_title">
|
||||
|
||||
<cyanogenmod.preference.SecureSettingSwitchPreference
|
||||
<lineageos.preference.SecureSettingSwitchPreference
|
||||
android:key="doze_enabled"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/ambient_display_enable_title"
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
public class TouchscreenGesturePreferenceActivity extends PreferenceActivity {
|
||||
public class ActionsPreferenceActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new TouchscreenGesturePreferenceFragment()).commit();
|
||||
.replace(android.R.id.content, new ActionsPreferenceFragment()).commit();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
@@ -30,15 +30,21 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class TouchscreenGesturePreferenceFragment extends PreferenceFragment {
|
||||
import java.io.File;
|
||||
|
||||
import org.lineageos.internal.util.FileUtils;
|
||||
import org.lineageos.settings.device.actions.Constants;
|
||||
|
||||
public class ActionsPreferenceFragment extends PreferenceFragment {
|
||||
private SwitchPreference mFlipPref;
|
||||
private NotificationManager mNotificationManager;
|
||||
private boolean mFlipClick = false;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.gesture_panel);
|
||||
addPreferencesFromResource(R.xml.actions_panel);
|
||||
final ActionBar actionBar = getActivity().getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
mNotificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
@@ -26,11 +27,14 @@ import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cyanogenmod.settings.device.ServiceWrapper.LocalBinder;
|
||||
import org.lineageos.internal.util.FileUtils;
|
||||
import org.lineageos.settings.device.actions.Constants;
|
||||
import org.lineageos.settings.device.ServiceWrapper.LocalBinder;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
static final String TAG = "CMActions";
|
||||
static final String TAG = "LineageActions";
|
||||
final String NAVBAR_SHOWN = "navbar_shown";
|
||||
|
||||
private ServiceWrapper mServiceWrapper;
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
@@ -43,7 +43,7 @@ public class DozePreferenceActivity extends PreferenceActivity {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.doze_panel);
|
||||
boolean dozeEnabled = CMActionsSettings.isDozeEnabled(getActivity().getContentResolver());
|
||||
boolean dozeEnabled = LineageActionsSettings.isDozeEnabled(getActivity().getContentResolver());
|
||||
mAmbientDisplayPreference = (SwitchPreference) findPreference(KEY_AMBIENT_DISPLAY_ENABLE);
|
||||
// Read from DOZE_ENABLED secure setting
|
||||
mAmbientDisplayPreference.setChecked(dozeEnabled);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Context;
|
||||
@@ -26,9 +27,23 @@ import android.util.Log;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class CMActionsService extends IntentService implements ScreenStateNotifier,
|
||||
import org.lineageos.settings.device.actions.UpdatedStateNotifier;
|
||||
import org.lineageos.settings.device.actions.CameraActivationSensor;
|
||||
import org.lineageos.settings.device.actions.ChopChopSensor;
|
||||
import org.lineageos.settings.device.actions.FlipToMute;
|
||||
import org.lineageos.settings.device.actions.LiftToSilence;
|
||||
import org.lineageos.settings.device.actions.ProximitySilencer;
|
||||
|
||||
import org.lineageos.settings.device.doze.DozePulseAction;
|
||||
//import org.lineageos.settings.device.doze.GlanceSensor;
|
||||
import org.lineageos.settings.device.doze.ProximitySensor;
|
||||
import org.lineageos.settings.device.doze.ScreenReceiver;
|
||||
import org.lineageos.settings.device.doze.ScreenStateNotifier;
|
||||
import org.lineageos.settings.device.doze.StowSensor;
|
||||
|
||||
public class LineageActionsService extends IntentService implements ScreenStateNotifier,
|
||||
UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
@@ -42,13 +57,13 @@ public class CMActionsService extends IntentService implements ScreenStateNotifi
|
||||
private final List<UpdatedStateNotifier> mUpdatedStateNotifiers =
|
||||
new LinkedList<UpdatedStateNotifier>();
|
||||
|
||||
public CMActionsService(Context context) {
|
||||
super("CMActionService");
|
||||
public LineageActionsService(Context context) {
|
||||
super("LineageActionService");
|
||||
mContext = context;
|
||||
|
||||
Log.d(TAG, "Starting");
|
||||
|
||||
CMActionsSettings cmActionsSettings = new CMActionsSettings(context, this);
|
||||
LineageActionsSettings lineageActionsSettings = new LineageActionsSettings(context, this);
|
||||
mSensorHelper = new SensorHelper(context);
|
||||
mScreenReceiver = new ScreenReceiver(context, this);
|
||||
|
||||
@@ -56,19 +71,19 @@ public class CMActionsService extends IntentService implements ScreenStateNotifi
|
||||
mScreenStateNotifiers.add(mDozePulseAction);
|
||||
|
||||
// Actionable sensors get screen on/off notifications
|
||||
//mScreenStateNotifiers.add(new GlanceSensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new ProximitySensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new StowSensor(cmActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
//mScreenStateNotifiers.add(new GlanceSensor(lineageActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new ProximitySensor(lineageActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
mScreenStateNotifiers.add(new StowSensor(lineageActionsSettings, mSensorHelper, mDozePulseAction));
|
||||
|
||||
// Other actions that are always enabled
|
||||
mUpdatedStateNotifiers.add(new CameraActivationSensor(cmActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ChopChopSensor(cmActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ProximitySilencer(cmActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new FlipToMute(cmActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new LiftToSilence(cmActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new CameraActivationSensor(lineageActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ChopChopSensor(lineageActionsSettings, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new ProximitySilencer(lineageActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new FlipToMute(lineageActionsSettings, context, mSensorHelper));
|
||||
mUpdatedStateNotifiers.add(new LiftToSilence(lineageActionsSettings, context, mSensorHelper));
|
||||
|
||||
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CMActionsWakeLock");
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "LineageActionsWakeLock");
|
||||
updateState();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -24,8 +25,13 @@ import android.provider.Settings;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class CMActionsSettings {
|
||||
private static final String TAG = "CMActions";
|
||||
import org.lineageos.settings.device.actions.Constants;
|
||||
import org.lineageos.settings.device.actions.UpdatedStateNotifier;
|
||||
import org.lineageos.settings.device.actions.CameraActivationAction;
|
||||
import org.lineageos.settings.device.actions.TorchAction;
|
||||
|
||||
public class LineageActionsSettings {
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private static final String GESTURE_CAMERA_ACTION_KEY = "gesture_camera_action";
|
||||
private static final String GESTURE_CHOP_CHOP_KEY = "gesture_chop_chop";
|
||||
@@ -46,7 +52,7 @@ public class CMActionsSettings {
|
||||
private boolean mFlipToMuteEnabled;
|
||||
private boolean mLiftToSilenceEnabled;
|
||||
|
||||
public CMActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) {
|
||||
public LineageActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
loadPreferences(sharedPrefs);
|
||||
sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
interface SensorAction {
|
||||
public interface SensorAction {
|
||||
public void action();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -29,7 +30,7 @@ import android.hardware.TriggerEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class SensorHelper {
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private static final int SENSOR_TYPE_MMI_CAMERA_ACTIVATION = 65540;
|
||||
private static final int SENSOR_TYPE_MMI_CHOP_CHOP = 65546;
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
@@ -23,10 +24,10 @@ import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
public class ServiceWrapper extends android.app.Service {
|
||||
static final String TAG = "CMActions-ServiceWrapper";
|
||||
static final String TAG = "LineageActions-ServiceWrapper";
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
private CMActionsService mCmActionsService;
|
||||
private LineageActionsService mLineageActionsService;
|
||||
|
||||
public interface ServiceCallback {
|
||||
void sendResults(int resultCode, Bundle b);
|
||||
@@ -44,7 +45,7 @@ public class ServiceWrapper extends android.app.Service {
|
||||
public void onCreate() {
|
||||
Log.i(TAG, "onCreate");
|
||||
super.onCreate();
|
||||
mCmActionsService = new CMActionsService(this);
|
||||
mLineageActionsService = new LineageActionsService(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,8 +32,10 @@ import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.SensorAction;
|
||||
|
||||
public class CameraActivationAction implements SensorAction {
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,20 +25,23 @@ import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
public class CameraActivationSensor implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-CameraSensor";
|
||||
private static final String TAG = "LineageActions-CameraSensor";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
|
||||
private final Sensor mSensor;
|
||||
|
||||
private boolean mIsEnabled;
|
||||
|
||||
public CameraActivationSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
public CameraActivationSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper) {
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getCameraActivationSensor();
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
@@ -45,10 +49,10 @@ public class CameraActivationSensor implements SensorEventListener, UpdatedState
|
||||
|
||||
@Override
|
||||
public synchronized void updateState() {
|
||||
if (mCMActionsSettings.isCameraGestureEnabled() && !mIsEnabled) {
|
||||
if (mLineageActionsSettings.isCameraGestureEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mIsEnabled = true;
|
||||
} else if (! mCMActionsSettings.isCameraGestureEnabled() && mIsEnabled) {
|
||||
} else if (! mLineageActionsSettings.isCameraGestureEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mIsEnabled = false;
|
||||
}
|
||||
@@ -57,7 +61,7 @@ public class CameraActivationSensor implements SensorEventListener, UpdatedState
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
Log.d(TAG, "activate camera");
|
||||
if (mIsEnabled) mCMActionsSettings.cameraAction();
|
||||
if (mIsEnabled) mLineageActionsSettings.cameraAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,12 +25,15 @@ import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-ChopChopSensor";
|
||||
private static final String TAG = "LineageActions-ChopChopSensor";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mSensor;
|
||||
private final Sensor mProx;
|
||||
@@ -37,8 +41,8 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier
|
||||
private boolean mIsEnabled;
|
||||
private boolean mProxIsCovered;
|
||||
|
||||
public ChopChopSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
public ChopChopSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper) {
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getChopChopSensor();
|
||||
mProx = sensorHelper.getProximitySensor();
|
||||
@@ -46,12 +50,12 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier
|
||||
|
||||
@Override
|
||||
public synchronized void updateState() {
|
||||
if (mCMActionsSettings.isChopChopGestureEnabled() && !mIsEnabled) {
|
||||
if (mLineageActionsSettings.isChopChopGestureEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mSensorHelper.registerListener(mProx, mProxListener);
|
||||
mIsEnabled = true;
|
||||
} else if (! mCMActionsSettings.isChopChopGestureEnabled() && mIsEnabled) {
|
||||
} else if (! mLineageActionsSettings.isChopChopGestureEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(this);
|
||||
mSensorHelper.unregisterListener(mProxListener);
|
||||
@@ -66,7 +70,7 @@ public class ChopChopSensor implements SensorEventListener, UpdatedStateNotifier
|
||||
Log.d(TAG, "proximity sensor covered, ignoring chop-chop");
|
||||
return;
|
||||
}
|
||||
mCMActionsSettings.chopChopAction();
|
||||
mLineageActionsSettings.chopChopAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -24,11 +25,11 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.cyanogenmod.internal.util.FileUtils;
|
||||
import org.lineageos.internal.util.FileUtils;
|
||||
|
||||
public class Constants {
|
||||
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
// Swap keys
|
||||
public static final String FP_HOME_KEY = "fp_home";
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -26,11 +27,14 @@ import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
public class FlipToMute implements UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-FlipToMute";
|
||||
private static final String TAG = "LineageActions-FlipToMute";
|
||||
|
||||
private final NotificationManager mNotificationManager;
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mFlatDown;
|
||||
private final Sensor mStow;
|
||||
@@ -42,9 +46,9 @@ public class FlipToMute implements UpdatedStateNotifier {
|
||||
private Context mContext;
|
||||
private Receiver mReceiver;
|
||||
|
||||
public FlipToMute(CMActionsSettings cmActionsSettings, Context context,
|
||||
public FlipToMute(LineageActionsSettings lineageActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mContext = context;
|
||||
mSensorHelper = sensorHelper;
|
||||
mFlatDown = sensorHelper.getFlatDownSensor();
|
||||
@@ -57,14 +61,14 @@ public class FlipToMute implements UpdatedStateNotifier {
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isFlipToMuteEnabled() && !mIsEnabled) {
|
||||
if (mLineageActionsSettings.isFlipToMuteEnabled() && !mIsEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mFlatDown, mFlatDownListener);
|
||||
mSensorHelper.registerListener(mStow, mStowListener);
|
||||
mContext.registerReceiver(mReceiver,
|
||||
new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED));
|
||||
mIsEnabled = true;
|
||||
} else if (!mCMActionsSettings.isFlipToMuteEnabled() && mIsEnabled) {
|
||||
} else if (!mLineageActionsSettings.isFlipToMuteEnabled() && mIsEnabled) {
|
||||
Log.d(TAG, "Disabling");
|
||||
mSensorHelper.unregisterListener(mFlatDownListener);
|
||||
mSensorHelper.unregisterListener(mStowListener);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
@@ -25,10 +26,13 @@ import android.telecom.TelecomManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class LiftToSilence extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-LiftToSilence";
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
public class LiftToSilence extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "LineageActions-LiftToSilence";
|
||||
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mFlatUpSensor;
|
||||
private final Sensor mStowSensor;
|
||||
@@ -40,9 +44,9 @@ public class LiftToSilence extends PhoneStateListener implements SensorEventList
|
||||
private boolean mIsStowed;
|
||||
private boolean mLastFlatUp;
|
||||
|
||||
public LiftToSilence(CMActionsSettings cmActionsSettings, Context context,
|
||||
public LiftToSilence(LineageActionsSettings lineageActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mFlatUpSensor = sensorHelper.getFlatUpSensor();
|
||||
mStowSensor = sensorHelper.getStowSensor();
|
||||
@@ -52,7 +56,7 @@ public class LiftToSilence extends PhoneStateListener implements SensorEventList
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isLiftToSilenceEnabled()) {
|
||||
if (mLineageActionsSettings.isLiftToSilenceEnabled()) {
|
||||
mTelephonyManager.listen(this, LISTEN_CALL_STATE);
|
||||
} else {
|
||||
mTelephonyManager.listen(this, 0);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
@@ -25,28 +26,31 @@ import android.telecom.TelecomManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
import static android.telephony.TelephonyManager.*;
|
||||
|
||||
public class ProximitySilencer extends PhoneStateListener implements SensorEventListener, UpdatedStateNotifier {
|
||||
private static final String TAG = "CMActions-ProximitySilencer";
|
||||
private static final String TAG = "LineageActions-ProximitySilencer";
|
||||
|
||||
private static final int SILENCE_DELAY_MS = 500;
|
||||
|
||||
private final TelecomManager mTelecomManager;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final Sensor mSensor;
|
||||
private boolean mIsRinging;
|
||||
private long mRingStartedMs;
|
||||
private boolean mCoveredRinging;
|
||||
|
||||
public ProximitySilencer(CMActionsSettings cmActionsSettings, Context context,
|
||||
public ProximitySilencer(LineageActionsSettings lineageActionsSettings, Context context,
|
||||
SensorHelper sensorHelper) {
|
||||
mTelecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensor = sensorHelper.getProximitySensor();
|
||||
mCoveredRinging = false;
|
||||
@@ -55,7 +59,7 @@ public class ProximitySilencer extends PhoneStateListener implements SensorEvent
|
||||
|
||||
@Override
|
||||
public void updateState() {
|
||||
if (mCMActionsSettings.isIrSilencerEnabled()) {
|
||||
if (mLineageActionsSettings.isIrSilencerEnabled()) {
|
||||
mTelephonyManager.listen(this, LISTEN_CALL_STATE);
|
||||
} else {
|
||||
mTelephonyManager.listen(this, 0);
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
@@ -23,8 +24,10 @@ import android.hardware.camera2.CameraAccessException;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.SensorAction;
|
||||
|
||||
public class TorchAction implements SensorAction {
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.actions;
|
||||
|
||||
interface UpdatedStateNotifier {
|
||||
public interface UpdatedStateNotifier {
|
||||
public void updateState();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,14 +15,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.doze;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.device.SensorAction;
|
||||
|
||||
public class DozePulseAction implements SensorAction, ScreenStateNotifier {
|
||||
private static final String TAG = "CMActions";
|
||||
private static final String TAG = "LineageActions";
|
||||
|
||||
private static final int DELAY_BETWEEN_DOZES_IN_MS = 1500;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,17 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.doze;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.util.Log;
|
||||
|
||||
public class ProximitySensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private static final String TAG = "CMActions-ProximitySensor";
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorAction;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
public class ProximitySensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private static final String TAG = "LineageActions-ProximitySensor";
|
||||
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final SensorAction mSensorAction;
|
||||
private final Sensor mSensor;
|
||||
@@ -33,9 +38,9 @@ public class ProximitySensor implements ScreenStateNotifier, SensorEventListener
|
||||
|
||||
private boolean mSawNear = false;
|
||||
|
||||
public ProximitySensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper,
|
||||
public ProximitySensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper,
|
||||
SensorAction action) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensorAction = action;
|
||||
|
||||
@@ -53,7 +58,7 @@ public class ProximitySensor implements ScreenStateNotifier, SensorEventListener
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (mCMActionsSettings.isIrWakeupEnabled() && !mEnabled) {
|
||||
if (mLineageActionsSettings.isIrWakeupEnabled() && !mEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mEnabled = true;
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.doze;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,6 +24,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import org.lineageos.settings.device.actions.Constants;
|
||||
|
||||
public class ScreenReceiver extends BroadcastReceiver {
|
||||
private final ScreenStateNotifier mNotifier;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.doze;
|
||||
|
||||
interface ScreenStateNotifier {
|
||||
public interface ScreenStateNotifier {
|
||||
public void screenTurnedOn();
|
||||
public void screenTurnedOff();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cyanogenmod.settings.device;
|
||||
package org.lineageos.settings.device.doze;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
@@ -23,11 +24,15 @@ import android.util.Log;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
import org.lineageos.settings.device.LineageActionsSettings;
|
||||
import org.lineageos.settings.device.SensorAction;
|
||||
import org.lineageos.settings.device.SensorHelper;
|
||||
|
||||
public class StowSensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private static final String TAG = "CMActions-StowSensor";
|
||||
private static final String TAG = "LineageActions-StowSensor";
|
||||
private static final int IN_POCKET_MIN_TIME = 5000;
|
||||
|
||||
private final CMActionsSettings mCMActionsSettings;
|
||||
private final LineageActionsSettings mLineageActionsSettings;
|
||||
private final SensorHelper mSensorHelper;
|
||||
private final SensorAction mSensorAction;
|
||||
private final Sensor mSensor;
|
||||
@@ -36,9 +41,9 @@ public class StowSensor implements ScreenStateNotifier, SensorEventListener {
|
||||
private boolean mLastStowed;
|
||||
private long isStowedTime;
|
||||
|
||||
public StowSensor(CMActionsSettings cmActionsSettings, SensorHelper sensorHelper,
|
||||
public StowSensor(LineageActionsSettings lineageActionsSettings, SensorHelper sensorHelper,
|
||||
SensorAction action) {
|
||||
mCMActionsSettings = cmActionsSettings;
|
||||
mLineageActionsSettings = lineageActionsSettings;
|
||||
mSensorHelper = sensorHelper;
|
||||
mSensorAction = action;
|
||||
|
||||
@@ -56,8 +61,8 @@ public class StowSensor implements ScreenStateNotifier, SensorEventListener {
|
||||
|
||||
@Override
|
||||
public void screenTurnedOff() {
|
||||
if (!mCMActionsSettings.isIrWakeupEnabled() &&
|
||||
mCMActionsSettings.isPickUpEnabled() && !mEnabled) {
|
||||
if (!mLineageActionsSettings.isIrWakeupEnabled() &&
|
||||
mLineageActionsSettings.isPickUpEnabled() && !mEnabled) {
|
||||
Log.d(TAG, "Enabling");
|
||||
mSensorHelper.registerListener(mSensor, this);
|
||||
mEnabled = true;
|
||||
@@ -1,125 +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 org.cyanogenmod.internal.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class FileUtils {
|
||||
private static final String TAG = "FileUtils";
|
||||
|
||||
private FileUtils() {
|
||||
// This class is not supposed to be instantiated
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the first line of text from the given file.
|
||||
* Reference {@link BufferedReader#readLine()} for clarification on what a line is
|
||||
*
|
||||
* @return the read line contents, or null on failure
|
||||
*/
|
||||
public static String readOneLine(String fileName) {
|
||||
String line = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(fileName), 512);
|
||||
line = reader.readLine();
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(TAG, "No such file " + fileName + " for reading", e);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not read from file " + fileName, e);
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignored, not much we can do anyway
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given value into the given file
|
||||
*
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
public static boolean writeLine(String fileName, String value) {
|
||||
BufferedWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new BufferedWriter(new FileWriter(fileName));
|
||||
writer.write(value);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(TAG, "No such file " + fileName + " for writing", e);
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not write to file " + fileName, e);
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignored, not much we can do anyway
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given file exists
|
||||
*
|
||||
* @return true if exists, false if not
|
||||
*/
|
||||
public static boolean fileExists(String fileName) {
|
||||
final File file = new File(fileName);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given file is readable
|
||||
*
|
||||
* @return true if readable, false if not
|
||||
*/
|
||||
public static boolean isFileReadable(String fileName) {
|
||||
final File file = new File(fileName);
|
||||
return file.exists() && file.canRead();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given file is writable
|
||||
*
|
||||
* @return true if writable, false if not
|
||||
*/
|
||||
public static boolean isFileWritable(String fileName) {
|
||||
final File file = new File(fileName);
|
||||
return file.exists() && file.canWrite();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user