adding some initial gesture handling
This commit is contained in:
parent
64403c2385
commit
64e52873cb
|
@ -3,8 +3,10 @@ package com.simplemobiletools.launcher.activities
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.simplemobiletools.commons.extensions.appLaunched
|
import com.simplemobiletools.commons.extensions.appLaunched
|
||||||
|
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||||
import com.simplemobiletools.commons.extensions.statusBarHeight
|
import com.simplemobiletools.commons.extensions.statusBarHeight
|
||||||
import com.simplemobiletools.launcher.BuildConfig
|
import com.simplemobiletools.launcher.BuildConfig
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
|
@ -12,6 +14,10 @@ import com.simplemobiletools.launcher.fragments.AllAppsFragment
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
|
private var mTouchDownY = 0
|
||||||
|
private var mScreenHeight = 0
|
||||||
|
private var mCurrentFragmentY = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
showTransparentNavigation = true
|
showTransparentNavigation = true
|
||||||
|
@ -21,6 +27,9 @@ class MainActivity : SimpleActivity() {
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
window.setDecorFitsSystemWindows(false)
|
window.setDecorFitsSystemWindows(false)
|
||||||
(all_apps_fragment as AllAppsFragment).setupFragment(this)
|
(all_apps_fragment as AllAppsFragment).setupFragment(this)
|
||||||
|
mScreenHeight = realScreenSize.y
|
||||||
|
mCurrentFragmentY = mScreenHeight
|
||||||
|
all_apps_fragment.y = mScreenHeight.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -34,4 +43,21 @@ class MainActivity : SimpleActivity() {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
(all_apps_fragment as AllAppsFragment).onConfigurationChanged()
|
(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) {
|
fun setupFragment(activity: SimpleActivity) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
getLaunchers()
|
getLaunchers()
|
||||||
|
setBackgroundColor(activity.getProperBackgroundColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onConfigurationChanged() {
|
fun onConfigurationChanged() {
|
||||||
|
|
|
@ -8,4 +8,9 @@
|
||||||
android:id="@+id/all_apps_fragment"
|
android:id="@+id/all_apps_fragment"
|
||||||
layout="@layout/all_apps_fragment" />
|
layout="@layout/all_apps_fragment" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in New Issue