+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="46.0dip"
- android:height="46.0dip"
- android:autoMirrored="true"
- android:viewportWidth="46.0"
- android:viewportHeight="46.0">
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M20,20m-19.5,0a19.5,19.5 0,1 1,39 0a19.5,19.5 0,1 1,-39 0" />
- <path android:fillColor="#00000000" android:pathData="M20.0003,20.0038m-16.3277,6.4349a17.55,17.55 113.49,1 1,32.6554 -12.8699a17.55,17.55 113.49,1 1,-32.6554 12.8699" android:strokeColor="#ff0bbbef" android:strokeWidth="0.28" android:strokeAlpha="0.0" android:fillAlpha="0.0" />
- <path android:fillColor="#00000000" android:pathData="M20.0003,20.0062m-6.4349,16.3277a17.55,17.55 66.51,1 1,12.8699 -32.6554a17.55,17.55 66.51,1 1,-12.8699 32.6554" android:strokeColor="#ff0bbbef" android:strokeWidth="0.28" android:strokeAlpha="0.0" android:fillAlpha="0.0" />
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M14.2,13.79c0.15,-0.13 0.27,-0.17 0.48,0A1.49,1.49 0,0 1,15.23 15a1.55,1.55 0,0 1,-0.27 0.88c-0.48,0.75 -1,1.54 -1.67,2.51a1.71,1.71 0,0 0,-0.35 1,1.36 1.36,0 0,0 0.17,0.64 1.48,1.48 0,0 0,1.41 0.73s-1.68,10.62 -4,10.53a5.17,5.17 0,0 1,-4.75 -4.49c-0.07,-0.7 -0.08,-1.4 -0.08,-2 0,-0.24 0,-0.47 0,-0.71v-0.85a3.42,3.42 0,0 1,1.13 -2.62c2,-1.86 4.07,-3.74 6.07,-5.56Z" />
- <path android:fillColor="#ffffffff" android:pathData="M4.59,24.73L4.59,24c0,-0.24 0,-0.48 0,-0.72v-0.11a4.56,4.56 0,0 1,1.48 -3.44c2,-1.86 4.08,-3.74 6.07,-5.56L13.46,13a1.4,1.4 0,0 1,1.92 0,2.59 2.59,0 0,1 0.94,2 2.72,2.72 0,0 1,-0.44 1.48c-0.48,0.75 -1,1.55 -1.69,2.53a0.71,0.71 0,0 0,-0.15 0.34,0.25 0.25,0 0,0 0,0.12c0,0.07 0.09,0.15 0.45,0.15 0,0 -1.69,12.81 -4,12.73a6.24,6.24 0,0 1,-5.8 -5.49C4.6,26.09 4.59,25.35 4.59,24.73ZM5.69,23.3L5.69,24c0,0.24 0,0.47 0,0.71 0,0.6 0,1.3 0.08,2a5.17,5.17 0,0 0,4.75 4.49c2.33,0.09 4,-10.53 4,-10.53A1.48,1.48 0,0 1,13.11 20a1.36,1.36 0,0 1,-0.17 -0.64,1.71 1.71,0 0,1 0.35,-1c0.66,-1 1.19,-1.76 1.67,-2.51a1.55,1.55 0,0 0,0.27 -0.88,1.49 1.49,0 0,0 -0.55,-1.17c-0.21,-0.18 -0.33,-0.14 -0.48,0L12.89,15c-2,1.82 -4.05,3.7 -6.07,5.56a3.42,3.42 0,0 0,-1.13 2.62Z" />
- <path android:fillColor="#ffffffff" android:pathData="M24.49,23.31m-1.05,0a1.05,1.05 0,1 1,2.1 0a1.05,1.05 0,1 1,-2.1 0" />
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M20,20.22l6.84,-0.29h0.07A1.61,1.61 0,0 1,27 23.15l-10.35,0.44Z" />
- <path android:fillColor="#ffffffff" android:pathData="M26.94,20.63a0.91,0.91 0,0 1,0 1.82l-7.07,0.3h0l-1.49,0.06 1.91,-1.91 6.57,-0.27h0m0,-1.4h-0.1l-6.57,0.28 -0.54,0 -0.39,0.38 -1.91,1.91L14.9,24.36l3.58,-0.15L20,24.14l7.07,-0.3a2.31,2.31 0,0 0,-0.1 -4.61Z" />
- <path android:fillColor="#ffffffff" android:pathData="M5.9285,25.595L19.0736,12.4499A2.11,2.11 90,0 1,22.0576 12.4499L27.5094,17.9017A2.11,2.11 90,0 1,27.5094 20.8857L14.3643,34.0308A2.11,2.11 90,0 1,11.3803 34.0308L5.9285,28.579A2.11,2.11 90,0 1,5.9285 25.595z" />
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M6.6909,26.0646l12.9047,-12.9047l7.1983,7.1983l-12.9047,12.9047z" />
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M20.11,29.48a1.58,1.58 0,0 1,-1.47 -1A1.6,1.6 0,0 1,19 26.75a1.74,1.74 0,0 1,1.12 -0.49l0.69,-0.06h0.1a1.65,1.65 0,0 1,1.62 1.26,1.62 1.62,0 0,1 -0.3,1.33 1.6,1.6 0,0 1,-1.2 0.63l-0.8,0.06Z" />
- <path android:fillColor="#ffffffff" android:pathData="M20.89,26.9a1,1 0,0 1,0.94 0.71A0.91,0.91 0,0 1,21 28.72l-0.83,0.07h0a0.9,0.9 0,0 1,-0.63 -1.54,0.93 0.93,0 0,1 0.65,-0.29l0.72,-0.06h0m0,-1.4h-0.16l-0.7,0.06a2.36,2.36 0,0 0,-1.54 0.69,2.3 2.3,0 0,0 1.62,3.92h0.15l0.81,-0.07a2.31,2.31 0,0 0,2.12 -2.8,2.35 2.35,0 0,0 -2.3,-1.81Z" />
- <path android:fillColor="#ff00a09b" android:pathData="M17.13,32.46A1.6,1.6 0,0 1,16 29.73a1.67,1.67 0,0 1,1.11 -0.49l0.69,-0.06h0.1a1.61,1.61 0,0 1,1.33 2.59,1.62 1.62,0 0,1 -1.21,0.62l-0.8,0.07Z" />
- <path android:fillColor="#ffffffff" android:pathData="M17.91,29.87a1,1 0,0 1,0.94 0.71A0.92,0.92 0,0 1,18 31.7l-0.82,0.06h-0.05a0.9,0.9 0,0 1,-0.63 -1.54,1 1,0 0,1 0.65,-0.28l0.72,-0.06h0m0,-1.39h-0.16l-0.69,0.06a2.34,2.34 0,0 0,-1.55 0.69,2.3 2.3,0 0,0 1.62,3.92h0.16l0.8,-0.06a2.29,2.29 0,0 0,1.7 -0.9,2.33 2.33,0 0,0 0.42,-1.91 2.35,2.35 0,0 0,-2.3 -1.8Z" />
- <path android:fillColor="?android:attr/colorAccent" android:pathData="M23.18,26.42a1.6,1.6 0,0 1,-1.13 -2.73,1.67 1.67,0 0,1 1.11,-0.49l0.69,-0.06H24a1.64,1.64 0,0 1,1.62 1.25,1.61 1.61,0 0,1 -0.29,1.34 1.62,1.62 0,0 1,-1.21 0.62l-0.8,0.07Z" />
- <path android:fillColor="#ffffffff" android:pathData="M24,23.83a0.94,0.94 0,0 1,0.94 0.71A0.92,0.92 0,0 1,24 25.66l-0.82,0.06h0a0.9,0.9 0,0 1,-0.64 -1.54,1 1,0 0,1 0.65,-0.28l0.72,-0.07h0m0,-1.39h-0.16l-0.69,0.06a2.31,2.31 0,0 0,-1.54 0.69,2.3 2.3,0 0,0 1.62,3.92h0.15l0.8,-0.06a2.33,2.33 0,0 0,1.7 -0.9,2.29 2.29,0 0,0 0.42,-1.91 2.34,2.34 0,0 0,-2.3 -1.8Z" />
- <path android:strokeColor="@color/quick" android:pathData="M29.44,16.46a1,1 0,0 1,-0.53 -0.15A26.91,26.91 0,0 1,24.82 13c-2.7,-2.63 -4.82,-6.46 -3.54,-8 0.74,-0.92 2,-0.79 3.78,0.38A1,1 0,1 1,24 7a5.43,5.43 0,0 0,-1.09 -0.58,11.45 11.45,0 0,0 3.32,5.18 23.86,23.86 0,0 0,3.78 3,1 1,0 0,1 0.3,1.37A1,1 0,0 1,29.44 16.46Z" />
- <path android:pathData="M34.25,18.78a6.07,6.07 0,0 1,-1.57 -0.23,1 1,0 1,1 0.52,-1.92 3.44,3.44 0,0 0,1.23 0.17c0,-0.55 -0.83,-2.31 -3.33,-5a22.89,22.89 0,0 0,-3.92 -3.41,1 1,0 0,1 1.09,-1.65 24.54,24.54 0,0 1,4.28 3.71c4,4.36 4.18,6.45 3.59,7.43A2,2 0,0 1,34.25 18.78Z" />
-</vector>
+++ /dev/null
-/*
- * 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.app.KeyguardManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.PowerManager;
-import android.os.UserHandle;
-import android.os.VibrationEffect;
-import android.os.Vibrator;
-import android.provider.MediaStore;
-
-import org.lineageos.settings.device.SensorAction;
-
-import java.util.List;
-
-public class CameraActivationAction implements SensorAction {
- private static final String TAG = "CameraActivationAction";
-
- private static final int TURN_SCREEN_ON_WAKE_LOCK_MS = 500;
-
- private final Context mContext;
- private final KeyguardManager mKeyguardManager;
- private final PackageManager mPackageManager;
- private final PowerManager mPowerManager;
- private final PowerManager.WakeLock mScreenWakelock;
-
- public CameraActivationAction(Context context) {
- mContext = context;
- mKeyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
- mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
- mPackageManager = context.getPackageManager();
- mScreenWakelock = mPowerManager.newWakeLock(
- PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
- TAG + ":Wakelock");
- }
-
- @Override
- public void action() {
- vibrate();
- turnScreenOn();
- if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
- launchSecureCamera();
- } else {
- launchCamera();
- }
- }
-
- private void vibrate() {
- Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
- v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
- }
-
- private void turnScreenOn() {
- mScreenWakelock.acquire(TURN_SCREEN_ON_WAKE_LOCK_MS);
- }
-
- private void launchCamera() {
- Intent intent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- if (getBestActivityInfo(intent) != null) {
- // Only launch if we can succeed, but let the user pick the action
- mContext.startActivityAsUser(intent, UserHandle.CURRENT);
- }
- }
-
- private void launchSecureCamera() {
- // Keyguard won't allow a picker, try to pick the secure intent in the package
- // that would be the one used for a default action of launching the camera
- Intent normalIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- Intent secureIntent = createIntent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE);
- ActivityInfo normalActivity = getBestActivityInfo(normalIntent);
- ActivityInfo secureActivity = getBestActivityInfo(secureIntent, normalActivity);
- if (secureActivity != null) {
- secureIntent.setComponent(componentName(secureActivity));
- mContext.startActivityAsUser(secureIntent, UserHandle.CURRENT);
- }
- }
-
- private Intent createIntent(String intentName) {
- Intent intent = new Intent(intentName);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
- return intent;
- }
-
- private ActivityInfo getBestActivityInfo(Intent intent) {
- ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
- if (resolveInfo != null) {
- return resolveInfo.activityInfo;
- } else {
- // If the resolving failed, just find our own best match
- return getBestActivityInfo(intent, null);
- }
- }
-
- private ActivityInfo getBestActivityInfo(Intent intent, ActivityInfo match) {
- List<ResolveInfo> 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);
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}