mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 10:11:58 +00:00
Fix rage displays
This commit is contained in:
parent
64bb0e83b5
commit
0cdc869cdc
8 changed files with 54 additions and 31 deletions
|
|
@ -137,7 +137,7 @@
|
||||||
android:id="@+id/rage_meter_view"
|
android:id="@+id/rage_meter_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/pill_bg"
|
style="@style/Pill"
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:paddingBottom="2dp"
|
android:paddingBottom="2dp"
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@
|
||||||
android:background="@drawable/layout_rounded_bg_gray_700"
|
android:background="@drawable/layout_rounded_bg_gray_700"
|
||||||
android:padding="@dimen/spacing_medium"
|
android:padding="@dimen/spacing_medium"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginBottom="@dimen/spacing_medium">
|
android:layout_marginBottom="@dimen/spacing_medium"
|
||||||
|
android:visibility="gone">
|
||||||
<com.facebook.drawee.view.SimpleDraweeView
|
<com.facebook.drawee.view.SimpleDraweeView
|
||||||
android:id="@+id/quest_scroll_image_view"
|
android:id="@+id/quest_scroll_image_view"
|
||||||
android:layout_width="@dimen/gear_image_size"
|
android:layout_width="@dimen/gear_image_size"
|
||||||
|
|
@ -120,6 +121,7 @@
|
||||||
app:srcCompat="@drawable/ic_keyboard_arrow_right_gray_24dp"/>
|
app:srcCompat="@drawable/ic_keyboard_arrow_right_gray_24dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/quest_image_wrapper"
|
android:id="@+id/quest_image_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -134,6 +136,7 @@
|
||||||
android:layout_gravity="center_horizontal"/>
|
android:layout_gravity="center_horizontal"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<com.habitrpg.android.habitica.ui.views.social.OldQuestProgressView
|
<com.habitrpg.android.habitica.ui.views.social.OldQuestProgressView
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/quest_progress_view"
|
android:id="@+id/quest_progress_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,14 @@
|
||||||
app:valueTextColor="@color/red_100"
|
app:valueTextColor="@color/red_100"
|
||||||
app:labelSpacing="@dimen/spacing_medium"
|
app:labelSpacing="@dimen/spacing_medium"
|
||||||
app:descriptionTextColor="@color/yellow_5"/>
|
app:descriptionTextColor="@color/yellow_5"/>
|
||||||
|
<com.habitrpg.android.habitica.ui.views.ValueBar
|
||||||
|
android:id="@+id/bossRageView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barForegroundColor="@color/orange_100"
|
||||||
|
app:lightBackground="true"
|
||||||
|
app:valueTextColor="@color/orange_100"
|
||||||
|
app:labelSpacing="@dimen/spacing_medium" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/collectionContainer"
|
android:id="@+id/collectionContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ open class QuestBoss : RealmObject() {
|
||||||
var rage: QuestBossRage? = null
|
var rage: QuestBossRage? = null
|
||||||
|
|
||||||
fun hasRage(): Boolean {
|
fun hasRage(): Boolean {
|
||||||
return rage?.value != 0.0
|
return rage?.value ?: 0.0 > 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class MaintenanceActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openInPlayStore() {
|
private fun openInPlayStore() {
|
||||||
val appPackageName = packageName
|
val appPackageName = packageName
|
||||||
try {
|
try {
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appPackageName")))
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appPackageName")))
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,9 @@ class PurchaseDialog(context: Context, component: AppComponent?, val item: ShopI
|
||||||
priceLabel.cantAfford = true
|
priceLabel.cantAfford = true
|
||||||
}
|
}
|
||||||
|
|
||||||
checkGearClass()
|
if (shopItem.isTypeGear) {
|
||||||
|
checkGearClass()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dismiss() {
|
override fun dismiss() {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
||||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||||
|
|
||||||
fun setQuestContent(questContent: QuestContent) {
|
fun setQuestContent(questContent: QuestContent) {
|
||||||
|
rageMeterView.visibility = View.GONE
|
||||||
if (questContent.isBossQuest) {
|
if (questContent.isBossQuest) {
|
||||||
questTypeTextView.setText(R.string.boss_quest)
|
questTypeTextView.setText(R.string.boss_quest)
|
||||||
questCollectView.visibility = View.GONE
|
questCollectView.visibility = View.GONE
|
||||||
|
|
@ -59,7 +60,7 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
||||||
|
|
||||||
questDetailView.visibility = View.VISIBLE
|
questDetailView.visibility = View.VISIBLE
|
||||||
|
|
||||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
|
||||||
|
|
||||||
if (questContent.drop != null && questContent.drop.items != null) {
|
if (questContent.drop != null && questContent.drop.items != null) {
|
||||||
questContent.drop.items
|
questContent.drop.items
|
||||||
|
|
@ -79,36 +80,36 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (questContent.drop.exp > 0) {
|
if (questContent.drop.exp > 0) {
|
||||||
val view = inflater.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as ViewGroup
|
val view = inflater?.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as? ViewGroup
|
||||||
val imageView = view.findViewById<ImageView>(R.id.imageView)
|
val imageView = view?.findViewById<ImageView>(R.id.imageView)
|
||||||
imageView.scaleType = ImageView.ScaleType.CENTER
|
imageView?.scaleType = ImageView.ScaleType.CENTER
|
||||||
imageView.setImageBitmap(HabiticaIconsHelper.imageOfExperienceReward())
|
imageView?.setImageBitmap(HabiticaIconsHelper.imageOfExperienceReward())
|
||||||
val titleTextView = view.findViewById<TextView>(R.id.titleTextView)
|
val titleTextView = view?.findViewById<TextView>(R.id.titleTextView)
|
||||||
titleTextView.text = context.getString(R.string.experience_reward, questContent.drop.exp)
|
titleTextView?.text = context.getString(R.string.experience_reward, questContent.drop.exp)
|
||||||
rewardsList.addView(view)
|
rewardsList.addView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (questContent.drop.gp > 0) {
|
if (questContent.drop.gp > 0) {
|
||||||
val view = inflater.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as ViewGroup
|
val view = inflater?.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as? ViewGroup
|
||||||
val imageView = view.findViewById<ImageView>(R.id.imageView)
|
val imageView = view?.findViewById<ImageView>(R.id.imageView)
|
||||||
imageView.scaleType = ImageView.ScaleType.CENTER
|
imageView?.scaleType = ImageView.ScaleType.CENTER
|
||||||
imageView.setImageBitmap(HabiticaIconsHelper.imageOfGoldReward())
|
imageView?.setImageBitmap(HabiticaIconsHelper.imageOfGoldReward())
|
||||||
val titleTextView = view.findViewById<TextView>(R.id.titleTextView)
|
val titleTextView = view?.findViewById<TextView>(R.id.titleTextView)
|
||||||
titleTextView.text = context.getString(R.string.gold_reward, questContent.drop.gp)
|
titleTextView?.text = context.getString(R.string.gold_reward, questContent.drop.gp)
|
||||||
rewardsList.addView(view)
|
rewardsList.addView(view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addRewardsRow(inflater: LayoutInflater, item: QuestDropItem, containerView: ViewGroup?) {
|
private fun addRewardsRow(inflater: LayoutInflater?, item: QuestDropItem, containerView: ViewGroup?) {
|
||||||
val view = inflater.inflate(R.layout.row_quest_reward, containerView, false) as ViewGroup
|
val view = inflater?.inflate(R.layout.row_quest_reward, containerView, false) as? ViewGroup
|
||||||
val imageView = view.findViewById<View>(R.id.imageView) as SimpleDraweeView
|
val imageView = view?.findViewById(R.id.imageView) as? SimpleDraweeView
|
||||||
val titleTextView = view.findViewById<View>(R.id.titleTextView) as TextView
|
val titleTextView = view?.findViewById(R.id.titleTextView) as? TextView
|
||||||
DataBindingUtils.loadImage(imageView, item.imageName)
|
DataBindingUtils.loadImage(imageView, item.imageName)
|
||||||
if (item.count > 1) {
|
if (item.count > 1) {
|
||||||
titleTextView.text = context.getString(R.string.quest_reward_count, item.text, item.count)
|
titleTextView?.text = context.getString(R.string.quest_reward_count, item.text, item.count)
|
||||||
} else {
|
} else {
|
||||||
titleTextView.text = item.text
|
titleTextView?.text = item.text
|
||||||
}
|
}
|
||||||
containerView?.addView(view)
|
containerView?.addView(view)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.facebook.drawee.view.SimpleDraweeView
|
import com.facebook.drawee.view.SimpleDraweeView
|
||||||
import com.habitrpg.android.habitica.R
|
import com.habitrpg.android.habitica.R
|
||||||
|
import com.habitrpg.android.habitica.extensions.inflate
|
||||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||||
import com.habitrpg.android.habitica.extensions.setScaledPadding
|
import com.habitrpg.android.habitica.extensions.setScaledPadding
|
||||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||||
|
|
@ -27,6 +28,7 @@ class OldQuestProgressView : LinearLayout {
|
||||||
|
|
||||||
private val bossNameView: TextView by bindView(R.id.bossNameView)
|
private val bossNameView: TextView by bindView(R.id.bossNameView)
|
||||||
private val bossHealthView: ValueBar by bindView(R.id.bossHealthView)
|
private val bossHealthView: ValueBar by bindView(R.id.bossHealthView)
|
||||||
|
private val bossRageView: ValueBar by bindView(R.id.bossRageView)
|
||||||
private val collectionContainer: ViewGroup by bindView(R.id.collectionContainer)
|
private val collectionContainer: ViewGroup by bindView(R.id.collectionContainer)
|
||||||
|
|
||||||
private val rect = RectF()
|
private val rect = RectF()
|
||||||
|
|
@ -45,8 +47,7 @@ class OldQuestProgressView : LinearLayout {
|
||||||
|
|
||||||
private fun setupView(context: Context) {
|
private fun setupView(context: Context) {
|
||||||
setWillNotDraw(false)
|
setWillNotDraw(false)
|
||||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
inflate(R.layout.quest_progress_old, true)
|
||||||
inflater.inflate(R.layout.quest_progress_old, this)
|
|
||||||
|
|
||||||
orientation = LinearLayout.VERTICAL
|
orientation = LinearLayout.VERTICAL
|
||||||
|
|
||||||
|
|
@ -54,6 +55,7 @@ class OldQuestProgressView : LinearLayout {
|
||||||
|
|
||||||
bossHealthView.setSecondaryIcon(HabiticaIconsHelper.imageOfHeartLightBg())
|
bossHealthView.setSecondaryIcon(HabiticaIconsHelper.imageOfHeartLightBg())
|
||||||
bossHealthView.setDescriptionIcon(HabiticaIconsHelper.imageOfDamage())
|
bossHealthView.setDescriptionIcon(HabiticaIconsHelper.imageOfDamage())
|
||||||
|
bossRageView.setSecondaryIcon(HabiticaIconsHelper.imageOfRage())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas?) {
|
override fun onDraw(canvas: Canvas?) {
|
||||||
|
|
@ -73,23 +75,30 @@ class OldQuestProgressView : LinearLayout {
|
||||||
if (progress != null) {
|
if (progress != null) {
|
||||||
bossHealthView.set(progress.hp, quest.boss.hp.toDouble())
|
bossHealthView.set(progress.hp, quest.boss.hp.toDouble())
|
||||||
}
|
}
|
||||||
|
if (quest.boss.hasRage()) {
|
||||||
|
bossRageView.visibility = View.VISIBLE
|
||||||
|
bossRageView.set(progress?.rage ?: 0.0, quest.boss.rage?.value ?: 0.0)
|
||||||
|
} else {
|
||||||
|
bossRageView.visibility = View.GONE
|
||||||
|
}
|
||||||
bossNameView.visibility = View.VISIBLE
|
bossNameView.visibility = View.VISIBLE
|
||||||
bossHealthView.visibility = View.VISIBLE
|
bossHealthView.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
bossNameView.visibility = View.GONE
|
bossNameView.visibility = View.GONE
|
||||||
bossHealthView.visibility = View.GONE
|
bossHealthView.visibility = View.GONE
|
||||||
|
bossRageView.visibility = View.GONE
|
||||||
|
|
||||||
if (progress != null) {
|
if (progress != null) {
|
||||||
val inflater = LayoutInflater.from(context)
|
val inflater = LayoutInflater.from(context)
|
||||||
for (collect in progress.collect ?: emptyList<QuestProgressCollect>()) {
|
for (collect in progress.collect ?: emptyList<QuestProgressCollect>()) {
|
||||||
val contentCollect = quest.getCollectWithKey(collect.key) ?: continue
|
val contentCollect = quest.getCollectWithKey(collect.key) ?: continue
|
||||||
val view = inflater.inflate(R.layout.quest_collect, collectionContainer, false)
|
val view = inflater.inflate(R.layout.quest_collect, collectionContainer, false)
|
||||||
val iconView = view.findViewById<View>(R.id.icon_view) as SimpleDraweeView
|
val iconView = view.findViewById(R.id.icon_view) as? SimpleDraweeView
|
||||||
val nameView = view.findViewById<View>(R.id.name_view) as TextView
|
val nameView = view.findViewById(R.id.name_view) as? TextView
|
||||||
val valueView = view.findViewById<View>(R.id.value_view) as ValueBar
|
val valueView = view.findViewById(R.id.value_view) as? ValueBar
|
||||||
DataBindingUtils.loadImage(iconView, "quest_" + quest.key + "_" + collect.key)
|
DataBindingUtils.loadImage(iconView, "quest_" + quest.key + "_" + collect.key)
|
||||||
nameView.text = contentCollect.text
|
nameView?.text = contentCollect.text
|
||||||
valueView.set(collect.count.toDouble(), contentCollect.count.toDouble())
|
valueView?.set(collect.count.toDouble(), contentCollect.count.toDouble())
|
||||||
|
|
||||||
collectionContainer.addView(view)
|
collectionContainer.addView(view)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue