mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	adding an extra check to avoid clicking through expanded fragments
This commit is contained in:
		| @@ -261,6 +261,7 @@ class MainActivity : SimpleActivity(), FlingListener { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         window.navigationBarColor = resources.getColor(R.color.semitransparent_navigation) |         window.navigationBarColor = resources.getColor(R.color.semitransparent_navigation) | ||||||
|  |         home_screen_grid.fragmentExpanded() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun hideFragment(fragment: View) { |     private fun hideFragment(fragment: View) { | ||||||
| @@ -271,6 +272,7 @@ class MainActivity : SimpleActivity(), FlingListener { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         window.navigationBarColor = Color.TRANSPARENT |         window.navigationBarColor = Color.TRANSPARENT | ||||||
|  |         home_screen_grid.fragmentCollapsed() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun homeScreenLongPressed(x: Float, y: Float) { |     fun homeScreenLongPressed(x: Float, y: Float) { | ||||||
|   | |||||||
| @@ -535,6 +535,18 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|         isFirstDraw = false |         isFirstDraw = false | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     fun fragmentExpanded() { | ||||||
|  |         widgetViews.forEach { | ||||||
|  |             it.ignoreTouches = true | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     fun fragmentCollapsed() { | ||||||
|  |         widgetViews.forEach { | ||||||
|  |             it.ignoreTouches = false | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // get the clickable area around the icon, it includes text too |     // get the clickable area around the icon, it includes text too | ||||||
|     private fun getClickableRect(item: HomeScreenGridItem): Rect { |     private fun getClickableRect(item: HomeScreenGridItem): Rect { | ||||||
|         val clickableLeft = item.left * rowWidth + sideMargins.left |         val clickableLeft = item.left * rowWidth + sideMargins.left | ||||||
|   | |||||||
| @@ -14,9 +14,22 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) { | |||||||
|     private var actionDownCoords = PointF() |     private var actionDownCoords = PointF() | ||||||
|     private var currentCoords = PointF() |     private var currentCoords = PointF() | ||||||
|     var hasLongPressed = false |     var hasLongPressed = false | ||||||
|  |     var ignoreTouches = false | ||||||
|     var longPressListener: ((x: Float, y: Float) -> Unit)? = null |     var longPressListener: ((x: Float, y: Float) -> Unit)? = null | ||||||
|  |  | ||||||
|  |     override fun onTouchEvent(event: MotionEvent?): Boolean { | ||||||
|  |         return if (ignoreTouches) { | ||||||
|  |             true | ||||||
|  |         } else { | ||||||
|  |             super.onTouchEvent(event) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     override fun onInterceptTouchEvent(event: MotionEvent): Boolean { |     override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | ||||||
|  |         if (ignoreTouches) { | ||||||
|  |             return true | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (hasLongPressed) { |         if (hasLongPressed) { | ||||||
|             hasLongPressed = false |             hasLongPressed = false | ||||||
|             return true |             return true | ||||||
| @@ -34,7 +47,9 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) { | |||||||
|                 currentCoords.x = event.rawX |                 currentCoords.x = event.rawX | ||||||
|                 currentCoords.y = event.rawY |                 currentCoords.y = event.rawY | ||||||
|             } |             } | ||||||
|             MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> longPressHandler.removeCallbacksAndMessages(null) |             MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { | ||||||
|  |                 longPressHandler.removeCallbacksAndMessages(null) | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false |         return false | ||||||
|   | |||||||
| @@ -4,8 +4,7 @@ | |||||||
|     android:id="@+id/all_apps_holder" |     android:id="@+id/all_apps_holder" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="wrap_content" |     android:layout_height="wrap_content" | ||||||
|     android:background="@drawable/all_apps_background" |     android:background="@drawable/all_apps_background"> | ||||||
|     android:clickable="true"> |  | ||||||
|  |  | ||||||
|     <com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller |     <com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller | ||||||
|         android:id="@+id/all_apps_fastscroller" |         android:id="@+id/all_apps_fastscroller" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user