Code reformat

This commit is contained in:
2020-09-02 00:05:03 -07:00
parent 8e0252f49e
commit 05b1f8ad01
12 changed files with 228 additions and 96 deletions

View File

@@ -2,19 +2,20 @@ package com.majinnaibu.monstercards;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.microsoft.appcenter.AppCenter;
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.crashes.Crashes;
public class MainActivity extends AppCompatActivity {
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -8,17 +8,21 @@ public class Ability {
}
private String mName;
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
private String mDescription;
public String getDescription() {
return mDescription;
}
public void setDescription(String description) {
mDescription = description;
}

View File

@@ -8,17 +8,21 @@ public class Action {
}
private String mName;
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
private String mDescription;
public String getDescription() {
return mDescription;
}
public void setDescription(String description) {
mDescription = description;
}

View File

@@ -9,25 +9,31 @@ public class DamageType {
}
private String mName;
public String getName() {
return mName;
}
public void setName(String value) {
mName = value;
}
private String mNote;
public String getNote() {
return mNote;
}
public void setNote(String value) {
mNote = value;
}
private String mType;
public String getType() {
return mType;
}
public void setType(String value) {
mType = value;
}

View File

@@ -10,17 +10,21 @@ public class Language implements Comparator<Language>, Comparable<Language> {
}
private String mName;
public String getName() {
return mName;
}
public void setName(String value) {
mName = value;
}
private boolean mSpeaks;
public boolean getSpeaks() {
return mSpeaks;
}
public void setSpeaks(boolean value) {
mSpeaks = value;
}

View File

@@ -23,41 +23,51 @@ public class Monster {
}
private String mName;
public String getName() {
return mName;
}
public void setName(String value) {
mName = value;
}
private String mSize;
public String getSize() {
return mSize;
}
public void setSize(String value) {
mSize = value;
}
private String mType;
public String getType() {
return mType;
}
public void setType(String value) {
mType = value;
}
private String mTag;
public String getTag() {
return mTag;
}
public void setTag(String value) {
mTag = value;
}
private String mAlignment;
public String getAlignment() {
return mAlignment;
}
public void setAlignment(String value) {
mAlignment = value;
}
@@ -130,99 +140,125 @@ public class Monster {
}
private int mStrengthScore;
public int getStrengthScore() {
return mStrengthScore;
}
public void setStrengthScore(int value) {
mStrengthScore = value;
}
public int getStrengthModifier() {
return getAbilityModifierForScore(getStrengthScore());
}
private int mDexterityScore;
public int getDexterityScore() {
return mDexterityScore;
}
public void setDexterityScore(int value) {
mDexterityScore = value;
}
public int getDexterityModifier() {
return getAbilityModifierForScore(getDexterityScore());
}
private int mConstitutionScore;
public int getConstitutionScore() {
return mConstitutionScore;
}
public void setConstitutionScore(int value) {
mConstitutionScore = value;
}
public int getConstitutionModifier() {
return getAbilityModifierForScore(getConstitutionScore());
}
private int mIntelligenceScore;
public int getIntelligenceScore() {
return mIntelligenceScore;
}
public void setIntelligenceScore(int value) {
mIntelligenceScore = value;
}
public int getIntelligenceModifier() {
return getAbilityModifierForScore(getIntelligenceScore());
}
private int mWisdomScore;
public int getWisdomScore() {
return mWisdomScore;
}
public void setWisdomScore(int value) {
mWisdomScore = value;
}
public int getWisdomModifier() {
return getAbilityModifierForScore(getWisdomScore());
}
private int mCharismaScore;
public int getCharismaScore() {
return mCharismaScore;
}
public void setCharismaScore(int value) {
mCharismaScore = value;
}
public int getCharismaModifier() {
return getAbilityModifierForScore(getCharismaScore());
}
private String mArmorName;
public String getArmorName() {
return mArmorName;
}
public void setArmorName(String value) {
mArmorName = value;
}
private int mShieldBonus;
public int getShieldBonus() {
return mShieldBonus;
}
public void setShieldBonus(int value) {
mShieldBonus = value;
}
private int mNaturalArmorBonus;
public int getNaturalArmorBonus() {
return mNaturalArmorBonus;
}
public void setNaturalArmorBonus(int value) {
mNaturalArmorBonus = value;
}
private String mOtherArmorDescription;
public String getOtherArmorDescription() {
return mOtherArmorDescription;
}
public void setOtherArmorDescription(String value) {
mOtherArmorDescription = value;
}
@@ -299,25 +335,31 @@ public class Monster {
private static final int PLATE_ARMOR_CLASS = BASE_ARMOR_CLASS + 8;
private int mHitDice;
public int getHitDice() {
return mHitDice;
}
public void setHitDice(int value) {
mHitDice = value;
}
private boolean mCustomHP;
public boolean getCustomHP() {
return mCustomHP;
}
public void setCustomHP(boolean value) {
mCustomHP = value;
}
private String mHPText;
public String getHPText() {
return mHPText;
}
public void setHPText(String value) {
mHPText = value;
}
@@ -353,65 +395,81 @@ public class Monster {
}
private String mSpeed;
public String getSpeed() {
return mSpeed;
}
public void setSpeed(String value) {
mSpeed = value;
}
private String mBurrowSpeed;
public String getBurrowSpeed() {
return mBurrowSpeed;
}
public void setBurrowSpeed(String value) {
mBurrowSpeed = value;
}
private String mClimbSpeed;
public String getClimbSpeed() {
return mClimbSpeed;
}
public void setClimbSpeed(String value) {
mClimbSpeed = value;
}
private String mFlySpeed;
public String getFlySpeed() {
return mFlySpeed;
}
public void setFlySpeed(String value) {
mFlySpeed = value;
}
private boolean mHover;
public boolean getHover() {
return mHover;
}
public void setHover(boolean value) {
mHover = value;
}
private String mSwimSpeed;
public String getSwimSpeed() {
return mSwimSpeed;
}
public void setSwimSpeed(String value) {
mSwimSpeed = value;
}
private boolean mCustomSpeed;
public boolean getCustomSpeed() {
return mCustomSpeed;
}
public void setCustomSpeed(boolean value) {
mCustomSpeed = value;
}
private String mSpeedDescription;
public String getSpeedDescription() {
return mSpeedDescription;
}
public void setSpeedDescription(String value) {
mSpeedDescription = value;
}
@@ -471,15 +529,19 @@ public class Monster {
}
private HashSet<SavingThrow> mSavingThrows;
public Set<SavingThrow> getSavingThrows() {
return mSavingThrows;
}
public void addSavingThrow(SavingThrow savingThrow) {
mSavingThrows.add(savingThrow);
}
public void removeSavingThrow(SavingThrow savingThrow) {
mSavingThrows.remove(savingThrow);
}
public void clearSavingThrows() {
mSavingThrows.clear();
}
@@ -570,40 +632,50 @@ public class Monster {
}
private String mChallengeRating;
public String getChallengeRating() {
return mChallengeRating;
}
public void setChallengeRating(String challengeRating) {
mChallengeRating = challengeRating;
// TODO: update proficiency bonus based on CR
}
private String mCustomChallengeRating;
public String getCustomChallengeRating() {
return mCustomChallengeRating;
}
public void setCustomChallengeRating(String challengeRating) {
mCustomChallengeRating = challengeRating;
}
private int mCustomProficiencyBonus;
public int getCustomProficiencyBonus() {
return mCustomProficiencyBonus;
}
public void setCustomProficiencyBonus(int proficiencyBonus) {
mCustomProficiencyBonus = proficiencyBonus;
}
private HashSet<Skill> mSkills;
public Set<Skill> getSkills() {
return mSkills;
}
public void addSkill(Skill skill) {
mSkills.add(skill);
}
public void removeSkill(Skill skill) {
mSkills.remove(skill);
}
public void clearSkill(Skill skill) {
mSkills.clear();
}
@@ -626,16 +698,20 @@ public class Monster {
}
private HashSet<DamageType> mDamageTypes;
public Set<DamageType> getDamageTypes() {
return mDamageTypes;
}
public void addDamageType(DamageType damageType) {
// TODO: make this remove the damage type with the same name if it exists first
mDamageTypes.add(damageType);
}
public void removeDamageType(DamageType damageType) {
mDamageTypes.remove(damageType);
}
public void clearDamageTypes() {
mDamageTypes.clear();
}
@@ -650,6 +726,7 @@ public class Monster {
Collections.sort(vulnerabilities);
return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities);
}
public String getDamageResistancesDescription() {
ArrayList<String> vulnerabilities = new ArrayList<>();
for (DamageType damageType : mDamageTypes) {
@@ -660,6 +737,7 @@ public class Monster {
Collections.sort(vulnerabilities);
return StringHelper.oxfordJoin(", ", ", and ", " and ", vulnerabilities);
}
public String getDamageImmunitiesDescription() {
ArrayList<String> vulnerabilities = new ArrayList<>();
for (DamageType damageType : mDamageTypes) {
@@ -672,17 +750,21 @@ public class Monster {
}
private HashSet<String> mConditionImmunities;
public Set<String> getConditionImmunities() {
return mConditionImmunities;
}
public void addConditionImmunity(String condition) {
// TODO: filter out duplicates
mConditionImmunities.add(condition);
}
public void removeConditionImmunity(String condition) {
// TODO: make sure this works even though we're using strings
mConditionImmunities.remove(condition);
}
public void clearConditionImmunities() {
mConditionImmunities.clear();
}
@@ -694,41 +776,51 @@ public class Monster {
}
private String mBlindsight;
public String getBlindsight() {
return mBlindsight;
}
public void setBlindsight(String value) {
mBlindsight = value;
}
private boolean mIsBlind;
public boolean getIsBlind() {
return mIsBlind;
}
public void setIsBlind(boolean value) {
mIsBlind = value;
}
private String mDarkvision;
public String getDarkvision() {
return mDarkvision;
}
public void setDarkvision(String value) {
mDarkvision = value;
}
private String mTremorsense;
public String getTremorsense() {
return mTremorsense;
}
public void setTremorsense(String value) {
mTremorsense = value;
}
private String mTruesight;
public String getTruesight() {
return mTruesight;
}
public void setTruesight(String value) {
mTruesight = value;
}
@@ -758,31 +850,39 @@ public class Monster {
}
private HashSet<Language> mLanguages;
public Set<Language> getLanguages() {
return mLanguages;
}
public void addLanguage(Language value) {
mLanguages.add(value);
}
public void removeLanguage(Language value) {
mLanguages.remove(value);
}
public void clearLanguages() {
mLanguages.clear();
}
private int mTelepathy;
public int getTelepathy() {
return mTelepathy;
}
public void setTelepathy(int value) {
mTelepathy = value;
}
private String mUnderstandsBut;
public String getUnderstandsBut() {
return mUnderstandsBut;
}
public void setUnderstandsBut(String value) {
mUnderstandsBut = value;
}
@@ -921,15 +1021,19 @@ public class Monster {
}
private ArrayList<Ability> mAbilities;
public List<Ability> getAbilities() {
return mAbilities;
}
public void addAbility(Ability ability) {
mAbilities.add(ability);
}
public void removeAbility(Ability ability) {
mAbilities.remove(ability);
}
public void clearAbilities() {
mAbilities.clear();
}
@@ -989,15 +1093,19 @@ public class Monster {
}
private ArrayList<Action> mActions;
public List<Action> getActions() {
return mActions;
}
public void addAction(Action ability) {
mActions.add(ability);
}
public void removeAction(Action ability) {
mActions.remove(ability);
}
public void clearActions() {
mActions.clear();
}

View File

@@ -10,17 +10,21 @@ public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingTh
}
private String mName;
public String getName() {
return mName;
}
public void setName(String value) {
mName = value;
}
private int mOrder;
public int getOrder() {
return mOrder;
}
public void setOrder(int value) {
mOrder = value;
}

View File

@@ -24,6 +24,7 @@ public class Skill implements Comparator<Skill>, Comparable<Skill> {
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
@@ -31,6 +32,7 @@ public class Skill implements Comparator<Skill>, Comparable<Skill> {
public String getAbilityScoreName() {
return mAbilityScoreName;
}
public void setAbilityScoreName(String abilityScoreName) {
mAbilityScoreName = abilityScoreName;
}

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView 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:layout_width="match_parent"
@@ -119,12 +118,12 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/label_dex"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/strength_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/label_dex"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/strength"
@@ -134,10 +133,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_str"
app:layout_constraintEnd_toEndOf="@+id/label_str"
app:layout_constraintTop_toBottomOf="@+id/label_str"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_str"
app:layout_constraintStart_toStartOf="@+id/label_str"
app:layout_constraintTop_toBottomOf="@+id/label_str"
tools:text="2 (-4)" />
<!-- Dexterity -->
@@ -149,12 +148,12 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toEndOf="@+id/label_str"
app:layout_constraintEnd_toStartOf="@+id/label_con"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/dexterity_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/label_con"
app:layout_constraintStart_toEndOf="@+id/label_str"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/dexterity"
@@ -164,10 +163,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_dex"
app:layout_constraintEnd_toEndOf="@+id/label_dex"
app:layout_constraintTop_toBottomOf="@+id/label_dex"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_dex"
app:layout_constraintStart_toStartOf="@+id/label_dex"
app:layout_constraintTop_toBottomOf="@+id/label_dex"
tools:text="20 (+5)" />
<!-- Constitution -->
@@ -179,24 +178,24 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toEndOf="@+id/label_dex"
app:layout_constraintEnd_toStartOf="@+id/label_int"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/constitution_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/label_int"
app:layout_constraintStart_toEndOf="@+id/label_dex"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/constitution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_con"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_con"
app:layout_constraintStart_toStartOf="@+id/label_con"
app:layout_constraintTop_toBottomOf="@+id/label_con"
tools:text="8 (-1)" />
@@ -209,12 +208,12 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toEndOf="@+id/label_con"
app:layout_constraintEnd_toStartOf="@+id/label_wis"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/intelligence_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/label_wis"
app:layout_constraintStart_toEndOf="@+id/label_con"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/intelligence"
@@ -224,10 +223,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_int"
app:layout_constraintEnd_toEndOf="@+id/label_int"
app:layout_constraintTop_toBottomOf="@+id/label_int"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_int"
app:layout_constraintStart_toStartOf="@+id/label_int"
app:layout_constraintTop_toBottomOf="@+id/label_int"
tools:text="10 (+0)" />
<!-- Wisdom -->
@@ -239,12 +238,12 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toEndOf="@+id/label_int"
app:layout_constraintEnd_toStartOf="@+id/label_cha"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/wisdom_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/label_cha"
app:layout_constraintStart_toEndOf="@+id/label_int"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/wisdom"
@@ -254,10 +253,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_wis"
app:layout_constraintEnd_toEndOf="@+id/label_wis"
app:layout_constraintTop_toBottomOf="@+id/label_wis"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_wis"
app:layout_constraintStart_toStartOf="@+id/label_wis"
app:layout_constraintTop_toBottomOf="@+id/label_wis"
tools:text="14 (+2)" />
<!-- Charisma -->
@@ -269,12 +268,12 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toEndOf="@+id/label_wis"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider2"
android:text="@string/charisma_abbreviation"
android:textAlignment="center"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/label_wis"
app:layout_constraintTop_toBottomOf="@+id/divider2" />
<TextView
android:id="@+id/charisma"
@@ -284,10 +283,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="@+id/label_cha"
app:layout_constraintEnd_toEndOf="@+id/label_cha"
app:layout_constraintTop_toBottomOf="@+id/label_cha"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@+id/label_cha"
app:layout_constraintStart_toStartOf="@+id/label_cha"
app:layout_constraintTop_toBottomOf="@+id/label_cha"
tools:text="15 (+2)" />
<ImageView
@@ -425,13 +424,13 @@
<!-- Abilities -->
<LinearLayout
android:id="@+id/abilities"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="0dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/challenge"
@@ -445,10 +444,10 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/actions_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/abilities"
android:text="@string/actions_label" />
app:layout_constraintTop_toBottomOf="@+id/abilities" />
<ImageView
android:id="@+id/divider4"
@@ -468,13 +467,13 @@
<!-- Actions -->
<LinearLayout
android:id="@+id/actions"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="0dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider4"

View File

@@ -23,10 +23,10 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:importantForAutofill="no"
android:ems="10"
android:inputType="textPersonName"
android:hint="@string/label_search_query"
android:importantForAutofill="no"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="@+id/button_search"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />