import android.app.ActionBar;
import android.os.Bundle;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragment;
import androidx.preference.SwitchPreference;
import android.text.TextUtils;
import android.view.MenuItem;
+import org.lineageos.settings.device.actions.CameraActivationSensor;
+
import java.io.File;
public class ActionsPreferenceFragment extends PreferenceFragment {
+ private final String KEY_ACTIONS_CATEGORY = "actions_key";
+ private final String KEY_GESTURE_CAMERA_ACTION = "gesture_camera_action";
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.actions_panel);
final ActionBar actionBar = getActivity().getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
+
+ if (!CameraActivationSensor.hasSensor(getContext())) {
+ PreferenceCategory category = findPreference(KEY_ACTIONS_CATEGORY);
+ category.removePreferenceRecursively(KEY_GESTURE_CAMERA_ACTION);
+ }
}
@Override
/*
* Copyright (c) 2015 The CyanogenMod Project
- * Copyright (c) 2017 The LineageOS Project
+ * Copyright (c) 2017-2020 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.
import java.util.List;
+import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
+
+ public static boolean hasSensor(Context context) {
+ SensorHelper sensorHelper = new SensorHelper(context);
+ return sensorHelper.getCameraActivationSensor() != null;
+ }
}