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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/DateDialogNormalizer.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/DateDialogNormalizer.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/DateDialogNormalizer.java b/content/public/android/java/src/org/chromium/content/browser/input/DateDialogNormalizer.java
deleted file mode 100644
index 709d0e73943d9f289dfffb965f7079673302f931..0000000000000000000000000000000000000000
--- a/content/public/android/java/src/org/chromium/content/browser/input/DateDialogNormalizer.java
+++ /dev/null
@@ -1,77 +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.widget.DatePicker;
-import android.widget.DatePicker.OnDateChangedListener;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-
-/**
- * Normalize a date dialog so that it respect min and max.
- */
-class DateDialogNormalizer {
-
- private static void setLimits(DatePicker picker, long minMillis, long maxMillis) {
- // DatePicker intervals are non inclusive, the DatePicker will throw an
- // exception when setting the min/max attribute to the current date
- // so make sure this never happens
- if (maxMillis <= minMillis) {
- return;
- }
- Calendar minCal = trimToDate(minMillis);
- Calendar maxCal = trimToDate(maxMillis);
- int currentYear = picker.getYear();
- int currentMonth = picker.getMonth();
- int currentDayOfMonth = picker.getDayOfMonth();
- picker.updateDate(maxCal.get(Calendar.YEAR),
- maxCal.get(Calendar.MONTH),
- maxCal.get(Calendar.DAY_OF_MONTH));
- picker.setMinDate(minCal.getTimeInMillis());
- picker.updateDate(minCal.get(Calendar.YEAR),
- minCal.get(Calendar.MONTH),
- minCal.get(Calendar.DAY_OF_MONTH));
- picker.setMaxDate(maxCal.getTimeInMillis());
-
- // Restore the current date, this will keep the min/max settings
- // previously set into account.
- picker.updateDate(currentYear, currentMonth, currentDayOfMonth);
- }
-
- private static Calendar trimToDate(long time) {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- cal.clear();
- cal.setTimeInMillis(time);
- Calendar result = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- result.clear();
- result.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
- 0, 0, 0);
- return result;
- }
-
- /**
- * Normalizes an existing DateDialogPicker changing the default date if
- * needed to comply with the {@code min} and {@code max} attributes.
- */
- static void normalize(DatePicker picker, OnDateChangedListener listener,
- int year, int month, int day, int hour, int minute, long minMillis, long maxMillis) {
- Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- calendar.clear();
- calendar.set(year, month, day, hour, minute, 0);
- if (calendar.getTimeInMillis() < minMillis) {
- calendar.clear();
- calendar.setTimeInMillis(minMillis);
- } else if (calendar.getTimeInMillis() > maxMillis) {
- calendar.clear();
- calendar.setTimeInMillis(maxMillis);
- }
- picker.init(
- calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH), listener);
-
- setLimits(picker, minMillis, maxMillis);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698