Use FooterPreference in xml explicitly
We don't rely on FooterPreferenceMixinCompat to create footer preference in dashboard fragment. Instead, declare a FooterPreference explicitly in xml of screen. It makes more sense for our referenceController design. Test: visual, robotest Bug: 124129485 Change-Id: I0b0c0f9e38d85aa89b815ce2b84ddff30a1d206b
This commit is contained in:
@@ -29,20 +29,19 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TimeZoneInfoPreferenceController extends BaseTimeZonePreferenceController {
|
||||
public class TimeZoneInfoPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String PREFERENCE_KEY = FooterPreference.KEY_FOOTER;
|
||||
@VisibleForTesting
|
||||
Date mDate;
|
||||
private TimeZoneInfo mTimeZoneInfo;
|
||||
private final DateFormat mDateFormat;
|
||||
|
||||
public TimeZoneInfoPreferenceController(Context context) {
|
||||
super(context, PREFERENCE_KEY);
|
||||
public TimeZoneInfoPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mDateFormat = DateFormat.getDateInstance(SimpleDateFormat.LONG);
|
||||
mDateFormat.setContext(DisplayContext.CAPITALIZATION_NONE);
|
||||
mDate = new Date();
|
||||
@@ -50,24 +49,18 @@ public class TimeZoneInfoPreferenceController extends BaseTimeZonePreferenceCont
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
return mTimeZoneInfo != null ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
CharSequence formattedTimeZone = mTimeZoneInfo == null ? "" : formatInfo(mTimeZoneInfo);
|
||||
preference.setTitle(formattedTimeZone);
|
||||
preference.setVisible(mTimeZoneInfo != null);
|
||||
public CharSequence getSummary() {
|
||||
return mTimeZoneInfo == null ? "" : formatInfo(mTimeZoneInfo);
|
||||
}
|
||||
|
||||
public void setTimeZoneInfo(TimeZoneInfo timeZoneInfo) {
|
||||
mTimeZoneInfo = timeZoneInfo;
|
||||
}
|
||||
|
||||
public TimeZoneInfo getTimeZoneInfo() {
|
||||
return mTimeZoneInfo;
|
||||
}
|
||||
|
||||
private CharSequence formatOffsetAndName(TimeZoneInfo item) {
|
||||
String name = item.getGenericName();
|
||||
if (name == null) {
|
||||
@@ -130,5 +123,4 @@ public class TimeZoneInfoPreferenceController extends BaseTimeZonePreferenceCont
|
||||
} while (transition != null);
|
||||
return transition;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user