mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 19:29:02 +00:00
redesign fix character values screen
This commit is contained in:
parent
bd4ce296e5
commit
ffbbed6d9e
8 changed files with 202 additions and 157 deletions
|
|
@ -5,7 +5,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.habitrpg.android.habitica.ui.activities.FixCharacterValuesActivity">
|
||||
tools:context="com.habitrpg.android.habitica.ui.activities.FixCharacterValuesActivity"
|
||||
android:background="@color/white">
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
|
@ -30,152 +31,77 @@
|
|||
android:id="@+id/textView5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/outer_inset"
|
||||
android:text="@string/fix_character_description" />
|
||||
android:padding="@dimen/outer_inset"
|
||||
android:text="@string/fix_character_description"
|
||||
android:background="@color/gray_700"
|
||||
android:layout_marginBottom="16dp"
|
||||
/>
|
||||
|
||||
<TableLayout
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/healthEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/outer_inset"
|
||||
android:layout_marginRight="@dimen/outer_inset">
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stats"
|
||||
style="@style/TableHeader"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/HP_default"
|
||||
android:labelFor="@+id/healthEditText"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/healthEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/XP_default"
|
||||
android:labelFor="@+id/experienceEditText" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/experienceEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/gold_singular"
|
||||
android:labelFor="@+id/goldEditText"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/goldEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/MP_default"
|
||||
android:labelFor="@+id/manaEditText"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/manaEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/level"
|
||||
android:labelFor="@+id/levelEditText"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/levelEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/profile_achievements"
|
||||
style="@style/TableHeader"
|
||||
/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/streak_label"
|
||||
android:labelFor="@+id/streakEditText"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/streakEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/HP_default"
|
||||
app:fixIconName="health"
|
||||
app:hintStyle="@style/RedTextLabel"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/red_500"/>
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/experienceEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/XP_default"
|
||||
app:fixIconName="experience"
|
||||
app:hintStyle="@style/YellowTextLabel"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/yellow_500"/>
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/manaEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/MP_default"
|
||||
app:fixIconName="mana"
|
||||
app:hintStyle="@style/BlueTextLabel"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/blue_500"/>
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/goldEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/gold_plural"
|
||||
app:fixIconName="gold"
|
||||
app:hintStyle="@style/YellowTextLabel"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/yellow_500"/>
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/levelEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/character_level"
|
||||
app:fixIconName="level"
|
||||
app:hintStyle="@style/PurpleTextLabel"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/brand_300"/>
|
||||
<com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
android:id="@+id/streakEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/streak_label"
|
||||
app:fixIconName="streak"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:iconBgColor="@color/gray_400"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
38
Habitica/res/layout/fixvalues_edittext.xml
Normal file
38
Habitica/res/layout/fixvalues_edittext.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge 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="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_margin="6dp"
|
||||
android:background="@drawable/layout_rounded_bg"
|
||||
tools:parentTag="FrameLayout">
|
||||
<View
|
||||
android:id="@+id/iconBackgroundView"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@color/red_500"/>
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/editTextWrapper"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700">
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="number" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
<ImageView
|
||||
android:id="@+id/iconView"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:scaleType="center"/>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
|
|
@ -42,4 +42,10 @@
|
|||
<declare-styleable name="CurrencyViews">
|
||||
<attr name="hasLightBackground" format="boolean" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="FixValuesEditText">
|
||||
<attr name="fixIconName" format="string" />
|
||||
<attr name="title" format="string" />
|
||||
<attr name="iconBgColor" format="color" />
|
||||
<attr name="hintStyle" format="integer" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@
|
|||
<string name="level">Level</string>
|
||||
<string name="streak_label">21-Day Streaks</string>
|
||||
<string name="stats">Stats</string>
|
||||
<string name="fix_character_description">If you\'ve encountered a bug or made a mistake that unfairly changed your character (damage you shouldn\'t have taken, Gold you didn\'t really earn, etc.), you can manually correct your numbers here. Yes, this makes it possible to cheat: use this feature wisely, or you\'ll sabotage your own habit-building!</string>
|
||||
<string name="fix_character_description">If you’ve encountered a bug or made a mistake that unfairly changed your character, you can manually correct those values here.</string>
|
||||
<string name="fix_character_values">Fix Character Values</string>
|
||||
<string name="saving">Saving</string>
|
||||
<string name="forgot_password_title">Email a Password Reset Link</string>
|
||||
|
|
@ -688,4 +688,5 @@
|
|||
<string name="change_email">Change Email Address</string>
|
||||
<string name="change_login_name">Change Login Name</string>
|
||||
<string name="change">Change</string>
|
||||
<string name="character_level">Character Level</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -409,4 +409,18 @@
|
|||
<style name="TableHeader" parent="Title1">
|
||||
<item name="android:layout_marginTop">@dimen/content_section_spacing</item>
|
||||
</style>
|
||||
|
||||
<style name="RedTextLabel" parent="TextAppearance.AppCompat">
|
||||
<item name="android:textColor">@color/red_10</item>
|
||||
</style>
|
||||
<style name="YellowTextLabel" parent="TextAppearance.AppCompat">
|
||||
<item name="android:textColor">@color/yellow_10</item>
|
||||
</style>
|
||||
<style name="BlueTextLabel" parent="TextAppearance.AppCompat">
|
||||
<item name="android:textColor">@color/blue_10</item>
|
||||
</style>
|
||||
<style name="PurpleTextLabel" parent="TextAppearance.AppCompat">
|
||||
<item name="android:textColor">@color/brand_300</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -12,6 +12,7 @@ import com.habitrpg.android.habitica.data.UserRepository
|
|||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.ui.views.settings.FixValuesEditText
|
||||
import kotlinx.android.synthetic.main.activity_fixcharacter.*
|
||||
import rx.functions.Action0
|
||||
import rx.functions.Action1
|
||||
|
|
@ -78,16 +79,16 @@ class FixCharacterValuesActivity: BaseActivity() {
|
|||
}
|
||||
|
||||
private fun updateFields(user: User) {
|
||||
healthEditText.setText(user.stats?.hp.toString())
|
||||
experienceEditText.setText(user.stats?.exp.toString())
|
||||
goldEditText.setText(user.stats?.gp.toString())
|
||||
manaEditText.setText(user.stats?.mp.toString())
|
||||
levelEditText.setText(user.stats?.lvl.toString())
|
||||
streakEditText.setText(user.streakCount.toString())
|
||||
healthEditText.text = user.stats?.hp.toString()
|
||||
experienceEditText.text = user.stats?.exp.toString()
|
||||
goldEditText.text = user.stats?.gp.toString()
|
||||
manaEditText.text = user.stats?.mp.toString()
|
||||
levelEditText.text = user.stats?.lvl.toString()
|
||||
streakEditText.text = user.streakCount.toString()
|
||||
}
|
||||
|
||||
fun EditText.getDoubleValue(): Double {
|
||||
val stringValue = this.text.toString()
|
||||
fun FixValuesEditText.getDoubleValue(): Double {
|
||||
val stringValue = this.text
|
||||
return stringValue.toDouble()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@ import butterknife.BindView
|
|||
import com.habitrpg.android.habitica.ui.fragments.preferences.APIPreferenceFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.preferences.AuthenticationPreferenceFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.preferences.ProfilePreferencesFragment
|
||||
import kotlinx.android.synthetic.main.activity_prefs.*
|
||||
|
||||
class PrefsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
lateinit var toolbar: Toolbar
|
||||
|
||||
override fun getLayoutResId(): Int = R.layout.activity_prefs
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package com.habitrpg.android.habitica.ui.views.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.PorterDuff
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
||||
import butterknife.BindView
|
||||
import butterknife.ButterKnife
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
import kotlinx.android.synthetic.main.fixvalues_edittext.view.*
|
||||
|
||||
class FixValuesEditText(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {
|
||||
|
||||
var text: String
|
||||
get() = editText?.text.toString()
|
||||
set(value) {
|
||||
editText?.setText(value)
|
||||
}
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.fixvalues_edittext, this)
|
||||
ButterKnife.bind(this)
|
||||
|
||||
val attributes = context.theme.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.FixValuesEditText,
|
||||
0, 0)
|
||||
|
||||
editText.hint = attributes.getString(R.styleable.FixValuesEditText_title)
|
||||
editTextWrapper.hint = editText.hint
|
||||
editTextWrapper.setHintTextAppearance(attributes.getInteger(R.styleable.FixValuesEditText_hintStyle, R.style.PurpleTextLabel))
|
||||
val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg)
|
||||
backgroundDrawable.setColorFilter(attributes.getColor(R.styleable.FixValuesEditText_iconBgColor, 0), PorterDuff.Mode.MULTIPLY)
|
||||
backgroundDrawable.alpha = 50
|
||||
|
||||
iconBackgroundView.background = backgroundDrawable
|
||||
|
||||
val iconName = attributes.getString(R.styleable.FixValuesEditText_fixIconName)
|
||||
if (iconName == "health") {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfHeartLightBg())
|
||||
} else if (iconName == "experience") {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfExperience())
|
||||
} else if (iconName == "mana") {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfMagic())
|
||||
} else if (iconName == "gold") {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfGold())
|
||||
} else if (iconName == "level") {
|
||||
iconView.setImageBitmap(HabiticaIconsHelper.imageOfRogueLightBg())
|
||||
} else if (iconName == "streak") {
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue