sdm710-common: Doze: Minor code simplification and clean up
Change-Id: Idff05f2626138c96dccd3ab4c26c4df1be40a606
This commit is contained in:
parent
a7e74415e0
commit
2f05326436
3 changed files with 9 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The CyanogenMod Project
|
* 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");
|
* 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.
|
||||||
|
@ -25,9 +25,7 @@ import android.app.DialogFragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.ContentObserver;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.support.v14.preference.PreferenceFragment;
|
import android.support.v14.preference.PreferenceFragment;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
@ -96,21 +94,15 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
|
||||||
|
|
||||||
boolean dozeEnabled = Utils.isDozeEnabled(getActivity());
|
boolean dozeEnabled = Utils.isDozeEnabled(getActivity());
|
||||||
|
|
||||||
mTextView = (TextView) view.findViewById(R.id.switch_text);
|
mTextView = view.findViewById(R.id.switch_text);
|
||||||
mTextView.setText(getString(dozeEnabled ?
|
mTextView.setText(getString(dozeEnabled ?
|
||||||
R.string.switch_bar_on : R.string.switch_bar_off));
|
R.string.switch_bar_on : R.string.switch_bar_off));
|
||||||
|
|
||||||
View switchBar = view.findViewById(R.id.switch_bar);
|
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.setChecked(dozeEnabled);
|
||||||
switchWidget.setOnCheckedChangeListener(this);
|
switchWidget.setOnCheckedChangeListener(this);
|
||||||
|
switchBar.setOnClickListener(v -> switchWidget.setChecked(!switchWidget.isChecked()));
|
||||||
switchBar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switchWidget.setChecked(!switchWidget.isChecked());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,12 +138,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.doze_settings_help_title)
|
.setTitle(R.string.doze_settings_help_title)
|
||||||
.setMessage(R.string.doze_settings_help_text)
|
.setMessage(R.string.doze_settings_help_text)
|
||||||
.setNegativeButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.dialog_ok, (dialog, which) -> dialog.cancel())
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015 The CyanogenMod Project
|
* 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");
|
* 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.
|
||||||
|
@ -44,7 +44,7 @@ public class ProximitySensor implements SensorEventListener {
|
||||||
|
|
||||||
public ProximitySensor(Context context) {
|
public ProximitySensor(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = mContext.getSystemService(SensorManager.class);
|
||||||
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
|
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015 The CyanogenMod Project
|
* 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");
|
* 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.
|
||||||
|
@ -41,7 +41,7 @@ public class TiltSensor implements SensorEventListener {
|
||||||
|
|
||||||
public TiltSensor(Context context) {
|
public TiltSensor(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = mContext.getSystemService(SensorManager.class);
|
||||||
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TILT_DETECTOR);
|
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TILT_DETECTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue