OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.content.DialogInterface.OnClickListener; | 10 import android.content.DialogInterface.OnClickListener; |
11 import android.os.Build; | 11 import android.os.Build; |
12 import android.os.Bundle; | 12 import android.os.Bundle; |
13 import android.view.LayoutInflater; | 13 import android.view.LayoutInflater; |
14 import android.view.View; | 14 import android.view.View; |
15 | 15 |
16 import org.chromium.content.app.AppResource; | |
17 import org.chromium.content.browser.MonthPicker.OnMonthChangedListener; | 16 import org.chromium.content.browser.MonthPicker.OnMonthChangedListener; |
| 17 import org.chromium.content.R; |
18 | 18 |
19 public class MonthPickerDialog extends AlertDialog implements OnClickListener, | 19 public class MonthPickerDialog extends AlertDialog implements OnClickListener, |
20 OnMonthChangedListener { | 20 OnMonthChangedListener { |
21 | 21 |
22 private static final String YEAR = "year"; | 22 private static final String YEAR = "year"; |
23 private static final String MONTH = "month"; | 23 private static final String MONTH = "month"; |
24 | 24 |
25 private final MonthPicker mMonthPicker; | 25 private final MonthPicker mMonthPicker; |
26 private final OnMonthSetListener mCallBack; | 26 private final OnMonthSetListener mCallBack; |
27 | 27 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 */ | 61 */ |
62 public MonthPickerDialog(Context context, | 62 public MonthPickerDialog(Context context, |
63 int theme, | 63 int theme, |
64 OnMonthSetListener callBack, | 64 OnMonthSetListener callBack, |
65 int year, | 65 int year, |
66 int monthOfYear) { | 66 int monthOfYear) { |
67 super(context, theme); | 67 super(context, theme); |
68 | 68 |
69 mCallBack = callBack; | 69 mCallBack = callBack; |
70 | 70 |
71 assert AppResource.STRING_DATE_PICKER_DIALOG_SET != 0; | |
72 assert AppResource.STRING_MONTH_PICKER_DIALOG_TITLE != 0; | |
73 assert AppResource.LAYOUT_MONTH_PICKER_DIALOG != 0; | |
74 assert AppResource.ID_DATE_PICKER != 0; | |
75 | |
76 setButton(BUTTON_POSITIVE, context.getText( | 71 setButton(BUTTON_POSITIVE, context.getText( |
77 AppResource.STRING_DATE_PICKER_DIALOG_SET), this); | 72 R.string.date_picker_dialog_set), this); |
78 setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel), | 73 setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel), |
79 (OnClickListener) null); | 74 (OnClickListener) null); |
80 setIcon(0); | 75 setIcon(0); |
81 setTitle(AppResource.STRING_MONTH_PICKER_DIALOG_TITLE); | 76 setTitle(R.string.month_picker_dialog_title); |
82 | 77 |
83 LayoutInflater inflater = | 78 LayoutInflater inflater = |
84 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATE
R_SERVICE); | 79 (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATE
R_SERVICE); |
85 View view = inflater.inflate(AppResource.LAYOUT_MONTH_PICKER_DIALOG, nul
l); | 80 View view = inflater.inflate(R.layout.month_picker_dialog, null); |
86 setView(view); | 81 setView(view); |
87 mMonthPicker = (MonthPicker) view.findViewById(AppResource.ID_DATE_PICKE
R); | 82 mMonthPicker = (MonthPicker) view.findViewById(R.id.date_picker); |
88 mMonthPicker.init(year, monthOfYear, this); | 83 mMonthPicker.init(year, monthOfYear, this); |
89 } | 84 } |
90 | 85 |
91 @Override | 86 @Override |
92 public void onClick(DialogInterface dialog, int which) { | 87 public void onClick(DialogInterface dialog, int which) { |
93 tryNotifyMonthSet(); | 88 tryNotifyMonthSet(); |
94 } | 89 } |
95 | 90 |
96 private void tryNotifyMonthSet() { | 91 private void tryNotifyMonthSet() { |
97 if (mCallBack != null) { | 92 if (mCallBack != null) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 137 } |
143 | 138 |
144 @Override | 139 @Override |
145 public void onRestoreInstanceState(Bundle savedInstanceState) { | 140 public void onRestoreInstanceState(Bundle savedInstanceState) { |
146 super.onRestoreInstanceState(savedInstanceState); | 141 super.onRestoreInstanceState(savedInstanceState); |
147 int year = savedInstanceState.getInt(YEAR); | 142 int year = savedInstanceState.getInt(YEAR); |
148 int month = savedInstanceState.getInt(MONTH); | 143 int month = savedInstanceState.getInt(MONTH); |
149 mMonthPicker.init(year, month, this); | 144 mMonthPicker.init(year, month, this); |
150 } | 145 } |
151 } | 146 } |
OLD | NEW |