mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-22 05:45:04 +00:00
Update world boss dialogs
This commit is contained in:
parent
24e0407870
commit
aeac52ef88
10 changed files with 116 additions and 69 deletions
|
|
@ -13,13 +13,13 @@
|
|||
android:paddingTop="@dimen/spacing_large"
|
||||
android:paddingBottom="@dimen/spacing_large"
|
||||
android:textSize="18sp"
|
||||
android:layout_marginBottom="@dimen/spacing_large"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
tools:text="This is the title!"
|
||||
tools:background="@color/brand_300"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:id="@+id/subtitleTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -44,10 +44,4 @@
|
|||
android:paddingRight="@dimen/spacing_large"
|
||||
tools:text="This is an example message"
|
||||
tools:visibility="visible"/>
|
||||
<FrameLayout
|
||||
android:id="@+id/contentViewContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large" />
|
||||
</LinearLayout>
|
||||
17
Habitica/res/layout/npc_banner.xml
Normal file
17
Habitica/res/layout/npc_banner.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?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">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/shop_height" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/sceneView"
|
||||
android:layout_width="375dp"
|
||||
android:layout_height="@dimen/shop_scene_height" />
|
||||
</merge>
|
||||
|
|
@ -6,14 +6,11 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundView"
|
||||
<com.habitrpg.android.habitica.ui.views.NPCBannerView
|
||||
android:id="@+id/npcBannerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/shop_height"/>
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/sceneView"
|
||||
android:layout_width="375dp"
|
||||
android:layout_height="@dimen/shop_scene_height" />
|
||||
android:layout_height="@dimen/shop_scene_height"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@
|
|||
<string name="insufficientSubscriberGems">You have bought all the Gems you can this month. More become available within the first three days of each month. Thanks for subscribing!</string>
|
||||
<string name="insufficientSubscriberGemsTitle">Monthly Gem Cap Reached</string>
|
||||
<string name="chat_message">Chat Message</string>
|
||||
<string name="world_boss_description_title">The DysHeartener attacks!</string>
|
||||
<string name="world_boss_description_title">What’s a World Boss?</string>
|
||||
<string name="world_boss_description_description">A World Boss is a special event where the whole community works together to take down a powerful monster with their tasks!\nComplete tasks to damage the Boss\nThe Boss won’t damage you for missed tasks, but its Rage meter will go up. If the bar fills up, the Boss will attack one of the shopkeepers!\nYou can continue with normal Quest Bosses, damage will apply to both\nCheck the Tavern to see Boss progress and Rage attacks</string>
|
||||
<string name="world_boss_description_intro">A World Boss is a special event where the whole community works together to take down a powerful monster with their tasks!</string>
|
||||
<string name="world_boss_description_1">Complete tasks to damage the Boss</string>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.habitrpg.android.habitica.models.user.User
|
|||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.ShopItemViewHolder
|
||||
import com.habitrpg.android.habitica.ui.views.NPCBannerView
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
|
|
@ -40,7 +41,7 @@ class ShopRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
private var ownedItems: Map<String, Item> = HashMap()
|
||||
|
||||
|
||||
var shopSpriteSuffix: String? = null
|
||||
var shopSpriteSuffix: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
notifyItemChanged(0)
|
||||
|
|
@ -229,31 +230,16 @@ class ShopRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
internal class ShopHeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val descriptionView: TextView by bindView(itemView, R.id.descriptionView)
|
||||
private val sceneView: SimpleDraweeView by bindView(itemView, R.id.sceneView)
|
||||
private val backgroundView: ImageView by bindView(itemView, R.id.backgroundView)
|
||||
private val npcBannerView: NPCBannerView by bindView(itemView, R.id.npcBannerView)
|
||||
private val namePlate: TextView by bindView(itemView, R.id.namePlate)
|
||||
|
||||
init {
|
||||
descriptionView.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
fun bind(shop: Shop, shopSpriteSuffix: String?) {
|
||||
DataBindingUtils.loadImage(sceneView, shop.identifier + "_scene" + shopSpriteSuffix)
|
||||
|
||||
backgroundView.scaleType = ImageView.ScaleType.FIT_START
|
||||
|
||||
DataBindingUtils.loadImage(shop.identifier + "_background" + shopSpriteSuffix, {
|
||||
val aspectRatio = it.width / it.height.toFloat()
|
||||
val height = itemView.context.resources.getDimension(R.dimen.shop_height).toInt()
|
||||
val width = Math.round(height * aspectRatio)
|
||||
val drawable = BitmapDrawable(itemView.context.resources, Bitmap.createScaledBitmap(it, width, height, false))
|
||||
drawable.tileModeX = Shader.TileMode.REPEAT
|
||||
Observable.just(drawable)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action1 {
|
||||
backgroundView.backgroundCompat = it
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
fun bind(shop: Shop, shopSpriteSuffix: String) {
|
||||
npcBannerView.shopSpriteSuffix = shopSpriteSuffix
|
||||
npcBannerView.identifier = shop.identifier
|
||||
|
||||
descriptionView.text = Html.fromHtml(shop.notes)
|
||||
namePlate.setText(shop.npcNameResource)
|
||||
|
|
|
|||
|
|
@ -95,22 +95,8 @@ class TavernDetailFragment : BaseFragment() {
|
|||
descriptionView.setText(R.string.tavern_description)
|
||||
namePlate.setText(R.string.tavern_owner)
|
||||
|
||||
DataBindingUtils.loadImage(sceneView, "tavern_scene" + configManager.shopSpriteSuffix())
|
||||
|
||||
backgroundView.scaleType = ImageView.ScaleType.FIT_START
|
||||
|
||||
DataBindingUtils.loadImage("tavern_background" + configManager.shopSpriteSuffix(), {bitmap ->
|
||||
val aspectRatio = bitmap.width / bitmap.height.toFloat()
|
||||
val height = context?.resources?.getDimension(R.dimen.shop_height)?.toInt() ?: 0
|
||||
val width = Math.round(height * aspectRatio)
|
||||
val drawable = BitmapDrawable(context?.resources, Bitmap.createScaledBitmap(bitmap, width, height, false))
|
||||
drawable.tileModeX = Shader.TileMode.REPEAT
|
||||
Observable.just(drawable)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action1 {
|
||||
backgroundView.backgroundCompat = it
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
npcBannerView.shopSpriteSuffix = configManager.shopSpriteSuffix()
|
||||
npcBannerView.identifier = "tavern"
|
||||
|
||||
addPlayerTiers()
|
||||
bindButtons()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.support.v4.content.ContextCompat
|
|||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
|
@ -18,7 +17,8 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context) {
|
|||
private val titleTextView: TextView by bindView(view, R.id.titleTextView)
|
||||
private val subtitleTextView: TextView by bindView(view, R.id.subtitleTextView)
|
||||
private val messageTextView: TextView by bindView(view, R.id.messageTextView)
|
||||
private val contentViewContainer: ViewGroup by bindView(view, R.id.contentViewContainer)
|
||||
|
||||
private var additionalContentView: View? = null
|
||||
|
||||
init {
|
||||
setView(view)
|
||||
|
|
@ -66,26 +66,20 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context) {
|
|||
setMessage(context.getString(messageId))
|
||||
}
|
||||
|
||||
fun setAdditionalContentView(layoutResID: Int) {
|
||||
fun setAdditionalContentView(layoutResID: Int, index: Int = -1) {
|
||||
val inflater = context.layoutInflater
|
||||
setAdditionalContentView(inflater.inflate(layoutResID, contentViewContainer, false))
|
||||
setAdditionalContentView(inflater.inflate(layoutResID, view, false))
|
||||
}
|
||||
|
||||
fun setAdditionalContentView(view: View?) {
|
||||
contentViewContainer.removeAllViewsInLayout()
|
||||
if (view != null) {
|
||||
contentViewContainer.visibility = View.VISIBLE
|
||||
fun setAdditionalContentView(view: View?, index: Int = -1) {
|
||||
this.view.removeView(additionalContentView)
|
||||
additionalContentView = view
|
||||
if (index >= 0) {
|
||||
this.view.addView(view, index)
|
||||
} else {
|
||||
contentViewContainer.visibility = View.GONE
|
||||
this.view.addView(view)
|
||||
}
|
||||
contentViewContainer.addView(view)
|
||||
}
|
||||
|
||||
fun getContentView(): View? {
|
||||
return if (contentViewContainer.childCount > 0) {
|
||||
contentViewContainer.getChildAt(0)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
fun getContentView(): View? = additionalContentView
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.habitrpg.android.habitica.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Shader
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.backgroundCompat
|
||||
import com.habitrpg.android.habitica.extensions.bindView
|
||||
import com.habitrpg.android.habitica.extensions.layoutInflater
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.functions.Action1
|
||||
|
||||
class NPCBannerView(context: Context?, attrs: AttributeSet?) : FrameLayout(context, attrs) {
|
||||
|
||||
private val backgroundView: ImageView by bindView(R.id.backgroundView)
|
||||
private val sceneView: SimpleDraweeView by bindView(R.id.sceneView)
|
||||
|
||||
var shopSpriteSuffix: String = ""
|
||||
set(value) {
|
||||
field = if (value.isEmpty() || value.startsWith("_")) {
|
||||
value
|
||||
} else {
|
||||
"_"+value
|
||||
}
|
||||
if (identifier.isNotEmpty()) {
|
||||
setImage()
|
||||
}
|
||||
}
|
||||
var identifier: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
setImage()
|
||||
}
|
||||
|
||||
init {
|
||||
context?.layoutInflater?.inflate(R.layout.npc_banner, this)
|
||||
}
|
||||
|
||||
private fun setImage() {
|
||||
DataBindingUtils.loadImage(sceneView, identifier + "_scene" + shopSpriteSuffix)
|
||||
|
||||
backgroundView.scaleType = ImageView.ScaleType.FIT_START
|
||||
|
||||
DataBindingUtils.loadImage(identifier + "_background" + shopSpriteSuffix, {
|
||||
val aspectRatio = it.width / it.height.toFloat()
|
||||
val height = context.resources.getDimension(R.dimen.shop_height).toInt()
|
||||
val width = Math.round(height * aspectRatio)
|
||||
val drawable = BitmapDrawable(context.resources, Bitmap.createScaledBitmap(it, width, height, false))
|
||||
drawable.tileModeX = Shader.TileMode.REPEAT
|
||||
Observable.just(drawable)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action1 {
|
||||
backgroundView.backgroundCompat = it
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -210,6 +210,12 @@ class QuestProgressView : LinearLayout {
|
|||
alert.setTitleBackground(R.color.orange_10)
|
||||
alert.setSubtitle(context.getString(R.string.strike_active_subtitle, getNpcName(key)))
|
||||
alert.setMessage(context.getString(R.string.strike_active_description, getLongNPCName(key), quest?.boss?.name ?: "", getLocationName(key)))
|
||||
|
||||
val npcBannerView = NPCBannerView(context, null)
|
||||
npcBannerView.shopSpriteSuffix = quest?.key ?: ""
|
||||
npcBannerView.identifier = key
|
||||
alert.setAdditionalContentView(npcBannerView, 1)
|
||||
|
||||
alert.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.close), { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue