Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/input/WeekPickerDialog.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/MonthPickerDialog.java b/content/public/android/java/src/org/chromium/content/browser/input/WeekPickerDialog.java |
| similarity index 54% |
| copy from content/public/android/java/src/org/chromium/content/browser/input/MonthPickerDialog.java |
| copy to content/public/android/java/src/org/chromium/content/browser/input/WeekPickerDialog.java |
| index 354810e5e429662ca400284a90d5dcc54cf3a054..921ba19d1df7756463f9eb003f94062d714d586a 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/input/MonthPickerDialog.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/WeekPickerDialog.java |
| @@ -12,43 +12,43 @@ import android.os.Build; |
| import android.os.Bundle; |
| import android.view.View; |
| -import org.chromium.content.browser.input.MonthPicker.OnMonthChangedListener; |
| +import org.chromium.content.browser.input.WeekPicker.OnWeekChangedListener; |
| import org.chromium.content.R; |
| -public class MonthPickerDialog extends AlertDialog implements OnClickListener, |
| - OnMonthChangedListener { |
| +public class WeekPickerDialog extends AlertDialog implements OnClickListener, |
|
Miguel Garcia
2013/05/10 15:17:59
Same here (even more I think) both dialogs are ess
keishi
2013/05/14 13:47:47
Most of the methods have a week/month parameter so
Miguel Garcia
2013/05/17 11:23:38
I still don't understand what the problem is, just
keishi
2013/05/22 07:33:26
I've made the dialog base class by making the para
|
| + OnWeekChangedListener { |
| - private static final String YEAR = "year"; |
| - private static final String MONTH = "month"; |
| + private static final String WEEK_YEAR = "weekyear"; |
| + private static final String WEEK = "week"; |
| - private final MonthPicker mMonthPicker; |
| - private final OnMonthSetListener mCallBack; |
| + private final WeekPicker mWeekPicker; |
| + private final OnWeekSetListener mCallBack; |
| /** |
| * The callback used to indicate the user is done filling in the date. |
| */ |
| - public interface OnMonthSetListener { |
| + public interface OnWeekSetListener { |
| /** |
| * @param view The view associated with this listener. |
| * @param year The year that was set. |
| - * @param monthOfYear The month that was set (0-11) for compatibility |
| + * @param weekOfYear The week in year. |
| * with {@link java.util.Calendar}. |
| */ |
| - void onMonthSet(MonthPicker view, int year, int monthOfYear); |
| + void onWeekSet(WeekPicker view, int weekYear, int weekOfYear); |
| } |
| /** |
| * @param context The context the dialog is to run in. |
| * @param callBack How the parent is notified that the date is set. |
| * @param year The initial year of the dialog. |
| - * @param monthOfYear The initial month of the dialog. |
| + * @param weekOfYear The initial week of the dialog. |
| */ |
| - public MonthPickerDialog(Context context, |
| - OnMonthSetListener callBack, |
| - int year, |
| - int monthOfYear) { |
| - this(context, 0, callBack, year, monthOfYear); |
| + public WeekPickerDialog(Context context, |
| + OnWeekSetListener callBack, |
| + int weekYear, |
| + int weekOfYear) { |
| + this(context, 0, callBack, weekYear, weekOfYear); |
| } |
| /** |
| @@ -56,13 +56,13 @@ public class MonthPickerDialog extends AlertDialog implements OnClickListener, |
| * @param theme the theme to apply to this dialog |
| * @param callBack How the parent is notified that the date is set. |
| * @param year The initial year of the dialog. |
| - * @param monthOfYear The initial month of the dialog. |
| + * @param weekOfYear The initial week of the dialog. |
| */ |
| - public MonthPickerDialog(Context context, |
| + public WeekPickerDialog(Context context, |
| int theme, |
| - OnMonthSetListener callBack, |
| - int year, |
| - int monthOfYear) { |
| + OnWeekSetListener callBack, |
| + int weekYear, |
| + int weekOfYear) { |
| super(context, theme); |
| mCallBack = callBack; |
| @@ -72,23 +72,23 @@ public class MonthPickerDialog extends AlertDialog implements OnClickListener, |
| setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel), |
| (OnClickListener) null); |
| setIcon(0); |
| - setTitle(R.string.month_picker_dialog_title); |
| + setTitle(R.string.week_picker_dialog_title); |
| - mMonthPicker = new MonthPicker(context); |
| - setView(mMonthPicker); |
| - mMonthPicker.init(year, monthOfYear, this); |
| + mWeekPicker = new WeekPicker(context); |
| + setView(mWeekPicker); |
| + mWeekPicker.init(weekYear, weekOfYear, this); |
| } |
| @Override |
| public void onClick(DialogInterface dialog, int which) { |
| - tryNotifyMonthSet(); |
| + tryNotifyWeekSet(); |
| } |
| - private void tryNotifyMonthSet() { |
| + private void tryNotifyWeekSet() { |
| if (mCallBack != null) { |
| - mMonthPicker.clearFocus(); |
| - mCallBack.onMonthSet(mMonthPicker, mMonthPicker.getYear(), |
| - mMonthPicker.getMonth()); |
| + mWeekPicker.clearFocus(); |
| + mCallBack.onWeekSet(mWeekPicker, mWeekPicker.getWeekYear(), |
| + mWeekPicker.getWeek()); |
| } |
| } |
| @@ -99,48 +99,48 @@ public class MonthPickerDialog extends AlertDialog implements OnClickListener, |
| // Dismissing a dialog (by pressing back for example) |
| // applies the chosen date. This code is added here so that the custom |
| // pickers behave the same as the internal DatePickerDialog. |
| - tryNotifyMonthSet(); |
| + tryNotifyWeekSet(); |
| } |
| super.onStop(); |
| } |
| @Override |
| - public void onMonthChanged(MonthPicker view, int year, int month) { |
| - mMonthPicker.init(year, month, null); |
| + public void onWeekChanged(WeekPicker view, int weekYear, int week) { |
| + mWeekPicker.init(weekYear, week, null); |
| } |
| /** |
| - * Gets the {@link MonthPicker} contained in this dialog. |
| + * Gets the {@link WeekPicker} contained in this dialog. |
| * |
| * @return The calendar view. |
| */ |
| - public MonthPicker getMonthPicker() { |
| - return mMonthPicker; |
| + public WeekPicker getWeekPicker() { |
| + return mWeekPicker; |
| } |
| /** |
| * Sets the current date. |
| * |
| - * @param year The date year. |
| - * @param monthOfYear The date month. |
| + * @param weekYear The date week year. |
| + * @param weekOfYear The date week. |
| */ |
| - public void updateDate(int year, int monthOfYear) { |
| - mMonthPicker.updateMonth(year, monthOfYear); |
| + public void updateDate(int weekYear, int weekOfYear) { |
| + mWeekPicker.updateWeek(weekYear, weekOfYear); |
| } |
| @Override |
| public Bundle onSaveInstanceState() { |
| Bundle state = super.onSaveInstanceState(); |
| - state.putInt(YEAR, mMonthPicker.getYear()); |
| - state.putInt(MONTH, mMonthPicker.getMonth()); |
| + state.putInt(WEEK_YEAR, mWeekPicker.getWeekYear()); |
| + state.putInt(WEEK, mWeekPicker.getWeek()); |
| return state; |
| } |
| @Override |
| public void onRestoreInstanceState(Bundle savedInstanceState) { |
| super.onRestoreInstanceState(savedInstanceState); |
| - int year = savedInstanceState.getInt(YEAR); |
| - int month = savedInstanceState.getInt(MONTH); |
| - mMonthPicker.init(year, month, this); |
| + int weekYear = savedInstanceState.getInt(WEEK_YEAR); |
| + int week = savedInstanceState.getInt(WEEK); |
| + mWeekPicker.init(weekYear, week, this); |
| } |
| } |