Polish some behaviors of the battery saver schedule screen

This CL removes the line that was showing between the radio
buttons and the seek bar. Additionally it makes it so the seekbar
updates continuously as a user moves it and fixes a visual bug
where it would show 5% regardless of what the user had set it to
when exiting then re-entering the screen.

Test: visual
Change-Id: Icdb9cafe2bdda03d94230d1c8538f4c322b050e9
Fixes: 121388626
Fixes: 121211075
This commit is contained in:
Salvador Martinez
2019-01-08 13:51:45 -08:00
parent 6498d8f621
commit cd365b6533
2 changed files with 18 additions and 4 deletions

View File

@@ -54,9 +54,11 @@ public class BatterySaverScheduleSeekBarController implements
mContext = context;
mSeekBarPreference = new SeekBarPreference(context);
mSeekBarPreference.setOnPreferenceChangeListener(this);
mSeekBarPreference.setMax(BatterySaverScheduleSeekBarController.MAX_SEEKBAR_VALUE);
mSeekBarPreference.setMin(BatterySaverScheduleSeekBarController.MIN_SEEKBAR_VALUE);
mSeekBarPreference.setContinuousUpdates(true);
mSeekBarPreference.setMax(MAX_SEEKBAR_VALUE);
mSeekBarPreference.setMin(MIN_SEEKBAR_VALUE);
mSeekBarPreference.setKey(KEY_BATTERY_SAVER_SEEK_BAR);
updateSeekBar();
}
@Override
@@ -83,11 +85,12 @@ public class BatterySaverScheduleSeekBarController implements
if (threshold <= 0) {
mSeekBarPreference.setVisible(false);
} else {
final int currentSeekbarValue = Math.max(threshold / 5, MIN_SEEKBAR_VALUE);
mSeekBarPreference.setVisible(true);
mSeekBarPreference.setProgress(MIN_SEEKBAR_VALUE);
mSeekBarPreference.setProgress(currentSeekbarValue);
mSeekBarPreference.setTitle(mContext.getString(
R.string.battery_saver_seekbar_title,
Utils.formatPercentage(MIN_SEEKBAR_VALUE * 5)));
Utils.formatPercentage(currentSeekbarValue * 5)));
}
} else {
mSeekBarPreference.setVisible(false);

View File

@@ -17,10 +17,14 @@
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settings.R;
@@ -58,6 +62,13 @@ public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
context, mSeekBarController);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setDivider(new ColorDrawable(Color.TRANSPARENT));
setDividerHeight(0);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);