use prefs-style layout for setup wizard date/time settings on non-xlarge screens
Adjusted the screen size test to fall back to phone version of DateTimeSettingsSetupWizard on large screens. I made the following changes from how the phone version works: 1. Some layout changes. (Tablet look, bigger margins.) 2. Use zone picker to select time zone. 3. Added isFirstRun boolean extra to hide the pref fields we don't need to see from setup wizard Furthermore, I made the following fixes to the existing phone flow (which had probably never yet been tried on a phone): 1. Added conditionals around access to some variables that only exist in the xlarge layout. 2. Implemented PreferenceFragment.OnPreferenceStartFragmentCallback in DateTimeSettingsSetupWizard in order to catch the user tapping on the timezone preference and show the time zone picker popup. (Note: for phones in ICS, we might want to launch the zone picker preferences style, like it would have been had this been a PreferenceActivity. Or maybe we should just create a separate DateTimeSettingsSetupWizardPhone activity that subclasses PreferencesActivity and doesn't need to play this trick.) Change-Id: Ib5774a005c9f44d730d86c13746d91eb712141cc
This commit is contained in:
@@ -60,6 +60,9 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
private static final int DIALOG_DATEPICKER = 0;
|
||||
private static final int DIALOG_TIMEPICKER = 1;
|
||||
|
||||
// have we been launched from the setup wizard?
|
||||
protected static final String EXTRA_IS_FIRST_RUN = "firstRun";
|
||||
|
||||
private CheckBoxPreference mAutoTimePref;
|
||||
private Preference mTimePref;
|
||||
private Preference mTime24Pref;
|
||||
@@ -81,15 +84,18 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
boolean autoTimeEnabled = getAutoState(Settings.System.AUTO_TIME);
|
||||
boolean autoTimeZoneEnabled = getAutoState(Settings.System.AUTO_TIME_ZONE);
|
||||
|
||||
Intent intent = getActivity().getIntent();
|
||||
boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
|
||||
|
||||
mDummyDate = Calendar.getInstance();
|
||||
mDummyDate.set(mDummyDate.get(Calendar.YEAR), 11, 31, 13, 0, 0);
|
||||
|
||||
mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
|
||||
mAutoTimePref.setChecked(autoTimeEnabled);
|
||||
mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE);
|
||||
// Override auto-timezone if it's a wifi-only device.
|
||||
// TODO: Remove this when auto-timezone is implemented based on wifi-location.
|
||||
if (Utils.isWifiOnly()) {
|
||||
// Override auto-timezone if it's a wifi-only device or if we're still in setup wizard.
|
||||
// TODO: Remove the wifiOnly test when auto-timezone is implemented based on wifi-location.
|
||||
if (Utils.isWifiOnly() || isFirstRun) {
|
||||
getPreferenceScreen().removePreference(mAutoTimeZonePref);
|
||||
autoTimeZoneEnabled = false;
|
||||
}
|
||||
@@ -100,6 +106,10 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
mTimeZone = findPreference("timezone");
|
||||
mDatePref = findPreference("date");
|
||||
mDateFormat = (ListPreference) findPreference(KEY_DATE_FORMAT);
|
||||
if (isFirstRun) {
|
||||
getPreferenceScreen().removePreference(mTime24Pref);
|
||||
getPreferenceScreen().removePreference(mDateFormat);
|
||||
}
|
||||
|
||||
String [] dateFormats = getResources().getStringArray(R.array.date_format_values);
|
||||
String [] formattedDates = new String[dateFormats.length];
|
||||
@@ -158,7 +168,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private void updateTimeAndDateDisplay(Context context) {
|
||||
public void updateTimeAndDateDisplay(Context context) {
|
||||
java.text.DateFormat shortDateFormat = DateFormat.getDateFormat(context);
|
||||
final Calendar now = Calendar.getInstance();
|
||||
Date dummyDate = mDummyDate.getTime();
|
||||
|
Reference in New Issue
Block a user