Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49c7a01a authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Adding DatePciker widget based on the Calednar team code. Updated...

Merge "Adding DatePciker widget based on the Calednar team code. Updated DatePciker and DatePickerDialog as the second part of the Time/Date pciker refresh feature."
parents b3147489 50f34d14
Loading
Loading
Loading
Loading
+206 −1
Original line number Diff line number Diff line
@@ -184323,6 +184323,19 @@
<parameter name="gmtoff" type="long">
</parameter>
</method>
<method name="getJulianMondayFromWeeksSinceEpoch"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="week" type="int">
</parameter>
</method>
<method name="getWeekNumber"
 return="int"
 abstract="false"
@@ -184334,6 +184347,21 @@
 visibility="public"
>
</method>
<method name="getWeeksSinceEpochFromJulianDay"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="julianDay" type="int">
</parameter>
<parameter name="firstDayOfWeek" type="int">
</parameter>
</method>
<method name="isEpoch"
 return="boolean"
 abstract="false"
@@ -184557,6 +184585,17 @@
 visibility="public"
>
</field>
<field name="MONDAY_BEFORE_JULIAN_EPOCH"
 type="int"
 transient="false"
 volatile="false"
 value="2440585"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="MONTH"
 type="int"
 transient="false"
@@ -234482,7 +234521,7 @@
>
<parameter name="year" type="int">
</parameter>
<parameter name="monthOfYear" type="int">
<parameter name="month" type="int">
</parameter>
<parameter name="dayOfMonth" type="int">
</parameter>
@@ -234534,6 +234573,172 @@
</parameter>
</method>
</interface>
<class name="DayPicker"
 extends="android.widget.FrameLayout"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="DayPicker"
 type="android.widget.DayPicker"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
<constructor name="DayPicker"
 type="android.widget.DayPicker"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<constructor name="DayPicker"
 type="android.widget.DayPicker"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyle" type="int">
</parameter>
</constructor>
<method name="getSelectedDay"
 return="java.util.Calendar"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="goTo"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="year" type="int">
</parameter>
<parameter name="month" type="int">
</parameter>
<parameter name="dayOfMonth" type="int">
</parameter>
<parameter name="animate" type="boolean">
</parameter>
<parameter name="setSelected" type="boolean">
</parameter>
<parameter name="forceScroll" type="boolean">
</parameter>
</method>
<method name="goTo"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="date" type="java.util.Calendar">
</parameter>
<parameter name="animate" type="boolean">
</parameter>
<parameter name="setSelected" type="boolean">
</parameter>
<parameter name="forceScroll" type="boolean">
</parameter>
</method>
<method name="setOnDateChangeListener"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="listener" type="android.widget.DayPicker.OnSelectedDayChangeListener">
</parameter>
</method>
<method name="setRange"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="startRangeDate" type="java.util.Calendar">
</parameter>
<parameter name="endRangeDate" type="java.util.Calendar">
</parameter>
</method>
<method name="setSelectedDay"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="selectedDay" type="java.util.Calendar">
</parameter>
</method>
</class>
<interface name="DayPicker.OnSelectedDayChangeListener"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="onSelectedDayChange"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="view" type="android.widget.DayPicker">
</parameter>
<parameter name="year" type="int">
</parameter>
<parameter name="month" type="int">
</parameter>
<parameter name="dayOfMonth" type="int">
</parameter>
</method>
</interface>
<class name="DialerFilter"
 extends="android.widget.RelativeLayout"
 abstract="false"
+6 −51
Original line number Diff line number Diff line
@@ -16,23 +16,18 @@

package android.app;

import com.android.internal.R;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils.TruncateAt;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.DatePicker.OnDateChangedListener;

import com.android.internal.R;

import java.text.DateFormatSymbols;
import java.util.Calendar;

/**
 * A simple dialog containing an {@link android.widget.DatePicker}.
 *
@@ -48,13 +43,6 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,

    private final DatePicker mDatePicker;
    private final OnDateSetListener mCallBack;
    private final Calendar mCalendar;
    private final java.text.DateFormat mTitleDateFormat;
    private final String[] mWeekDays;

    private int mInitialYear;
    private int mInitialMonth;
    private int mInitialDay;

    /**
     * The callback used to indicate the user is done filling in the date.
@@ -106,40 +94,18 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
        super(context, theme);

        mCallBack = callBack;
        mInitialYear = year;
        mInitialMonth = monthOfYear;
        mInitialDay = dayOfMonth;
        DateFormatSymbols symbols = new DateFormatSymbols();
        mWeekDays = symbols.getShortWeekdays();

        mTitleDateFormat = java.text.DateFormat.
                                getDateInstance(java.text.DateFormat.FULL);
        mCalendar = Calendar.getInstance();
        updateTitle(mInitialYear, mInitialMonth, mInitialDay);

        setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this);
        setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), (OnClickListener) null);
        setIcon(R.drawable.ic_dialog_time);
        setIcon(0);
        setTitle(R.string.date_picker_dialog_title);

        LayoutInflater inflater =
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.date_picker_dialog, null);
        setView(view);
        mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
        mDatePicker.init(mInitialYear, mInitialMonth, mInitialDay, this);
    }

    @Override
    public void show() {
        super.show();

        /* Sometimes the full month is displayed causing the title
         * to be very long, in those cases ensure it doesn't wrap to
         * 2 lines (as that looks jumpy) and ensure we ellipsize the end.
         */
        TextView title = (TextView) findViewById(R.id.alertTitle);
        title.setSingleLine();
        title.setEllipsize(TruncateAt.END);
        mDatePicker.init(year, monthOfYear, dayOfMonth, this);
    }

    public void onClick(DialogInterface dialog, int which) {
@@ -152,23 +118,13 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,

    public void onDateChanged(DatePicker view, int year,
            int month, int day) {
        updateTitle(year, month, day);
        mDatePicker.init(year, month, day, null);
    }

    public void updateDate(int year, int monthOfYear, int dayOfMonth) {
        mInitialYear = year;
        mInitialMonth = monthOfYear;
        mInitialDay = dayOfMonth;
        mDatePicker.updateDate(year, monthOfYear, dayOfMonth);
    }

    private void updateTitle(int year, int month, int day) {
        mCalendar.set(Calendar.YEAR, year);
        mCalendar.set(Calendar.MONTH, month);
        mCalendar.set(Calendar.DAY_OF_MONTH, day);
        setTitle(mTitleDateFormat.format(mCalendar.getTime()));
    }

    @Override
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
@@ -185,6 +141,5 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
        int month = savedInstanceState.getInt(MONTH);
        int day = savedInstanceState.getInt(DAY);
        mDatePicker.init(year, month, day, this);
        updateTitle(year, month, day);
    }
}
+41 −0
Original line number Diff line number Diff line
@@ -41,6 +41,12 @@ public class Time {
     */
    public static final int EPOCH_JULIAN_DAY = 2440588;

    /**
     * The Julian day of the Monday in the week of the epoch, December 29, 1969
     * on the Gregorian calendar.
     */
    public static final int MONDAY_BEFORE_JULIAN_EPOCH = EPOCH_JULIAN_DAY - 3;

    /**
     * True if this is an allDay event. The hour, minute, second fields are
     * all zero, and the date is displayed the same in all time zones.
@@ -770,4 +776,39 @@ public class Time {
        millis = normalize(true);
        return millis;
    }

    /**
     * Returns the week since {@link #EPOCH_JULIAN_DAY} (Jan 1, 1970) adjusted
     * for first day of week. This takes a julian day and the week start day and
     * calculates which week since {@link #EPOCH_JULIAN_DAY} that day occurs in,
     * starting at 0. *Do not* use this to compute the ISO week number for the
     * year.
     *
     * @param julianDay The julian day to calculate the week number for
     * @param firstDayOfWeek Which week day is the first day of the week, see
     *            {@link #SUNDAY}
     * @return Weeks since the epoch
     */
    public static int getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek) {
        int diff = THURSDAY - firstDayOfWeek;
        if (diff < 0) {
            diff += 7;
        }
        int refDay = EPOCH_JULIAN_DAY - diff;
        return (julianDay - refDay) / 7;
    }

    /**
     * Takes a number of weeks since the epoch and calculates the Julian day of
     * the Monday for that week. This assumes that the week containing the
     * {@link #EPOCH_JULIAN_DAY} is considered week 0. It returns the Julian day
     * for the Monday week weeks after the Monday of the week containing the
     * epoch.
     *
     * @param week Number of weeks since the epoch
     * @return The julian day for the Monday of the given week since the epoch
     */
    public static int getJulianMondayFromWeeksSinceEpoch(int week) {
        return MONDAY_BEFORE_JULIAN_EPOCH + week * 7;
    }
}
+197 −212

File changed.

Preview size limit exceeded, changes collapsed.

+1474 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading