msm8937-common: Doze: Minor code simplification and clean up

Change-Id: Idff05f2626138c96dccd3ab4c26c4df1be40a606
This commit is contained in:
Bruno Martins 2018-04-08 15:18:44 +01:00 committed by Isaac Chen
parent f601f8c507
commit 3fcd6d5cc4
3 changed files with 9 additions and 22 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
* 2017 The LineageOS Project
* 2017-2018 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.
@ -25,9 +25,7 @@ import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.support.v14.preference.PreferenceFragment;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
@ -96,21 +94,15 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
boolean dozeEnabled = Utils.isDozeEnabled(getActivity());
mTextView = (TextView) view.findViewById(R.id.switch_text);
mTextView = view.findViewById(R.id.switch_text);
mTextView.setText(getString(dozeEnabled ?
R.string.switch_bar_on : R.string.switch_bar_off));
View switchBar = view.findViewById(R.id.switch_bar);
Switch switchWidget = (Switch) switchBar.findViewById(android.R.id.switch_widget);
Switch switchWidget = switchBar.findViewById(android.R.id.switch_widget);
switchWidget.setChecked(dozeEnabled);
switchWidget.setOnCheckedChangeListener(this);
switchBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchWidget.setChecked(!switchWidget.isChecked());
}
});
switchBar.setOnClickListener(v -> switchWidget.setChecked(!switchWidget.isChecked()));
}
@Override
@ -146,12 +138,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.doze_settings_help_title)
.setMessage(R.string.doze_settings_help_text)
.setNegativeButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
})
.setNegativeButton(R.string.dialog_ok, (dialog, which) -> dialog.cancel())
.create();
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2015 The CyanogenMod Project
* 2017 The LineageOS Project
* 2017-2018 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.
@ -44,7 +44,7 @@ public class ProximitySensor implements SensorEventListener {
public ProximitySensor(Context context) {
mContext = context;
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
mSensorManager = mContext.getSystemService(SensorManager.class);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2015 The CyanogenMod Project
* 2017 The LineageOS Project
* 2017-2018 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.
@ -41,7 +41,7 @@ public class TiltSensor implements SensorEventListener {
public TiltSensor(Context context) {
mContext = context;
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
mSensorManager = mContext.getSystemService(SensorManager.class);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TILT_DETECTOR);
}