Compare commits

..

No commits in common. "8e140e2e69d88ab3190642cc271ffb0f793e7c82" and "0baa889de5fdd577a076e71d6935c62cac384d2d" have entirely different histories.

10 changed files with 38 additions and 51 deletions

View file

@ -23,8 +23,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 35 targetSdkVersion 35
compileSdk 35 compileSdk 35
versionCode 43 versionCode 41
versionName "0.1.3" versionName "0.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View file

@ -2,10 +2,10 @@ package de.jrpie.android.launcher.ui
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.res.Configuration
import android.content.res.Resources import android.content.res.Resources
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.DisplayMetrics
import android.view.KeyEvent import android.view.KeyEvent
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
@ -56,11 +56,22 @@ class HomeActivity : UIObject, AppCompatActivity() {
super<AppCompatActivity>.onCreate(savedInstanceState) super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate() super<UIObject>.onCreate()
val displayMetrics = DisplayMetrics()
@Suppress("deprecation") // required to support API < 30
windowManager.defaultDisplay.getMetrics(displayMetrics)
val width = displayMetrics.widthPixels
val height = displayMetrics.heightPixels
touchGestureDetector = TouchGestureDetector( touchGestureDetector = TouchGestureDetector(
this, 0, 0, this,
width,
height,
LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
) )
touchGestureDetector.updateScreenSize(windowManager)
// Initialise layout // Initialise layout
binding = HomeBinding.inflate(layoutInflater) binding = HomeBinding.inflate(layoutInflater)
@ -92,11 +103,6 @@ class HomeActivity : UIObject, AppCompatActivity() {
} }
} }
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
touchGestureDetector.updateScreenSize(windowManager)
}
override fun onStart() { override fun onStart() {
super<AppCompatActivity>.onStart() super<AppCompatActivity>.onStart()

View file

@ -5,10 +5,8 @@ import android.graphics.Insets
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.DisplayMetrics
import android.view.MotionEvent import android.view.MotionEvent
import android.view.ViewConfiguration import android.view.ViewConfiguration
import android.view.WindowManager
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.actions.Gesture import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.preferences.LauncherPreferences
@ -19,8 +17,8 @@ import kotlin.math.tan
class TouchGestureDetector( class TouchGestureDetector(
private val context: Context, private val context: Context,
var width: Int, val width: Int,
var height: Int, val height: Int,
var edgeWidth: Float var edgeWidth: Float
) { ) {
private val ANGULAR_THRESHOLD = tan(Math.PI / 6) private val ANGULAR_THRESHOLD = tan(Math.PI / 6)
@ -321,14 +319,6 @@ class TouchGestureDetector(
} }
} }
fun updateScreenSize(windowManager: WindowManager) {
val displayMetrics = DisplayMetrics()
@Suppress("deprecation") // required to support API < 30
windowManager.defaultDisplay.getMetrics(displayMetrics)
width = displayMetrics.widthPixels
height = displayMetrics.heightPixels
}
@RequiresApi(Build.VERSION_CODES.Q) @RequiresApi(Build.VERSION_CODES.Q)
fun setSystemGestureInsets(insets: Insets) { fun setSystemGestureInsets(insets: Insets) {
systemGestureInsetTop = insets.top systemGestureInsetTop = insets.top

View file

@ -9,7 +9,8 @@ import android.window.OnBackInvokedDispatcher
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.content.res.AppCompatResources
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.tabs.TabLayoutMediator
import de.jrpie.android.launcher.Application import de.jrpie.android.launcher.Application
import de.jrpie.android.launcher.R import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.LauncherAction import de.jrpie.android.launcher.actions.LauncherAction
@ -224,10 +225,13 @@ class ListActivity : AppCompatActivity(), UIObject {
updateTitle() updateTitle()
val sectionsPagerAdapter = ListSectionsPagerAdapter(this) val sectionsPagerAdapter = ListSectionsPagerAdapter(this)
binding.listViewpager.let { binding.listViewpager.apply {
it.adapter = sectionsPagerAdapter adapter = sectionsPagerAdapter
binding.listTabs.setupWithViewPager(it) currentItem = 0
} }
TabLayoutMediator(binding.listTabs, binding.listViewpager) { tab, position ->
tab.text = sectionsPagerAdapter.getPageTitle(position)
}.attach()
} }
} }
@ -239,17 +243,11 @@ private val TAB_TITLES = arrayOf(
/** /**
* The [ListSectionsPagerAdapter] returns the fragment, * The [ListSectionsPagerAdapter] returns the fragment,
* which corresponds to the selected tab in [ListActivity]. * which corresponds to the selected tab in [ListActivity].
*
* This should eventually be replaced by a [FragmentStateAdapter]
* However this keyboard does not open when using [ViewPager2]
* so currently [ViewPager] is used here.
* https://github.com/jrpie/launcher/issues/130
*/ */
@Suppress("deprecation")
class ListSectionsPagerAdapter(private val activity: ListActivity) : class ListSectionsPagerAdapter(private val activity: ListActivity) :
FragmentPagerAdapter(activity.supportFragmentManager) { FragmentStateAdapter(activity) {
override fun getItem(position: Int): Fragment { override fun createFragment(position: Int): Fragment {
return when (position) { return when (position) {
0 -> ListFragmentApps() 0 -> ListFragmentApps()
1 -> ListFragmentOther() 1 -> ListFragmentOther()
@ -257,11 +255,11 @@ class ListSectionsPagerAdapter(private val activity: ListActivity) :
} }
} }
override fun getPageTitle(position: Int): CharSequence { fun getPageTitle(position: Int): CharSequence {
return activity.resources.getString(TAB_TITLES[position]) return activity.resources.getString(TAB_TITLES[position])
} }
override fun getCount(): Int { override fun getItemCount(): Int {
return when (activity.intention) { return when (activity.intention) {
ListActivity.ListActivityIntention.VIEW -> 1 ListActivity.ListActivityIntention.VIEW -> 1
else -> 2 else -> 2

View file

@ -109,7 +109,7 @@ class SettingsActivity : AppCompatActivity(), UIObject {
} }
private val TAB_TITLES = arrayOf( private val TAB_TITLES = arrayOf(
R.string.settings_tab_actions, R.string.settings_tab_app,
R.string.settings_tab_launcher, R.string.settings_tab_launcher,
R.string.settings_tab_meta R.string.settings_tab_meta
) )

View file

@ -95,12 +95,7 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<!-- <androidx.viewpager2.widget.ViewPager2
Should be replaced by androidx.viewpager2.widget.ViewPager2
but there is an issue with opening the keyboard:
https://github.com/jrpie/launcher/issues/130
-->
<androidx.viewpager.widget.ViewPager
android:id="@+id/list_viewpager" android:id="@+id/list_viewpager"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"

View file

@ -14,7 +14,7 @@
- -
--> -->
<string name="settings_title">Einstellungen</string> <string name="settings_title">Einstellungen</string>
<string name="settings_tab_actions">Aktionen</string> <string name="settings_tab_app">Apps</string>
<string name="settings_tab_launcher">Launcher</string> <string name="settings_tab_launcher">Launcher</string>
<string name="settings_tab_meta">Meta</string> <string name="settings_tab_meta">Meta</string>
<!-- <!--
@ -54,9 +54,9 @@
<string name="settings_gesture_description_down_left_edge">An der linken Kante nach unten wischen</string> <string name="settings_gesture_description_down_left_edge">An der linken Kante nach unten wischen</string>
<string name="settings_gesture_down_right_edge">Abwärts (rechts)</string> <string name="settings_gesture_down_right_edge">Abwärts (rechts)</string>
<string name="settings_gesture_description_down_right_edge">An der rechten Kanten nach unten wischen</string> <string name="settings_gesture_description_down_right_edge">An der rechten Kanten nach unten wischen</string>
<string name="settings_gesture_vol_up">Lauter-Taste</string> <string name="settings_gesture_vol_up">Lautstärke +</string>
<string name="settings_gesture_description_vol_up">Die Taste \"Lauter\" drücken</string> <string name="settings_gesture_description_vol_up">Die Taste \"Lauter\" drücken</string>
<string name="settings_gesture_vol_down">Leiser-Taste</string> <string name="settings_gesture_vol_down">Lautstärke -</string>
<string name="settings_gesture_description_vol_down">Die Taste \"Leiser\" drücken</string> <string name="settings_gesture_description_vol_down">Die Taste \"Leiser\" drücken</string>
<string name="settings_gesture_double_click">Doppelklick</string> <string name="settings_gesture_double_click">Doppelklick</string>
<string name="settings_gesture_description_double_click">In einem leeren Bereich doppelt klicken</string> <string name="settings_gesture_description_double_click">In einem leeren Bereich doppelt klicken</string>

View file

@ -16,7 +16,7 @@
--> -->
<string name="settings_title">Settings</string> <string name="settings_title">Settings</string>
<string name="settings_tab_actions">Actions</string> <string name="settings_tab_app">Apps</string>
<string name="settings_tab_launcher">Launcher</string> <string name="settings_tab_launcher">Launcher</string>
<string name="settings_tab_meta">Meta</string> <string name="settings_tab_meta">Meta</string>
@ -85,9 +85,9 @@
<string name="settings_gesture_swipe_lambda_reverse">Λ (Reverse)</string> <string name="settings_gesture_swipe_lambda_reverse">Λ (Reverse)</string>
<string name="settings_gesture_description_swipe_lambda_reverse">Bottom right -> top mid -> bottom left</string> <string name="settings_gesture_description_swipe_lambda_reverse">Bottom right -> top mid -> bottom left</string>
<string name="settings_gesture_vol_up">Volume Up Key</string> <string name="settings_gesture_vol_up">Volume Up</string>
<string name="settings_gesture_description_vol_up">Press the volume up button</string> <string name="settings_gesture_description_vol_up">Press the volume up button</string>
<string name="settings_gesture_vol_down">Volume Down Key</string> <string name="settings_gesture_vol_down">Volume Down</string>
<string name="settings_gesture_description_vol_down">Press the volume down button</string> <string name="settings_gesture_description_vol_down">Press the volume down button</string>
<string name="settings_gesture_double_click">Double Click</string> <string name="settings_gesture_double_click">Double Click</string>
<string name="settings_gesture_description_double_click">Double click an empty area</string> <string name="settings_gesture_description_double_click">Double click an empty area</string>

View file

@ -1 +0,0 @@
* Fixed bug where keyboard does not open automatically

View file

@ -1 +0,0 @@
* Fixed gesture detection in landscape orientation