From 2b9db81936ad5c6f0985bbd4b08e64a2f6426811 Mon Sep 17 00:00:00 2001 From: ottoptj Date: Sat, 31 Aug 2024 00:32:19 +0300 Subject: [PATCH] Fixed weather spacing --- .../eu/ottop/yamlauncher/AppMenuAdapter.kt | 2 +- .../settings/GestureAppsAdapter.kt | 2 +- .../yamlauncher/settings/HiddenAppsAdapter.kt | 2 +- .../settings/LocationListAdapter.kt | 4 +- .../eu/ottop/yamlauncher/utils/UIUtils.kt | 46 +++++++++++-------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt index 03e9e62..8676629 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/AppMenuAdapter.kt @@ -134,7 +134,7 @@ class AppMenuAdapter( uiUtils.setAppSize(holder.textView, holder.editText) - uiUtils.setAppSpacing(holder.textView) + uiUtils.setItemSpacing(holder.textView) // Update the application information (allows updating apps to work) val appInfo = appUtils.getAppInfo( diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsAdapter.kt index 0f646ce..2b3c876 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsAdapter.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsAdapter.kt @@ -64,7 +64,7 @@ class GestureAppsAdapter( uiUtils.setAppSize(holder.textView) - uiUtils.setAppSpacing(holder.textView) + uiUtils.setItemSpacing(holder.textView) // Does not need to be specially updated since it's in a separate activity and thus reloads when opened again val appInfo = app.first.activityInfo.applicationInfo diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/HiddenAppsAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/HiddenAppsAdapter.kt index 9368f14..7c4b4e8 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/HiddenAppsAdapter.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/HiddenAppsAdapter.kt @@ -65,7 +65,7 @@ class HiddenAppsAdapter( uiUtils.setAppSize(holder.textView) - uiUtils.setAppSpacing(holder.textView) + uiUtils.setItemSpacing(holder.textView) // Separate activity from Main so does not need special update val appInfo = app.first.activityInfo.applicationInfo diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/LocationListAdapter.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/LocationListAdapter.kt index d1d7a55..829718a 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/LocationListAdapter.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/LocationListAdapter.kt @@ -25,7 +25,7 @@ class LocationListAdapter( } inner class AppViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - private val listItem: ConstraintLayout = itemView.findViewById(R.id.locationPlace) + val listItem: ConstraintLayout = itemView.findViewById(R.id.locationPlace) val textView: TextView = listItem.findViewById(R.id.locationName) val regionText: TextView = listItem.findViewById(R.id.regionName) @@ -55,7 +55,7 @@ class LocationListAdapter( uiUtils.setAppSize(holder.textView, null, holder.regionText) - uiUtils.setAppSpacing(holder.textView) + uiUtils.setWeatherSpacing(holder.listItem) holder.textView.text = location["name"] holder.regionText.text = context.getString(R.string.region_text, location["region"], location["country"]) 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 bb5f7d8..f22b34e 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt @@ -16,6 +16,7 @@ import android.view.WindowInsetsController import android.widget.LinearLayout import android.widget.TextClock import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.children import com.google.android.material.textfield.TextInputEditText import eu.ottop.yamlauncher.settings.SharedPreferenceManager @@ -357,22 +358,7 @@ class UIUtils(private val context: Context) { } catch (_: Exception) {} } - // Status bar visibility - fun setStatusBar(window: Window) { - val windowInsetsController = window.insetsController - - windowInsetsController?.let { - if (sharedPreferenceManager.isBarVisible()) { - it.show(WindowInsets.Type.statusBars()) - } - else { - it.hide(WindowInsets.Type.statusBars()) - it.systemBarsBehavior = - WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } - } - } - + // Spacing fun setShortcutsSpacing(shortcuts: LinearLayout) { val shortcutWeight = sharedPreferenceManager.getShortcutWeight() shortcuts.children.forEach { @@ -392,11 +378,19 @@ class UIUtils(private val context: Context) { shortcut.layoutParams = layoutParams } - fun setAppSpacing(app: TextView) { + fun setItemSpacing(item: TextView) { val spacing = sharedPreferenceManager.getAppSpacing() if (spacing != null) { val spacingPx = dpToPx(spacing) - app.setPadding(app.paddingLeft, spacingPx, app.paddingRight, spacingPx) + item.setPadding(item.paddingLeft, spacingPx, item.paddingRight, spacingPx) + } + } + + fun setWeatherSpacing(item: ConstraintLayout) { + val spacing = sharedPreferenceManager.getAppSpacing() + if (spacing != null) { + val spacingPx = dpToPx(spacing) + item.setPadding(item.paddingLeft, spacingPx, item.paddingRight, spacingPx) } } @@ -404,4 +398,20 @@ class UIUtils(private val context: Context) { val density = context.resources.displayMetrics.density return (dp * density).toInt() } + + // Status bar visibility + fun setStatusBar(window: Window) { + val windowInsetsController = window.insetsController + + windowInsetsController?.let { + if (sharedPreferenceManager.isBarVisible()) { + it.show(WindowInsets.Type.statusBars()) + } + else { + it.hide(WindowInsets.Type.statusBars()) + it.systemBarsBehavior = + WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + } + } } \ No newline at end of file