From 71d2efb52cef22d763bd852377f61299f480cd66 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Fri, 31 May 2024 15:53:16 +0200 Subject: [PATCH] fix npc banner layout --- Habitica/res/layout/npc_banner.xml | 26 +++++++++++-------- .../android/habitica/models/shops/Shop.kt | 1 + .../habitica/ui/views/NPCBannerView.kt | 20 +++++++++----- fastlane/README.md | 8 ++++++ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Habitica/res/layout/npc_banner.xml b/Habitica/res/layout/npc_banner.xml index ec77a576e..79c11ae9c 100644 --- a/Habitica/res/layout/npc_banner.xml +++ b/Habitica/res/layout/npc_banner.xml @@ -1,18 +1,22 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + tools:parentTag="android.widget.RelativeLayout" + tools:showIn="@layout/shop_header"> + android:id="@+id/backgroundView" + android:layout_width="match_parent" + android:layout_alignParentTop="true" + android:layout_alignParentStart="true" + android:layout_height="@dimen/shop_height" /> + android:id="@+id/sceneView" + android:layout_width="match_parent" + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_height="@dimen/shop_scene_height" /> diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/Shop.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/Shop.kt index 57108013e..eca48d2ef 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/Shop.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/Shop.kt @@ -19,6 +19,7 @@ class Shop { SEASONAL_SHOP -> R.string.seasonalShop_owner TIME_TRAVELERS_SHOP -> R.string.timetravelers_owner CUSTOMIZATIONS -> R.string.customizations_owner + "customizationsShop" -> R.string.customizations_owner else -> R.string.market_owner } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/NPCBannerView.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/NPCBannerView.kt index 53777adae..a5ac0d5f8 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/NPCBannerView.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/NPCBannerView.kt @@ -7,6 +7,7 @@ import android.graphics.drawable.BitmapDrawable import android.util.AttributeSet import android.widget.FrameLayout import android.widget.ImageView +import android.widget.RelativeLayout import androidx.core.graphics.drawable.toBitmap import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.databinding.NpcBannerBinding @@ -16,7 +17,7 @@ import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch import kotlin.math.roundToInt -class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) { +class NPCBannerView(context: Context, attrs: AttributeSet?) : RelativeLayout(context, attrs) { private val binding = NpcBannerBinding.inflate(context.layoutInflater, this) var shopSpriteSuffix: String? = null @@ -41,15 +42,12 @@ class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(contex } private fun setImage() { - DataBindingUtils.loadImage(context, identifier + "_scene" + shopSpriteSuffix) { - binding.sceneView.setImageDrawable(it) - } - binding.backgroundView.scaleType = ImageView.ScaleType.FIT_START + binding.sceneView.scaleType = ImageView.ScaleType.MATRIX + val height = context.resources.getDimension(R.dimen.shop_height).toInt() DataBindingUtils.loadImage(context, identifier + "_background" + shopSpriteSuffix) { val aspectRatio = it.intrinsicWidth / it.intrinsicHeight.toFloat() - val height = context.resources.getDimension(R.dimen.shop_height).toInt() val width = (height * aspectRatio).roundToInt() val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(it.toBitmap(), width, height, false)) drawable.tileModeX = Shader.TileMode.REPEAT @@ -57,5 +55,15 @@ class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(contex binding.backgroundView.background = drawable } } + + DataBindingUtils.loadImage(context, identifier + "_scene" + shopSpriteSuffix) { + val aspectRatio = it.intrinsicWidth / it.intrinsicHeight.toFloat() + val width = (height * aspectRatio).roundToInt() + val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(it.toBitmap(), width, height, false)) + drawable.tileModeX = Shader.TileMode.CLAMP + MainScope().launch { + binding.sceneView.background = drawable + } + } } } diff --git a/fastlane/README.md b/fastlane/README.md index f57928b5d..2eff082fe 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -63,6 +63,14 @@ Submit a new Beta Build to Google Play Deploy a new version to the Google Play +### android upload_to_slack + +```sh +[bundle exec] fastlane android upload_to_slack +``` + +Upload the latest output APK to slack + ---- This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.