diff --git a/app/src/main/java/com/vincent_falzon/discreetlauncher/ActivityMain.java b/app/src/main/java/com/vincent_falzon/discreetlauncher/ActivityMain.java index 40396bcd..eb71c23d 100644 --- a/app/src/main/java/com/vincent_falzon/discreetlauncher/ActivityMain.java +++ b/app/src/main/java/com/vincent_falzon/discreetlauncher/ActivityMain.java @@ -799,6 +799,9 @@ public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, // Ignore the gesture if the applications drawer is opened if(drawer.getVisibility() == View.VISIBLE) return false ; + // Ignore incomplete gestures (may happen due to the interactive clock) + if((event1 == null) || (event2 == null)) return false ; + // Calculate the traveled distances on both axes float x_distance = event1.getX() - event2.getX() ; float y_distance = event1.getY() - event2.getY() ; diff --git a/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java b/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java index 0a6f196b..9fcf485e 100644 --- a/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java +++ b/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java @@ -364,25 +364,33 @@ public boolean onTouch(View view, MotionEvent event) int x = Math.round(event.getX()) ; int y = Math.round(event.getY()) ; - // If the touch was in the time area, try to start the selected clock app - if(rect_time.contains(x, y) && (event.getAction() == MotionEvent.ACTION_DOWN)) - return Utils.searchAndStartApplication(this, settings, Constants.CLOCK_APP) ; + // If the touch starts and ends in the time area, try to start the selected clock app + if(rect_time.contains(x, y)) + { + if(event.getAction() == MotionEvent.ACTION_DOWN) return true ; + if(event.getAction() == MotionEvent.ACTION_UP) + return Utils.searchAndStartApplication(this, settings, Constants.CLOCK_APP) ; + } - // If the touch was in the date area, try to start the default calendar - if(rect_date.contains(x, y) && (event.getAction() == MotionEvent.ACTION_DOWN)) + // If the touch starts and ends in the time area, try to start the default calendar + if(rect_date.contains(x, y)) { - try - { - Intent calendarIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_CALENDAR) ; - calendarIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ; - getContext().startActivity(calendarIntent) ; - return true ; - } - catch(ActivityNotFoundException|NullPointerException exception) - { - Utils.displayLongToast(getContext(), getContext().getString(R.string.error_app_not_found, "{calendar}")) ; - return false ; - } + if(event.getAction() == MotionEvent.ACTION_DOWN) return true ; + if(event.getAction() == MotionEvent.ACTION_UP) + { + try + { + Intent calendarIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_CALENDAR) ; + calendarIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) ; + getContext().startActivity(calendarIntent) ; + return true ; + } + catch(ActivityNotFoundException|NullPointerException exception) + { + Utils.displayLongToast(getContext(), getContext().getString(R.string.error_app_not_found, "{calendar}")) ; + return false ; + } + } } // Do not handle touchs outside the date/time areas