mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	adding some initial gesture handling
This commit is contained in:
		| @@ -3,8 +3,10 @@ package com.simplemobiletools.launcher.activities | ||||
| import android.content.res.Configuration | ||||
| import android.graphics.Color | ||||
| import android.os.Bundle | ||||
| import android.view.MotionEvent | ||||
| import android.widget.FrameLayout | ||||
| import com.simplemobiletools.commons.extensions.appLaunched | ||||
| import com.simplemobiletools.commons.extensions.realScreenSize | ||||
| import com.simplemobiletools.commons.extensions.statusBarHeight | ||||
| import com.simplemobiletools.launcher.BuildConfig | ||||
| import com.simplemobiletools.launcher.R | ||||
| @@ -12,6 +14,10 @@ import com.simplemobiletools.launcher.fragments.AllAppsFragment | ||||
| import kotlinx.android.synthetic.main.activity_main.* | ||||
|  | ||||
| class MainActivity : SimpleActivity() { | ||||
|     private var mTouchDownY = 0 | ||||
|     private var mScreenHeight = 0 | ||||
|     private var mCurrentFragmentY = 0 | ||||
|  | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|         useDynamicTheme = false | ||||
|         showTransparentNavigation = true | ||||
| @@ -21,6 +27,9 @@ class MainActivity : SimpleActivity() { | ||||
|         appLaunched(BuildConfig.APPLICATION_ID) | ||||
|         window.setDecorFitsSystemWindows(false) | ||||
|         (all_apps_fragment as AllAppsFragment).setupFragment(this) | ||||
|         mScreenHeight = realScreenSize.y | ||||
|         mCurrentFragmentY = mScreenHeight | ||||
|         all_apps_fragment.y = mScreenHeight.toFloat() | ||||
|     } | ||||
|  | ||||
|     override fun onResume() { | ||||
| @@ -34,4 +43,21 @@ class MainActivity : SimpleActivity() { | ||||
|         super.onConfigurationChanged(newConfig) | ||||
|         (all_apps_fragment as AllAppsFragment).onConfigurationChanged() | ||||
|     } | ||||
|  | ||||
|     override fun onTouchEvent(event: MotionEvent): Boolean { | ||||
|         when (event.actionMasked) { | ||||
|             MotionEvent.ACTION_DOWN -> { | ||||
|                 mTouchDownY = event.y.toInt() | ||||
|                 mCurrentFragmentY = all_apps_fragment.y.toInt() | ||||
|             } | ||||
|  | ||||
|             MotionEvent.ACTION_MOVE -> { | ||||
|                 val diffY = mTouchDownY - event.y | ||||
|                 val newY = mCurrentFragmentY - diffY | ||||
|                 all_apps_fragment.y = Math.min(Math.max(0f, newY), mScreenHeight.toFloat()) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return true | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -28,6 +28,7 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : RelativeLa | ||||
|     fun setupFragment(activity: SimpleActivity) { | ||||
|         this.activity = activity | ||||
|         getLaunchers() | ||||
|         setBackgroundColor(activity.getProperBackgroundColor()) | ||||
|     } | ||||
|  | ||||
|     fun onConfigurationChanged() { | ||||
|   | ||||
| @@ -8,4 +8,9 @@ | ||||
|         android:id="@+id/all_apps_fragment" | ||||
|         layout="@layout/all_apps_fragment" /> | ||||
|  | ||||
|     <Button | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:text="@string/about" /> | ||||
|  | ||||
| </RelativeLayout> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user