mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
improve world boss display
This commit is contained in:
parent
0555a0d578
commit
da18a6b77d
7 changed files with 126 additions and 57 deletions
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="1962"
|
||||
android:versionName="1.3.3"
|
||||
android:versionCode="1964"
|
||||
android:versionName="1.4"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true">
|
||||
<com.habitrpg.android.habitica.ui.views.WrapContentDraweeView
|
||||
android:id="@+id/bossArtView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="120dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/red_10"
|
||||
android:layout_marginTop="-30dp"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:id="@+id/topView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
android:paddingTop="@dimen/spacing_medium"
|
||||
android:paddingBottom="@dimen/spacing_medium">
|
||||
<TextView
|
||||
android:id="@+id/bossNameView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/typeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/world_boss"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"/>
|
||||
</LinearLayout>
|
||||
<com.habitrpg.android.habitica.ui.views.ValueBar
|
||||
android:id="@+id/healthBarView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/spacing_medium"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
android:paddingTop="@dimen/spacing_medium"
|
||||
android:paddingBottom="@dimen/spacing_small"
|
||||
app:barForegroundColor="@color/red_100"
|
||||
app:barBackgroundColor="@color/white_15_alpha"/>
|
||||
</LinearLayout>
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true">
|
||||
<LinearLayout
|
||||
android:id="@+id/topView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/spacing_large"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
android:paddingTop="@dimen/spacing_medium"
|
||||
android:paddingBottom="@dimen/spacing_medium">
|
||||
<ImageButton
|
||||
android:id="@+id/closeButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_close_white_24dp"
|
||||
android:background="@color/transparent"
|
||||
android:contentDescription="@string/hide_boss_art"
|
||||
android:layout_gravity="right"/>
|
||||
<TextView
|
||||
android:id="@+id/bossNameView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Boss Name"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/typeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/world_boss"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"/>
|
||||
</LinearLayout>
|
||||
<com.habitrpg.android.habitica.ui.views.ValueBar
|
||||
android:id="@+id/healthBarView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/spacing_medium"
|
||||
android:paddingRight="@dimen/spacing_large"
|
||||
android:paddingTop="@dimen/spacing_medium"
|
||||
android:paddingBottom="@dimen/spacing_small"
|
||||
app:barForegroundColor="@color/red_100"
|
||||
app:barBackgroundColor="@color/white_15_alpha"
|
||||
tools:background="@color/brand_50"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -754,4 +754,5 @@
|
|||
<string name="market_owner_long">Alex the Merchant</string>
|
||||
<string name="tavern_owner_long">Daniel the inn keeper</string>
|
||||
<string name="stable_owner_long">Matt the beast master</string>
|
||||
<string name="hide_boss_art">Hide Boss Art</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ import com.habitrpg.android.habitica.utils.TaskSerializer;
|
|||
import com.habitrpg.android.habitica.utils.TaskTagDeserializer;
|
||||
import com.habitrpg.android.habitica.utils.TutorialStepListDeserializer;
|
||||
import com.habitrpg.android.habitica.utils.UserDeserializer;
|
||||
import com.habitrpg.android.habitica.utils.WorldStateSerialization;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
|
|
@ -275,6 +276,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
.registerTypeAdapter(questDropItemListType, new QuestDropItemsListSerialization())
|
||||
.registerTypeAdapter(Quest.class, new QuestDeserializer())
|
||||
.registerTypeAdapter(Member.class, new MemberSerialization())
|
||||
.registerTypeAdapter(WorldState.class, new WorldStateSerialization())
|
||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
.create();
|
||||
return GsonConverterFactory.create(gson);
|
||||
|
|
|
|||
|
|
@ -107,6 +107,15 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
adapter.tintColor = questContent.colors?.lightColor ?: 0
|
||||
adapter.backgroundTintColor = questContent.colors?.darkColor ?: 0
|
||||
|
||||
|
||||
/* Reenable this once the boss art can be displayed correctly.
|
||||
|
||||
val preferences = context?.getSharedPreferences("collapsible_sections", 0)
|
||||
if (preferences?.getBoolean("boss_art_collapsed", false) == true) {
|
||||
questMenuView.hideBossArt()
|
||||
} else {
|
||||
questMenuView.showBossArt()
|
||||
}*/
|
||||
questMenuView.hideBossArt()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +1,39 @@
|
|||
package com.habitrpg.android.habitica.ui.views.social
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.widget.ImageViewCompat
|
||||
import android.support.v7.widget.AppCompatImageButton
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
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.models.inventory.Quest
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import com.habitrpg.android.habitica.ui.views.ValueBar
|
||||
|
||||
class QuestMenuView : LinearLayout {
|
||||
|
||||
private val bossArtView: SimpleDraweeView by bindView(R.id.bossArtView)
|
||||
private val bossNameView: TextView by bindView(R.id.bossNameView)
|
||||
private val typeTextView: TextView by bindView(R.id.typeTextView)
|
||||
private val healthBarView: ValueBar by bindView(R.id.healthBarView)
|
||||
private val topView: LinearLayout by bindView(R.id.topView)
|
||||
private val closeButton: AppCompatImageButton by bindView(R.id.closeButton)
|
||||
|
||||
private var questContent: QuestContent? = null
|
||||
|
||||
var collapsed = false
|
||||
set(value) {
|
||||
field = value
|
||||
if (field) {
|
||||
showBossArt()
|
||||
} else {
|
||||
hideBossArt()
|
||||
}
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
setupView(context)
|
||||
}
|
||||
|
|
@ -49,6 +48,14 @@ class QuestMenuView : LinearLayout {
|
|||
|
||||
healthBarView.setIcon(HabiticaIconsHelper.imageOfHeartDarkBg())
|
||||
healthBarView.setLabelVisibility(View.GONE)
|
||||
|
||||
closeButton.setOnClickListener {
|
||||
hideBossArt()
|
||||
val preferences = context.getSharedPreferences("collapsible_sections", 0)
|
||||
val editPreferences = preferences?.edit()
|
||||
editPreferences?.putBoolean("boss_art_collapsed", true)
|
||||
editPreferences?.apply()
|
||||
}
|
||||
}
|
||||
|
||||
fun configure(quest: Quest) {
|
||||
|
|
@ -59,21 +66,28 @@ class QuestMenuView : LinearLayout {
|
|||
this.questContent = questContent
|
||||
healthBarView.maxValue = questContent.boss.hp.toDouble()
|
||||
healthBarView.setBackgroundColor(questContent.colors?.darkColor ?: 0)
|
||||
topView.setBackgroundColor(questContent.colors?.mediumColor ?: 0)
|
||||
bossArtView.setBackgroundColor(questContent.colors?.mediumColor ?: 0)
|
||||
DataBindingUtils.loadImage(bossArtView, "quest_"+questContent?.key)
|
||||
bossNameView.text = questContent.boss.name
|
||||
}
|
||||
|
||||
fun hideBossArt() {
|
||||
topView.orientation = LinearLayout.HORIZONTAL
|
||||
topView.setBackgroundColor(questContent?.colors?.mediumColor ?: 0)
|
||||
bossNameView.gravity = Gravity.LEFT
|
||||
bossNameView.layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1F)
|
||||
bossArtView.visibility = View.GONE
|
||||
typeTextView.setTextColor(questContent?.colors?.extraLightColor ?: 0)
|
||||
closeButton.visibility = View.GONE
|
||||
}
|
||||
|
||||
fun showBossArt() {
|
||||
topView.orientation = LinearLayout.VERTICAL
|
||||
topView.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent))
|
||||
bossNameView.gravity = Gravity.RIGHT
|
||||
bossNameView.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
bossNameView.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
bossArtView.visibility = View.VISIBLE
|
||||
typeTextView.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
closeButton.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,10 @@ import com.habitrpg.android.habitica.ui.views.*
|
|||
import io.realm.RealmList
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import com.habitrpg.android.habitica.extensions.backgroundCompat
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.functions.Action1
|
||||
|
||||
|
||||
class QuestProgressView : LinearLayout {
|
||||
|
|
@ -87,6 +91,8 @@ class QuestProgressView : LinearLayout {
|
|||
preferences = context.getSharedPreferences("collapsible_sections", 0)
|
||||
if (preferences?.getBoolean("boss_art_collapsed", false) == true) {
|
||||
hideQuestImage()
|
||||
} else {
|
||||
showQuestImage()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,12 +180,18 @@ class QuestProgressView : LinearLayout {
|
|||
val iconView = ImageView(context)
|
||||
if (strike.wasHit) {
|
||||
DataBindingUtils.loadImage("rage_strike_${strike.key}", {
|
||||
val displayDensity = resources.displayMetrics.density
|
||||
val width = it.width * displayDensity
|
||||
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) }
|
||||
Observable.just(it)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Action1 {
|
||||
val displayDensity = resources.displayMetrics.density
|
||||
val width = it.width * displayDensity
|
||||
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)
|
||||
}
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
})
|
||||
} else {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfRageStrikeInactive())
|
||||
|
|
@ -281,8 +293,9 @@ class QuestProgressView : LinearLayout {
|
|||
private fun showQuestImage() {
|
||||
questImageCaretView.setImageBitmap(HabiticaIconsHelper.imageOfCaret(ContextCompat.getColor(context, R.color.white), true))
|
||||
questImageView.visibility = View.VISIBLE
|
||||
DataBindingUtils.loadImage(questImageView, "quest_"+quest?.key)
|
||||
val editPreferences = preferences?.edit()
|
||||
editPreferences?.putBoolean("boss_art_collapsed", true)
|
||||
editPreferences?.putBoolean("boss_art_collapsed", false)
|
||||
editPreferences?.apply()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue