From 2e86ad1f91473600d87929d64f2701d387292503 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Fri, 28 Oct 2022 18:38:55 +0800 Subject: [PATCH] MotoActions: Drop camera activation action AOSP has exact the same built-in feature. Change-Id: Ib508cddc74498a3eba507e1b1962c53c7b591e6e --- .../res/drawable/ic_settings_twist.xml | 26 ---- MotoActions/res/xml/actions_panel.xml | 7 - .../device/ActionsPreferenceFragment.java | 8 - .../settings/device/MotoActionsService.java | 2 - .../settings/device/MotoActionsSettings.java | 16 +- .../settings/device/SensorHelper.java | 5 - .../actions/CameraActivationAction.java | 137 ------------------ .../actions/CameraActivationSensor.java | 70 --------- 8 files changed, 1 insertion(+), 270 deletions(-) delete mode 100644 MotoActions/res/drawable/ic_settings_twist.xml delete mode 100644 MotoActions/src/org/lineageos/settings/device/actions/CameraActivationAction.java delete mode 100644 MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java diff --git a/MotoActions/res/drawable/ic_settings_twist.xml b/MotoActions/res/drawable/ic_settings_twist.xml deleted file mode 100644 index f04e77f..0000000 --- a/MotoActions/res/drawable/ic_settings_twist.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/MotoActions/res/xml/actions_panel.xml b/MotoActions/res/xml/actions_panel.xml index c4ced85..edf7056 100644 --- a/MotoActions/res/xml/actions_panel.xml +++ b/MotoActions/res/xml/actions_panel.xml @@ -22,13 +22,6 @@ - - activities = mPackageManager.queryIntentActivities(intent, 0); - ActivityInfo best = null; - if (activities.size() > 0) { - best = activities.get(0).activityInfo; - if (match != null) { - String packageName = match.applicationInfo.packageName; - for (int i = activities.size() - 1; i >= 0; i--) { - ActivityInfo activityInfo = activities.get(i).activityInfo; - if (packageName.equals(activityInfo.applicationInfo.packageName)) { - best = activityInfo; - } - } - } - } - return best; - } - - private ComponentName componentName(ActivityInfo activity) { - return new ComponentName(activity.applicationInfo.packageName, activity.name); - } -} diff --git a/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java b/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java deleted file mode 100644 index 847777c..0000000 --- a/MotoActions/src/org/lineageos/settings/device/actions/CameraActivationSensor.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015 The CyanogenMod Project - * Copyright (c) 2017-2022 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. - * 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.lineageos.settings.device.actions; - -import android.content.Context; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.util.Log; - -import org.lineageos.settings.device.MotoActionsSettings; -import org.lineageos.settings.device.SensorHelper; - -public class CameraActivationSensor implements SensorEventListener, UpdatedStateNotifier { - private static final String TAG = "MotoActions-CameraSensor"; - - private final MotoActionsSettings mMotoActionsSettings; - - private boolean mIsEnabled; - - public CameraActivationSensor(MotoActionsSettings motoActionsSettings, - SensorHelper sensorHelper) { - mMotoActionsSettings = motoActionsSettings; - Sensor sensor = sensorHelper.getCameraActivationSensor(); - sensorHelper.registerListener(sensor, this); - } - - @Override - public synchronized void updateState() { - if (mMotoActionsSettings.isCameraGestureEnabled() && !mIsEnabled) { - Log.d(TAG, "Enabling"); - mIsEnabled = true; - } else if (!mMotoActionsSettings.isCameraGestureEnabled() && mIsEnabled) { - Log.d(TAG, "Disabling"); - mIsEnabled = false; - } - } - - @Override - public void onSensorChanged(SensorEvent event) { - Log.d(TAG, "activate camera"); - if (mIsEnabled) { - mMotoActionsSettings.cameraAction(); - } - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - public static boolean hasSensor(Context context) { - SensorHelper sensorHelper = new SensorHelper(context); - return sensorHelper.getCameraActivationSensor() != null; - } -} -- 2.20.1