Add icon to current screen saver preference

The screen saver setting is coming from different apps to modify
their options. This will confuse people that they were modifying
something in Settings rather than in other apps. To improve that,
we added an icon of active dream and put it on the left side of
current screen saver setting, which is to let people clearer to
know that they were modifying the options in other apps.

Bug: 129994275
Test: robotests
Change-Id: I014c9de745044c2bd39d22782b6c36f8605d8f56
This commit is contained in:
Mill Chen
2020-04-25 02:25:48 +08:00
parent 6fcac1d389
commit c91a8bce5b

View File

@@ -20,8 +20,10 @@ import android.content.Context;
import androidx.preference.Preference;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.widget.GearPreference;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.dream.DreamBackend;
import com.android.settingslib.dream.DreamBackend.DreamInfo;
@@ -45,6 +47,7 @@ public class CurrentDreamPreferenceController extends BasePreferenceController {
public void updateState(Preference preference) {
super.updateState(preference);
setGearClickListenerForPreference(preference);
setActiveDreamIcon(preference);
}
@Override
@@ -78,4 +81,13 @@ public class CurrentDreamPreferenceController extends BasePreferenceController {
.filter((info) -> info.isActive)
.findFirst();
}
private void setActiveDreamIcon(Preference preference) {
if (!(preference instanceof GearPreference)) {
return;
}
final GearPreference gearPref = (GearPreference) preference;
gearPref.setIconSize(RestrictedPreference.ICON_SIZE_SMALL);
Utils.setSafeIcon(gearPref, mBackend.getActiveIcon());
}
}