MotoActions: Don't show preference for non existing sensor
* Looks like some variants don't have a CameraActivationSensor, so let's remove the preference as the user's choice won't have an effect anyway Change-Id: I7d157a992a6cb9ee333752772bc5e3b647b614f2
This commit is contained in:
parent
9ccc54c3d2
commit
3cffd7470f
@ -20,20 +20,31 @@ package org.lineageos.settings.device;
|
|||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceFragment;
|
import androidx.preference.PreferenceFragment;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import org.lineageos.settings.device.actions.CameraActivationSensor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class ActionsPreferenceFragment extends PreferenceFragment {
|
public class ActionsPreferenceFragment extends PreferenceFragment {
|
||||||
|
|
||||||
|
private final String KEY_ACTIONS_CATEGORY = "actions_key";
|
||||||
|
private final String KEY_GESTURE_CAMERA_ACTION = "gesture_camera_action";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
addPreferencesFromResource(R.xml.actions_panel);
|
addPreferencesFromResource(R.xml.actions_panel);
|
||||||
final ActionBar actionBar = getActivity().getActionBar();
|
final ActionBar actionBar = getActivity().getActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
if (!CameraActivationSensor.hasSensor(getContext())) {
|
||||||
|
PreferenceCategory category = findPreference(KEY_ACTIONS_CATEGORY);
|
||||||
|
category.removePreferenceRecursively(KEY_GESTURE_CAMERA_ACTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015 The CyanogenMod Project
|
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,6 +19,7 @@ package org.lineageos.settings.device.actions;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
@ -67,4 +68,9 @@ public class CameraActivationSensor implements SensorEventListener, UpdatedState
|
|||||||
@Override
|
@Override
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasSensor(Context context) {
|
||||||
|
SensorHelper sensorHelper = new SensorHelper(context);
|
||||||
|
return sensorHelper.getCameraActivationSensor() != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user