From e453742ce8654c2fa9c0d57b5fbf21af63d7cab7 Mon Sep 17 00:00:00 2001 From: ottoptj Date: Fri, 30 Aug 2024 18:15:48 +0300 Subject: [PATCH] Updated gradle and added customization to Shortcut Spacing --- .../java/eu/ottop/yamlauncher/MainActivity.kt | 6 ++++++ .../settings/SharedPreferenceManager.kt | 4 ++++ .../eu/ottop/yamlauncher/utils/UIUtils.kt | 19 +++++++++++++++++++ app/src/main/res/values/arrays.xml | 18 ++++++++++++++++++ app/src/main/res/xml/root_preferences.xml | 9 +++++++++ build.gradle.kts | 2 +- 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index adf84b0..8da7e11 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -297,6 +297,8 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh uiUtils.setShortcutsSize(binding.homeView) uiUtils.setSearchSize(searchView) + uiUtils.setShortcutsSpacing(binding.homeView) + uiUtils.setStatusBar(window) leftSwipeActivity = gestureUtils.getSwipeInfo(launcherApps, "left") @@ -413,6 +415,10 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh uiUtils.setSearchSize(searchView) } + "shortcutWeight" -> { + uiUtils.setShortcutsSpacing(binding.homeView) + } + "barVisibility" -> { uiUtils.setStatusBar(window) } diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt index 6b3a545..f20b8c4 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt @@ -83,6 +83,10 @@ class SharedPreferenceManager (private val context: Context) { return preferences.getString("shortcutSize", "medium") } + fun getShortcutWeight(): Float? { + return preferences.getString("shortcutWeight", "0.09")?.toFloat() + } + fun isBatteryEnabled(): Boolean { return preferences.getBoolean("batteryEnabled", false) } 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 7466f09..0ce59c0 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt @@ -316,4 +316,23 @@ class UIUtils(context: Context) { } } } + + fun setShortcutsSpacing(shortcuts: LinearLayout) { + val shortcutWeight = sharedPreferenceManager.getShortcutWeight() + shortcuts.children.forEach { + if (it is TextView) { + setShortcutSpacing(it, shortcutWeight) + } + } + } + + private fun setShortcutSpacing(shortcut: TextView, shortcutWeight: Float?) { + val layoutParams = shortcut.layoutParams as LinearLayout.LayoutParams + + if (shortcutWeight != null) { + layoutParams.weight = shortcutWeight + } + + shortcut.layoutParams = layoutParams + } } \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 5294987..a1cba8d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -105,6 +105,24 @@ extra + + Small + Medium + Large + Extra Large + Huge + Extra Huge + + + + 0.06 + 0.09 + 0.12 + 0.15 + 0.18 + 0.21 + + °C diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index f55ee26..f973fc7 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -105,6 +105,15 @@ app:key="shortcutSize" app:title="Shortcut Size" app:useSimpleSummaryProvider="true" /> +