mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
parent
a38c683cd2
commit
09926d34ed
7 changed files with 99 additions and 17 deletions
|
@ -36,19 +36,30 @@ lateinit var launcherPreferences: SharedPreferences
|
|||
/* Preference Key Constants */
|
||||
|
||||
const val ACTION_UP = "action_upApp"
|
||||
const val ACTION_DOUBLE_UP = "action_doubleUpApp"
|
||||
const val ACTION_DOWN = "action_downApp"
|
||||
const val ACTION_DOUBLE_DOWN = "action_doubleDownApp"
|
||||
const val ACTION_RIGHT = "action_rightApp"
|
||||
const val ACTION_DOUBLE_RIGHT = "action_doubleRightApp"
|
||||
const val ACTION_LEFT = "action_leftApp"
|
||||
const val ACTION_DOUBLE_LEFT = "action_doubleLeftApp"
|
||||
|
||||
const val ACTION_VOL_UP = "action_volumeUpApp"
|
||||
const val ACTION_VOL_DOWN = "action_volumeDownApp"
|
||||
const val ACTION_DOUBLE_CLICK = "action_doubleClickApp"
|
||||
const val ACTION_LONG_CLICK = "action_longClickApp"
|
||||
|
||||
const val ACTION_CALENDAR = "action_calendarApp"
|
||||
const val ACTION_CLOCK = "action_clockApp"
|
||||
|
||||
val ACTIONS = listOf(ACTION_UP, ACTION_DOWN, ACTION_RIGHT, ACTION_LEFT,
|
||||
ACTION_VOL_UP, ACTION_VOL_DOWN, ACTION_DOUBLE_CLICK, ACTION_LONG_CLICK,
|
||||
ACTION_CALENDAR, ACTION_CLOCK)
|
||||
val ACTIONS = listOf(
|
||||
ACTION_UP, ACTION_DOUBLE_UP,
|
||||
ACTION_DOWN, ACTION_DOUBLE_DOWN,
|
||||
ACTION_RIGHT, ACTION_LEFT,
|
||||
ACTION_VOL_UP, ACTION_VOL_DOWN,
|
||||
ACTION_DOUBLE_CLICK, ACTION_LONG_CLICK,
|
||||
ACTION_CALENDAR, ACTION_CLOCK
|
||||
)
|
||||
|
||||
const val PREF_DOMINANT = "custom_dominant"
|
||||
const val PREF_VIBRANT = "custom_vibrant"
|
||||
|
@ -58,6 +69,8 @@ const val PREF_THEME = "theme"
|
|||
const val PREF_SCREEN_TIMEOUT_DISABLED = "disableTimeout"
|
||||
const val PREF_SCREEN_FULLSCREEN = "useFullScreen"
|
||||
const val PREF_DATE_FORMAT = "dateFormat"
|
||||
|
||||
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
|
||||
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
||||
|
||||
const val PREF_STARTED = "startedBefore"
|
||||
|
@ -72,9 +85,13 @@ val appsList: MutableList<AppInfo> = ArrayList()
|
|||
val displayMetrics = DisplayMetrics()
|
||||
|
||||
var upApp = ""
|
||||
var doubleUpApp = ""
|
||||
var downApp = ""
|
||||
var doubleDownApp = ""
|
||||
var rightApp = ""
|
||||
var doubleRightApp = ""
|
||||
var leftApp = ""
|
||||
var doubleLeftApp = ""
|
||||
var volumeUpApp = ""
|
||||
var volumeDownApp = ""
|
||||
var doubleClickApp = ""
|
||||
|
@ -331,9 +348,13 @@ fun loadApps(packageManager: PackageManager) {
|
|||
|
||||
fun loadSettings() {
|
||||
upApp = launcherPreferences.getString(ACTION_UP, "")!!
|
||||
doubleUpApp = launcherPreferences.getString(ACTION_DOUBLE_UP, "")!!
|
||||
downApp = launcherPreferences.getString(ACTION_DOWN, "")!!
|
||||
doubleDownApp = launcherPreferences.getString(ACTION_DOUBLE_DOWN, "")!!
|
||||
rightApp = launcherPreferences.getString(ACTION_RIGHT, "")!!
|
||||
doubleRightApp = launcherPreferences.getString(ACTION_DOUBLE_RIGHT, "")!!
|
||||
leftApp = launcherPreferences.getString(ACTION_LEFT, "")!!
|
||||
doubleLeftApp = launcherPreferences.getString(ACTION_DOUBLE_LEFT, "")!!
|
||||
volumeUpApp = launcherPreferences.getString(ACTION_VOL_UP, "")!!
|
||||
volumeDownApp = launcherPreferences.getString(ACTION_VOL_DOWN, "")!!
|
||||
|
||||
|
@ -362,6 +383,9 @@ fun resetSettings(context: Context) {
|
|||
.putString(PREF_THEME, "finn")
|
||||
.putBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false)
|
||||
.putBoolean(PREF_SEARCH_AUTO_LAUNCH, false)
|
||||
.putInt(PREF_DATE_FORMAT, 0)
|
||||
.putBoolean(PREF_SCREEN_FULLSCREEN, true)
|
||||
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
|
||||
// load action defaults
|
||||
for (actionKey in ACTIONS)
|
||||
|
@ -390,15 +414,20 @@ fun setWindowFlags(window: Window) {
|
|||
fun pickDefaultApp(action: String, context: Context) : String {
|
||||
val arrayResource = when (action) {
|
||||
ACTION_UP -> R.array.default_up
|
||||
ACTION_DOUBLE_UP -> R.array.default_double_up
|
||||
ACTION_DOWN -> R.array.default_down
|
||||
ACTION_DOUBLE_DOWN -> R.array.default_double_down
|
||||
ACTION_RIGHT -> R.array.default_right
|
||||
ACTION_DOUBLE_RIGHT -> R.array.default_double_right
|
||||
ACTION_LEFT -> R.array.default_left
|
||||
ACTION_DOUBLE_LEFT -> R.array.default_double_left
|
||||
ACTION_VOL_UP -> R.array.default_volume_up
|
||||
ACTION_VOL_DOWN -> R.array.default_volume_down
|
||||
ACTION_DOUBLE_CLICK -> R.array.default_double_click
|
||||
ACTION_LONG_CLICK -> R.array.default_long_click
|
||||
ACTION_CLOCK -> R.array.default_clock
|
||||
ACTION_CALENDAR -> R.array.default_left
|
||||
|
||||
else -> return "" // just prevent crashing on unknown input
|
||||
}
|
||||
|
||||
|
|
|
@ -145,26 +145,34 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
|
||||
override fun onFling(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean {
|
||||
|
||||
Toast.makeText(this, bufferedPointerCount.toString(), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
||||
val width = displayMetrics.widthPixels
|
||||
val height = displayMetrics.heightPixels
|
||||
|
||||
val diffX = e1.x - e2.x
|
||||
val diffY = e1.y - e2.y
|
||||
|
||||
val strictness = 4 // how distinguished the swipe has to be to be accepted
|
||||
val doubleActions = launcherPreferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
|
||||
// how distinguished the swipe has to be to launch something
|
||||
val strictness = (4 / bufferedPointerCount)
|
||||
|
||||
// Only open if the swipe was not from the phones top edge
|
||||
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100)
|
||||
launch(downApp,this, R.anim.top_down)
|
||||
else if (diffY > height / 8 && abs(diffY) > strictness * abs(diffX))
|
||||
launch(upApp, this, R.anim.bottom_up)
|
||||
else if (diffX > width / 4 && abs(diffX) > strictness * abs(diffY))
|
||||
launch(leftApp,this, R.anim.right_left)
|
||||
else if (diffX < -width / 4 && abs(diffX) > strictness * abs(diffY))
|
||||
launch(rightApp, this, R.anim.left_right)
|
||||
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) {
|
||||
if (bufferedPointerCount == 1) launch(downApp, this, R.anim.top_down)
|
||||
else if (bufferedPointerCount == 2 && doubleActions) launch(doubleDownApp, this, R.anim.top_down)
|
||||
}
|
||||
else if (diffY > height / 8 && abs(diffY) > strictness * abs(diffX)) {
|
||||
if (bufferedPointerCount == 1) launch(upApp, this, R.anim.bottom_up)
|
||||
else if (bufferedPointerCount == 2 && doubleActions) launch(doubleUpApp, this, R.anim.bottom_up)
|
||||
}
|
||||
else if (diffX > width / 4 && abs(diffX) > strictness * abs(diffY)) {
|
||||
if (bufferedPointerCount == 1) launch(leftApp,this, R.anim.right_left)
|
||||
else if (bufferedPointerCount == 2 && doubleActions) launch(doubleLeftApp,this, R.anim.right_left)
|
||||
}
|
||||
else if (diffX < -width / 4 && abs(diffX) > strictness * abs(diffY)) {
|
||||
if (bufferedPointerCount == 1) launch(rightApp, this, R.anim.left_right)
|
||||
else if (bufferedPointerCount == 2 && doubleActions) launch(doubleRightApp, this, R.anim.left_right)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -213,7 +221,7 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
// Buffer / Debounce the pointer count
|
||||
if (event.pointerCount > bufferedPointerCount) {
|
||||
bufferedPointerCount = event.pointerCount
|
||||
pointerBufferTimer = fixedRateTimer("pointerBufferTimer", true, 200, 1000) {
|
||||
pointerBufferTimer = fixedRateTimer("pointerBufferTimer", true, 300, 1000) {
|
||||
bufferedPointerCount = 1
|
||||
this.cancel() // a non-recurring timer
|
||||
}
|
||||
|
|
|
@ -134,19 +134,33 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
}
|
||||
|
||||
init {
|
||||
val doubleActions = launcherPreferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
|
||||
actionsList = ArrayList()
|
||||
actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_up),"upApp",
|
||||
upApp
|
||||
))
|
||||
if ( doubleActions) actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_double_up), "doubleUpApp",
|
||||
doubleUpApp
|
||||
))
|
||||
actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_down),"downApp",
|
||||
downApp
|
||||
))
|
||||
if ( doubleActions) actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_double_down), "doubleDownApp",
|
||||
doubleDownApp
|
||||
))
|
||||
actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_left), "leftApp",
|
||||
leftApp
|
||||
))
|
||||
if ( doubleActions) actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_double_left), "doubleLeftApp",
|
||||
doubleLeftApp
|
||||
))
|
||||
actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_right), "rightApp",
|
||||
rightApp
|
||||
))
|
||||
if ( doubleActions) actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_double_right), "doubleRightApp",
|
||||
doubleRightApp
|
||||
))
|
||||
actionsList.add(ActionInfo(activity.getString(R.string.settings_apps_vol_up), "volumeUpApp",
|
||||
volumeUpApp
|
||||
))
|
||||
|
|
|
@ -26,9 +26,13 @@
|
|||
-
|
||||
-->
|
||||
<string name="settings_apps_up">Hochwischen</string>
|
||||
<string name="settings_apps_double_up">Doppelt hoch</string>
|
||||
<string name="settings_apps_down">Runterwischen</string>
|
||||
<string name="settings_apps_double_down">Doppelt runter</string>
|
||||
<string name="settings_apps_left">Linkswischen</string>
|
||||
<string name="settings_apps_double_left">Doppelt links</string>
|
||||
<string name="settings_apps_right">Rechtswischen</string>
|
||||
<string name="settings_apps_double_right">Doppelt rechts</string>
|
||||
<string name="settings_apps_vol_up">Lautstärke +</string>
|
||||
<string name="settings_apps_vol_down">Lautstärke -</string>
|
||||
<string name="settings_apps_double_click">Doppelklick</string>
|
||||
|
|
|
@ -26,9 +26,13 @@
|
|||
-
|
||||
-->
|
||||
<string name="settings_apps_up">Balayez haut</string>
|
||||
<string name="settings_apps_double_up">Double haut</string>
|
||||
<string name="settings_apps_down">Balayez bas</string>
|
||||
<string name="settings_apps_double_down">Double bas</string>
|
||||
<string name="settings_apps_left">Balayez gauche</string>
|
||||
<string name="settings_apps_double_left">Double gauche</string>
|
||||
<string name="settings_apps_right">Balayez droit</string>
|
||||
<string name="settings_apps_double_right">Double droit</string>
|
||||
<string name="settings_apps_vol_up">Monter volume</string>
|
||||
<string name="settings_apps_vol_down">Baisser volume</string>
|
||||
<string name="settings_apps_double_click">Double clic</string>
|
||||
|
|
|
@ -8,9 +8,15 @@
|
|||
<item>launcher:choose</item> <!-- The apps list -->
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe double up - Translation app -->
|
||||
<string-array name="default_double_up">
|
||||
<item>com.google.android.apps.translate</item> <!-- Google Translate -->
|
||||
<item>com.microsoft.translator</item> <!-- Microsoft Translate -->
|
||||
<item>translate.speech.text.translation.voicetranslator</item> <!-- MindMover Translate -->
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe down - Browser -->
|
||||
<string-array name="default_down">
|
||||
<item>org.torproject.torbrowser</item> <!-- Tor Browser -->
|
||||
<item>org.mozilla.firefox</item> <!-- Firefox -->
|
||||
<item>com.brave.browser</item> <!-- Brave Browser -->
|
||||
<item>com.duckduckgo.mobile.android</item> <!-- DuckDuckGo Browser -->
|
||||
|
@ -18,6 +24,11 @@
|
|||
<item>com.android.chrome</item> <!-- Chrome -->
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe double down - Secure Browser -->
|
||||
<string-array name="default_double_down">
|
||||
<item>org.torproject.torbrowser</item> <!-- Tor Browser -->
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe right - Mail -->
|
||||
<string-array name="default_right">
|
||||
<item>de.web.mobile.android.mail</item> <!-- WebMail -->
|
||||
|
@ -31,6 +42,14 @@
|
|||
<item>com.samsung.android.calendar</item> <!-- Samsung Calendar -->
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe double left -->
|
||||
<string-array name="default_double_left">
|
||||
</string-array>
|
||||
|
||||
<!-- Swipe double right -->
|
||||
<string-array name="default_double_right">
|
||||
</string-array>
|
||||
|
||||
<!-- Volume up - Messaging -->
|
||||
<string-array name="default_volume_up">
|
||||
<item>com.whatsapp</item> <!-- WhatsApp -->
|
||||
|
|
|
@ -34,9 +34,13 @@
|
|||
-
|
||||
-->
|
||||
<string name="settings_apps_up">Swipe Up</string>
|
||||
<string name="settings_apps_double_up">Double Up</string>
|
||||
<string name="settings_apps_down">Swipe Down</string>
|
||||
<string name="settings_apps_double_down">Double Down</string>
|
||||
<string name="settings_apps_left">Swipe Left</string>
|
||||
<string name="settings_apps_double_left">Double Left</string>
|
||||
<string name="settings_apps_right">Swipe Right</string>
|
||||
<string name="settings_apps_double_right">Double Right</string>
|
||||
<string name="settings_apps_vol_up">Volume Up</string>
|
||||
<string name="settings_apps_vol_down">Volume Down</string>
|
||||
<string name="settings_apps_double_click">Double Click</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue