diff options
author | Michael Chan <mchan@android.com> | 2009-09-26 23:35:31 -0700 |
---|---|---|
committer | Michael Chan <mchan@android.com> | 2009-09-26 23:35:31 -0700 |
commit | 80bbecfb183210ccbe53ec99e8b3d9aab323da2b (patch) | |
tree | 230481451f8cf54b9e40205347de957a153bd54d | |
parent | 72ee2270002d0f1b2a5a96231fe17dc65282652a (diff) | |
download | Calendar-80bbecfb183210ccbe53ec99e8b3d9aab323da2b.tar.gz |
b/2123455 Single tap on an event will always launch the event details.
Previously,
a "short" press would trigger the hover card. This has been removed.
a "medium" press would launch the event details.
a "long" press woudl trigger the long press menu.
Change-Id: I6d696a988e11fdd3d06950ed89048f4efbc0064f
-rw-r--r-- | src/com/android/calendar/CalendarActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/calendar/CalendarView.java | 49 |
2 files changed, 24 insertions, 31 deletions
diff --git a/src/com/android/calendar/CalendarActivity.java b/src/com/android/calendar/CalendarActivity.java index b8078bef..f5b17432 100644 --- a/src/com/android/calendar/CalendarActivity.java +++ b/src/com/android/calendar/CalendarActivity.java @@ -343,12 +343,6 @@ public class CalendarActivity extends Activity implements Navigator { } @Override - public void onShowPress(MotionEvent ev) { - CalendarView view = (CalendarView) mViewSwitcher.getCurrentView(); - view.doShowPress(ev); - } - - @Override public void onLongPress(MotionEvent ev) { CalendarView view = (CalendarView) mViewSwitcher.getCurrentView(); view.doLongPress(ev); diff --git a/src/com/android/calendar/CalendarView.java b/src/com/android/calendar/CalendarView.java index 3710cc9e..6716edf9 100644 --- a/src/com/android/calendar/CalendarView.java +++ b/src/com/android/calendar/CalendarView.java @@ -149,7 +149,6 @@ public class CalendarView extends View boolean mSelectionAllDay; private int mCellWidth; - private boolean mLaunchNewView; // Pre-allocate these objects and re-use them private Rect mRect = new Rect(); @@ -2336,21 +2335,10 @@ public class CalendarView extends View mTouchMode = TOUCH_MODE_DOWN; mViewStartX = 0; mOnFlingCalled = false; - mLaunchNewView = false; getHandler().removeCallbacks(mContinueScroll); } void doSingleTapUp(MotionEvent ev) { - mSelectionMode = SELECTION_SELECTED; - mRedrawScreen = true; - invalidate(); - if (mLaunchNewView) { - mLaunchNewView = false; - switchViews(false /* not the trackball */); - } - } - - void doShowPress(MotionEvent ev) { int x = (int) ev.getX(); int y = (int) ev.getY(); Event selectedEvent = mSelectedEvent; @@ -2359,29 +2347,41 @@ public class CalendarView extends View boolean validPosition = setSelectionFromPosition(x, y); if (!validPosition) { + // return if the touch wasn't on an area of concern return; } - mSelectionMode = SELECTION_PRESSED; + mSelectionMode = SELECTION_SELECTED; mRedrawScreen = true; invalidate(); - // If the tap is on an already selected event or hour slot, - // then launch a new view. Otherwise, just select the event. - if (selectedEvent != null && selectedEvent == mSelectedEvent) { - // Launch the "View event" view when the finger lifts up, - // unless the finger moves before lifting up. - mLaunchNewView = true; - } else if (selectedEvent == null && selectedDay == mSelectionDay + boolean launchNewView = false; + if (mSelectedEvent != null) { + // If the tap is on an event, launch the "View event" view + launchNewView = true; + } else if (mSelectedEvent == null && selectedDay == mSelectionDay && selectedHour == mSelectionHour) { - // Launch the Day/Agenda view when the finger lifts up, - // unless the finger moves before lifting up. - mLaunchNewView = true; + // If the tap is on an already selected hour slot, + // then launch the Day/Agenda view. Otherwise, just select the hour + // slot. + launchNewView = true; + } + + if (launchNewView) { + switchViews(false /* not the trackball */); } } void doLongPress(MotionEvent ev) { - mLaunchNewView = false; + int x = (int) ev.getX(); + int y = (int) ev.getY(); + + boolean validPosition = setSelectionFromPosition(x, y); + if (!validPosition) { + // return if the touch wasn't on an area of concern + return; + } + mSelectionMode = SELECTION_LONGPRESS; mRedrawScreen = true; invalidate(); @@ -2389,7 +2389,6 @@ public class CalendarView extends View } void doScroll(MotionEvent e1, MotionEvent e2, float deltaX, float deltaY) { - mLaunchNewView = false; // Use the distance from the current point to the initial touch instead // of deltaX and deltaY to avoid accumulating floating-point rounding // errors. Also, we don't need floats, we can use ints. |