Search in sources :

Example 1 with TimePickerDialog

use of android.app.TimePickerDialog in project qksms by moezbhatti.

the class TimePickerFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mPreference == null) {
        Log.w(TAG, "No preference set");
        return null;
    }
    mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();
    try {
        Date date = simpleDateFormat.parse(mPrefs.getString(mPreference.getKey(), "6:00"));
        c.setTime(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity());
    return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
Also used : Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with TimePickerDialog

use of android.app.TimePickerDialog in project android_frameworks_base by ParanoidAndroid.

the class TimeDialogActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout layout = new FrameLayout(this);
    Button b = new Button(this);
    b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    b.setText("Show dialog");
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new TimePickerDialog(TimeDialogActivity.this, null, 12, 12, true).show();
        }
    });
    layout.addView(b);
    setContentView(layout);
}
Also used : Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) TimePickerDialog(android.app.TimePickerDialog) View(android.view.View)

Example 3 with TimePickerDialog

use of android.app.TimePickerDialog in project Etar-Calendar by Etar-Group.

the class OtherPreferences method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    PreferenceManager manager = getPreferenceManager();
    manager.setSharedPreferencesName(SHARED_PREFS_NAME);
    SharedPreferences prefs = manager.getSharedPreferences();
    addPreferencesFromResource(R.xml.other_preferences);
    mCopyDb = findPreference(KEY_OTHER_COPY_DB);
    mSkipReminders = (ListPreference) findPreference(KEY_OTHER_REMINDERS_RESPONDED);
    String skipPreferencesValue = null;
    if (mSkipReminders != null) {
        skipPreferencesValue = mSkipReminders.getValue();
        mSkipReminders.setOnPreferenceChangeListener(this);
    }
    updateSkipRemindersSummary(skipPreferencesValue);
    Activity activity = getActivity();
    if (activity == null) {
        Log.d(TAG, "Activity was null");
    }
    mIs24HourMode = DateFormat.is24HourFormat(activity);
    mQuietHours = (CheckBoxPreference) findPreference(KEY_OTHER_QUIET_HOURS);
    int startHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_HOUR, QUIET_HOURS_DEFAULT_START_HOUR);
    int startMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_MINUTE, QUIET_HOURS_DEFAULT_START_MINUTE);
    mQuietHoursStart = findPreference(KEY_OTHER_QUIET_HOURS_START);
    mQuietHoursStartListener = new TimeSetListener(START_LISTENER);
    mQuietHoursStartDialog = new TimePickerDialog(activity, mQuietHoursStartListener, startHour, startMinute, mIs24HourMode);
    mQuietHoursStart.setSummary(formatTime(startHour, startMinute));
    int endHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_HOUR, QUIET_HOURS_DEFAULT_END_HOUR);
    int endMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_MINUTE, QUIET_HOURS_DEFAULT_END_MINUTE);
    mQuietHoursEnd = findPreference(KEY_OTHER_QUIET_HOURS_END);
    mQuietHoursEndListener = new TimeSetListener(END_LISTENER);
    mQuietHoursEndDialog = new TimePickerDialog(activity, mQuietHoursEndListener, endHour, endMinute, mIs24HourMode);
    mQuietHoursEnd.setSummary(formatTime(endHour, endMinute));
}
Also used : SharedPreferences(android.content.SharedPreferences) Activity(android.app.Activity) TimePickerDialog(android.app.TimePickerDialog) PreferenceManager(android.preference.PreferenceManager)

Example 4 with TimePickerDialog

use of android.app.TimePickerDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DateTimeSettings method onCreateDialog.

@Override
public Dialog onCreateDialog(int id) {
    final Calendar calendar = Calendar.getInstance();
    switch(id) {
        case DIALOG_DATEPICKER:
            DatePickerDialog d = new DatePickerDialog(getActivity(), this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
            configureDatePicker(d.getDatePicker());
            return d;
        case DIALOG_TIMEPICKER:
            return new TimePickerDialog(getActivity(), this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(getActivity()));
        default:
            throw new IllegalArgumentException();
    }
}
Also used : DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog)

Example 5 with TimePickerDialog

use of android.app.TimePickerDialog in project chromeview by pwnall.

the class InputDialogContainer method showDialog.

void showDialog(final int dialogType, int year, int month, int monthDay, int hour, int minute, int second) {
    if (isDialogShowing())
        mDialog.dismiss();
    Time time = normalizeTime(year, month, monthDay, hour, minute, second);
    if (dialogType == sTextInputTypeDate) {
        mDialog = new DatePickerDialog(mContext, new DateListener(dialogType), time.year, time.month, time.monthDay);
        mDialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
    } else if (dialogType == sTextInputTypeTime) {
        mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType), time.hour, time.minute, DateFormat.is24HourFormat(mContext));
    } else if (dialogType == sTextInputTypeDateTime || dialogType == sTextInputTypeDateTimeLocal) {
        mDialog = new DateTimePickerDialog(mContext, new DateTimeListener(dialogType), time.year, time.month, time.monthDay, time.hour, time.minute, DateFormat.is24HourFormat(mContext));
    } else if (dialogType == sTextInputTypeMonth) {
        mDialog = new MonthPickerDialog(mContext, new MonthListener(dialogType), time.year, time.month);
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.date_picker_dialog_set), (DialogInterface.OnClickListener) mDialog);
    mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getText(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDialogAlreadyDismissed = true;
            mInputActionDelegate.cancelDateTimeDialog();
        }
    });
    mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getText(R.string.date_picker_dialog_clear), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDialogAlreadyDismissed = true;
            mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0, 0, 0, 0);
        }
    });
    mDialogAlreadyDismissed = false;
    mDialog.show();
}
Also used : DatePickerDialog(android.app.DatePickerDialog) DialogInterface(android.content.DialogInterface) Time(android.text.format.Time) TimePickerDialog(android.app.TimePickerDialog)

Aggregations

TimePickerDialog (android.app.TimePickerDialog)66 TimePicker (android.widget.TimePicker)30 Calendar (java.util.Calendar)26 View (android.view.View)23 TextView (android.widget.TextView)16 DatePickerDialog (android.app.DatePickerDialog)15 DialogInterface (android.content.DialogInterface)12 Context (android.content.Context)11 AlertDialog (android.app.AlertDialog)9 Button (android.widget.Button)8 CompoundButton (android.widget.CompoundButton)8 Bundle (android.os.Bundle)7 DatePicker (android.widget.DatePicker)6 LocalTime (java.time.LocalTime)6 Intent (android.content.Intent)5 FrameLayout (android.widget.FrameLayout)5 Date (java.util.Date)5 SuppressLint (android.annotation.SuppressLint)4 Nullable (android.support.annotation.Nullable)4 LinearLayout (android.widget.LinearLayout)4