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

Commit c291a7bf authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "The calendar view widget was jumping incorrectly to the next week while...

Merge "The calendar view widget was jumping incorrectly to the next week while selectiong the last day of the week." into honeycomb
parents 89378fd1 58f51255
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -897,10 +897,13 @@ public class CalendarView extends FrameLayout {
            throw new IllegalArgumentException("fromDate: " + mMinDate.getTime()
                    + " does not precede toDate: " + date.getTime());
        }
        int fromDateDayOfWeek = mMinDate.get(Calendar.DAY_OF_WEEK);
        long diff = (fromDateDayOfWeek - mFirstDayOfWeek) * MILLIS_IN_DAY;
        long refDay = mMinDate.getTimeInMillis() - diff;
        return (int) ((date.getTimeInMillis() - refDay) / MILLIS_IN_WEEK);
        long endTimeMillis = date.getTimeInMillis()
                + date.getTimeZone().getOffset(date.getTimeInMillis());
        long startTimeMillis = mMinDate.getTimeInMillis()
                + mMinDate.getTimeZone().getOffset(mMinDate.getTimeInMillis());
        long dayOffsetMillis = (mMinDate.get(Calendar.DAY_OF_WEEK) - mFirstDayOfWeek)
                * MILLIS_IN_DAY;
        return (int) ((endTimeMillis - startTimeMillis + dayOffsetMillis) / MILLIS_IN_WEEK);
    }

    /**
@@ -1180,6 +1183,7 @@ public class CalendarView extends FrameLayout {
            mNumCells = mShowWeekNumber ? mDaysPerWeek + 1 : mDaysPerWeek;
            mWeek = weekNumber;
            mTempDate.setTimeInMillis(mMinDate.getTimeInMillis());

            mTempDate.add(Calendar.WEEK_OF_YEAR, mWeek);
            mTempDate.setFirstDayOfWeek(mFirstDayOfWeek);

+9 −2
Original line number Diff line number Diff line
@@ -184,6 +184,8 @@ public class DatePicker extends FrameLayout {
                // now set the date to the adjusted one
                setDate(mTempDate.get(Calendar.YEAR), mTempDate.get(Calendar.MONTH),
                        mTempDate.get(Calendar.DAY_OF_MONTH));
                updateSpinners();
                updateCalendarView();
                notifyDateChanged();
            }
        };
@@ -195,6 +197,7 @@ public class DatePicker extends FrameLayout {
        mCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            public void onSelectedDayChange(CalendarView view, int year, int month, int monthDay) {
                setDate(year, month, monthDay);
                updateSpinners();
                notifyDateChanged();
            }
        });
@@ -469,6 +472,8 @@ public class DatePicker extends FrameLayout {
            return;
        }
        setDate(year, month, dayOfMonth);
        updateSpinners();
        updateCalendarView();
        notifyDateChanged();
    }

@@ -489,6 +494,8 @@ public class DatePicker extends FrameLayout {
        SavedState ss = (SavedState) state;
        super.onRestoreInstanceState(ss.getSuperState());
        setDate(ss.mYear, ss.mMonth, ss.mDay);
        updateSpinners();
        updateCalendarView();
    }

    /**
@@ -504,6 +511,8 @@ public class DatePicker extends FrameLayout {
    public void init(int year, int monthOfYear, int dayOfMonth,
            OnDateChangedListener onDateChangedListener) {
        setDate(year, monthOfYear, dayOfMonth);
        updateSpinners();
        updateCalendarView();
        mOnDateChangedListener = onDateChangedListener;
    }

@@ -553,8 +562,6 @@ public class DatePicker extends FrameLayout {
        } else if (mCurrentDate.after(mMaxDate)) {
            mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
        }
        updateSpinners();
        updateCalendarView();
    }

    private void updateSpinners() {
+9 −5
Original line number Diff line number Diff line
@@ -623,7 +623,11 @@ public class NumberPicker extends LinearLayout {
                    hideInputControls();
                    return true;
                }
                if (isEventInInputText(event)) {
                if (isEventInViewHitRect(event, mInputText)
                        || (!mIncrementButton.isShown()
                                && isEventInViewHitRect(event, mIncrementButton))
                        || (!mDecrementButton.isShown()
                                && isEventInViewHitRect(event, mDecrementButton))) {
                    mAdjustScrollerOnUpEvent = false;
                    setDrawSelectorWheel(true);
                    hideInputControls();
@@ -708,7 +712,7 @@ public class NumberPicker extends LinearLayout {
    public boolean dispatchTouchEvent(MotionEvent event) {
        int action = event.getActionMasked();
        if ((action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP)
                && !isEventInInputText(event)) {
                && !isEventInViewHitRect(event, mInputText)) {
            removeAllCallbacks();
        }
        return super.dispatchTouchEvent(event);
@@ -1177,10 +1181,10 @@ public class NumberPicker extends LinearLayout {
    }

    /**
     * @return If the <code>event</code> is in the input text.
     * @return If the <code>event</code> is in the <code>view</code>.
     */
    private boolean isEventInInputText(MotionEvent event) {
        mInputText.getHitRect(mTempRect);
    private boolean isEventInViewHitRect(MotionEvent event, View view) {
        view.getHitRect(mTempRect);
        return mTempRect.contains((int) event.getX(), (int) event.getY());
    }