mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-22 22:11:27 +01:00
feature: edge gestures
This commit is contained in:
parent
624f07ae21
commit
8515062238
12 changed files with 162 additions and 39 deletions
|
@ -10,6 +10,8 @@ This is a fork of [finnmglas's app Launcher][original-repo].
|
|||
|
||||
## Notable changes:
|
||||
|
||||
* Edge gestures: There is a setting to allow distinguishing swiping at the edges of the screen from swiping in the center.
|
||||
|
||||
### Visual
|
||||
* This app uses the system wallpaper instead of rolling a custom solution.
|
||||
* The font has been changed to [Hack][hack-font].
|
||||
|
@ -26,6 +28,7 @@ This is a fork of [finnmglas's app Launcher][original-repo].
|
|||
* Different apps set as default.
|
||||
* Package name was changed to `de.jrpie.android.launcher` to avoid clashing with the original app.
|
||||
* Dropped support for API < 21 (i.e. pre Lollypop)
|
||||
* Some refactoring
|
||||
---
|
||||
---
|
||||
[hack-font]: https://sourcefoundry.org/hack/
|
||||
|
|
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "de.jrpie.android.launcher"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 35
|
||||
versionCode 14
|
||||
versionName "j-alpha-0.2"
|
||||
versionCode 15
|
||||
versionName "j-alpha-0.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 14,
|
||||
"versionName": "j-alpha-0.2",
|
||||
"versionCode": 15,
|
||||
"versionName": "j-alpha-0.3",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
|
|
@ -50,6 +50,7 @@ const val PREF_SCREEN_FULLSCREEN = "useFullScreen"
|
|||
const val PREF_DATE_FORMAT = "dateFormat"
|
||||
|
||||
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
|
||||
const val PREF_EDGE_ACTIONS_ENABLED = "enableEdgeActions"
|
||||
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
||||
const val PREF_SEARCH_AUTO_KEYBOARD = "searchAutoKeyboard"
|
||||
|
||||
|
|
|
@ -21,14 +21,26 @@ enum class Gesture (val id: String, private val labelResource: Int,
|
|||
LONG_CLICK("action_longClickApp", R.string.settings_gesture_long_click, R.array.default_long_click, 0,0),
|
||||
DOUBLE_CLICK("action_doubleClickApp", R.string.settings_gesture_double_click, R.array.default_double_click,0,0),
|
||||
SWIPE_UP("action_upApp", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up),
|
||||
SWIPE_UP_LEFT_EDGE("action_up_leftApp", R.string.settings_gesture_up_left_edge, R.array.default_up_left, R.anim.bottom_up),
|
||||
SWIPE_UP_RIGHT_EDGE("action_up_rightApp", R.string.settings_gesture_up_right_edge, R.array.default_up_right, R.anim.bottom_up),
|
||||
SWIPE_UP_DOUBLE( "action_doubleUpApp", R.string.settings_gesture_double_up, R.array.default_double_up, R.anim.bottom_up),
|
||||
SWIPE_DOWN("action_downApp", R.string.settings_gesture_down, R.array.default_down, R.anim.top_down),
|
||||
SWIPE_DOWN_LEFT_EDGE("action_down_leftApp", R.string.settings_gesture_down_left_edge, R.array.default_down_left, R.anim.top_down),
|
||||
SWIPE_DOWN_RIGHT_EDGE("action_down_rightApp", R.string.settings_gesture_down_right_edge, R.array.default_down_right, R.anim.top_down),
|
||||
SWIPE_DOWN_DOUBLE("action_doubleDownApp", R.string.settings_gesture_double_down, R.array.default_double_down, R.anim.top_down),
|
||||
SWIPE_LEFT("action_leftApp", R.string.settings_gesture_left, R.array.default_left, R.anim.right_left),
|
||||
SWIPE_LEFT_TOP_EDGE("action_left_topApp", R.string.settings_gesture_left_top_edge, R.array.default_left_top, R.anim.right_left),
|
||||
SWIPE_LEFT_BOTTOM_EDGE("action_left_bottomApp", R.string.settings_gesture_left_bottom_edge, R.array.default_left_bottom, R.anim.right_left),
|
||||
SWIPE_LEFT_DOUBLE("action_doubleLeftApp", R.string.settings_gesture_double_left, R.array.default_double_left, R.anim.right_left),
|
||||
SWIPE_RIGHT("action_rightApp", R.string.settings_gesture_right, R.array.default_right, R.anim.left_right),
|
||||
SWIPE_RIGHT_TOP_EDGE("action_right_topApp", R.string.settings_gesture_right_top_edge, R.array.default_right_top, R.anim.left_right),
|
||||
SWIPE_RIGHT_BOTTOM_EDGE("action_right_bottomApp", R.string.settings_gesture_right_bottom_edge, R.array.default_right_bottom, R.anim.left_right),
|
||||
SWIPE_RIGHT_DOUBLE("action_doubleRightApp", R.string.settings_gesture_double_right, R.array.default_double_right, R.anim.left_right);
|
||||
|
||||
enum class Edge{
|
||||
TOP, BOTTOM, LEFT, RIGHT
|
||||
}
|
||||
|
||||
fun getApp(context: Context): String {
|
||||
return getPreferences(context).getString(this.id, "")!!
|
||||
}
|
||||
|
@ -66,6 +78,35 @@ enum class Gesture (val id: String, private val labelResource: Int,
|
|||
}
|
||||
}
|
||||
|
||||
fun getEdgeVariant(edge: Edge): Gesture {
|
||||
return when(edge) {
|
||||
Edge.TOP ->
|
||||
when(this) {
|
||||
SWIPE_LEFT -> SWIPE_LEFT_TOP_EDGE
|
||||
SWIPE_RIGHT -> SWIPE_RIGHT_TOP_EDGE
|
||||
else -> this
|
||||
}
|
||||
Edge.BOTTOM ->
|
||||
when(this) {
|
||||
SWIPE_LEFT -> SWIPE_LEFT_BOTTOM_EDGE
|
||||
SWIPE_RIGHT -> SWIPE_RIGHT_BOTTOM_EDGE
|
||||
else -> this
|
||||
}
|
||||
Edge.LEFT ->
|
||||
when(this) {
|
||||
SWIPE_UP -> SWIPE_UP_LEFT_EDGE
|
||||
SWIPE_DOWN -> SWIPE_DOWN_LEFT_EDGE
|
||||
else -> this
|
||||
}
|
||||
Edge.RIGHT ->
|
||||
when(this) {
|
||||
SWIPE_UP -> SWIPE_UP_RIGHT_EDGE
|
||||
SWIPE_DOWN -> SWIPE_DOWN_RIGHT_EDGE
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isDoubleVariant(): Boolean {
|
||||
return when(this){
|
||||
SWIPE_UP_DOUBLE,
|
||||
|
@ -76,6 +117,20 @@ enum class Gesture (val id: String, private val labelResource: Int,
|
|||
}
|
||||
}
|
||||
|
||||
fun isEdgeVariant(): Boolean {
|
||||
return when(this){
|
||||
SWIPE_UP_RIGHT_EDGE,
|
||||
SWIPE_UP_LEFT_EDGE,
|
||||
SWIPE_DOWN_LEFT_EDGE,
|
||||
SWIPE_DOWN_RIGHT_EDGE,
|
||||
SWIPE_LEFT_TOP_EDGE,
|
||||
SWIPE_LEFT_BOTTOM_EDGE,
|
||||
SWIPE_RIGHT_TOP_EDGE,
|
||||
SWIPE_RIGHT_BOTTOM_EDGE -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
operator fun invoke(activity: Activity) {
|
||||
launch(this.getApp(activity), activity, this.animationIn, this.animationOut)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.text.SimpleDateFormat
|
|||
import java.util.*
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* [HomeActivity] is the actual application Launcher,
|
||||
|
@ -146,7 +148,8 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
val preferences = getPreferences(this)
|
||||
|
||||
val doubleActions = preferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
|
||||
val edgeActions = preferences.getBoolean(PREF_EDGE_ACTIONS_ENABLED, false)
|
||||
val edgeStrictness = 0.15
|
||||
// how distinguished the swipe has to be to launch something
|
||||
// strictness = opposite of sensitivity. TODO - May have to be adjusted
|
||||
val strictness = (4 / bufferedPointerCount) * ((100 - preferences.getInt(PREF_SLIDE_SENSITIVITY, 50)) / 50)
|
||||
|
@ -169,6 +172,20 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
if (doubleActions && bufferedPointerCount > 1) {
|
||||
gesture = gesture?.let(Gesture::getDoubleVariant)
|
||||
}
|
||||
|
||||
if (edgeActions) {
|
||||
if(max(e1.x, e2.x) < edgeStrictness * width){
|
||||
gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.LEFT)};
|
||||
} else if (min(e1.x, e2.x) > (1-edgeStrictness) * width){
|
||||
gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.RIGHT)};
|
||||
}
|
||||
|
||||
if(max(e1.y, e2.y) < edgeStrictness * height){
|
||||
gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.TOP)};
|
||||
} else if (min(e1.y, e2.y) > (1-edgeStrictness) * height){
|
||||
gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.BOTTOM)};
|
||||
}
|
||||
}
|
||||
gesture?.invoke(this)
|
||||
|
||||
return true
|
||||
|
|
|
@ -118,7 +118,10 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
|
||||
init {
|
||||
val doubleActions = getPreferences(activity).getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
gesturesList = Gesture.values().filter { doubleActions || !it.isDoubleVariant() }
|
||||
val edgeActions = getPreferences(activity).getBoolean(PREF_EDGE_ACTIONS_ENABLED, false)
|
||||
gesturesList = Gesture.values().filter {
|
||||
(doubleActions || !it.isDoubleVariant())
|
||||
&& (edgeActions || !it.isEdgeVariant())}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
|
|
@ -9,9 +9,11 @@ import android.view.ViewGroup
|
|||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Switch
|
||||
import androidx.fragment.app.Fragment
|
||||
import de.jrpie.android.launcher.PREF_DATE_FORMAT
|
||||
import de.jrpie.android.launcher.PREF_DOUBLE_ACTIONS_ENABLED
|
||||
import de.jrpie.android.launcher.PREF_EDGE_ACTIONS_ENABLED
|
||||
import de.jrpie.android.launcher.PREF_SCREEN_FULLSCREEN
|
||||
import de.jrpie.android.launcher.PREF_SCREEN_TIMEOUT_DISABLED
|
||||
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_KEYBOARD
|
||||
|
@ -58,6 +60,8 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
setSwitchColor(settings_launcher_switch_auto_launch, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_auto_keyboard, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_enable_double, vibrantColor)
|
||||
setSwitchColor(settings_launcher_switch_enable_edge, vibrantColor)
|
||||
|
||||
|
||||
setButtonColor(settings_launcher_button_choose_wallpaper, vibrantColor)
|
||||
settings_seekbar_sensitivity.progressDrawable.setColorFilter(vibrantColor, PorterDuff.Mode.SRC_IN)
|
||||
|
@ -65,6 +69,18 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
override fun setOnClicks() {
|
||||
|
||||
val preferences = getPreferences(activity!!)
|
||||
|
||||
fun bindSwitchToPref(switch: Switch, pref: String, default: Boolean, onChange: (Boolean) -> Unit){
|
||||
switch.isChecked = preferences.getBoolean(pref, default)
|
||||
switch.setOnCheckedChangeListener { _, isChecked -> // Toggle double actions
|
||||
preferences.edit()
|
||||
.putBoolean(pref, isChecked)
|
||||
.apply()
|
||||
onChange(isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
settings_launcher_button_choose_wallpaper.setOnClickListener {
|
||||
// https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271
|
||||
val intent = Intent(Intent.ACTION_SET_WALLPAPER)
|
||||
|
@ -74,45 +90,21 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
startActivity(intent)
|
||||
}
|
||||
|
||||
val preferences = getPreferences(activity!!)
|
||||
|
||||
settings_launcher_switch_screen_timeout.isChecked = preferences.getBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false)
|
||||
settings_launcher_switch_screen_timeout.setOnCheckedChangeListener { _, isChecked -> // Toggle screen timeout
|
||||
preferences.edit()
|
||||
.putBoolean(PREF_SCREEN_TIMEOUT_DISABLED, isChecked)
|
||||
.apply()
|
||||
|
||||
bindSwitchToPref(settings_launcher_switch_screen_timeout, PREF_SCREEN_TIMEOUT_DISABLED, false) {
|
||||
setWindowFlags(activity!!.window)
|
||||
}
|
||||
settings_launcher_switch_screen_full.isChecked = preferences.getBoolean(PREF_SCREEN_FULLSCREEN, true)
|
||||
settings_launcher_switch_screen_full.setOnCheckedChangeListener { _, isChecked -> // Toggle fullscreen
|
||||
preferences.edit()
|
||||
.putBoolean(PREF_SCREEN_FULLSCREEN, isChecked)
|
||||
.apply()
|
||||
|
||||
bindSwitchToPref(settings_launcher_switch_screen_full, PREF_SCREEN_FULLSCREEN, true) {
|
||||
setWindowFlags(activity!!.window)
|
||||
}
|
||||
|
||||
settings_launcher_switch_auto_launch.isChecked = preferences.getBoolean(PREF_SEARCH_AUTO_LAUNCH, false)
|
||||
settings_launcher_switch_auto_launch.setOnCheckedChangeListener { _, isChecked -> // Toggle double actions
|
||||
preferences.edit()
|
||||
.putBoolean(PREF_SEARCH_AUTO_LAUNCH, isChecked)
|
||||
.apply()
|
||||
bindSwitchToPref(settings_launcher_switch_auto_launch, PREF_SEARCH_AUTO_LAUNCH, false) {}
|
||||
bindSwitchToPref(settings_launcher_switch_auto_keyboard, PREF_SEARCH_AUTO_KEYBOARD, true) {}
|
||||
bindSwitchToPref(settings_launcher_switch_enable_double, PREF_DOUBLE_ACTIONS_ENABLED, false) {
|
||||
intendedSettingsPause = true
|
||||
activity!!.recreate()
|
||||
}
|
||||
|
||||
settings_launcher_switch_auto_keyboard.isChecked = preferences.getBoolean(PREF_SEARCH_AUTO_KEYBOARD, true)
|
||||
settings_launcher_switch_auto_keyboard.setOnCheckedChangeListener { _, isChecked -> // Toggle double actions
|
||||
preferences.edit()
|
||||
.putBoolean(PREF_SEARCH_AUTO_KEYBOARD, isChecked)
|
||||
.apply()
|
||||
}
|
||||
|
||||
settings_launcher_switch_enable_double.isChecked = preferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
settings_launcher_switch_enable_double.setOnCheckedChangeListener { _, isChecked -> // Toggle double actions
|
||||
preferences.edit()
|
||||
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, isChecked)
|
||||
.apply()
|
||||
|
||||
bindSwitchToPref(settings_launcher_switch_enable_edge, PREF_EDGE_ACTIONS_ENABLED, false) {
|
||||
intendedSettingsPause = true
|
||||
activity!!.recreate()
|
||||
}
|
||||
|
|
|
@ -307,5 +307,34 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16sp"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="8sp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_launcher_text_enable_edge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_launcher_enable_edge"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<android.widget.Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/settings_launcher_switch_enable_edge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -8,6 +8,9 @@
|
|||
<item>launcher:choose</item> <!-- The apps list -->
|
||||
</string-array>
|
||||
|
||||
<string-array name="default_up_left" />
|
||||
<string-array name="default_up_right" />
|
||||
|
||||
<!-- Swipe double up - Translation app -->
|
||||
<string-array name="default_double_up">
|
||||
<item>com.google.android.apps.translate</item> <!-- Google Translate -->
|
||||
|
@ -26,6 +29,9 @@
|
|||
<item>com.android.chrome</item> <!-- Chrome -->
|
||||
</string-array>
|
||||
|
||||
<string-array name="default_down_left" />
|
||||
<string-array name="default_down_right" />
|
||||
|
||||
<!-- Swipe double down - Secure Browser -->
|
||||
<string-array name="default_double_down">
|
||||
<item>org.torproject.torbrowser</item> <!-- Tor Browser -->
|
||||
|
@ -39,6 +45,9 @@
|
|||
<item>com.google.android.gm</item> <!-- Google Mail -->
|
||||
</string-array>
|
||||
|
||||
<string-array name="default_right_top" />
|
||||
<string-array name="default_right_bottom" />
|
||||
|
||||
<!-- Swipe double right -->
|
||||
<string-array name="default_double_right">
|
||||
<item>com.android.documentsui</item>
|
||||
|
@ -52,6 +61,11 @@
|
|||
<item>org.thoughtcrime.securesms</item> <!-- Signal -->
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="default_left_top" />
|
||||
<string-array name="default_left_bottom" />
|
||||
|
||||
|
||||
<!-- Swipe double left - More messengers -->
|
||||
<string-array name="default_double_left">
|
||||
<item>com.whatsapp</item> <!-- WhatsApp -->
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
<string name="settings_gesture_double_left">Double Left</string>
|
||||
<string name="settings_gesture_right">Swipe Right</string>
|
||||
<string name="settings_gesture_double_right">Double Right</string>
|
||||
<string name="settings_gesture_right_top_edge">Swipe Right (Top)</string>
|
||||
<string name="settings_gesture_right_bottom_edge">Swipe Right (Bottom)</string>
|
||||
<string name="settings_gesture_left_bottom_edge">Swipe Left (Bottom)</string>
|
||||
<string name="settings_gesture_left_top_edge">Swipe Left (Top)</string>
|
||||
<string name="settings_gesture_up_left_edge">Swipe Up (Left Edge)</string>
|
||||
<string name="settings_gesture_up_right_edge">Swipe Up (Right Edge)</string>
|
||||
<string name="settings_gesture_down_left_edge">Swipe Down (Left Edge)</string>
|
||||
<string name="settings_gesture_down_right_edge">Swipe Down (Right Edge)</string>
|
||||
<string name="settings_gesture_vol_up">Volume Up</string>
|
||||
<string name="settings_gesture_vol_down">Volume Down</string>
|
||||
<string name="settings_gesture_double_click">Double Click</string>
|
||||
|
@ -102,6 +110,7 @@
|
|||
<string name="settings_launcher_section_functions">Functions</string>
|
||||
|
||||
<string name="settings_launcher_enable_double">Double swipe actions</string>
|
||||
<string name="settings_launcher_enable_edge">Edge swipe actions</string>
|
||||
<string name="settings_launcher_auto_launch">Launch search results</string>
|
||||
<string name="settings_launcher_auto_keyboard">Start keyboard for search</string>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
This is more like a fallback- theme that may partially be used by older apis.
|
||||
|
||||
-->
|
||||
<style name="baseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<style name="launcherBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/finnmglasTheme_background_color</item>
|
||||
<item name="colorPrimaryDark">@color/finnmglasTheme_background_color</item>
|
||||
<item name="android:colorBackground">@color/finnmglasTheme_background_color</item>
|
||||
|
|
Loading…
Add table
Reference in a new issue