Time picker style preference implemented

This commit is contained in:
Phillip Hsu 2016-07-25 14:28:26 -07:00
parent 6f2adb6eb1
commit 6585cca738
2 changed files with 25 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
@ -321,14 +322,23 @@ public class EditAlarmActivity extends BaseActivity implements
// If we keep a reference to the dialog, we keep its previous state as well. // If we keep a reference to the dialog, we keep its previous state as well.
// So the next time we call show() on it, the input field will show the // So the next time we call show() on it, the input field will show the
// last inputted time. // last inputted time.
// TODO: Read preferences to see what time picker style to show. BaseTimePickerDialog dialog = null;
BaseTimePickerDialog dialog; String numpadStyle = getString(R.string.number_pad);
dialog = NumberGridTimePickerDialog.newInstance( String gridStyle = getString(R.string.grid_selector);
this, // OnTimeSetListener String prefTimePickerStyle = PreferenceManager.getDefaultSharedPreferences(this).getString(
0, // Initial hour of day // key for the preference value to retrieve
0, // Initial minute getString(R.string.key_time_picker_style),
DateFormat.is24HourFormat(this)); // default value
// dialog = NumpadTimePickerDialog.newInstance(this); numpadStyle);
if (prefTimePickerStyle.equals(numpadStyle)) {
dialog = NumpadTimePickerDialog.newInstance(this);
} else if (prefTimePickerStyle.equals(gridStyle)) {
dialog = NumberGridTimePickerDialog.newInstance(
this, // OnTimeSetListener
0, // Initial hour of day
0, // Initial minute
DateFormat.is24HourFormat(this));
}
dialog.show(getSupportFragmentManager(), TAG_TIME_PICKER); dialog.show(getSupportFragmentManager(), TAG_TIME_PICKER);
} }

View File

@ -5,11 +5,15 @@
<!-- Time picker style --> <!-- Time picker style -->
<string name="key_time_picker_style">key_time_picker_style</string> <string name="key_time_picker_style">key_time_picker_style</string>
<string name="title_time_picker_style">Time picker style</string> <string name="title_time_picker_style">Time picker style</string>
<string name="number_pad">Number pad</string> <!-- Internally, we refer to this picker as a numpad because it's concise.
<string name="radial_clock">Radial clock</string> However, "numeric keypad" is more descriptive when describing the style to users. -->
<string name="number_pad">Numeric keypad</string>
<!--<string name="radial_clock">Radial clock</string>-->
<string name="grid_selector">Grid selector</string>
<string-array name="array_time_picker_styles"> <string-array name="array_time_picker_styles">
<item>@string/number_pad</item> <item>@string/number_pad</item>
<item>@string/radial_clock</item> <!--<item>@string/radial_clock</item>-->
<item>@string/grid_selector</item>
</string-array> </string-array>
<!-- Silence after --> <!-- Silence after -->