Adds Edit Armor screen to edit a monster's armor stats.

This commit is contained in:
2021-05-29 19:46:28 -07:00
parent 82ce3d3788
commit f4dd3855d6
9 changed files with 396 additions and 91 deletions

View File

@@ -0,0 +1,15 @@
package com.majinnaibu.monstercards.helpers;
import java.util.Objects;
public final class ArrayHelper {
public static int indexOf(Object[] array, Object target) {
for (int index = 0; index < array.length; index++) {
if (Objects.equals(array[index], target)) {
return index;
}
}
return -1;
}
}

View File

@@ -0,0 +1,107 @@
package com.majinnaibu.monstercards.ui.editmonster;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavBackStackEntry;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import com.majinnaibu.monstercards.R;
import com.majinnaibu.monstercards.data.enums.ArmorType;
import com.majinnaibu.monstercards.helpers.ArrayHelper;
import com.majinnaibu.monstercards.utils.TextChangedListener;
@SuppressWarnings("FieldCanBeLocal")
public class EditArmorFragment extends Fragment {
private EditMonsterViewModel mViewModel;
private ViewHolder mHolder;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment);
NavBackStackEntry backStackEntry = navController.getBackStackEntry(R.id.edit_monster_navigation);
mViewModel = new ViewModelProvider(backStackEntry).get(EditMonsterViewModel.class);
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_edit_armor, container, false);
mHolder = new ViewHolder(root);
mHolder.armorType.setAdapter(new ArrayAdapter<ArmorType>(requireContext(), R.layout.dropdown_list_item, ArmorType.values()) {
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ArmorType item = getItem(position);
TextView view = (TextView) super.getView(position, convertView, parent);
view.setText(item.displayName);
return view;
}
@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ArmorType item = getItem(position);
TextView view = (TextView) super.getDropDownView(position, convertView, parent);
view.setText(item.displayName);
return view;
}
});
mHolder.armorType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
ArmorType selectedItem = (ArmorType) parent.getItemAtPosition(position);
mViewModel.setArmorType(selectedItem);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
mViewModel.setArmorType(ArmorType.NONE);
}
});
mHolder.armorType.setSelection(ArrayHelper.indexOf(ArmorType.values(), mViewModel.getArmorType().getValue()));
mHolder.naturalArmorBonus.setText(mViewModel.getNaturalArmorBonusValueAsString());
mHolder.naturalArmorBonus.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setNaturalArmorBonus(s.toString()))));
mHolder.hasShield.setChecked(mViewModel.getHasShieldValueAsBoolean());
mHolder.hasShield.setOnCheckedChangeListener((buttonView, isChecked) -> mViewModel.setHasShield(isChecked));
mHolder.shieldBonus.setText(mViewModel.getShieldBonusValueAsString());
mHolder.shieldBonus.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setShieldBonus(s.toString()))));
mHolder.customArmor.setText(mViewModel.getCustomArmor().getValue());
mHolder.customArmor.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setCustomArmor(s.toString()))));
return root;
}
private static class ViewHolder {
private final Spinner armorType;
private final EditText naturalArmorBonus;
private final SwitchCompat hasShield;
private final EditText shieldBonus;
private final EditText customArmor;
ViewHolder(View root) {
armorType = root.findViewById(R.id.armorType);
naturalArmorBonus = root.findViewById(R.id.naturalArmorBonus);
hasShield = root.findViewById(R.id.hasShield);
shieldBonus = root.findViewById(R.id.shieldBonus);
customArmor = root.findViewById(R.id.customArmor);
}
}
}

View File

@@ -6,7 +6,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavBackStackEntry; import androidx.navigation.NavBackStackEntry;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@@ -15,12 +14,8 @@ import androidx.navigation.Navigation;
import com.google.android.material.switchmaterial.SwitchMaterial; import com.google.android.material.switchmaterial.SwitchMaterial;
import com.majinnaibu.monstercards.R; import com.majinnaibu.monstercards.R;
import com.majinnaibu.monstercards.ui.MCFragment; import com.majinnaibu.monstercards.ui.MCFragment;
import com.majinnaibu.monstercards.utils.Logger;
import com.majinnaibu.monstercards.utils.TextChangedListener; import com.majinnaibu.monstercards.utils.TextChangedListener;
/**
* A simple {@link Fragment} subclass.
*/
@SuppressWarnings("FieldCanBeLocal") @SuppressWarnings("FieldCanBeLocal")
public class EditBasicInfoFragment extends MCFragment { public class EditBasicInfoFragment extends MCFragment {
private EditMonsterViewModel mViewModel; private EditMonsterViewModel mViewModel;
@@ -38,52 +33,28 @@ public class EditBasicInfoFragment extends MCFragment {
mHolder = new ViewHolder(root); mHolder = new ViewHolder(root);
mHolder.name.setText(mViewModel.getName().getValue()); mHolder.name.setText(mViewModel.getName().getValue());
mHolder.name.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.name.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setName(s.toString())));
mViewModel.setName(s.toString());
Logger.logDebug(String.format("Monster Name changed to %s", mViewModel.getName().getValue()));
}));
mHolder.size.setText(mViewModel.getSize().getValue()); mHolder.size.setText(mViewModel.getSize().getValue());
mHolder.size.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.size.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setSize(s.toString())));
mViewModel.setSize(s.toString());
Logger.logDebug(String.format("Monster Size changed to %s", mViewModel.getSize().getValue()));
}));
mHolder.type.setText(mViewModel.getType().getValue()); mHolder.type.setText(mViewModel.getType().getValue());
mHolder.type.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.type.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setType(s.toString())));
mViewModel.setType(s.toString());
Logger.logDebug(String.format("Monster Type changed to %s", mViewModel.getType().getValue()));
}));
mHolder.subtype.setText(mViewModel.getSubtype().getValue()); mHolder.subtype.setText(mViewModel.getSubtype().getValue());
mHolder.subtype.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.subtype.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setSubtype(s.toString())));
mViewModel.setSubtype(s.toString());
Logger.logDebug(String.format("Monster Subtype changed to %s", mViewModel.getSubtype().getValue()));
}));
mHolder.alignment.setText(mViewModel.getAlignment().getValue()); mHolder.alignment.setText(mViewModel.getAlignment().getValue());
mHolder.alignment.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.alignment.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setAlignment(s.toString())));
mViewModel.setAlignment(s.toString());
Logger.logDebug(String.format("Monster Alignment changed to %s", mViewModel.getAlignment().getValue()));
}));
mHolder.customHitPoints.setText(mViewModel.getCustomHitPoints().getValue()); mHolder.customHitPoints.setText(mViewModel.getCustomHitPoints().getValue());
mHolder.customHitPoints.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.customHitPoints.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setCustomHitPoints(s.toString()))));
mViewModel.setCustomHitPoints(s.toString());
Logger.logDebug(String.format("Monster Custom Hit Points changed to %s", mViewModel.getCustomHitPoints().getValue()));
})));
mHolder.hitDice.setText(mViewModel.getHitDiceValueAsString()); mHolder.hitDice.setText(mViewModel.getHitDiceValueAsString());
mHolder.hitDice.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> { mHolder.hitDice.addTextChangedListener((new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setHitDice(s.toString()))));
mViewModel.setHitDice(s.toString());
Logger.logDebug(String.format("Monster Hit Dice changed to %s", mViewModel.getHitDiceValueAsString()));
})));
mHolder.hasCustomHitPoints.setChecked(mViewModel.getHasCustomHitPointsValueAsBoolean()); mHolder.hasCustomHitPoints.setChecked(mViewModel.getHasCustomHitPointsValueAsBoolean());
mHolder.hasCustomHitPoints.setOnCheckedChangeListener((button, isChecked) -> { mHolder.hasCustomHitPoints.setOnCheckedChangeListener((button, isChecked) -> mViewModel.setHasCustomHitPoints(isChecked));
mViewModel.setHasCustomHitPoints(isChecked);
Logger.logDebug(String.format("Monster Has Custom Hit Points changed to %s", isChecked ? "TRUE" : "FALSE"));
});
return root; return root;
} }

View File

@@ -86,6 +86,12 @@ public class EditMonsterFragment extends MCFragment {
assert view != null; assert view != null;
Navigation.findNavController(view).navigate(action); Navigation.findNavController(view).navigate(action);
}); });
mHolder.armorButton.setOnClickListener(v -> {
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditArmorFragment();
View view = getView();
assert view != null;
Navigation.findNavController(view).navigate(action);
});
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) { requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
@Override @Override
@@ -137,9 +143,11 @@ public class EditMonsterFragment extends MCFragment {
private static class ViewHolder { private static class ViewHolder {
TextView basicInfoButton; TextView basicInfoButton;
TextView armorButton;
ViewHolder(View root) { ViewHolder(View root) {
basicInfoButton = root.findViewById(R.id.basicInfo); basicInfoButton = root.findViewById(R.id.basicInfo);
armorButton = root.findViewById(R.id.armor);
} }
} }
} }

View File

@@ -5,26 +5,34 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import com.majinnaibu.monstercards.data.enums.ArmorType;
import com.majinnaibu.monstercards.helpers.StringHelper; import com.majinnaibu.monstercards.helpers.StringHelper;
import com.majinnaibu.monstercards.models.Monster; import com.majinnaibu.monstercards.models.Monster;
import com.majinnaibu.monstercards.utils.Logger;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings({"ConstantConditions", "unused"}) @SuppressWarnings({"ConstantConditions", "unused"})
public class EditMonsterViewModel extends ViewModel { public class EditMonsterViewModel extends ViewModel {
private final MutableLiveData<String> mName;
private final MutableLiveData<UUID> mMonsterId; private final MutableLiveData<UUID> mMonsterId;
private final MutableLiveData<String> mErrorMessage;
private final MutableLiveData<Boolean> mHasError; private final MutableLiveData<Boolean> mHasError;
private final MutableLiveData<Boolean> mHasLoaded; private final MutableLiveData<Boolean> mHasLoaded;
private final MutableLiveData<Boolean> mHasChanges;
private final MutableLiveData<Boolean> mHasCustomHitPoints;
private final MutableLiveData<Boolean> mHasShield;
private final MutableLiveData<ArmorType> mArmorType;
private final MutableLiveData<Integer> mHitDice;
private final MutableLiveData<Integer> mNaturalArmorBonus;
private final MutableLiveData<Integer> mShieldBonus;
private final MutableLiveData<String> mName;
private final MutableLiveData<String> mErrorMessage;
private final MutableLiveData<String> mSize; private final MutableLiveData<String> mSize;
private final MutableLiveData<String> mType; private final MutableLiveData<String> mType;
private final MutableLiveData<String> mSubtype; private final MutableLiveData<String> mSubtype;
private final MutableLiveData<String> mAlignment; private final MutableLiveData<String> mAlignment;
private final MutableLiveData<String> mCustomHitPoints; private final MutableLiveData<String> mCustomHitPoints;
private final MutableLiveData<Boolean> mHasChanges; private final MutableLiveData<String> mCustomArmor;
private final MutableLiveData<Integer> mHitDice;
private final MutableLiveData<Boolean> mHasCustomHitPoints;
public EditMonsterViewModel() { public EditMonsterViewModel() {
@@ -39,7 +47,12 @@ public class EditMonsterViewModel extends ViewModel {
mAlignment = new MutableLiveData<>(""); mAlignment = new MutableLiveData<>("");
mCustomHitPoints = new MutableLiveData<>(""); mCustomHitPoints = new MutableLiveData<>("");
mHitDice = new MutableLiveData<>(0); mHitDice = new MutableLiveData<>(0);
mNaturalArmorBonus = new MutableLiveData<>(0);
mHasCustomHitPoints = new MutableLiveData<>(false); mHasCustomHitPoints = new MutableLiveData<>(false);
mArmorType = new MutableLiveData<>(ArmorType.NONE);
mHasShield = new MutableLiveData<>(false);
mShieldBonus = new MutableLiveData<>(0);
mCustomArmor = new MutableLiveData<>("");
// TODO: consider initializing this to true so all new monsters need saving // TODO: consider initializing this to true so all new monsters need saving
mHasChanges = new MutableLiveData<>(false); mHasChanges = new MutableLiveData<>(false);
} }
@@ -54,7 +67,12 @@ public class EditMonsterViewModel extends ViewModel {
mAlignment.setValue(monster.alignment); mAlignment.setValue(monster.alignment);
mCustomHitPoints.setValue(monster.customHPDescription); mCustomHitPoints.setValue(monster.customHPDescription);
mHitDice.setValue(monster.hitDice); mHitDice.setValue(monster.hitDice);
mNaturalArmorBonus.setValue(monster.naturalArmorBonus);
mHasCustomHitPoints.setValue(monster.hasCustomHP); mHasCustomHitPoints.setValue(monster.hasCustomHP);
mArmorType.setValue(monster.armorType);
mHasShield.setValue(monster.shieldBonus != 0);
mShieldBonus.setValue(monster.shieldBonus);
mCustomArmor.setValue(monster.otherArmorDescription);
mHasChanges.setValue(false); mHasChanges.setValue(false);
} }
@@ -63,8 +81,10 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setName(@NonNull String name) { public void setName(@NonNull String name) {
mName.setValue(name); if (!Objects.equals(mName.getValue(), name)) {
mHasChanges.setValue(true); mName.setValue(name);
mHasChanges.setValue(true);
}
} }
public LiveData<UUID> getMonsterId() { public LiveData<UUID> getMonsterId() {
@@ -108,8 +128,10 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setSize(@NonNull String size) { public void setSize(@NonNull String size) {
mSize.setValue(size); if (!Objects.equals(mSize.getValue(), size)) {
mHasChanges.setValue(true); mSize.setValue(size);
mHasChanges.setValue(true);
}
} }
public LiveData<String> getType() { public LiveData<String> getType() {
@@ -117,17 +139,21 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setType(@NonNull String type) { public void setType(@NonNull String type) {
mType.setValue(type); if (!Objects.equals(mType.getValue(), type)) {
mHasChanges.setValue(true); mType.setValue(type);
mHasChanges.setValue(true);
}
} }
public LiveData<String> getSubtype() { public LiveData<String> getSubtype() {
return mSubtype; return mSubtype;
} }
public void setSubtype(@NonNull String subType) { public void setSubtype(@NonNull String subtype) {
mSubtype.setValue(subType); if (!Objects.equals(mSubtype.getValue(), subtype)) {
mHasChanges.setValue(true); mSubtype.setValue(subtype);
mHasChanges.setValue(true);
}
} }
public LiveData<String> getAlignment() { public LiveData<String> getAlignment() {
@@ -135,8 +161,10 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setAlignment(@NonNull String alignment) { public void setAlignment(@NonNull String alignment) {
mAlignment.setValue(alignment); if (!Objects.equals(mAlignment.getValue(), alignment)) {
mHasChanges.setValue(true); mAlignment.setValue(alignment);
mHasChanges.setValue(true);
}
} }
public LiveData<String> getCustomHitPoints() { public LiveData<String> getCustomHitPoints() {
@@ -144,8 +172,10 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setCustomHitPoints(String customHitPoints) { public void setCustomHitPoints(String customHitPoints) {
mCustomHitPoints.setValue(customHitPoints); if (!Objects.equals(mCustomHitPoints.getValue(), customHitPoints)) {
mHasChanges.setValue(true); mCustomHitPoints.setValue(customHitPoints);
mHasChanges.setValue(true);
}
} }
public LiveData<Boolean> getHasChanges() { public LiveData<Boolean> getHasChanges() {
@@ -165,8 +195,10 @@ public class EditMonsterViewModel extends ViewModel {
} }
public void setHitDice(int hitDice) { public void setHitDice(int hitDice) {
mHitDice.setValue(hitDice); if (!Objects.equals(mHitDice.getValue(), hitDice)) {
mHasChanges.setValue(true); mHitDice.setValue(hitDice);
mHasChanges.setValue(true);
}
} }
public void setHitDice(String hitDice) { public void setHitDice(String hitDice) {
@@ -178,19 +210,93 @@ public class EditMonsterViewModel extends ViewModel {
return mHitDice.getValue().toString(); return mHitDice.getValue().toString();
} }
public LiveData<Integer> getNaturalArmorBonus() {
return mNaturalArmorBonus;
}
public void setNaturalArmorBonus(int naturalArmorBonus) {
if (!Objects.equals(mNaturalArmorBonus.getValue(), naturalArmorBonus)) {
mNaturalArmorBonus.setValue(naturalArmorBonus);
mHasChanges.setValue(true);
}
}
public void setNaturalArmorBonus(String naturalArmorBonus) {
Integer parsedValue = StringHelper.parseInt(naturalArmorBonus);
this.setNaturalArmorBonus(parsedValue != null ? parsedValue : 0);
}
public String getNaturalArmorBonusValueAsString() {
return mNaturalArmorBonus.getValue().toString();
}
public LiveData<Boolean> getHasCustomHitPoints() { public LiveData<Boolean> getHasCustomHitPoints() {
return mHasCustomHitPoints; return mHasCustomHitPoints;
} }
public void setHasCustomHitPoints(boolean hasCustomHitPoints) { public void setHasCustomHitPoints(boolean hasCustomHitPoints) {
mHasCustomHitPoints.setValue(hasCustomHitPoints); if (!Objects.equals(mHasCustomHitPoints.getValue(), hasCustomHitPoints)) {
mHasChanges.setValue(true); mHasCustomHitPoints.setValue(hasCustomHitPoints);
mHasChanges.setValue(true);
}
} }
public boolean getHasCustomHitPointsValueAsBoolean() { public boolean getHasCustomHitPointsValueAsBoolean() {
return mHasCustomHitPoints.getValue(); return mHasCustomHitPoints.getValue();
} }
public LiveData<ArmorType> getArmorType() {
return mArmorType;
}
public void setArmorType(ArmorType armorType) {
Logger.logDebug(String.format("Setting ArmorType to %s", armorType.displayName));
if (!Objects.equals(mArmorType.getValue(), armorType)) {
mArmorType.setValue(armorType);
mHasChanges.setValue(true);
}
}
public LiveData<Boolean> getHasShield() {
return mHasShield;
}
public void setHasShield(boolean hasShield) {
mHasShield.setValue(hasShield);
mHasChanges.setValue(true);
}
public boolean getHasShieldValueAsBoolean() {
return mHasShield.getValue();
}
public LiveData<Integer> getShieldBonus() {
return mShieldBonus;
}
public void setShieldBonus(int shieldBonus) {
mShieldBonus.setValue(shieldBonus);
mHasChanges.setValue(true);
}
public void setShieldBonus(String shieldBonus) {
Integer parsedValue = StringHelper.parseInt(shieldBonus);
this.setShieldBonus(parsedValue != null ? parsedValue : 0);
}
public LiveData<String> getCustomArmor() {
return mCustomArmor;
}
public void setCustomArmor(String customArmor) {
mCustomArmor.setValue(customArmor);
mHasChanges.setValue(true);
}
public String getShieldBonusValueAsString() {
return mShieldBonus.getValue().toString();
}
public Monster buildMonster() { public Monster buildMonster() {
Monster monster = new Monster(); Monster monster = new Monster();
@@ -203,6 +309,10 @@ public class EditMonsterViewModel extends ViewModel {
monster.customHPDescription = mCustomHitPoints.getValue(); monster.customHPDescription = mCustomHitPoints.getValue();
monster.hitDice = mHitDice.getValue(); monster.hitDice = mHitDice.getValue();
monster.hasCustomHP = mHasCustomHitPoints.getValue(); monster.hasCustomHP = mHasCustomHitPoints.getValue();
monster.armorType = mArmorType.getValue();
monster.naturalArmorBonus = mNaturalArmorBonus.getValue();
monster.shieldBonus = mShieldBonus.getValue();
monster.otherArmorDescription = mCustomArmor.getValue();
return monster; return monster;
} }

View File

@@ -0,0 +1,9 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:padding="@dimen/text_margin"
android:textSize="20sp"
tools:text="Hello, World!" />

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.editmonster.EditBasicInfoFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Spinner
android:id="@+id/armorType"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/naturalArmorBonus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0123456789"
android:hint="@string/label_natural_armor_bonus"
android:importantForAutofill="no"
android:inputType="numberSigned"
tools:text="+2" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/hasShield"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="@string/label_has_a_shield"
android:textSize="20sp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/shieldBonus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0123456789"
android:hint="@string/label_shield_bonus"
android:importantForAutofill="no"
android:inputType="numberSigned"
tools:text="4" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/customArmor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_custom_armor"
android:importantForAutofill="no"
android:inputType="text"
tools:text="John Doe" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>

View File

@@ -75,12 +75,20 @@
<action <action
android:id="@+id/action_editMonsterFragment_to_editBasicInfoFragment" android:id="@+id/action_editMonsterFragment_to_editBasicInfoFragment"
app:destination="@id/editBasicInfoFragment" /> app:destination="@id/editBasicInfoFragment" />
<action
android:id="@+id/action_editMonsterFragment_to_editArmorFragment"
app:destination="@id/editArmorFragment" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/editBasicInfoFragment" android:id="@+id/editBasicInfoFragment"
android:name="com.majinnaibu.monstercards.ui.editmonster.EditBasicInfoFragment" android:name="com.majinnaibu.monstercards.ui.editmonster.EditBasicInfoFragment"
android:label="fragment_edit_basic_info" android:label="fragment_edit_basic_info"
tools:layout="@layout/fragment_edit_basic_info" /> tools:layout="@layout/fragment_edit_basic_info" />
<fragment
android:id="@+id/editArmorFragment"
android:name="com.majinnaibu.monstercards.ui.editmonster.EditArmorFragment"
android:label="fragment_edit_armor"
tools:layout="@layout/fragment_edit_armor" />
</navigation> </navigation>
</navigation> </navigation>

View File

@@ -1,49 +1,53 @@
<resources> <resources>
<string name="action_add_monster">Add monster</string>
<string name="action_edit">Edit</string>
<string name="actions_label">Actions</string> <string name="actions_label">Actions</string>
<string name="app_name">MonsterCards</string> <string name="app_name">MonsterCards</string>
<string name="charisma_abbreviation">CHA</string> <string name="charisma_abbreviation">CHA</string>
<string name="constitution_abbreviation">CON</string> <string name="constitution_abbreviation">CON</string>
<string name="default_monster_name">Unnamed Monster</string>
<string name="dexterity_abbreviation">DEX</string> <string name="dexterity_abbreviation">DEX</string>
<string name="intelligence_abbreviation">INT</string> <string name="intelligence_abbreviation">INT</string>
<string name="label_search_query">Query</string>
<string name="section_divider">section divider</string>
<string name="strength_abbreviation">STR</string>
<string name="title_collections">Collections</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_library">Library</string>
<string name="title_search">Search</string>
<string name="wisdom_abbreviation">WIS</string>
<string name="action_add_monster">Add monster</string>
<string name="action_edit">Edit</string>
<string name="label_basic_info">Basic Info</string>
<string name="label_armor">Armor</string>
<string name="label_speed">Speed</string>
<string name="label_ability_scores">Ability Scores</string> <string name="label_ability_scores">Ability Scores</string>
<string name="label_saving_throws">Saving Throws</string> <string name="label_abilities">Abilities</string>
<string name="label_skills">Skills</string> <string name="label_actions">Actions</string>
<string name="label_alignment">Alignment</string>
<string name="label_armor">Armor</string>
<string name="label_basic_info">Basic Info</string>
<string name="label_challenge_rating">Challenge Rating</string>
<string name="label_condition_immunities">Condition Immunities</string> <string name="label_condition_immunities">Condition Immunities</string>
<string name="label_custom_armor">Custom Armor</string>
<string name="label_custom_hp">Custom HP</string>
<string name="label_damage_immunities">Damage Immunities</string> <string name="label_damage_immunities">Damage Immunities</string>
<string name="label_damage_resistances">Damage Resistances</string> <string name="label_damage_resistances">Damage Resistances</string>
<string name="label_damage_vulnerabilities">Damage Vulnerabilities</string> <string name="label_damage_vulnerabilities">Damage Vulnerabilities</string>
<string name="label_senses">Senses</string> <string name="label_has_custom_hp">Has Custom HP</string>
<string name="label_languages">Languages</string> <string name="label_has_a_shield">Has a Shield</string>
<string name="label_challenge_rating">Challenge Rating</string> <string name="label_hit_dice">Hit Dice</string>
<string name="label_abilities">Abilities</string>
<string name="label_actions">Actions</string>
<string name="label_reactions">Reactions</string>
<string name="label_legendary_actions">Legendary Actions</string>
<string name="label_lair_actions">Lair Actions</string> <string name="label_lair_actions">Lair Actions</string>
<string name="label_languages">Languages</string>
<string name="label_legendary_actions">Legendary Actions</string>
<string name="label_natural_armor_bonus">Natural Armor Bonus</string>
<string name="label_name">Name</string>
<string name="label_reactions">Reactions</string>
<string name="label_regional_actions">Regional Actions</string> <string name="label_regional_actions">Regional Actions</string>
<string name="title_edit_monster">Edit %1$s</string> <string name="label_saving_throws">Saving Throws</string>
<string name="default_monster_name">Unnamed Monster</string> <string name="label_search_query">Query</string>
<string name="label_senses">Senses</string>
<string name="label_shield_bonus">Shield Bonus</string>
<string name="label_size">Size</string>
<string name="label_skills">Skills</string>
<string name="label_speed">Speed</string>
<string name="label_subtype">Subtype</string>
<string name="label_type">Type</string>
<string name="section_divider">section divider</string>
<string name="snackbar_failed_to_create_monster">Failed to create monster</string> <string name="snackbar_failed_to_create_monster">Failed to create monster</string>
<string name="snackbar_monster_created">%1$s created</string> <string name="snackbar_monster_created">%1$s created</string>
<string name="label_name">Name</string> <string name="strength_abbreviation">STR</string>
<string name="label_size">Size</string> <string name="title_collections">Collections</string>
<string name="label_type">Type</string> <string name="title_dashboard">Dashboard</string>
<string name="label_subtype">Subtype</string> <string name="title_edit_monster">Edit %1$s</string>
<string name="label_alignment">Alignment</string> <string name="title_library">Library</string>
<string name="label_custom_hp">Custom HP</string> <string name="title_search">Search</string>
<string name="label_has_custom_hp">Has Custom HP</string> <string name="wisdom_abbreviation">WIS</string>
<string name="label_hit_dice">Hit Dice</string>
</resources> </resources>