Compare commits

..

5 commits

Author SHA1 Message Date
8e140e2e69
rename tab "Apps" to "Actions" and "Volume Up/Down" to "Volume Up/Down Key"
Some checks failed
Android CI / build (push) Has been cancelled
2025-03-20 16:23:01 +01:00
7fc58fe384
0.1.3 2025-03-20 15:52:12 +01:00
54409b6312
fix #133 2025-03-20 14:55:22 +01:00
865cd47583
0.1.2 2025-03-20 14:16:29 +01:00
58ddd3c8cc
fix #130 - revert part of 9043461 as ViewPager2 causes an issue with opening the keyboard 2025-03-20 14:09:00 +01:00
10 changed files with 51 additions and 38 deletions

View file

@ -23,8 +23,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 35 targetSdkVersion 35
compileSdk 35 compileSdk 35
versionCode 41 versionCode 43
versionName "0.1.1" versionName "0.1.3"
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,22 +56,11 @@ 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, this, 0, 0,
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)
@ -103,6 +92,11 @@ 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,8 +5,10 @@ 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
@ -17,8 +19,8 @@ import kotlin.math.tan
class TouchGestureDetector( class TouchGestureDetector(
private val context: Context, private val context: Context,
val width: Int, var width: Int,
val height: Int, var height: Int,
var edgeWidth: Float var edgeWidth: Float
) { ) {
private val ANGULAR_THRESHOLD = tan(Math.PI / 6) private val ANGULAR_THRESHOLD = tan(Math.PI / 6)
@ -319,6 +321,14 @@ 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,8 +9,7 @@ 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.viewpager2.adapter.FragmentStateAdapter import androidx.fragment.app.FragmentPagerAdapter
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
@ -225,13 +224,10 @@ class ListActivity : AppCompatActivity(), UIObject {
updateTitle() updateTitle()
val sectionsPagerAdapter = ListSectionsPagerAdapter(this) val sectionsPagerAdapter = ListSectionsPagerAdapter(this)
binding.listViewpager.apply { binding.listViewpager.let {
adapter = sectionsPagerAdapter it.adapter = sectionsPagerAdapter
currentItem = 0 binding.listTabs.setupWithViewPager(it)
} }
TabLayoutMediator(binding.listTabs, binding.listViewpager) { tab, position ->
tab.text = sectionsPagerAdapter.getPageTitle(position)
}.attach()
} }
} }
@ -243,11 +239,17 @@ 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) :
FragmentStateAdapter(activity) { FragmentPagerAdapter(activity.supportFragmentManager) {
override fun createFragment(position: Int): Fragment { override fun getItem(position: Int): Fragment {
return when (position) { return when (position) {
0 -> ListFragmentApps() 0 -> ListFragmentApps()
1 -> ListFragmentOther() 1 -> ListFragmentOther()
@ -255,11 +257,11 @@ class ListSectionsPagerAdapter(private val activity: ListActivity) :
} }
} }
fun getPageTitle(position: Int): CharSequence { override fun getPageTitle(position: Int): CharSequence {
return activity.resources.getString(TAB_TITLES[position]) return activity.resources.getString(TAB_TITLES[position])
} }
override fun getItemCount(): Int { override fun getCount(): 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_app, R.string.settings_tab_actions,
R.string.settings_tab_launcher, R.string.settings_tab_launcher,
R.string.settings_tab_meta R.string.settings_tab_meta
) )

View file

@ -95,7 +95,12 @@
</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_app">Apps</string> <string name="settings_tab_actions">Aktionen</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">Lautstärke +</string> <string name="settings_gesture_vol_up">Lauter-Taste</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">Lautstärke -</string> <string name="settings_gesture_vol_down">Leiser-Taste</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_app">Apps</string> <string name="settings_tab_actions">Actions</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</string> <string name="settings_gesture_vol_up">Volume Up Key</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</string> <string name="settings_gesture_vol_down">Volume Down Key</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

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

View file

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