remove old code

This commit is contained in:
Phillip Thelen 2022-12-19 16:40:18 +01:00
parent bc685cdc82
commit 25fa75497e
40 changed files with 4 additions and 453 deletions

View file

@ -72,9 +72,8 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<include
<androidx.compose.ui.platform.ComposeView
android:id="@+id/avatar_with_bars"
layout="@layout/avatar_with_bars"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout

View file

@ -4,8 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:maxHeightMultiplier="0.7">
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -221,8 +221,6 @@
<string name="quests">Мисии</string>
<string name="pets">Любимци</string>
<string name="mounts">Превози</string>
<string name="armoireEquipment">Намерихте рядък предмет в гардероба: %s! Страхотно!</string>
<string name="armoireFood">Тършувате из гардероба и намирате %1$s %2$s. Какво ли прави това там?</string>
<string name="armoireExp">Сборвате се с гардероба и получавате опит. Така му се пада!</string>
<string name="sell">Продаване (%d злато)</string>
<string name="hatch_with_potion">Излюпване с отвара</string>

View file

@ -179,8 +179,6 @@
<string name="quests">Missions</string>
<string name="pets">Mascotes</string>
<string name="mounts">Montures</string>
<string name="armoireEquipment">Has trobat una peça d\'equipament rar a l\'Armari: %s! Genial!</string>
<string name="armoireFood">Rebusques a l\'Armari i trobes %1$s %2$s. Què fa això aquí?</string>
<string name="armoireExp">Et baralles amb l\'Armari i ganes experiència. Va!</string>
<string name="sell">Ven (%d Or)</string>
<string name="hatch_with_potion">Eclosione-ho amb una poció</string>

View file

@ -202,8 +202,6 @@
<string name="quests">Úkoly</string>
<string name="pets">Mazlíčci</string>
<string name="mounts">Přepravní zvířata </string>
<string name="armoireEquipment">Našel jsi kousek vzácného vybavení v Airmoire: %s! Super!</string>
<string name="armoireFood">Prohrabeš Armoire a nalézáš %1$s %2$s. Co to tu dělá?</string>
<string name="armoireExp">Biješ se s Airmoire a získáváš zkušenosti. Vem si je!</string>
<string name="sell">Prodat (%dZlata)</string>
<string name="hatch_with_potion">Vylíhnout pomocí lektvaru</string>

View file

@ -178,8 +178,6 @@
<string name="quests">Quests</string>
<string name="pets">Kæledyr</string>
<string name="mounts">Ridedyr</string>
<string name="armoireEquipment">Du har fundet et stykke sjældent udstyr i Armoire: %s! Fedt!</string>
<string name="armoireFood">Du roder rundt i Armoire og finder %1$s %2$s. Hvad laver det her?</string>
<string name="armoireExp">Du kæmper med Armoire og får Erfaring. Tag den!</string>
<string name="sell">Sælg (%d Guld)</string>
<string name="hatch_with_potion">Udrug med eliksir</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Quests</string>
<string name="pets">Haustiere</string>
<string name="mounts">Reittiere</string>
<string name="armoireEquipment">Du hast %s im Schrank gefunden</string>
<string name="armoireFood">Du wühlst im Schrank herum und findest %1$s %2$s. Was macht das denn hier?</string>
<string name="armoireExp">Du ringst mit dem verzauberten Schrank und gewinnst Erfahrung. Nimm das!</string>
<string name="sell">Verkaufen (%d Gold)</string>
<string name="hatch_with_potion">Mit Elixier ausbrüten</string>

View file

@ -210,8 +210,6 @@
<string name="quests">Quests</string>
<string name="pets">Pets</string>
<string name="mounts">Mounts</string>
<string name="armoireEquipment">You found %s in the Armoire</string>
<string name="armoireFood">You rummage in the Armoire and find %1$s %2$s. What\'s that doing in here?</string>
<string name="armoireExp">You wrestle with the Armoire and gain Experience. Take that!</string>
<string name="sell">Sell (%d Gold)</string>
<string name="hatch_with_potion">Hatch with potion</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Misiones</string>
<string name="pets">Mascotas</string>
<string name="mounts">Monturas</string>
<string name="armoireEquipment">¡Genial! Has encontrado %s en el Armario</string>
<string name="armoireFood">Rebuscando en el Armario, encuentras esto: %1$s %2$s. ¿Qué hace aquí?</string>
<string name="armoireExp">Te peleas con el Armario y ganas experiencia. ¡Chúpate esa!</string>
<string name="sell">Vender (%d de oro)</string>
<string name="hatch_with_potion">Eclosionar con poción</string>

View file

@ -220,8 +220,6 @@
<string name="quests">Quêtes</string>
<string name="pets">Familiers</string>
<string name="mounts">Montures</string>
<string name="armoireEquipment">Vous avez trouvé %s dans l\'armoire enchantée</string>
<string name="armoireFood">Vous farfouillez dans l\'armoire enchantée et trouvez une %1$s %2$s. Qu\'est-ce que ça fait là \?</string>
<string name="armoireExp">Vous luttez contre l\'armoire enchantée et gagnez de l\'expérience. Prends ça !</string>
<string name="quest_items_found">Vous avez trouvé %d objets pour la quête</string>
<string name="sell">Vendre (%d pièces d\'or)</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Pustolovine</string>
<string name="pets">Ljubimci</string>
<string name="mounts">Jahače životinje</string>
<string name="armoireEquipment">Našao/la si komad rijetke Opreme u Ormaru: %s! Zakon!</string>
<string name="armoireFood">Pretražuješ po ormaru i nađeš %1$s %2$s. Što to radi tu?</string>
<string name="armoireExp">Hrvaš se s ormarom i dobivaš na iskustvu. Neka mu!</string>
<string name="sell">Prodaj(%d Zlatnika) </string>
<string name="hatch_with_potion">Izlegni s napitkom</string>

View file

@ -211,8 +211,6 @@
<string name="quests">Misi</string>
<string name="pets">Peliharaan</string>
<string name="mounts">Tunggangan</string>
<string name="armoireEquipment">Kamu menemukan Perlengkapan langka di dalam Peti Harta Karun: %s! Keren!</string>
<string name="armoireFood">Kamu mengacak-acak Peti Harta Karun dan menemukan %2$s %1$s. Kenapa berada di dalam sini, ya?</string>
<string name="armoireExp">Kamu bergulat dengan Peti Harta Karun dan mendapatkan Pengalaman. Rasakan itu!</string>
<string name="sell">Jual (%d Emas)</string>
<string name="hatch_with_potion">Tetaskan dengan ramuan</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Missioni</string>
<string name="pets">Animali</string>
<string name="mounts">Cavalcature</string>
<string name="armoireEquipment">Hai trovato %s nell\'Armadio</string>
<string name="armoireFood">Frughi nell\'Armadio e trovi %1$s %2$s. Cosa ci fa qui dentro\?</string>
<string name="armoireExp">Fai a botte con lo Scrigno e ottieni Esperienza. Prendi questo!</string>
<string name="sell">Vendi (%d Oro)</string>
<string name="hatch_with_potion">Schiudi con pozione</string>

View file

@ -185,8 +185,6 @@
<string name="quests">הרפתקאות</string>
<string name="pets">חיות מחמד</string>
<string name="mounts">חיות רכיבה</string>
<string name="armoireEquipment">מצאתם חתיכת ציוד נדיר בארמואר: %s! מגניב!</string>
<string name="armoireFood">אתם נוברים בארמואר ומוצאים %1$s %2$s. מה זה עושה פה?</string>
<string name="armoireExp">אתם נאבקים בארמואר וצוברים ניסיון. קבלו!</string>
<string name="sell">מיכרו (%d זהב)</string>
<string name="hatch_with_potion">הבקיעו עם שיקוי</string>

View file

@ -221,8 +221,6 @@
<string name="quests">クエスト</string>
<string name="pets">ペット</string>
<string name="mounts">乗騎</string>
<string name="armoireEquipment">宝箱から%sを見つけました</string>
<string name="armoireFood">宝箱をひっかきまわして%1$s%2$sを見つけた。何でこんなとこに?</string>
<string name="armoireExp">宝箱と格闘して経験値を増やした。どうぞっ!</string>
<string name="sell">%d ゴールドで売る</string>
<string name="hatch_with_potion">たまごがえしの薬を使う</string>

View file

@ -211,8 +211,6 @@
<string name="quests">퀘스트</string>
<string name="pets"></string>
<string name="mounts">탑승펫</string>
<string name="armoireEquipment">장롱에서 %s를(을) 찾았습니다</string>
<string name="armoireFood">장롱을 뒤지다가 %1$s %2$s 를(을) 발견했습니다. 왜 이게 여기 들어있지\?</string>
<string name="armoireExp">장롱과 씨름하여 경험치를 얻었습니다. 맛 좀 봐라!</string>
<string name="sell">팔기 (%d 골드)</string>
<string name="hatch_with_potion">물약으로 알 부화</string>

View file

@ -191,8 +191,6 @@
<string name="quests">Misijos</string>
<string name="pets">Maži Augintiniai</string>
<string name="mounts">Suaugę Augintiniai</string>
<string name="armoireEquipment">Radai retos aprangos dalį Drabužinėje: %s! Nuostabu!</string>
<string name="armoireFood">Betyrinėjant Drabužinę randi %1$s %2$s. Ką tai čia veikia?</string>
<string name="armoireExp">Besigrumiant su Drabužine, gauni patirties!</string>
<string name="sell">Parduoti (%d Augso)</string>
<string name="hatch_with_potion">Užauginti su eliksyru</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Queesten</string>
<string name="pets">Huisdieren</string>
<string name="mounts">Rijdieren</string>
<string name="armoireEquipment">Je hebt %s gevonden in het Kabinet</string>
<string name="armoireFood">Je rommelt wat rond in het Kabinet en vindt %1$s %2$s. Wat doet dat hier?</string>
<string name="armoireExp">Je worstelt met het Kabinet en verdient Ervaring. Pak aan!</string>
<string name="sell">Verkoop (%d Goud)</string>
<string name="hatch_with_potion">Broed uit met toverdrank</string>

View file

@ -197,8 +197,6 @@
<string name="quests">Oppdrag</string>
<string name="pets">Kjæledyr</string>
<string name="mounts">Ridedyr</string>
<string name="armoireEquipment">Du fant et stykke skjeldent Utstyr i Kabinettet: %s! Kjempemessig!</string>
<string name="armoireFood">Du ransaker Kabinettet og finner %1$s %2$s. Hva gjør den her?</string>
<string name="armoireExp">Du slåss med Kabinettet og får Erfaring. Ta den!</string>
<string name="sell">Selg (%d Gull)</string>
<string name="hatch_with_potion">Klekk med mikstur</string>

View file

@ -214,8 +214,6 @@
<string name="pets">Zwierzaki</string>
<string name="mounts">Wierzchowce</string>
<string name="quest_items_found">Znalazłeś %d przedmiot(y/ów) z zadania</string>
<string name="armoireEquipment">Znalazłeś element rzadkiego Ekwipunku w Skrzyni: %s! Super!</string>
<string name="armoireFood">Przeszukujesz Skrzynię i znajdujesz %1$s %2$s. Co to tam robi?</string>
<string name="armoireExp">Mocujesz się ze Skrzynią i zyskujesz Doświadczenie. A masz!</string>
<string name="sell">Sprzedaj (%d Złoto)</string>
<string name="hatch_with_potion">Wykluj za pomocą mikstury</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Missões</string>
<string name="pets">Mascotes</string>
<string name="mounts">Montarias</string>
<string name="armoireEquipment">Você encontrou %s no Armário</string>
<string name="armoireFood">Você abriu o Armário e encontrou %1$s %2$s. O que isso está fazendo aqui\?</string>
<string name="armoireExp">Você lutou com o Armário e ganhou Experiência. Toma essa!</string>
<string name="sell">Vender (%d Ouro)</string>
<string name="hatch_with_potion">Chocar com poção</string>

View file

@ -206,8 +206,6 @@
<string name="quests">Missões</string>
<string name="pets">Animais de Estimação</string>
<string name="mounts">Montarias</string>
<string name="armoireEquipment">Encontraste uma peça rara de Equipamento no Armário Encantado: %s! Fenomenal!</string>
<string name="armoireFood">Vasculhas o Armário e encontras %1$s %2$s. Que é que isto está aqui a fazer?</string>
<string name="armoireExp">Lutas com o Armário e ganhas experiência. Boa!</string>
<string name="sell">Vender (%d Ouro)</string>
<string name="hatch_with_potion">Nascimento com poção</string>

View file

@ -197,8 +197,6 @@
<string name="quests">Expediții</string>
<string name="pets">Animale de Companie</string>
<string name="mounts">Animale de Călărit</string>
<string name="armoireEquipment">Ai găsit o piesă rară de Echipament în Cufăr: %s! Super!</string>
<string name="armoireFood">Scotocești prin Cufăr și găsești %1$s %2$s. Ce caută asta aici?</string>
<string name="armoireExp">Te lupți împotriva cufărului și primești Experiență. Ia-o!</string>
<string name="sell">Vinde (%d Aur)</string>
<string name="hatch_with_potion">Eclozează cu o poțiune</string>

View file

@ -219,8 +219,6 @@
<string name="quests">Квесты</string>
<string name="pets">Питомцы</string>
<string name="mounts">Скакуны</string>
<string name="armoireEquipment">Вы нашли в зачарованном сундуке: %s</string>
<string name="armoireFood">Копаясь в сундуке, вы находите %1$s %2$s. Откуда это здесь?</string>
<string name="armoireExp">Вы сражаетесь с сундуком и набираете опыт. Получай!</string>
<string name="sell">Продать (%d золота)</string>
<string name="hatch_with_potion">Полить эликсиром</string>

View file

@ -197,8 +197,6 @@
<string name="quests">Uppdrag</string>
<string name="pets">Husdjur</string>
<string name="mounts">Riddjur</string>
<string name="armoireEquipment">Du hittade ovanlig utrustning i vapenskåpet: %s! Fantastiskt!</string>
<string name="armoireFood">Du krafsar runt i vapenskåpet och hittar %1$s %2$s. Vad gör den här?</string>
<string name="armoireExp">Du brottas med vapenskåpet och får erfarenhet. Touché!</string>
<string name="sell">Sälj (%d Guld)</string>
<string name="hatch_with_potion">Kläck med kläckningsdryck</string>

View file

@ -221,8 +221,6 @@
<string name="quests">Görevler</string>
<string name="pets">Evcil Hayvanlar</string>
<string name="mounts">Binekler</string>
<string name="armoireEquipment">Gardırop içerisinde nadir bir ekipman parçası buldun: %s!</string>
<string name="armoireFood">Gardırobun altını üstünü getirdin ve %1$s %2$s buldun. Onun burada ne işi var?</string>
<string name="armoireExp">Gardırop ile güreştin ve Tecrübe kazandın. Al sana!</string>
<string name="sell">Sat (%d Altın)</string>
<string name="hatch_with_potion">İksir ile üret</string>

View file

@ -235,8 +235,6 @@
<string name="hatch_with_potion">Висидіти з допомогою зілля</string>
<string name="sell">Продати (%d золота)</string>
<string name="armoireExp">Ви боретеся зі скринею і отримуєте досвід. Отримайте!</string>
<string name="armoireFood">Риючись в скрині, ви знаходите %1$s %2$s. Звідки це тут\?</string>
<string name="armoireEquipment">Ви знайшли в магічній скрині: %s</string>
<string name="mounts">Скакуни</string>
<string name="pets">Улюбленці</string>
<string name="quests">Квести</string>

View file

@ -241,8 +241,6 @@
<string name="use_animal">Dùng</string>
<string name="invite_party">Lời mời Tổ đội</string>
<string name="armoireExp">Bạn vật lộn với Rương đồ và nhận được Điểm kinh nghiệm. Lấy chúng!</string>
<string name="armoireFood">Bạn lục lọi trong Tủ Quần Áo và tìm thấy %1$s %2$s. Chuyện gì đang xảy xa ở đây\?</string>
<string name="armoireEquipment">Bạn tìm được %s trong Rương đồ</string>
<string name="remaining_1hour">còn 1 giờ</string>
<string name="remaining_hours">còn %d giờ</string>
<string name="remaining_minutes">còn %d tháng</string>

View file

@ -219,8 +219,6 @@
<string name="quests">副本</string>
<string name="pets">寵物</string>
<string name="mounts">坐騎</string>
<string name="armoireEquipment">你在魔法衣櫥裡找到了%s</string>
<string name="armoireFood">你在神秘寶箱裡找到了%1$s %2$s。它是用來做什麼的</string>
<string name="armoireExp">你奮力打開神秘寶箱而且獲得經驗值!</string>
<string name="sell">出售 (%d 金幣)</string>
<string name="hatch_with_potion">用藥水孵化</string>

View file

@ -223,8 +223,6 @@
<string name="quests">副本</string>
<string name="pets">宠物</string>
<string name="mounts">坐骑</string>
<string name="armoireEquipment">你在魔法衣橱里找到了%s</string>
<string name="armoireFood">你在魔法衣橱里找到了%1$s %2$s。它是用来做什么的</string>
<string name="armoireExp">你和大衣柜展开了殊死搏斗,并赢得了经验,尝尝这个吧!</string>
<string name="sell">出售 (%d金币)</string>
<string name="hatch_with_potion">用孵化药水孵化</string>

View file

@ -36,9 +36,6 @@
<attr name="gemDrawable" format="integer" />
</declare-styleable>
<declare-styleable name="MaxHeightLinearLayout">
<attr name="maxHeightMultiplier" format="float" />
</declare-styleable>
<declare-styleable name="SubscriptionOptionView">
<attr name="recurringText" format="string" />
<attr name="gemCapText" format="string" />

View file

@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="android:listSeparatorTextViewStyle">@style/MyOwnListSeperatorTextViewStyle</item>
<item name="android:elevation">0dp</item>

View file

@ -81,8 +81,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
// todos
@SerializedName("date")
var dueDate: Date? = null
// used for buyable items
var specialTag: String? = ""
@Ignore
var parsedText: Spanned? = null
@Ignore
@ -451,7 +449,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
dest.writeLong(this.startDate?.time ?: -1)
dest.writeParcelable(this.repeat, flags)
dest.writeLong(this.dueDate?.time ?: -1)
dest.writeString(this.specialTag)
dest.writeString(this.id)
dest.writeInt(this.counterUp ?: 0)
dest.writeInt(this.counterDown ?: 0)
@ -489,7 +486,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
this.repeat = `in`.readParcelable(Days::class.java.classLoader)
val tmpDuedate = `in`.readLong()
this.dueDate = if (tmpDuedate == -1L) null else Date(tmpDuedate)
this.specialTag = `in`.readString()
this.id = `in`.readString()
this.counterUp = `in`.readInt()
this.counterDown = `in`.readInt()

View file

@ -1,157 +0,0 @@
package com.habitrpg.android.habitica.ui
import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.core.os.bundleOf
import androidx.lifecycle.ViewModel
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.AvatarWithBarsBinding
import com.habitrpg.android.habitica.helpers.MainNavigationController
import com.habitrpg.android.habitica.models.user.Stats
import com.habitrpg.android.habitica.models.user.User
import com.habitrpg.android.habitica.ui.activities.mainActivityCreatedAt
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.common.habitica.helpers.Animations
import com.habitrpg.common.habitica.helpers.HealthFormatter
import com.habitrpg.shared.habitica.models.Avatar
import java.util.Date
import java.util.Locale
import kotlin.math.floor
class AvatarWithBarsViewModel(
private val context: Context,
private val binding: AvatarWithBarsBinding,
viewModel: MainUserViewModel? = null
): ViewModel() {
private var userObject: Avatar? = null
private var cachedMaxHealth: Int = 0
private var cachedMaxExp: Int = 0
private var cachedMaxMana: Int = 0
init {
binding.hpBar.setIcon(HabiticaIconsHelper.imageOfHeartLightBg())
binding.xpBar.setIcon(HabiticaIconsHelper.imageOfExperience())
binding.mpBar.setIcon(HabiticaIconsHelper.imageOfMagic())
setHpBarData(0.0, 50)
setXpBarData(0.0, 1)
setMpBarData(0.0, 1)
viewModel?.user?.observeForever {
if (it != null) {
updateData(it)
}
}
}
fun updateData(user: Avatar) {
userObject = user
val stats = user.stats ?: return
var userClass = ""
binding.avatarView.setAvatar(user)
if (stats.habitClass != null && stats is Stats) {
userClass = stats.getTranslatedClassName(context.resources)
}
binding.mpBar.visibility = if (stats.habitClass == null || (stats.lvl
?: 0) < 10 || user.preferences?.disableClasses == true
) View.GONE else View.VISIBLE
if (!user.hasClass) {
setUserLevel(context, binding.lvlTv, stats.lvl)
} else {
setUserLevelWithClass(
context, binding.lvlTv, stats.lvl,
userClass.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }, stats.habitClass
)
}
setHpBarData(stats.hp ?: 0.0, stats.maxHealth ?: 0)
setXpBarData(stats.exp ?: 0.0, stats.toNextLevel ?: 0)
setMpBarData(stats.mp ?: 0.0, stats.maxMP ?: 0)
if (!stats.isBuffed) {
binding.buffImageView.visibility = View.GONE
}
if (user is User) {
binding.currencyView.gold = stats.gp ?: 0.0
binding.currencyView.hourglasses = user.hourglassCount.toDouble()
binding.currencyView.gems = user.gemCount.toDouble()
}
binding.currencyView.setOnClickListener {
MainNavigationController.navigate(R.id.gemPurchaseActivity, bundleOf(Pair("openSubscription", false)))
}
binding.avatarView.setOnClickListener {
MainNavigationController.navigate(R.id.avatarOverviewFragment)
}
mainActivityCreatedAt?.let {
Log.i("LAUNCH TIME", "${Date().time - it.time}")
mainActivityCreatedAt = null
}
}
private fun setHpBarData(value: Double, valueMax: Int) {
if (valueMax != 0) {
cachedMaxHealth = valueMax
}
if (binding.hpBar.currentValue > value) {
binding.hpBar.progressBar.startAnimation(Animations.negativeShakeAnimation())
}
binding.hpBar.set(HealthFormatter.format(value), cachedMaxHealth.toDouble())
}
private fun setXpBarData(value: Double, valueMax: Int) {
if (valueMax != 0) {
cachedMaxExp = valueMax
}
binding.xpBar.set(floor(value), cachedMaxExp.toDouble())
}
private fun setMpBarData(value: Double, valueMax: Int) {
if (valueMax != 0) {
cachedMaxMana = valueMax
}
binding.mpBar.set(floor(value), cachedMaxMana.toDouble())
}
companion object {
private fun setUserLevel(context: Context, textView: TextView, level: Int?) {
textView.text = context.getString(R.string.user_level, level)
textView.contentDescription = context.getString(R.string.level_unabbreviated, level)
textView.setCompoundDrawables(null, null, null, null)
}
private fun setUserLevelWithClass(
context: Context,
textView: TextView,
level: Int?,
userClassString: String,
habitClass: String?
) {
textView.text = context.getString(R.string.user_level_with_class, level, userClassString)
textView.contentDescription = context.getString(R.string.user_level_with_class_unabbreviated, level, userClassString)
var drawable: Drawable? = null
when (habitClass) {
Stats.WARRIOR -> drawable = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfWarriorDarkBg())
Stats.ROGUE -> drawable = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfRogueDarkBg())
Stats.MAGE -> drawable = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfMageDarkBg())
Stats.HEALER -> drawable = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfHealerDarkBg())
}
drawable?.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
textView.setCompoundDrawables(drawable, null, null, null)
}
}
}

View file

@ -1,109 +0,0 @@
package com.habitrpg.android.habitica.ui
import android.content.Context
import android.content.DialogInterface
import android.view.Gravity
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.habitrpg.android.habitica.R
import com.habitrpg.common.habitica.extensions.loadImage
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.common.habitica.views.PixelArtView
class ItemDetailDialog(context: Context) : AlertDialog(context) {
private val itemImageView = PixelArtView(context)
private val contentTextView = TextView(context, null)
private val priceTextView = TextView(context, null)
private val currencyImageView = ImageView(context)
init {
// External ContentView
val contentViewLayout = LinearLayout(context)
contentViewLayout.orientation = LinearLayout.VERTICAL
// Gear Image
val gearImageLayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT
)
gearImageLayoutParams.gravity = Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL
gearImageLayoutParams.setMargins(0, 0, 0, 20)
itemImageView.minimumWidth = 200
itemImageView.minimumHeight = 200
itemImageView.layoutParams = gearImageLayoutParams
itemImageView.visibility = View.GONE
// Gear Description
contentTextView.setPadding(16, 0, 16, 0)
contentTextView.visibility = View.GONE
// GoldPrice View
val goldPriceLayout = LinearLayout(context)
goldPriceLayout.gravity = Gravity.CENTER_HORIZONTAL
val goldPriceLayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT
)
goldPriceLayoutParams.setMargins(0, 0, 0, 16)
goldPriceLayoutParams.gravity = Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL
goldPriceLayout.orientation = LinearLayout.HORIZONTAL
goldPriceLayout.layoutParams = goldPriceLayoutParams
goldPriceLayout.gravity = Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL
// Price View
priceTextView.setPadding(10, 0, 0, 0)
currencyImageView.minimumHeight = 50
currencyImageView.minimumWidth = 50
currencyImageView.setPadding(0, 0, 5, 0)
goldPriceLayout.addView(currencyImageView)
goldPriceLayout.addView(priceTextView)
contentViewLayout.gravity = Gravity.CENTER_VERTICAL
contentViewLayout.addView(itemImageView)
contentViewLayout.addView(goldPriceLayout)
contentViewLayout.addView(contentTextView)
setView(contentViewLayout)
this.setButton(BUTTON_NEGATIVE, context.getText(R.string.reward_dialog_dismiss)) { clickedDialog, _ -> clickedDialog.dismiss() }
}
fun setDescription(description: CharSequence) {
contentTextView.text = description
contentTextView.visibility = View.VISIBLE
}
fun setCurrency(currency: String) {
when (currency) {
"gold" -> currencyImageView.setImageBitmap(HabiticaIconsHelper.imageOfGold())
"gems" -> currencyImageView.setImageBitmap(HabiticaIconsHelper.imageOfGem())
else -> currencyImageView.setImageDrawable(null)
}
}
fun setValue(value: Double?) {
priceTextView.text = value?.toString()
}
fun setValue(value: Int?) {
priceTextView.text = value?.toString()
}
fun setImage(imageName: String) {
itemImageView.visibility = View.VISIBLE
itemImageView.loadImage(imageName)
}
fun setBuyListener(listener: DialogInterface.OnClickListener) {
this.setButton(DialogInterface.BUTTON_POSITIVE, context.getText(R.string.reward_dialog_buy), listener)
}
}

View file

@ -1,64 +0,0 @@
package com.habitrpg.android.habitica.ui
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.view.WindowManager
import android.widget.LinearLayout
import com.habitrpg.android.habitica.R
import kotlin.math.min
class MaxHeightLinearLayout : LinearLayout {
private val defaultHeight = 0.9f
private var maxHeight: Float = 0.toFloat()
private val displaymetrics = DisplayMetrics()
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
if (!isInEditMode) {
init(context, attrs)
}
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
if (!isInEditMode) {
init(context, attrs)
}
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
if (!isInEditMode) {
init(context, attrs)
}
}
private fun init(context: Context, attrs: AttributeSet?) {
if (attrs != null) {
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MaxHeightLinearLayout)
// 200 is a defualt value
maxHeight = styledAttrs.getFloat(R.styleable.MaxHeightLinearLayout_maxHeightMultiplier, defaultHeight)
styledAttrs.recycle()
}
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
var heightMeasurement = heightMeasureSpec
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val height = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
windowManager.currentWindowMetrics.bounds.height()
} else {
@Suppress("DEPRECATION")
windowManager.defaultDisplay?.getMetrics(displaymetrics)
(displaymetrics.heightPixels * maxHeight).toInt()
}
heightMeasurement = min(heightMeasurement, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST))
super.onMeasure(widthMeasureSpec, heightMeasurement)
}
}

View file

@ -1,6 +1,5 @@
package com.habitrpg.android.habitica.ui.viewHolders.tasks
import android.view.MotionEvent
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
@ -9,7 +8,6 @@ import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.RewardItemCardBinding
import com.habitrpg.android.habitica.helpers.GroupPlanInfoProvider
import com.habitrpg.android.habitica.models.tasks.Task
import com.habitrpg.android.habitica.ui.ItemDetailDialog
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.common.habitica.extensions.dpToPx
import com.habitrpg.common.habitica.helpers.NumberAbbreviator
@ -30,9 +28,6 @@ class RewardViewHolder(
) {
private val binding = RewardItemCardBinding.bind(itemView)
private val isItem: Boolean
get() = this.task?.specialTag == "item"
init {
binding.buyButton.setOnClickListener {
buyReward()
@ -40,33 +35,10 @@ class RewardViewHolder(
binding.goldIcon.setImageBitmap(HabiticaIconsHelper.imageOfGold())
}
override fun canContainMarkdown(): Boolean {
return !isItem
}
private fun buyReward() {
task?.let { scoreTaskFunc(it, TaskDirection.DOWN) }
}
override fun onTouch(view: View?, motionEvent: MotionEvent?): Boolean {
if (task?.isValid != true) {
return true
}
if (isItem) {
val dialog = ItemDetailDialog(context)
dialog.setTitle(task?.text)
dialog.setDescription(task?.notes ?: "")
dialog.setImage("shop_" + this.task?.id)
dialog.setCurrency("gold")
dialog.setValue(task?.value)
dialog.setBuyListener { _, _ -> this.buyReward() }
dialog.show()
} else {
super.onTouch(view, motionEvent)
}
return true
}
override fun setDisabled(openTaskDisabled: Boolean, taskActionsDisabled: Boolean) {
super.setDisabled(openTaskDisabled, taskActionsDisabled)
binding.buyButton.isEnabled = !taskActionsDisabled

View file

@ -1,23 +0,0 @@
package com.habitrpg.android.habitica.ui.views
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
object WobblyCircle : Shape {
override fun createOutline(
size: Size, layoutDirection: LayoutDirection, density: Density
): Outline {
val path = Path().apply {
addOval(Rect(Offset(0f, -size.height / 0.4f),
Size(size.width * 1.8f, size.height * 1.6f)))
}
return Outline.Generic(path)
}
}

View file

@ -2,6 +2,7 @@ package com.habitrpg.shared.habitica.models
interface Avatar {
val id: String?
val balance: Double
val authentication: AvatarAuthentication?
val stats: AvatarStats?

View file

@ -54,8 +54,6 @@ open class Task constructor(): Parcelable, BaseTask {
// todos
@Json(name="date")
var dueDate: Date? = null
// used for buyable items
var specialTag: String? = ""
@Json(ignore = true)
var parsedText: Spanned? = null
@ -209,7 +207,6 @@ open class Task constructor(): Parcelable, BaseTask {
dest.writeLong(this.startDate?.time ?: -1)
dest.writeParcelable(this.repeat, flags)
dest.writeLong(this.dueDate?.time ?: -1)
dest.writeString(this.specialTag)
dest.writeString(this.id)
dest.writeInt(this.counterUp ?: 0)
dest.writeInt(this.counterDown ?: 0)
@ -244,7 +241,6 @@ open class Task constructor(): Parcelable, BaseTask {
this.repeat = `in`.readParcelable(Days::class.java.classLoader)
val tmpDuedate = `in`.readLong()
this.dueDate = if (tmpDuedate == -1L) null else Date(tmpDuedate)
this.specialTag = `in`.readString()
this.id = `in`.readString()
this.counterUp = `in`.readInt()
this.counterDown = `in`.readInt()