diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 5339fd8..55b02dd 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -145,6 +145,25 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh setHomeListeners() + // Task to update the app menu every 5 seconds + lifecycleScope.launch { + lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) { + while (true) { + refreshAppMenu() + delay(5000) + } + } + } + + // Task to update the weather every 10 minutes + lifecycleScope.launch(Dispatchers.IO) { + repeatOnLifecycle(Lifecycle.State.STARTED) { + while (true) { + updateWeather() + delay(600000) + } + } + } setupApps() } @@ -1151,78 +1170,39 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh val deltaY = e2.y - e1.y val deltaX = e2.x - e1.x - if (Math.abs(deltaX) > Math.abs(deltaY)) { - // Swipe right - if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled( - "right" - ) - ) { - if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) { - canLaunchShortcut = false - appUtils.launchApp( - rightSwipeActivity.first!!.componentName, - launcherApps.profiles[rightSwipeActivity.second!!] - ) - } else { - Toast.makeText( - this@MainActivity, - getString(R.string.launch_error), - Toast.LENGTH_SHORT - ).show() - } - } else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && !sharedPreferenceManager.isGestureEnabled( - "right" - ) - ) { - canLaunchShortcut = false - if (gestureUtils.isAccessibilityServiceEnabled( - ScreenLockService::class.java - ) - ) { - val intent = Intent(this@MainActivity, ScreenLockService::class.java) - intent.action = "RECENTS" - startService(intent) - finishAndRemoveTask() - } else { - gestureUtils.promptEnableAccessibility() - } - } - // Swipe left - else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled( - "left" - ) - ) { - println(leftSwipeActivity) - if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) { - canLaunchShortcut = false - appUtils.launchApp( - leftSwipeActivity.first!!.componentName, - launcherApps.profiles[leftSwipeActivity.second!!] - ) - } else { - Toast.makeText( - this@MainActivity, - getString(R.string.launch_error), - Toast.LENGTH_SHORT - ).show() - } - } - } else { + // Swipe up + if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) { + canLaunchShortcut = false + openAppMenu() + } - // Swipe up - if (deltaY < -swipeThreshold && abs(velocityY) > swipeVelocityThreshold) { - canLaunchShortcut = false - openAppMenu() - } + // Swipe down + else if (deltaY > swipeThreshold && abs(velocityY) > swipeVelocityThreshold) { + val statusBarService = getSystemService(Context.STATUS_BAR_SERVICE) + val statusBarManager: Class<*> = Class.forName("android.app.StatusBarManager") + val expandMethod: Method = statusBarManager.getMethod("expandNotificationsPanel") + expandMethod.invoke(statusBarService) + } - // Swipe down - else if (deltaY > swipeThreshold && abs(velocityY) > swipeVelocityThreshold) { - val statusBarService = getSystemService(Context.STATUS_BAR_SERVICE) - val statusBarManager: Class<*> = - Class.forName("android.app.StatusBarManager") - val expandMethod: Method = - statusBarManager.getMethod("expandNotificationsPanel") - expandMethod.invoke(statusBarService) + // Swipe left + else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){ + println(leftSwipeActivity) + if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) { + canLaunchShortcut = false + appUtils.launchApp(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!]) + } else { + Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show() + } + } + + + // Swipe right + else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) { + if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) { + canLaunchShortcut = false + appUtils.launchApp(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!]) + } else { + Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show() } } } diff --git a/app/src/main/java/eu/ottop/yamlauncher/tasks/ScreenLockService.kt b/app/src/main/java/eu/ottop/yamlauncher/tasks/ScreenLockService.kt index afcf884..403ccec 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/tasks/ScreenLockService.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/tasks/ScreenLockService.kt @@ -16,9 +16,6 @@ class ScreenLockService : AccessibilityService() { if (intent != null && intent.action == "LOCK_SCREEN") { performLockScreen() } - if (intent != null && intent.action == "RECENTS") { - performShowRecents() - } stopSelf() return super.onStartCommand(intent, flags, startId) } @@ -26,8 +23,4 @@ class ScreenLockService : AccessibilityService() { private fun performLockScreen() { performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN) } - - private fun performShowRecents() { - performGlobalAction(GLOBAL_ACTION_RECENTS) - } } \ No newline at end of file diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt index 020bdda..a0b3c2d 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/Animations.kt @@ -118,10 +118,12 @@ class Animations (context: Context) { private fun View.fadeIn(duration: Long = sharedPreferenceManager.getAnimationSpeed()) { if (visibility != View.VISIBLE) { alpha = 0f + translationY = -height.toFloat()/100 visibility = View.VISIBLE animate() .alpha(1f) + .translationY(0f) .setDuration(duration) .setListener(null) } @@ -129,12 +131,12 @@ class Animations (context: Context) { private fun View.fadeOut() { if (visibility == View.VISIBLE) { - alpha = 0f isInAnim = true val duration = sharedPreferenceManager.getAnimationSpeed() animate() .alpha(0f) + .translationY(-height.toFloat()/100) .setDuration(duration/2) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt index 91635b1..d294800 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt @@ -350,11 +350,11 @@ class UIUtils(private val context: Context) { // Size fun setClockSize(clock: TextClock) { - setTextSize(clock, sharedPreferenceManager.getClockSize(), 66F, 58F, 70F, 78F, 82F, 84F) + setTextSize(clock, sharedPreferenceManager.getClockSize(), 48F, 58F, 70F, 78F, 82F, 84F) } fun setDateSize(dateText: TextClock) { - setTextSize(dateText, sharedPreferenceManager.getDateSize(), 22F, 17F, 20F, 23F, 26F, 29F) + setTextSize(dateText, sharedPreferenceManager.getDateSize(), 14F, 17F, 20F, 23F, 26F, 29F) } fun setShortcutsSize(shortcuts: LinearLayout) { @@ -363,9 +363,7 @@ class UIUtils(private val context: Context) { shortcuts.children.forEach { if (it is TextView) { - it.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22F) -// val padding = 15 -// it.setPadding(0, dpToPx(padding), 0, dpToPx(padding)) + setShortcutSize(it, size) } } } @@ -375,9 +373,9 @@ class UIUtils(private val context: Context) { when (size) { "tiny" -> { shortcut.setAutoSizeTextTypeUniformWithConfiguration( - 22, // Min text size in SP - 22, // Max text size in SP - 1, // Step granularity in SP + 5, // Min text size in SP + 20, // Max text size in SP + 2, // Step granularity in SP TypedValue.COMPLEX_UNIT_SP // Unit of measurement ) } @@ -436,9 +434,9 @@ class UIUtils(private val context: Context) { regionText: TextView? = null ) { val size = sharedPreferenceManager.getAppSize() - setTextSize(textView, size, 22F, 24F, 27F, 30F, 33F, 36F) + setTextSize(textView, size, 21F, 24F, 27F, 30F, 33F, 36F) if (editText != null) { - setTextSize(editText, size, 22F, 24F, 27F, 30F, 33F, 36F) + setTextSize(editText, size, 21F, 24F, 27F, 30F, 33F, 36F) } if (regionText != null) { setTextSize(regionText, size, 11F, 14F, 17F, 20F, 23F, 26F) @@ -446,11 +444,11 @@ class UIUtils(private val context: Context) { } fun setSearchSize(searchView: TextInputEditText) { - setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 22F, 21F, 25F, 27F, 30F, 33F) + setTextSize(searchView, sharedPreferenceManager.getSearchSize(), 18F, 21F, 25F, 27F, 30F, 33F) } fun setMenuTitleSize(menuTitle: TextView) { - setTextSize(menuTitle, sharedPreferenceManager.getAppSize(), 22F, 30F, 33F, 36F, 39F, 42F) + setTextSize(menuTitle, sharedPreferenceManager.getAppSize(), 27F, 30F, 33F, 36F, 39F, 42F) } private fun setTextSize(view: TextView, size: String?, t: Float, s: Float, m: Float, l: Float, x: Float, h: Float) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4186ab9..f6c8ff7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -17,6 +17,10 @@ android:orientation="vertical" android:visibility="invisible"> + + @@ -70,8 +75,8 @@ android:id="@+id/searchLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="22dp" - android:layout_marginTop="0dp" + android:layout_marginHorizontal="32dp" + android:layout_marginTop="5dp" android:layout_marginBottom="10dp" android:layout_weight="0.1" android:orientation="horizontal" @@ -91,6 +96,7 @@ android:singleLine="true" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.DeviceDefault" + android:textColorHighlight="#5F33B5E5" android:textSize="25sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/internetSearch" @@ -158,10 +164,9 @@ android:id="@+id/textClock" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginHorizontal="0dp" - android:layout_marginTop="0dp" - android:layout_marginBottom="78dp" - android:paddingHorizontal="19dp" + android:layout_marginHorizontal="32dp" + android:layout_marginTop="45dp" + android:layout_marginBottom="27dp" android:format12Hour="hh:mm" android:format24Hour="HH:mm" android:textAlignment="textStart" @@ -178,11 +183,9 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:format12Hour="dd MMM yyyy" - android:format24Hour="yyyy-MM-dd / EEEE" - android:lineSpacingExtra="0sp" - android:paddingTop="0dp" - android:paddingHorizontal="22dp" - android:layout_marginBottom="38dp" + android:format24Hour="dd MMM yyyy" + android:lineSpacingExtra="8sp" + android:paddingHorizontal="2dp" android:textAlignment="textStart" android:textAppearance="@android:style/TextAppearance.DeviceDefault" android:textColor="#F3F3F3" @@ -198,17 +201,18 @@ android:id="@+id/topSpace" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_weight="0" /> + android:layout_weight="0.22" /> - 0.15 + 0.06 0.09 0.11 0.14 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 2307f34..45e8c74 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -11,7 +11,7 @@ shortEdges false false - #FFCDCDCD + #FF80CBC4