Add clear button in radical selection
CHANGELOG.md
| 7 | 7 | Here is a list of changes that are not yet part of a release, but that will | |
| 8 | 8 | appear in next release. | |
| 9 | 9 | ||
| 10 | + | ### Features | |
| 11 | + | ||
| 12 | + | * New button in radical selection window to clear all radicals at once. | |
| 13 | + | ||
| 10 | 14 | Changes in 0.5.2 | |
| 11 | 15 | ---------------- | |
| 12 | 16 |
app/src/main/java/eu/lepiller/nani/RadicalSelectorFragment.java
| 43 | 43 | private ProgressBar radical_load; | |
| 44 | 44 | ||
| 45 | 45 | final List<String> selected = new ArrayList<>(); | |
| 46 | + | final List<ToggleButton> buttons = new ArrayList<>(); | |
| 46 | 47 | ||
| 47 | 48 | RadicalDict dictionary; | |
| 48 | 49 | private int radSize = 122; | |
… | |||
| 60 | 61 | ||
| 61 | 62 | Button close_button = getView().findViewById(R.id.close_button); | |
| 62 | 63 | Button help_button = getView().findViewById(R.id.help_button); | |
| 64 | + | Button clear_button = getView().findViewById(R.id.clear_button); | |
| 63 | 65 | kanji_row1 = getView().findViewById(R.id.kanji_row1); | |
| 64 | 66 | kanji_row2 = getView().findViewById(R.id.kanji_row2); | |
| 65 | 67 | radical_table = getView().findViewById(R.id.radical_table); | |
… | |||
| 90 | 92 | getParentFragmentManager().setFragmentResult("selectRadicals", result); | |
| 91 | 93 | }); | |
| 92 | 94 | ||
| 95 | + | clear_button.setOnClickListener((View v) -> { | |
| 96 | + | selected.clear(); | |
| 97 | + | for(ToggleButton b: buttons) | |
| 98 | + | if(b.isChecked()) | |
| 99 | + | b.toggle(); | |
| 100 | + | new Thread(dictionarySearch).start(); | |
| 101 | + | }); | |
| 102 | + | ||
| 93 | 103 | RadicalSelectorViewModel viewModel = new ViewModelProvider(requireActivity()).get(RadicalSelectorViewModel.class); | |
| 94 | 104 | viewModel.getPreferences().observe(getViewLifecycleOwner(), pref -> { | |
| 95 | 105 | if (pref.dictionary != null) { | |
… | |||
| 217 | 227 | ||
| 218 | 228 | new Thread(dictionarySearch).start(); | |
| 219 | 229 | }); | |
| 230 | + | buttons.add(radicalButton); | |
| 220 | 231 | box.addView(radicalButton); | |
| 221 | 232 | } | |
| 222 | 233 | ||
app/src/main/res/layout/content_radicals.xml
| 55 | 55 | android:layout_width="match_parent" | |
| 56 | 56 | android:layout_height="wrap_content"> | |
| 57 | 57 | ||
| 58 | + | <Button | |
| 59 | + | android:id="@+id/clear_button" | |
| 60 | + | android:layout_width="wrap_content" | |
| 61 | + | android:layout_height="wrap_content" | |
| 62 | + | android:text="@string/clear" /> | |
| 63 | + | ||
| 58 | 64 | <Space | |
| 59 | 65 | android:layout_width="0dp" | |
| 60 | 66 | android:layout_height="wrap_content" |
app/src/main/res/values-fr/strings.xml
| 24 | 24 | <string name="kanji_description">??criture</string> | |
| 25 | 25 | <string name="close">fermer</string> | |
| 26 | 26 | <string name="help">aide</string> | |
| 27 | + | <string name="clear">effacer</string> | |
| 27 | 28 | <string name="dictionary_size_mb">Taille r??elle : %d???Mo</string> | |
| 28 | 29 | <string name="dictionary_size_kb">Taille r??elle : %d???Ko</string> | |
| 29 | 30 | <string name="dictionary_size_b">Taille r??elle : %d???o</string> |
app/src/main/res/values/strings.xml
| 24 | 24 | <string name="kanji_description">Writing</string> | |
| 25 | 25 | <string name="close">close</string> | |
| 26 | 26 | <string name="help">help</string> | |
| 27 | + | <string name="clear">clear</string> | |
| 27 | 28 | <string name="other">other</string> | |
| 28 | 29 | ||
| 29 | 30 | <string name="dictionary_size_mb">Actual size: %dMB</string> |