mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
fix npc banner layout
This commit is contained in:
parent
2a648dd668
commit
71d2efb52c
4 changed files with 38 additions and 17 deletions
|
|
@ -1,18 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:showIn="@layout/shop_header">
|
||||
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">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/shop_height" />
|
||||
android:id="@+id/backgroundView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_height="@dimen/shop_height" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sceneView"
|
||||
android:layout_width="match_parent"
|
||||
android:scaleType="fitStart"
|
||||
android:layout_height="@dimen/shop_scene_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" />
|
||||
</merge>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue