Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1565)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/MonthPicker.java

Issue 574673003: Move *Picker.java and *PickerDialog.java to ui/android/java/... - Part1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased patch. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/MonthPicker.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/MonthPicker.java b/content/public/android/java/src/org/chromium/content/browser/input/MonthPicker.java
deleted file mode 100644
index 593aa00972a5dc23395a7724a2e4b42bf62c22a5..0000000000000000000000000000000000000000
--- a/content/public/android/java/src/org/chromium/content/browser/input/MonthPicker.java
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.content.browser.input;
-
-import android.content.Context;
-
-import org.chromium.content.R;
-
-import java.text.DateFormatSymbols;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.TimeZone;
-
-public class MonthPicker extends TwoFieldDatePicker {
- private static final int MONTHS_NUMBER = 12;
-
- private final String[] mShortMonths;
-
- public MonthPicker(Context context, double minValue, double maxValue) {
- super(context, minValue, maxValue);
-
- getPositionInYearSpinner().setContentDescription(
- getResources().getString(R.string.accessibility_date_picker_month));
-
- // initialization based on locale
- mShortMonths =
- DateFormatSymbols.getInstance(Locale.getDefault()).getShortMonths();
-
- // initialize to current date
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), null);
- }
-
- /**
- * Creates a date object from the |value| which is months since epoch.
- */
- public static Calendar createDateFromValue(double value) {
- int year = (int) Math.min(value / 12 + 1970, Integer.MAX_VALUE);
- int month = (int) (value % 12);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.clear();
- cal.set(year, month, 1);
- return cal;
- }
-
- @Override
- protected Calendar getDateForValue(double value) {
- return MonthPicker.createDateFromValue(value);
- }
-
- @Override
- protected void setCurrentDate(int year, int month) {
- Calendar date = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- date.set(year, month, 1);
- if (date.before(getMinDate())) {
- setCurrentDate(getMinDate());
- } else if (date.after(getMaxDate())) {
- setCurrentDate(getMaxDate());
- } else {
- setCurrentDate(date);
- }
- }
-
- @Override
- protected void updateSpinners() {
- super.updateSpinners();
-
- // make sure the month names are a zero based array
- // with the months in the month spinner
- String[] displayedValues = Arrays.copyOfRange(mShortMonths,
- getPositionInYearSpinner().getMinValue(),
- getPositionInYearSpinner().getMaxValue() + 1);
- getPositionInYearSpinner().setDisplayedValues(displayedValues);
- }
-
- /**
- * @return The selected month.
- */
- public int getMonth() {
- return getCurrentDate().get(Calendar.MONTH);
- }
-
- @Override
- public int getPositionInYear() {
- return getMonth();
- }
-
- @Override
- protected int getMaxYear() {
- return getMaxDate().get(Calendar.YEAR);
- }
-
- @Override
- protected int getMinYear() {
- return getMinDate().get(Calendar.YEAR);
- }
-
-
- @Override
- protected int getMaxPositionInYear(int year) {
- if (year == getMaxDate().get(Calendar.YEAR)) {
- return getMaxDate().get(Calendar.MONTH);
- }
- return MONTHS_NUMBER - 1;
- }
-
- @Override
- protected int getMinPositionInYear(int year) {
- if (year == getMinDate().get(Calendar.YEAR)) {
- return getMinDate().get(Calendar.MONTH);
- }
- return 0;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698