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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/WeekPicker.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/WeekPicker.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/WeekPicker.java b/content/public/android/java/src/org/chromium/content/browser/input/WeekPicker.java
deleted file mode 100644
index a53460fa4e629a143485a5f7b3b742ad5bbf961a..0000000000000000000000000000000000000000
--- a/content/public/android/java/src/org/chromium/content/browser/input/WeekPicker.java
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2013 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.util.Calendar;
-import java.util.TimeZone;
-
-// This class is heavily based on android.widget.DatePicker.
-public class WeekPicker extends TwoFieldDatePicker {
-
- public WeekPicker(Context context, double minValue, double maxValue) {
- super(context, minValue, maxValue);
-
- getPositionInYearSpinner().setContentDescription(
- getResources().getString(R.string.accessibility_date_picker_week));
-
- // initialize to current date
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.setFirstDayOfWeek(Calendar.MONDAY);
- cal.setMinimalDaysInFirstWeek(4);
- cal.setTimeInMillis(System.currentTimeMillis());
- init(getISOWeekYearForDate(cal), getWeekForDate(cal), null);
- }
-
- /**
- * Creates a date object from the |year| and |week|.
- */
- public static Calendar createDateFromWeek(int year, int week) {
- Calendar date = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- date.clear();
- date.setFirstDayOfWeek(Calendar.MONDAY);
- date.setMinimalDaysInFirstWeek(4);
- date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
- date.set(Calendar.YEAR, year);
- date.set(Calendar.WEEK_OF_YEAR, week);
- return date;
- }
-
- /**
- * Creates a date object from the |value| which is milliseconds since epoch.
- */
- public static Calendar createDateFromValue(double value) {
- Calendar date = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- date.clear();
- date.setFirstDayOfWeek(Calendar.MONDAY);
- date.setMinimalDaysInFirstWeek(4);
- date.setTimeInMillis((long) value);
- return date;
- }
-
- @Override
- protected Calendar getDateForValue(double value) {
- return WeekPicker.createDateFromValue(value);
- }
-
- public static int getISOWeekYearForDate(Calendar date) {
- int year = date.get(Calendar.YEAR);
- int month = date.get(Calendar.MONTH);
- int week = date.get(Calendar.WEEK_OF_YEAR);
- if (month == 0 && week > 51) {
- year--;
- } else if (month == 11 && week == 1) {
- year++;
- }
- return year;
- }
-
- public static int getWeekForDate(Calendar date) {
- return date.get(Calendar.WEEK_OF_YEAR);
- }
-
- @Override
- protected void setCurrentDate(int year, int week) {
- Calendar date = createDateFromWeek(year, week);
- if (date.before(getMinDate())) {
- setCurrentDate(getMinDate());
- } else if (date.after(getMaxDate())) {
- setCurrentDate(getMaxDate());
- } else {
- setCurrentDate(date);
- }
- }
-
- private int getNumberOfWeeks(int year) {
- // Create a date in the middle of the year, where the week year matches the year.
- Calendar date = createDateFromWeek(year, 20);
- return date.getActualMaximum(Calendar.WEEK_OF_YEAR);
- }
-
- /**
- * @return The selected year.
- */
- @Override
- public int getYear() {
- return getISOWeekYearForDate(getCurrentDate());
- }
-
- /**
- * @return The selected week.
- */
- public int getWeek() {
- return getWeekForDate(getCurrentDate());
- }
-
- @Override
- public int getPositionInYear() {
- return getWeek();
- }
-
- @Override
- protected int getMaxYear() {
- return getISOWeekYearForDate(getMaxDate());
- }
-
- @Override
- protected int getMinYear() {
- return getISOWeekYearForDate(getMinDate());
- }
-
- @Override
- protected int getMaxPositionInYear(int year) {
- if (year == getISOWeekYearForDate(getMaxDate())) {
- return getWeekForDate(getMaxDate());
- }
- return getNumberOfWeeks(year);
- }
-
- @Override
- protected int getMinPositionInYear(int year) {
- if (year == getISOWeekYearForDate(getMinDate())) {
- return getWeekForDate(getMinDate());
- }
- return 1;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698