Only show the schedule text for the night display and dark theme

In Android S design, night display and dark theme only show
schedule text for summary.

- Rmove redundant string resource.
- Remove redundant method in night display formatter.
- Refactor the code in dark mode preference and night display
controller.

Test: See the correct behavior in screen.
Fix: 174964139
Change-Id: I658b3073a0a6ed83f589103999c711e5430eaeb7
This commit is contained in:
Tsung-Mao Fang
2021-01-07 15:41:26 +08:00
parent cfedc19ab9
commit acab1a0364
4 changed files with 15 additions and 24 deletions

View File

@@ -17,6 +17,7 @@ import android.content.Context;
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.NightDisplayListener;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -32,6 +33,7 @@ public class NightDisplayPreferenceController extends TogglePreferenceController
private final ColorDisplayManager mColorDisplayManager;
private final NightDisplayListener mNightDisplayListener;
private final NightDisplayTimeFormatter mTimeFormatter;
private PrimarySwitchPreference mPreference;
public NightDisplayPreferenceController(Context context, String key) {
@@ -39,6 +41,7 @@ public class NightDisplayPreferenceController extends TogglePreferenceController
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
mNightDisplayListener = new NightDisplayListener(context);
mTimeFormatter = new NightDisplayTimeFormatter(context);
}
public static boolean isSuggestionComplete(Context context) {
@@ -86,6 +89,12 @@ public class NightDisplayPreferenceController extends TogglePreferenceController
return mColorDisplayManager.setNightDisplayActivated(isChecked);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
preference.setSummary(mTimeFormatter.getAutoModeSummary(mContext, mColorDisplayManager));
}
@Override
public void onActivated(boolean activated) {
updateState(mPreference);