Actions: Robustify

* Use not deprecated APIs where possible
* Added some NPE safety checks
* General cleaning of unsed code
This commit is contained in:
Alberto97
2018-11-17 13:32:04 +01:00
committed by Jorge Lucas
parent d70a65507e
commit 0f4d87a6d9
24 changed files with 85 additions and 114 deletions

View File

@@ -30,7 +30,7 @@ import com.moto.actions.actions.UpdatedStateNotifier;
import com.moto.actions.actions.CameraActivationAction;
import com.moto.actions.actions.TorchAction;
public class MotoActionsSettings {
public class MotoActionsSettings implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "MotoActions";
private static final String GESTURE_CAMERA_ACTION_KEY = "gesture_camera_action";
@@ -55,7 +55,7 @@ public class MotoActionsSettings {
public MotoActionsSettings(Context context, UpdatedStateNotifier updatedStateNotifier) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
loadPreferences(sharedPrefs);
sharedPrefs.registerOnSharedPreferenceChangeListener(mPrefListener);
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
mContext = context;
mUpdatedStateNotifier = updatedStateNotifier;
}
@@ -114,8 +114,6 @@ public class MotoActionsSettings {
mLiftToSilenceEnabled = sharedPreferences.getBoolean(GESTURE_LIFT_TO_SILENCE_KEY, false);
}
private SharedPreferences.OnSharedPreferenceChangeListener mPrefListener =
new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
boolean updated = true;
@@ -146,5 +144,4 @@ public class MotoActionsSettings {
mUpdatedStateNotifier.updateState();
}
}
};
}