Skip to content

Commit e38e4d7

Browse files
committed
Merge branch 'fix/ui-polish2' into 'master'
Přeleštění UI See merge request fmasa/pv239-project!85
2 parents 4c78193 + ff91a6c commit e38e4d7

21 files changed

+122
-134
lines changed

app/src/main/java/cz/muni/fi/rpg/ui/character/CharacterMiscFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ internal class CharacterMiscFragment : Fragment(R.layout.fragment_character_misc
7878
private fun openExperiencePointsDialog(currentXpPoints: Int) {
7979
val view = layoutInflater.inflate(R.layout.dialog_xp, null, false)
8080

81-
view.xpPointsInput.setText(currentXpPoints.toString())
81+
view.xpPointsInput.setDefaultValue(currentXpPoints.toString())
8282

8383
AlertDialog.Builder(requireContext(), R.style.FormDialog)
8484
.setTitle("Change amount of XP")
8585
.setView(view)
8686
.setPositiveButton(R.string.button_save) { _, _ ->
87-
val xpPoints = view.xpPointsInput.text.toString().toIntOrNull() ?: 0
87+
val xpPoints = view.xpPointsInput.getValue().toIntOrNull() ?: 0
8888
launch { viewModel.updateExperiencePoints(xpPoints) }
8989
}.create()
9090
.show()

app/src/main/java/cz/muni/fi/rpg/ui/character/inventory/InventoryItemDialog.kt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class InventoryItemDialog : DialogFragment(),
5050
val activity = requireActivity()
5151
val view = activity.layoutInflater.inflate(R.layout.inventory_item_edit_dialog, null)
5252

53-
existingItem?.let {
54-
view.itemName.setText(it.name)
55-
view.itemDescription.setText(it.description)
56-
view.itemQuantity.setText(it.quantity.toString())
57-
}
58-
5953
val dialog = AlertDialog.Builder(requireContext(), R.style.FormDialog)
6054
.setTitle(if (existingItem != null) null else getString(R.string.createInventoryItemTitle))
6155
.setView(view)
@@ -65,16 +59,19 @@ class InventoryItemDialog : DialogFragment(),
6559

6660

6761
val form = Form(requireContext()).apply {
68-
addTextInput(view.itemNameLayout).apply {
69-
setMaxLength(InventoryItem.NAME_MAX_LENGTH)
62+
addTextInput(view.nameInput).apply {
63+
setMaxLength(InventoryItem.NAME_MAX_LENGTH, false)
7064
setNotBlank(getString(R.string.error_name_blank))
65+
existingItem?.let { setDefaultValue(it.name) }
7166
}
7267

73-
addTextInput(view.itemDescriptionLayout).apply {
74-
setMaxLength(InventoryItem.DESCRIPTION_MAX_LENGTH)
68+
addTextInput(view.descriptionInput).apply {
69+
setMaxLength(InventoryItem.DESCRIPTION_MAX_LENGTH, false)
70+
existingItem?.let { setDefaultValue(it.description) }
7571
}
7672

77-
addTextInput(view.itemQuantityLayout).apply {
73+
addTextInput(view.quantityInput).apply {
74+
setDefaultValue(existingItem?.quantity?.toString() ?: "1")
7875
addLiveRule(getString(R.string.error_invalid_quantity)) {
7976
val value = it.toString().toIntOrNull()
8077

@@ -114,9 +111,9 @@ class InventoryItemDialog : DialogFragment(),
114111

115112
private fun createInventoryItem(view: View) = InventoryItem(
116113
id = this.existingItem?.id ?: InventoryItemId.randomUUID(),
117-
name = view.itemName.text.toString().trim(),
118-
description = view.itemDescription.text.toString().trim(),
119-
quantity = view.itemQuantity.text.toString().toInt()
114+
name = view.nameInput.getValue(),
115+
description = view.descriptionInput.getValue(),
116+
quantity = view.quantityInput.getValue().toInt()
120117
)
121118

122119
private suspend fun toast(message: String) {

app/src/main/java/cz/muni/fi/rpg/ui/character/skills/SkillDialog.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,25 @@ class SkillDialog : DialogFragment(), CoroutineScope by CoroutineScope(Dispatche
5656
.map { getString(it.getReadableNameId()) }
5757
.sorted()
5858

59+
characteristicSpinner.setAdapter(
60+
ArrayAdapter(requireContext(), R.layout.dropdown_menu_popup_item, characteristics)
61+
)
62+
characteristicSpinner.setText(characteristics[0], false)
63+
characteristicSpinner.setOnClickListener {
64+
(requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
65+
.hideSoftInputFromWindow(it.windowToken, 0)
66+
}
67+
68+
setDefaults(view)
69+
5970
val form = Form(requireContext()).apply {
60-
addTextInput(view.skillNameLayout).apply {
61-
setMaxLength(Skill.NAME_MAX_LENGTH)
71+
addTextInput(view.nameInput).apply {
72+
setMaxLength(Skill.NAME_MAX_LENGTH, false)
6273
setNotBlank(getString(R.string.error_skill_name_empty))
6374
}
6475

65-
addTextInput(view.skillDescriptionLayout).apply {
66-
setMaxLength(Skill.DESCRIPTION_MAX_LENGTH)
76+
addTextInput(view.descriptionInput).apply {
77+
setMaxLength(Skill.DESCRIPTION_MAX_LENGTH, false)
6778
}
6879

6980
view.advancesInput.setDefaultValue("1")
@@ -76,17 +87,6 @@ class SkillDialog : DialogFragment(), CoroutineScope by CoroutineScope(Dispatche
7687
}
7788
}
7889

79-
characteristicSpinner.setAdapter(
80-
ArrayAdapter(requireContext(), R.layout.dropdown_menu_popup_item, characteristics)
81-
)
82-
characteristicSpinner.setText(characteristics[0], false)
83-
characteristicSpinner.setOnClickListener {
84-
(requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager)
85-
.hideSoftInputFromWindow(it.windowToken, 0)
86-
}
87-
88-
setDefaults(view)
89-
9090
val dialog = AlertDialog.Builder(activity, R.style.FormDialog)
9191
.setView(view)
9292
.setTitle(if (skill != null) null else getString(R.string.title_addSkill))
@@ -106,16 +106,16 @@ class SkillDialog : DialogFragment(), CoroutineScope by CoroutineScope(Dispatche
106106
private fun setDefaults(view: View) {
107107
val skill = this.skill ?: return
108108

109-
view.skillName.setText(skill.name)
110-
view.skillDescription.setText(skill.description)
109+
view.nameInput.setDefaultValue(skill.name)
110+
view.descriptionInput.setDefaultValue(skill.description)
111111
view.skillCharacteristic.setText(getString(skill.characteristic.getReadableNameId()), false)
112112
view.skillAdvanced.isChecked = skill.advanced
113113
view.advancesInput.setDefaultValue(skill.advances.toString())
114114
}
115115

116116
private fun dialogSubmitted(dialog: AlertDialog, view: View, form: Form) {
117-
val name = view.skillName.text.toString()
118-
val description = view.skillDescription.text.toString()
117+
val name = view.nameInput.getValue()
118+
val description = view.descriptionInput.getValue()
119119

120120
if (!form.validate()) {
121121
return

app/src/main/java/cz/muni/fi/rpg/ui/character/skills/adapter/SkillHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class SkillHolder(
4646
}
4747
)
4848

49-
view.skillLevelValue.text =
49+
view.skillTestNumberValue.text =
5050
(calculateBaseLevel(skill.characteristic, stats) + skill.advances).toString()
5151

5252
view.setOnCreateContextMenuListener { menu, v, _ ->

app/src/main/java/cz/muni/fi/rpg/ui/character/skills/talents/TalentDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class TalentDialog : DialogFragment() {
4444

4545
val form = Form(requireContext()).apply {
4646
addTextInput(view.talentNameInput).apply {
47-
setMaxLength(Talent.NAME_MAX_LENGTH)
47+
setMaxLength(Talent.NAME_MAX_LENGTH, false)
4848
setNotBlank(getString(R.string.error_talent_name_empty))
4949
}
5050

5151
addTextInput(view.talentDescriptionInput).apply {
52-
setMaxLength(Talent.DESCRIPTION_MAX_LENGTH)
52+
setMaxLength(Talent.DESCRIPTION_MAX_LENGTH, false)
5353
}
5454

5555
addTextInput(view.talentTakenInput).apply {

app/src/main/java/cz/muni/fi/rpg/ui/character/spells/SpellDialog.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ class SpellDialog : DialogFragment(),
5151

5252
val form = Form(requireContext()).apply {
5353
addTextInput(view.spellNameInput).apply {
54-
setMaxLength(Spell.NAME_MAX_LENGTH)
54+
setMaxLength(Spell.NAME_MAX_LENGTH, false)
5555
setNotBlank(getString(R.string.error_cannot_be_empty))
5656
}
5757

5858
addTextInput(view.spellDurationInput).apply {
59-
setMaxLength(Spell.DURATION_MAX_LENGTH)
59+
setMaxLength(Spell.DURATION_MAX_LENGTH, false)
6060
}
6161

6262
addTextInput(view.spellRangeInput).apply {
63-
setMaxLength(Spell.RANGE_MAX_LENGTH)
63+
setMaxLength(Spell.RANGE_MAX_LENGTH, false)
6464
}
6565

6666
addTextInput(view.spellTargetInput).apply {
67-
setMaxLength(Spell.TARGET_MAX_LENGTH)
67+
setMaxLength(Spell.TARGET_MAX_LENGTH, false)
6868
}
6969

7070
addTextInput(view.spellCastingNumberInput).apply {
7171
setNotBlank("CN must not be empty")
7272
}
7373

7474
addTextInput(view.spellEffectInput).apply {
75-
setMaxLength(Spell.EFFECT_MAX_LENGTH)
75+
setMaxLength(Spell.EFFECT_MAX_LENGTH, false)
7676
}
7777
}
7878

app/src/main/java/cz/muni/fi/rpg/ui/gameMaster/encounters/CombatantFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class CombatantFragment : BaseFragment(R.layout.fragment_combatant),
8585
return false
8686
}
8787

88+
item.isEnabled = false
89+
8890
val name = nameInput.getValue()
8991
val note = noteInput.getValue()
9092
val maxWounds = maxWoundsInput.getValue().toInt()

app/src/main/res/layout/dialog_skill.xml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,36 @@
77
android:orientation="vertical"
88
android:padding="@dimen/dialogPadding">
99

10-
<com.google.android.material.textfield.TextInputLayout
11-
android:id="@+id/skillNameLayout"
12-
style="@style/OutlinedInputWithCounter"
10+
<cz.muni.fi.rpg.ui.views.TextInput
11+
android:id="@+id/nameInput"
12+
android:layout_marginBottom="16dp"
13+
android:maxLines="1"
1314
android:layout_width="match_parent"
1415
android:layout_height="wrap_content"
15-
android:hint="@string/label_skill_name">
16-
17-
<com.google.android.material.textfield.TextInputEditText
18-
android:id="@+id/skillName"
19-
android:layout_width="match_parent"
20-
android:layout_height="wrap_content" />
16+
app:inputLabel="@string/label_skill_name" />
2117

22-
</com.google.android.material.textfield.TextInputLayout>
2318

24-
<com.google.android.material.textfield.TextInputLayout
25-
android:id="@+id/skillDescriptionLayout"
26-
style="@style/OutlinedInputWithCounter"
19+
<cz.muni.fi.rpg.ui.views.TextInput
20+
android:id="@+id/descriptionInput"
21+
android:layout_marginBottom="16dp"
22+
android:minLines="3"
23+
android:inputType="textMultiLine"
2724
android:layout_width="match_parent"
2825
android:layout_height="wrap_content"
29-
android:hint="@string/label_skill_description">
26+
app:inputLabel="@string/label_skill_description" />
3027

31-
<com.google.android.material.textfield.TextInputEditText
32-
android:id="@+id/skillDescription"
33-
android:layout_width="match_parent"
34-
android:layout_height="wrap_content" />
3528

36-
</com.google.android.material.textfield.TextInputLayout>
29+
<TextView
30+
android:hint="@string/label_skill_characteristic"
31+
android:textSize="14sp"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content" />
3734

3835
<com.google.android.material.textfield.TextInputLayout
39-
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
36+
style="@style/ExposedDropdownMenu"
37+
android:layout_marginBottom="16dp"
4038
android:layout_width="match_parent"
41-
android:layout_height="wrap_content"
42-
android:hint="@string/label_skill_characteristic">
39+
android:layout_height="wrap_content">
4340

4441
<AutoCompleteTextView
4542
android:id="@+id/skillCharacteristic"
@@ -50,11 +47,10 @@
5047

5148
</com.google.android.material.textfield.TextInputLayout>
5249

53-
<com.google.android.material.switchmaterial.SwitchMaterial
50+
<com.google.android.material.checkbox.MaterialCheckBox
5451
android:id="@+id/skillAdvanced"
5552
android:layout_width="wrap_content"
5653
android:layout_height="wrap_content"
57-
android:layout_marginTop="8dp"
5854
android:checked="true"
5955
android:text="@string/label_skill_advanced"
6056
app:switchPadding="4dp" />

app/src/main/res/layout/dialog_spell.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,38 @@
1212

1313
<cz.muni.fi.rpg.ui.views.TextInput
1414
android:id="@+id/spellNameInput"
15+
android:maxLines="1"
1516
android:layout_width="match_parent"
1617
android:layout_height="wrap_content"
1718
app:inputLabel="@string/label_name" />
1819

1920
<cz.muni.fi.rpg.ui.views.TextInput
2021
android:id="@+id/spellRangeInput"
22+
android:maxLines="1"
2123
android:layout_marginTop="16dp"
2224
android:layout_width="match_parent"
2325
android:layout_height="wrap_content"
2426
app:inputLabel="@string/label_spell_range" />
2527

2628
<cz.muni.fi.rpg.ui.views.TextInput
2729
android:id="@+id/spellTargetInput"
30+
android:maxLines="1"
2831
android:layout_marginTop="16dp"
2932
android:layout_width="match_parent"
3033
android:layout_height="wrap_content"
3134
app:inputLabel="@string/label_spell_target" />
3235

3336
<cz.muni.fi.rpg.ui.views.TextInput
3437
android:id="@+id/spellDurationInput"
38+
android:maxLines="1"
3539
android:layout_marginTop="16dp"
3640
android:layout_width="match_parent"
3741
android:layout_height="wrap_content"
3842
app:inputLabel="@string/label_spell_duration" />
3943

4044
<cz.muni.fi.rpg.ui.views.TextInput
4145
android:id="@+id/spellCastingNumberInput"
46+
android:maxLines="1"
4247
android:layout_marginTop="16dp"
4348
android:layout_width="match_parent"
4449
android:inputType="number"
@@ -48,6 +53,8 @@
4853

4954
<cz.muni.fi.rpg.ui.views.TextInput
5055
android:id="@+id/spellEffectInput"
56+
android:minLines="3"
57+
android:inputType="textMultiLine"
5158
android:layout_marginTop="16dp"
5259
android:layout_width="match_parent"
5360
android:layout_height="wrap_content"

app/src/main/res/layout/dialog_talent.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88

99
<cz.muni.fi.rpg.ui.views.TextInput
1010
android:id="@+id/talentNameInput"
11+
android:maxLines="1"
1112
android:layout_width="match_parent"
1213
android:layout_height="wrap_content"
1314
app:inputLabel="@string/label_name" />
1415

1516
<cz.muni.fi.rpg.ui.views.TextInput
1617
android:layout_marginTop="16dp"
1718
android:id="@+id/talentDescriptionInput"
19+
android:minLines="3"
20+
android:inputType="textMultiLine"
1821
android:layout_width="match_parent"
1922
android:layout_height="wrap_content"
2023
app:inputLabel="@string/label_description" />
@@ -25,6 +28,7 @@
2528
android:layout_height="wrap_content"
2629
android:layout_marginTop="16dp"
2730
android:inputType="number"
31+
android:maxLines="1"
2832
android:maxLength="3"
2933
app:inputLabel="@string/label_talent_taken" />
3034
</LinearLayout>

0 commit comments

Comments
 (0)