Add element information to kanji result view

Julien LepillerSun Jun 26 19:46:53+0200 2022

34d686a

Add element information to kanji result view

.gitignore

11
*.iml
22
.gradle
33
/local.properties
4+
/.idea/misc.xml
45
/.idea/caches
56
/.idea/libraries
67
/.idea/modules.xml
78
/.idea/workspace.xml
89
/.idea/navEditor.xml
910
/.idea/assetWizardSettings.xml
10-
/.idea/misc.xml
1111
.DS_Store
1212
/build
1313
/captures

app/src/main/java/eu/lepiller/nani/ResultPagerAdapter.java

7171
7272
                TextView kanjiView = child_result.findViewById(R.id.kanji_view);
7373
                TextView strokesView = child_result.findViewById(R.id.kanji_strokes);
74+
                TextView elementsView = child_result.findViewById(R.id.kanji_elements);
7475
                LinearLayout senses_view = child_result.findViewById(R.id.sense_view);
7576
                TextView onView = child_result.findViewById(R.id.on_reading);
7677
                TextView kunView = child_result.findViewById(R.id.kun_reading);

8081
                strokesView.setText(String.format(context.getResources().getQuantityString(R.plurals.kanji_stroke, result.getStroke()),
8182
                        result.getStroke()));
8283
84+
                elementsView.setText(String.format(context.getResources().getQuantityString(R.plurals.kanji_elements, result.getElements().size()),
85+
                        getContent(result.getElements())));
86+
                if(result.getElements().isEmpty())
87+
                    elementsView.setVisibility(View.GONE);
88+
8389
                senses_view.removeAllViews();
8490
                Map<String, List<String>> meanings = new HashMap<>();
8591
                for(KanjiResult.Sense sense: result.getSenses()) {

app/src/main/java/eu/lepiller/nani/result/KanjiResult.java

108108
        return stroke;
109109
    }
110110
111+
    public List<String> getElements() {
112+
        return elements;
113+
    }
114+
111115
    public List<String> getKun() {
112116
        return kun;
113117
    }

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

6161
            android:layout_marginLeft="8dp"
6262
            android:layout_marginStart="8dp"
6363
            android:id="@+id/nanori_reading" />
64+
65+
        <TextView
66+
            android:layout_width="match_parent"
67+
            android:layout_height="wrap_content"
68+
            android:layout_marginTop="8dp"
69+
            android:layout_marginLeft="8dp"
70+
            android:layout_marginStart="8dp"
71+
            android:id="@+id/kanji_elements" />
6472
    </LinearLayout>
6573
6674

app/src/main/res/values/strings.xml

103103
    <string name="kun_reading">kunyomi: %s</string>
104104
    <string name="on_reading">onyomi: %s</string>
105105
    <string name="nanori_reading">nanori: %s</string>
106+
    <plurals name="kanji_elements">
107+
        <item quantity="one">element: %s</item>
108+
        <item quantity="other">elements: %s</item>
109+
    </plurals>
106110
107111
    <!-- About activity -->
108112
    <string name="nani_about">???Nani???? is an offline Japanese dictionary for Android. It helps