Adds ability to edit languages.
This commit is contained in:
@@ -0,0 +1,85 @@
|
|||||||
|
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.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.activity.OnBackPressedCallback;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
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.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.TextChangedListener;
|
||||||
|
|
||||||
|
public class EditLanguageFragment extends MCFragment {
|
||||||
|
private EditMonsterViewModel mEditMonsterViewModel;
|
||||||
|
private EditLanguageViewModel mViewModel;
|
||||||
|
private ViewHolder mHolder;
|
||||||
|
private Language mOldLanguage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
mViewModel = new ViewModelProvider(this).get(EditLanguageViewModel.class);
|
||||||
|
Bundle arguments = getArguments();
|
||||||
|
if (arguments != null) {
|
||||||
|
EditLanguageFragmentArgs args = EditLanguageFragmentArgs.fromBundle(arguments);
|
||||||
|
mOldLanguage = new Language(args.getName(), args.getCanSpeak());
|
||||||
|
mViewModel.copyFromLanguage(mOldLanguage);
|
||||||
|
} else {
|
||||||
|
Logger.logWTF("EditLanguageFragment needs arguments");
|
||||||
|
mOldLanguage = null;
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||||
|
NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment);
|
||||||
|
NavBackStackEntry backStackEntry = navController.getBackStackEntry(R.id.edit_monster_navigation);
|
||||||
|
mEditMonsterViewModel = new ViewModelProvider(backStackEntry).get(EditMonsterViewModel.class);
|
||||||
|
|
||||||
|
View root = inflater.inflate(R.layout.fragment_edit_language, container, false);
|
||||||
|
|
||||||
|
|
||||||
|
mHolder = new ViewHolder(root);
|
||||||
|
|
||||||
|
mHolder.name.setText(mViewModel.getName().getValue());
|
||||||
|
mHolder.name.addTextChangedListener(new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setName(s.toString())));
|
||||||
|
|
||||||
|
mHolder.canSpeak.setChecked(mViewModel.getCanSpeakValue());
|
||||||
|
mHolder.canSpeak.setOnCheckedChangeListener((buttonView, isChecked) -> mViewModel.setCanSpeak(isChecked));
|
||||||
|
|
||||||
|
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed() {
|
||||||
|
if (mViewModel.hasChanges()) {
|
||||||
|
mEditMonsterViewModel.replaceLanguage(mOldLanguage, mViewModel.getLanguage().getValue());
|
||||||
|
}
|
||||||
|
Navigation.findNavController(requireView()).navigateUp();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ViewHolder {
|
||||||
|
EditText name;
|
||||||
|
CheckBox canSpeak;
|
||||||
|
|
||||||
|
ViewHolder(View root) {
|
||||||
|
name = root.findViewById(R.id.name);
|
||||||
|
canSpeak = root.findViewById(R.id.canSpeak);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.editmonster;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.ChangeTrackedViewModel;
|
||||||
|
import com.majinnaibu.monstercards.utils.ChangeTrackedLiveData;
|
||||||
|
|
||||||
|
public class EditLanguageViewModel extends ChangeTrackedViewModel {
|
||||||
|
private final ChangeTrackedLiveData<String> mName;
|
||||||
|
private final ChangeTrackedLiveData<Boolean> mCanSpeak;
|
||||||
|
private final ChangeTrackedLiveData<Language> mLanguage;
|
||||||
|
|
||||||
|
public EditLanguageViewModel() {
|
||||||
|
super();
|
||||||
|
mName = new ChangeTrackedLiveData<>("New Language", this::makeDirty);
|
||||||
|
mCanSpeak = new ChangeTrackedLiveData<>(true, this::makeDirty);
|
||||||
|
mLanguage = new ChangeTrackedLiveData<>(makeLanguage(), this::makeDirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyFromLanguage(Language language) {
|
||||||
|
mName.resetValue(language.getName());
|
||||||
|
mCanSpeak.resetValue(language.getSpeaks());
|
||||||
|
makeClean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Language> getLanguage() {
|
||||||
|
return mLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<String> getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
mName.setValue(name);
|
||||||
|
mLanguage.setValue(makeLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getCanSpeak() {
|
||||||
|
return mCanSpeak;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanSpeak(boolean canSpeak) {
|
||||||
|
mCanSpeak.setValue(canSpeak);
|
||||||
|
mLanguage.setValue(makeLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCanSpeakValue(boolean defaultIfNull) {
|
||||||
|
Boolean boxedValue = mCanSpeak.getValue();
|
||||||
|
if (boxedValue == null) {
|
||||||
|
return defaultIfNull;
|
||||||
|
}
|
||||||
|
return boxedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCanSpeakValue() {
|
||||||
|
return getCanSpeakValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Language makeLanguage() {
|
||||||
|
Boolean boxedValue = mCanSpeak.getValue();
|
||||||
|
boolean canSpeak = boxedValue != null && boxedValue;
|
||||||
|
return new Language(mName.getValue(), canSpeak);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.editmonster;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.navigation.NavBackStackEntry;
|
||||||
|
import androidx.navigation.NavController;
|
||||||
|
import androidx.navigation.NavDirections;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.majinnaibu.monstercards.R;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.SwipeToDeleteCallback;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.TextChangedListener;
|
||||||
|
|
||||||
|
public class EditLanguagesFragment extends MCFragment {
|
||||||
|
private EditMonsterViewModel mViewModel;
|
||||||
|
private ViewHolder mHolder;
|
||||||
|
|
||||||
|
private void navigateToEditLanguage(Language language) {
|
||||||
|
NavDirections action = EditLanguagesFragmentDirections.actionEditLanguagesFragmentToEditLanguageFragment(language.getName(), language.getSpeaks());
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
|
||||||
|
View root = inflater.inflate(R.layout.fragment_edit_languages_list, container, false);
|
||||||
|
|
||||||
|
mHolder = new ViewHolder(root);
|
||||||
|
setupRecyclerView(mHolder.list);
|
||||||
|
setupAddLanguageButton(mHolder.addLanguage);
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
|
Context context = requireContext();
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
mViewModel.getLanguages().observe(getViewLifecycleOwner(), languages -> {
|
||||||
|
EditLanguagesRecyclerViewAdapter adapter = new EditLanguagesRecyclerViewAdapter(
|
||||||
|
mViewModel.getLanguagesArray(),
|
||||||
|
language -> {
|
||||||
|
if (language != null) {
|
||||||
|
navigateToEditLanguage(language);
|
||||||
|
} else {
|
||||||
|
Logger.logError("Can't navigate to EditSkill with a null skill");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mViewModel.getTelepathyRangeUnboxed(),
|
||||||
|
(value, previousValue) -> mViewModel.setTelepathyRange(value),
|
||||||
|
mViewModel.getUnderstandsButDescription().getValue(),
|
||||||
|
new TextChangedListener((TextChangedListener.OnTextChangedCallback) (s, start, before, count) -> mViewModel.setUnderstandsButDescription(s.toString())));
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
});
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, layoutManager.getOrientation());
|
||||||
|
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new SwipeToDeleteCallback(context, mViewModel::removeLanguage));
|
||||||
|
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupAddLanguageButton(@NonNull FloatingActionButton fab) {
|
||||||
|
fab.setOnClickListener(view -> {
|
||||||
|
Language newLanguage = mViewModel.addNewLanguage();
|
||||||
|
navigateToEditLanguage(newLanguage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ViewHolder {
|
||||||
|
RecyclerView list;
|
||||||
|
FloatingActionButton addLanguage;
|
||||||
|
|
||||||
|
ViewHolder(View root) {
|
||||||
|
this.list = root.findViewById(R.id.list);
|
||||||
|
this.addLanguage = root.findViewById(R.id.add_language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.editmonster;
|
||||||
|
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.databinding.FragmentEditLanguagesListHeaderBinding;
|
||||||
|
import com.majinnaibu.monstercards.databinding.FragmentEditLanguagesListItemBinding;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.ui.components.Stepper;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
private final List<Language> mValues;
|
||||||
|
private final ItemCallback mOnClick;
|
||||||
|
private final int mTelepathyRange;
|
||||||
|
private final String mUnderstandsBut;
|
||||||
|
private final Stepper.OnValueChangeListener mOnTelepathyRangeChanged;
|
||||||
|
private final TextWatcher mOnUnderstandsButChanged;
|
||||||
|
|
||||||
|
private final int HEADER_VIEW_TYPE = 1;
|
||||||
|
private final int ITEM_VIEW_TYPE = 2;
|
||||||
|
private final String DISTANCE_IN_FEET_FORMAT = "%d ft.";
|
||||||
|
|
||||||
|
public EditLanguagesRecyclerViewAdapter(List<Language> items, ItemCallback onClick, int telepathyRange, Stepper.OnValueChangeListener telepathyRangeChangedListener, String undderstandsBut, TextWatcher understandsButChangedListener) {
|
||||||
|
mValues = items;
|
||||||
|
mOnClick = onClick;
|
||||||
|
mTelepathyRange = telepathyRange;
|
||||||
|
mOnTelepathyRangeChanged = telepathyRangeChangedListener;
|
||||||
|
mUnderstandsBut = undderstandsBut;
|
||||||
|
mOnUnderstandsButChanged = understandsButChangedListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
|
||||||
|
if (viewType == HEADER_VIEW_TYPE) {
|
||||||
|
return new HeaderViewHolder(FragmentEditLanguagesListHeaderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
return new ItemViewHolder(FragmentEditLanguagesListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NotNull final RecyclerView.ViewHolder holder, int position) {
|
||||||
|
if (holder instanceof HeaderViewHolder) {
|
||||||
|
HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
|
||||||
|
headerViewHolder.telepathy.setOnFormatValueCallback(value -> String.format(DISTANCE_IN_FEET_FORMAT, value));
|
||||||
|
headerViewHolder.telepathy.setValue(mTelepathyRange);
|
||||||
|
headerViewHolder.telepathy.setOnValueChangeListener(mOnTelepathyRangeChanged);
|
||||||
|
headerViewHolder.understandsBut.setText(mUnderstandsBut);
|
||||||
|
headerViewHolder.understandsBut.addTextChangedListener(mOnUnderstandsButChanged);
|
||||||
|
} else if(holder instanceof ItemViewHolder) {
|
||||||
|
ItemViewHolder itemViewHolder = (ItemViewHolder)holder;
|
||||||
|
itemViewHolder.mItem = mValues.get(position-1);
|
||||||
|
itemViewHolder.mContentView.setText(itemViewHolder.mItem.getName());
|
||||||
|
itemViewHolder.itemView.setOnClickListener(view -> {
|
||||||
|
if (mOnClick != null) {
|
||||||
|
mOnClick.onItemCallback(itemViewHolder.mItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mValues.size() +1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if (position == 0) {
|
||||||
|
return HEADER_VIEW_TYPE;
|
||||||
|
}
|
||||||
|
return ITEM_VIEW_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ItemCallback {
|
||||||
|
void onItemCallback(Language language);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HeaderViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
public final Stepper telepathy;
|
||||||
|
public final EditText understandsBut;
|
||||||
|
|
||||||
|
public HeaderViewHolder(FragmentEditLanguagesListHeaderBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
telepathy = binding.telepathy;
|
||||||
|
understandsBut = binding.understandsBut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
public final TextView mContentView;
|
||||||
|
public Language mItem;
|
||||||
|
|
||||||
|
public ItemViewHolder(FragmentEditLanguagesListItemBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
mContentView = binding.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " '" + mContentView.getText() + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -140,6 +140,11 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
Navigation.findNavController(requireView()).navigate(action);
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mHolder.languages.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditLanguagesFragment();
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
});
|
||||||
|
|
||||||
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||||
@Override
|
@Override
|
||||||
public void handleOnBackPressed() {
|
public void handleOnBackPressed() {
|
||||||
|
|||||||
@@ -740,6 +740,10 @@ public class EditMonsterViewModel extends ChangeTrackedViewModel {
|
|||||||
return mTelepathyRange;
|
return mTelepathyRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTelepathyRangeUnboxed() {
|
||||||
|
return Helpers.unboxInteger(mTelepathyRange.getValue(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTelepathyRange(int telepathyRange) {
|
public void setTelepathyRange(int telepathyRange) {
|
||||||
mTelepathyRange.setValue(telepathyRange);
|
mTelepathyRange.setValue(telepathyRange);
|
||||||
}
|
}
|
||||||
@@ -1189,5 +1193,12 @@ public class EditMonsterViewModel extends ChangeTrackedViewModel {
|
|||||||
static <T> void replaceItemInList(MutableLiveData<List<T>> listData, T oldItem, T newItem) {
|
static <T> void replaceItemInList(MutableLiveData<List<T>> listData, T oldItem, T newItem) {
|
||||||
replaceItemInList(listData, oldItem, newItem, null);
|
replaceItemInList(listData, oldItem, newItem, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int unboxInteger(Integer value, int defaultIfNull) {
|
||||||
|
if (value == null) {
|
||||||
|
return defaultIfNull;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
app/src/main/res/layout/fragment_edit_language.xml
Normal file
35
app/src/main/res/layout/fragment_edit_language.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?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.EditLanguageFragment">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<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/name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/label_name"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
tools:text="Medicine" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/canSpeak"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_can_speak_language" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
33
app/src/main/res/layout/fragment_edit_languages_list.xml
Normal file
33
app/src/main/res/layout/fragment_edit_languages_list.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.editmonster.EditLanguagesFragment">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:divider="?android:attr/dividerVertical"
|
||||||
|
android:dividerPadding="@dimen/text_margin"
|
||||||
|
app:layoutManager="LinearLayoutManager"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:listitem="@layout/fragment_edit_languages_list_item" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/add_language"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:contentDescription="@string/action_add_language"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:srcCompat="@android:drawable/ic_input_add"
|
||||||
|
app:tint="@android:color/white" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout 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"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- understands but textbox -->
|
||||||
|
<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/understandsBut"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/label_understands_but"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="text"
|
||||||
|
tools:text="pretends not to speak" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<!-- TODO: add a divider here -->
|
||||||
|
|
||||||
|
<com.majinnaibu.monstercards.ui.components.Stepper
|
||||||
|
android:id="@+id/telepathy"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/text_margin"
|
||||||
|
app:label="Telepathy"
|
||||||
|
app:maxValue="1000"
|
||||||
|
app:minValue="0"
|
||||||
|
app:stepAmount="5" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/text_margin"
|
||||||
|
android:textAppearance="?attr/textAppearanceListItem" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -108,6 +108,9 @@
|
|||||||
<action
|
<action
|
||||||
android:id="@+id/action_editMonsterFragment_to_editDamageImmunitiesFragment"
|
android:id="@+id/action_editMonsterFragment_to_editDamageImmunitiesFragment"
|
||||||
app:destination="@id/editDamageImmunitiesFragment" />
|
app:destination="@id/editDamageImmunitiesFragment" />
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_editMonsterFragment_to_editLanguagesFragment"
|
||||||
|
app:destination="@id/editLanguagesFragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/editBasicInfoFragment"
|
android:id="@+id/editBasicInfoFragment"
|
||||||
@@ -251,5 +254,26 @@
|
|||||||
android:id="@+id/action_editDamageVulnerabilitiesFragment_to_editDamageVulnerabilityFragment"
|
android:id="@+id/action_editDamageVulnerabilitiesFragment_to_editDamageVulnerabilityFragment"
|
||||||
app:destination="@id/editDamageVulnerabilityFragment" />
|
app:destination="@id/editDamageVulnerabilityFragment" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/editLanguagesFragment"
|
||||||
|
android:name="com.majinnaibu.monstercards.ui.editmonster.EditLanguagesFragment"
|
||||||
|
android:label="fragment_edit_languages_list"
|
||||||
|
tools:layout="@layout/fragment_edit_languages_list">
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_editLanguagesFragment_to_editLanguageFragment"
|
||||||
|
app:destination="@id/editLanguageFragment" />
|
||||||
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/editLanguageFragment"
|
||||||
|
android:name="com.majinnaibu.monstercards.ui.editmonster.EditLanguageFragment"
|
||||||
|
android:label="fragment_edit_language"
|
||||||
|
tools:layout="@layout/fragment_edit_language">
|
||||||
|
<argument
|
||||||
|
android:name="name"
|
||||||
|
app:argType="string" />
|
||||||
|
<argument
|
||||||
|
android:name="canSpeak"
|
||||||
|
app:argType="boolean" />
|
||||||
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
||||||
</navigation>
|
</navigation>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<string name="action_add_monster">Add monster</string>
|
<string name="action_add_monster">Add monster</string>
|
||||||
<string name="action_add_sense">Add Sense</string>
|
<string name="action_add_sense">Add Sense</string>
|
||||||
<string name="action_add_skill">Add Skill</string>
|
<string name="action_add_skill">Add Skill</string>
|
||||||
|
<string name="action_add_language">Add Language</string>
|
||||||
<string name="action_add_condition_immunity">Add Condition</string>
|
<string name="action_add_condition_immunity">Add Condition</string>
|
||||||
<string name="action_edit">Edit</string>
|
<string name="action_edit">Edit</string>
|
||||||
<string name="actions_label">Actions</string>
|
<string name="actions_label">Actions</string>
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
<string name="label_legendary_actions">Legendary Actions</string>
|
<string name="label_legendary_actions">Legendary Actions</string>
|
||||||
<string name="label_natural_armor_bonus">Natural Armor Bonus</string>
|
<string name="label_natural_armor_bonus">Natural Armor Bonus</string>
|
||||||
<string name="label_name">Name</string>
|
<string name="label_name">Name</string>
|
||||||
|
<string name="label_understands_but">Understands But</string>
|
||||||
<string name="label_proficiency">Proficiency</string>
|
<string name="label_proficiency">Proficiency</string>
|
||||||
<string name="label_proficiency_expertise">Expertise</string>
|
<string name="label_proficiency_expertise">Expertise</string>
|
||||||
<string name="label_proficiency_none">None</string>
|
<string name="label_proficiency_none">None</string>
|
||||||
@@ -68,6 +70,7 @@
|
|||||||
<string name="label_strength">Strength</string>
|
<string name="label_strength">Strength</string>
|
||||||
<string name="label_subtype">Subtype</string>
|
<string name="label_subtype">Subtype</string>
|
||||||
<string name="label_swim_speed">Swim Speed</string>
|
<string name="label_swim_speed">Swim Speed</string>
|
||||||
|
<string name="label_telepathy">Telepathy</string>
|
||||||
<string name="label_type">Type</string>
|
<string name="label_type">Type</string>
|
||||||
<string name="label_wisdom">Wisdom</string>
|
<string name="label_wisdom">Wisdom</string>
|
||||||
<string name="section_divider">section divider</string>
|
<string name="section_divider">section divider</string>
|
||||||
@@ -83,4 +86,5 @@
|
|||||||
<string name="label_description">Description</string>
|
<string name="label_description">Description</string>
|
||||||
<string name="label_damage_type">Damage Type</string>
|
<string name="label_damage_type">Damage Type</string>
|
||||||
<string name="add_damage_type">Add Damage Type</string>
|
<string name="add_damage_type">Add Damage Type</string>
|
||||||
|
<string name="label_can_speak_language">Can Speak</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user