Separate license information to its own activity

Julien LepillerSun Jul 10 14:27:44+0200 2022

f208ed5

Separate license information to its own activity

.idea/misc.xml

88
        <entry key="app/src/main/res/drawable/ic_pitch.xml" value="0.1535" />
99
        <entry key="app/src/main/res/drawable/ic_rad.xml" value="0.1535" />
1010
        <entry key="app/src/main/res/drawable/ic_reading.xml" value="0.1535" />
11+
        <entry key="app/src/main/res/layout/activity_dictionary.xml" value="0.2078125" />
12+
        <entry key="app/src/main/res/layout/activity_license.xml" value="0.20677083333333332" />
1113
        <entry key="app/src/main/res/layout/activity_main.xml" value="0.2078125" />
1214
        <entry key="app/src/main/res/layout/content_main.xml" value="0.2078125" />
1315
        <entry key="app/src/main/res/layout/content_radicals.xml" value="0.1" />
1416
        <entry key="app/src/main/res/layout/fragment_results.xml" value="0.2078125" />
1517
        <entry key="app/src/main/res/layout/layout_example.xml" value="0.20677083333333332" />
18+
        <entry key="app/src/main/res/layout/layout_license.xml" value="0.20677083333333332" />
19+
        <entry key="app/src/main/res/layout/layout_license_description.xml" value="0.21927083333333333" />
20+
        <entry key="app/src/main/res/layout/layout_license_name.xml" value="0.20677083333333332" />
1621
        <entry key="app/src/main/res/layout/layout_result.xml" value="0.2078125" />
1722
        <entry key="app/src/main/res/layout/layout_sense.xml" value="0.2078125" />
23+
        <entry key="app/src/main/res/menu/menu_main.xml" value="0.2078125" />
1824
        <entry key="app/src/main/res/xml/preferences.xml" value="0.2078125" />
1925
      </map>
2026
    </option>

app/src/main/AndroidManifest.xml

6767
                android:value=".MainActivity" />
6868
        </activity>
6969
        <activity
70+
            android:name=".LicenseActivity"
71+
            android:label="@string/title_activity_license"
72+
            android:parentActivityName=".LicenseActivity"
73+
            tools:ignore="UnusedAttribute">
74+
            <meta-data
75+
                android:name="android.support.PARENT_ACTIVITY"
76+
                android:value=".MainActivity" />
77+
        </activity>
78+
        <activity
7079
            android:name=".HelpActivity"
7180
            android:label="@string/title_activity_help"
7281
            android:parentActivityName=".MainActivity"

app/src/main/java/eu/lepiller/nani/LicenseActivity.java unknown status 1

1+
package eu.lepiller.nani;
2+
3+
import android.os.Bundle;
4+
import android.widget.ExpandableListAdapter;
5+
import android.widget.ExpandableListView;
6+
import android.widget.ListView;
7+
8+
import androidx.annotation.Nullable;
9+
import androidx.appcompat.app.AppCompatActivity;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
public class LicenseActivity extends AppCompatActivity {
15+
    ExpandableListAdapter adapter;
16+
17+
    public static class License {
18+
        private final String name, description, license;
19+
        private final List<License> subProjects;
20+
        License(String name, String description, String license, List<License> subProjects) {
21+
            this.name = name;
22+
            this.description = description;
23+
            this.license = license;
24+
            this.subProjects = subProjects;
25+
        }
26+
27+
        public String getName() {
28+
            return name;
29+
        }
30+
31+
        public String getDescription() {
32+
            return description;
33+
        }
34+
35+
        public String getLicense() {
36+
            return license;
37+
        }
38+
39+
        @Nullable
40+
        public List<License> getSubProjects() {
41+
            return subProjects;
42+
        }
43+
    }
44+
45+
    private static final List<License> licenseInformation = new ArrayList<>();
46+
47+
    @Override
48+
    protected void onCreate(Bundle savedInstanceState) {
49+
        super.onCreate(savedInstanceState);
50+
        setContentView(R.layout.activity_license);
51+
52+
        licenseInformation.clear();
53+
        List<License> erdrgLicenses = new ArrayList<>();
54+
        erdrgLicenses.add(new License(getString(R.string.jmdict_title), getString(R.string.jmdict_descr), getString(R.string.jmdict_license), null));
55+
        erdrgLicenses.add(new License(getString(R.string.radk_title), getString(R.string.radk_descr), getString(R.string.radk_license), null));
56+
        erdrgLicenses.add(new License(getString(R.string.kanjidic_title), getString(R.string.kanjidic_descr), getString(R.string.kanjidic_license), null));
57+
        licenseInformation.add(
58+
                new License(getString(R.string.erdrg_title), getString(R.string.erdrg_descr), "",
59+
                        erdrgLicenses));
60+
61+
        licenseInformation.add(
62+
                new License(getString(R.string.kanjivg_title), getString(R.string.kanjivg_descr), getString(R.string.kanjivg_license), null)
63+
        );
64+
        licenseInformation.add(
65+
                new License(getString(R.string.jibiki_title), getString(R.string.jibiki_descr), getString(R.string.jibiki_license), null)
66+
        );
67+
        licenseInformation.add(
68+
                new License(getString(R.string.wadoku_title), getString(R.string.wadoku_descr), getString(R.string.wadoku_license), null)
69+
        );
70+
        licenseInformation.add(
71+
                new License(getString(R.string.tatoeba_title), getString(R.string.tatoeba_descr), getString(R.string.tatoeba_license), null)
72+
        );
73+
74+
        final ExpandableListView list_view = findViewById(R.id.license_view);
75+
        adapter = new LicenseAdapter(this, licenseInformation);
76+
        list_view.setAdapter(adapter);
77+
    }
78+
}

app/src/main/java/eu/lepiller/nani/LicenseAdapter.java unknown status 1

1+
package eu.lepiller.nani;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.BaseExpandableListAdapter;
8+
import android.widget.TextView;
9+
10+
import java.util.List;
11+
12+
public class LicenseAdapter extends BaseExpandableListAdapter {
13+
    Context context;
14+
    List<LicenseActivity.License> licenses;
15+
16+
    LicenseAdapter(Context context, List<LicenseActivity.License> licenses) {
17+
        this.licenses = licenses;
18+
        this.context = context;
19+
    }
20+
21+
    @Override
22+
    public int getGroupCount() {
23+
        return licenses.size();
24+
    }
25+
26+
    @Override
27+
    public int getChildrenCount(int i) {
28+
        List<LicenseActivity.License> projects = licenses.get(i).getSubProjects();
29+
        if(projects == null || projects.size() == 0)
30+
            return 1;
31+
        return projects.size() + 1;
32+
    }
33+
34+
    @Override
35+
    public Object getGroup(int i) {
36+
        return null;
37+
    }
38+
39+
    @Override
40+
    public Object getChild(int i, int i1) {
41+
        return null;
42+
    }
43+
44+
    @Override
45+
    public long getGroupId(int i) {
46+
        return 0;
47+
    }
48+
49+
    @Override
50+
    public long getChildId(int i, int i1) {
51+
        return 0;
52+
    }
53+
54+
    @Override
55+
    public boolean hasStableIds() {
56+
        return false;
57+
    }
58+
59+
    @Override
60+
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
61+
        if (view == null) {
62+
            LayoutInflater layoutInflater = (LayoutInflater) this.context.
63+
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
64+
            view = layoutInflater.inflate(R.layout.layout_license_name, viewGroup, false);
65+
        }
66+
        String name = licenses.get(i).getName();
67+
        TextView nameView = (TextView) view.findViewById(R.id.license_name);
68+
        nameView.setText(name);
69+
        return view;
70+
    }
71+
72+
    @Override
73+
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
74+
        List<LicenseActivity.License> projects = licenses.get(i).getSubProjects();
75+
        if(projects != null && projects.size() > 0)
76+
            i1 -= 1;
77+
        if(i1 < 0) {
78+
            if(view == null) {
79+
                LayoutInflater layoutInflater = (LayoutInflater) this.context.
80+
                        getSystemService(Context.LAYOUT_INFLATER_SERVICE);
81+
                view = layoutInflater.inflate(R.layout.layout_license, viewGroup, false);
82+
            }
83+
84+
            TextView nameView = (TextView) view.findViewById(R.id.name);
85+
            TextView descriptionView = (TextView) view.findViewById(R.id.description);
86+
            TextView licenseView = (TextView) view.findViewById(R.id.license);
87+
88+
            descriptionView.setText(licenses.get(i).getDescription());
89+
            nameView.setVisibility(View.GONE);
90+
            licenseView.setVisibility(View.GONE);
91+
            return view;
92+
        } else {
93+
            boolean subproject = projects != null && projects.size() > 0;
94+
            LicenseActivity.License license = subproject? projects.get(i1): licenses.get(i);
95+
96+
            if(view == null || i1 == 0) {
97+
                LayoutInflater layoutInflater = (LayoutInflater) this.context.
98+
                        getSystemService(Context.LAYOUT_INFLATER_SERVICE);
99+
                view = layoutInflater.inflate(R.layout.layout_license, viewGroup, false);
100+
            }
101+
102+
            TextView nameView = (TextView) view.findViewById(R.id.name);
103+
            TextView descriptionView = (TextView) view.findViewById(R.id.description);
104+
            TextView licenseView = (TextView) view.findViewById(R.id.license);
105+
106+
            nameView.setVisibility(subproject? View.VISIBLE: View.GONE);
107+
            licenseView.setVisibility(View.VISIBLE);
108+
109+
            nameView.setText(license.getName());
110+
            descriptionView.setText(license.getDescription());
111+
            licenseView.setText(license.getLicense());
112+
113+
            return view;
114+
        }
115+
    }
116+
117+
    @Override
118+
    public boolean isChildSelectable(int i, int i1) {
119+
        return false;
120+
    }
121+
}

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

432432
            Intent intent = new Intent(this, AboutActivity.class);
433433
            startActivity(intent);
434434
            return true;
435+
        } else if (id == R.id.action_licenses) {
436+
            Intent intent = new Intent(this, LicenseActivity.class);
437+
            startActivity(intent);
438+
            return true;
435439
        } else if (id == R.id.action_help) {
436440
            Intent intent = new Intent(this, HelpActivity.class);
437441
            startActivity(intent);

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

1717
            android:layout_width="wrap_content"
1818
            android:layout_height="wrap_content"
1919
            android:layout_gravity="center"
20-
            android:text="@string/data_licenses"
20+
            android:text="@string/title_activity_about"
2121
            android:textColor="@color/colorTitle"
2222
            android:textSize="@dimen/title_size" />
2323

105105
            android:text="@string/license_text"
106106
            app:lineHeight="22dp" />
107107
108-
        <TextView
109-
            android:layout_width="match_parent"
110-
            android:layout_height="wrap_content"
111-
            android:text="@string/data_licenses"
112-
            android:layout_marginTop="16dp"
113-
            android:textColor="@color/colorTitle"
114-
            android:textSize="@dimen/title_size" />
115-
116-
        <TextView
117-
            android:layout_width="wrap_content"
118-
            android:layout_height="wrap_content"
119-
            android:text="@string/data_intro"
120-
            app:lineHeight="22dp" />
121-
122-
        <TextView
123-
            android:id="@+id/textView10"
124-
            android:layout_width="match_parent"
125-
            android:layout_height="wrap_content"
126-
            android:layout_marginTop="16dp"
127-
            android:text="@string/erdrg_title"
128-
            android:textColor="@color/colorSubtitle"
129-
            android:textSize="@dimen/subtitle_size" />
130-
131-
        <TextView
132-
            android:layout_width="match_parent"
133-
            android:layout_height="wrap_content"
134-
            app:lineHeight="22dp"
135-
            android:text="@string/erdrg_descr" />
136-
137-
        <TextView
138-
            android:layout_width="match_parent"
139-
            android:layout_height="wrap_content"
140-
            app:lineHeight="22dp"
141-
            android:textSize="@dimen/subtitle_size"
142-
            android:layout_marginTop="8dp"
143-
            android:text="@string/jmdict_title" />
144-
145-
        <TextView
146-
            android:layout_width="match_parent"
147-
            android:layout_height="wrap_content"
148-
            app:lineHeight="22dp"
149-
            android:text="@string/jmdict_descr" />
150-
151-
        <TextView
152-
            android:layout_width="match_parent"
153-
            android:layout_height="wrap_content"
154-
            app:lineHeight="22dp"
155-
            android:text="@string/jmdict_license" />
156-
157-
        <TextView
158-
            android:layout_width="match_parent"
159-
            android:layout_height="wrap_content"
160-
            android:layout_marginTop="8dp"
161-
            android:lineHeight="22dp"
162-
            android:textSize="@dimen/subtitle_size"
163-
            android:text="@string/radk_title" />
164-
165-
        <TextView
166-
            android:layout_width="match_parent"
167-
            android:layout_height="wrap_content"
168-
            app:lineHeight="22dp"
169-
            android:text="@string/radk_descr" />
170-
171-
        <TextView
172-
            android:layout_width="match_parent"
173-
            android:layout_height="wrap_content"
174-
            app:lineHeight="22dp"
175-
            android:text="@string/radk_license" />
176-
177-
        <TextView
178-
            android:layout_width="match_parent"
179-
            android:layout_height="wrap_content"
180-
            android:layout_marginTop="8dp"
181-
            android:lineHeight="22dp"
182-
            android:textSize="@dimen/subtitle_size"
183-
            android:text="@string/kanjidic_title" />
184-
185-
        <TextView
186-
            android:layout_width="match_parent"
187-
            android:layout_height="wrap_content"
188-
            app:lineHeight="22dp"
189-
            android:text="@string/kanjidic_descr" />
190-
191-
        <TextView
192-
            android:layout_width="match_parent"
193-
            android:layout_height="wrap_content"
194-
            app:lineHeight="22dp"
195-
            android:text="@string/kanjidic_license" />
196-
197-
        <TextView
198-
            android:layout_width="match_parent"
199-
            android:layout_height="wrap_content"
200-
            android:layout_marginTop="8dp"
201-
            android:lineHeight="22dp"
202-
            android:textSize="@dimen/subtitle_size"
203-
            android:text="@string/kanjivg_title" />
204-
205-
        <TextView
206-
            android:layout_width="match_parent"
207-
            android:layout_height="wrap_content"
208-
            app:lineHeight="22dp"
209-
            android:text="@string/kanjivg_descr" />
210-
211-
        <TextView
212-
            android:layout_width="match_parent"
213-
            android:layout_height="wrap_content"
214-
            app:lineHeight="22dp"
215-
            android:text="@string/kanjivg_license" />
216-
217-
218-
        <TextView
219-
            android:layout_width="match_parent"
220-
            android:layout_height="wrap_content"
221-
            android:layout_marginTop="16dp"
222-
            android:text="@string/wadoku_title"
223-
            android:textColor="@color/colorSubtitle"
224-
            android:textSize="@dimen/subtitle_size" />
225-
226-
        <TextView
227-
            android:layout_width="match_parent"
228-
            android:layout_height="wrap_content"
229-
            app:lineHeight="22dp"
230-
            android:text="@string/wadoku_descr" />
231-
232-
        <TextView
233-
            android:layout_width="match_parent"
234-
            android:layout_height="wrap_content"
235-
            app:lineHeight="22dp"
236-
            android:text="@string/wadoku_license" />
237-
238-
        <TextView
239-
            android:layout_width="match_parent"
240-
            android:layout_height="wrap_content"
241-
            android:layout_marginTop="16dp"
242-
            android:text="@string/jibiki_title"
243-
            android:textColor="@color/colorSubtitle"
244-
            android:textSize="@dimen/subtitle_size" />
245-
246-
        <TextView
247-
            android:layout_width="match_parent"
248-
            android:layout_height="wrap_content"
249-
            app:lineHeight="22dp"
250-
            android:text="@string/jibiki_descr" />
251-
252-
        <TextView
253-
            android:layout_width="match_parent"
254-
            android:layout_height="wrap_content"
255-
            app:lineHeight="22dp"
256-
            android:text="@string/jibiki_license" />
257-
258-
        <TextView
259-
            android:layout_width="match_parent"
260-
            android:layout_height="wrap_content"
261-
            android:layout_marginTop="16dp"
262-
            android:text="@string/tatoeba_title"
263-
            android:textColor="@color/colorSubtitle"
264-
            android:textSize="@dimen/subtitle_size" />
265-
266-
        <TextView
267-
            android:layout_width="match_parent"
268-
            android:layout_height="wrap_content"
269-
            app:lineHeight="22dp"
270-
            android:text="@string/tatoeba_descr" />
271-
272-
        <TextView
273-
            android:layout_width="match_parent"
274-
            android:layout_height="wrap_content"
275-
            app:lineHeight="22dp"
276-
            android:text="@string/tatoeba_license" />
277-
278108
    </LinearLayout>
279109
280110
</ScrollView>
280110=
281111=
\ No newline at end of file

app/src/main/res/layout/activity_license.xml unknown status 1

1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
    xmlns:tools="http://schemas.android.com/tools"
4+
    android:layout_width="match_parent"
5+
    android:layout_height="match_parent"
6+
    android:orientation="vertical"
7+
    tools:context=".AboutActivity">
8+
9+
    <TextView
10+
        android:layout_width="wrap_content"
11+
        android:layout_height="wrap_content"
12+
        android:layout_gravity="center"
13+
        android:text="@string/data_licenses"
14+
        android:textColor="@color/colorTitle"
15+
        android:textSize="@dimen/title_size" />
16+
17+
    <ExpandableListView
18+
        android:id="@+id/license_view"
19+
        android:layout_width="match_parent"
20+
        android:layout_height="wrap_content"
21+
        android:layout_marginStart="8dp"
22+
        android:layout_marginLeft="8dp"
23+
        android:layout_marginTop="32dp"
24+
        android:layout_marginEnd="8dp"
25+
        android:layout_marginRight="8dp"
26+
        android:layout_marginBottom="8dp" />
27+
</LinearLayout>
27<
028<
\ No newline at end of file

app/src/main/res/layout/layout_license.xml unknown status 1

1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
    android:layout_width="match_parent"
4+
    android:layout_height="wrap_content"
5+
    xmlns:app="http://schemas.android.com/apk/res-auto"
6+
    android:orientation="vertical">
7+
8+
    <TextView
9+
        android:id="@+id/name"
10+
        android:layout_width="match_parent"
11+
        android:layout_height="wrap_content"
12+
        android:layout_marginTop="16dp"
13+
        android:textColor="@color/colorAccent"
14+
        android:textSize="@dimen/subtitle_size"
15+
        app:lineHeight="22dp" />
16+
    <TextView
17+
        android:id="@+id/description"
18+
        android:layout_width="match_parent"
19+
        android:layout_height="wrap_content"
20+
        android:layout_marginTop="16dp"
21+
        app:lineHeight="22dp" />
22+
    <TextView
23+
        android:id="@+id/license"
24+
        android:layout_width="match_parent"
25+
        android:layout_height="wrap_content"
26+
        android:layout_marginTop="16dp"
27+
        app:lineHeight="22dp" />
28+
</LinearLayout>
28<
029<
\ No newline at end of file

app/src/main/res/layout/layout_license_name.xml unknown status 1

1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
    android:layout_width="match_parent"
4+
    android:layout_height="match_parent"
5+
    android:orientation="vertical">
6+
    <TextView
7+
        android:id="@+id/license_name"
8+
        android:layout_width="match_parent"
9+
        android:layout_height="wrap_content"
10+
        android:layout_marginTop="16dp"
11+
        android:textColor="@color/colorSubtitle"
12+
        android:textSize="@dimen/title_size"/>
13+
</LinearLayout>
13<
014<
\ No newline at end of file

app/src/main/res/menu/menu_main.xml

2121
    <item
2222
        android:id="@+id/action_about"
2323
        android:title="@string/action_about" />
24+
    <item
25+
        android:id="@+id/action_licenses"
26+
        android:title="@string/action_licenses" />
2427
</menu>

app/src/main/res/values-night/colors.xml

33
    <color name="colorPrimary">#008577</color>
44
    <color name="colorPrimaryDark">#00574B</color>
55
    <color name="colorTitle">#00dac3</color>
6-
    <color name="colorSubtitle">#5474dd</color>
6+
    <color name="colorSubtitle">#6484ed</color>
77
    <color name="colorAccent">#F83B80</color>
88
    <color name="colorWhite">#000000</color>
99
    <color name="colorGrey">#111111</color>

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

55
    <string name="action_dictionaries">Manage Dictionaries</string>
66
    <string name="action_help">Help</string>
77
    <string name="action_about">About</string>
8+
    <string name="action_licenses">Licenses</string>
89
910
    <string name="search_hint">Search japanese word, kanji, meaning, ???</string>
1011
    <string name="search_button">Search</string>
1112
    <string name="title_activity_about">About</string>
13+
    <string name="title_activity_license">About licenses</string>
1214
    <string name="title_activity_dictionary">Dictionaries</string>
1315
    <string name="title_activity_dictionary_download">Download</string>
1416
    <string name="title_activity_help">Help</string>