mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 10:11:58 +00:00
Add alerts to explain rage strikes
This commit is contained in:
parent
2e09e951c1
commit
49d9b77d15
5 changed files with 158 additions and 4 deletions
47
Habitica/res/layout/dialog_habitica_base.xml
Normal file
47
Habitica/res/layout/dialog_habitica_base.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/titleTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/white"
|
||||
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:id="@+id/subtitleTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="@dimen/spacing_small"
|
||||
tools:text="This is a subtitle"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
tools:visibility="visible"/>
|
||||
<TextView
|
||||
android:id="@+id/messageTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/black_50_alpha"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
tools:text="This is an example message"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -160,4 +160,5 @@
|
|||
<color name="reward_buy_button_bg">#4cfedead</color>
|
||||
<color name="ic_launcher_background">#331960</color>
|
||||
<color name="scrollbarThumb">@color/gray_500</color>
|
||||
<color name="black">#000</color>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -741,4 +741,10 @@
|
|||
<string name="boss_art">Boss Art</string>
|
||||
<string name="world_boss_description">World Boss Description</string>
|
||||
<string name="rage_strike_count" formatted="false">Rage Strikes: %d/%d</string>
|
||||
<string name="pending_strike_description">This Strike hasn’t happened yet!\nThe World Boss will lash out and attack one of our friendly shopkeepers once its rage bar fills. Keep up with your Dailies to try and prevent it from happening!</string>
|
||||
<string name="pending_strike_title">Pending Strike</string>
|
||||
<string name="strike_description_title">What’s a Rage Strike?</string>
|
||||
<string name="strike_description_subtitle">There are 3 potential Rage Strikes</string>
|
||||
<string name="strike_description_description">This gauge fills when Habiticans miss their Dailies. If it fills up, the DysHeartener will unleash its Shattering Heartbreak attack on one of Habitica\'s shopkeepers, so be sure to do your tasks!</string>
|
||||
<string name="pending_strike_subtitle">This Strike hasn’t happened yet!</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.habitrpg.android.habitica.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.bindView
|
||||
|
||||
/**
|
||||
* Created by phillip on 01.02.18.
|
||||
*/
|
||||
|
||||
open class HabiticaAlertDialog(context: Context) : AlertDialog(context) {
|
||||
|
||||
private val view: LinearLayout = LayoutInflater.from(context).inflate(R.layout.dialog_habitica_base, null) as LinearLayout
|
||||
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)
|
||||
|
||||
init {
|
||||
setView(view)
|
||||
}
|
||||
|
||||
override fun setTitle(title: CharSequence?) {
|
||||
titleTextView.text = title
|
||||
}
|
||||
|
||||
override fun setTitle(titleId: Int) {
|
||||
setTitle(context.getString(titleId))
|
||||
}
|
||||
|
||||
fun setTitleBackground(colorId: Int) {
|
||||
titleTextView.setBackgroundColor(ContextCompat.getColor(context, colorId))
|
||||
}
|
||||
|
||||
fun setSubtitle(subtitle: CharSequence?) {
|
||||
if (subtitle != null) {
|
||||
subtitleTextView.visibility = View.VISIBLE
|
||||
} else {
|
||||
subtitleTextView.visibility = View.GONE
|
||||
}
|
||||
subtitleTextView.text = subtitle
|
||||
}
|
||||
|
||||
fun setSubtitle(subtitleId: Int) {
|
||||
setSubtitle(context.getString(subtitleId))
|
||||
}
|
||||
|
||||
override fun setMessage(message: CharSequence?) {
|
||||
if (message != null) {
|
||||
messageTextView.visibility = View.VISIBLE
|
||||
} else {
|
||||
messageTextView.visibility = View.GONE
|
||||
}
|
||||
messageTextView.text = message
|
||||
}
|
||||
|
||||
fun setMessage(messageId: Int) {
|
||||
setMessage(context.getString(messageId))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
package com.habitrpg.android.habitica.ui.views.social
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.RectF
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.content.res.ResourcesCompat
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
|
@ -17,16 +19,16 @@ import android.widget.TextView
|
|||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.bindView
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.interactors.CheckClassSelectionUseCase
|
||||
import com.habitrpg.android.habitica.models.inventory.Quest
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestProgress
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestProgressCollect
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIcons
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.ValueBar
|
||||
import com.habitrpg.android.habitica.ui.views.*
|
||||
import io.realm.RealmList
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class QuestProgressView : LinearLayout {
|
||||
|
||||
|
|
@ -79,6 +81,8 @@ class QuestProgressView : LinearLayout {
|
|||
showQuestImage()
|
||||
}
|
||||
}
|
||||
|
||||
rageStrikeDescriptionView.setOnClickListener { showStrikeDescriptionAlert() }
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
|
|
@ -164,9 +168,11 @@ class QuestProgressView : LinearLayout {
|
|||
val height = it.height * displayDensity
|
||||
val scaledImage = Bitmap.createScaledBitmap(it, width.toInt(), height.toInt(), false)
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfRageStrikeActive(context, scaledImage))
|
||||
iconView.setOnClickListener { showActiveStrikeAlert(strike.key) }
|
||||
})
|
||||
} else {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfRageStrikeInactive())
|
||||
iconView.setOnClickListener { showPendingStrikeAlert() }
|
||||
}
|
||||
val params = LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
val spacing = context.resources.getDimension(R.dimen.spacing_medium).toInt()
|
||||
|
|
@ -175,6 +181,34 @@ class QuestProgressView : LinearLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private fun showActiveStrikeAlert(key: String) {
|
||||
|
||||
}
|
||||
|
||||
private fun showPendingStrikeAlert() {
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
alert.setTitle(R.string.pending_strike_title)
|
||||
alert.setTitleBackground(R.color.orange_10)
|
||||
alert.setSubtitle(R.string.pending_strike_subtitle)
|
||||
alert.setMessage(R.string.pending_strike_description)
|
||||
alert.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.close), { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
})
|
||||
alert.show()
|
||||
}
|
||||
|
||||
private fun showStrikeDescriptionAlert() {
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
alert.setTitle(R.string.strike_description_title)
|
||||
alert.setTitleBackground(R.color.orange_10)
|
||||
alert.setSubtitle(R.string.strike_description_subtitle)
|
||||
alert.setMessage(R.string.strike_description_description)
|
||||
alert.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.close), { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
})
|
||||
alert.show()
|
||||
}
|
||||
|
||||
private fun setCollectionViews(collection: RealmList<QuestProgressCollect>, quest: QuestContent) {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
for (collect in collection) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue