Improve license activity design
.idea/misc.xml
| 14 | 14 | <entry key="app/src/main/res/layout/content_main.xml" value="0.2078125" /> | |
| 15 | 15 | <entry key="app/src/main/res/layout/content_radicals.xml" value="0.1" /> | |
| 16 | 16 | <entry key="app/src/main/res/layout/fragment_results.xml" value="0.2078125" /> | |
| 17 | + | <entry key="app/src/main/res/layout/layout_dictionary.xml" value="0.3932291666666667" /> | |
| 17 | 18 | <entry key="app/src/main/res/layout/layout_example.xml" value="0.20677083333333332" /> | |
| 18 | 19 | <entry key="app/src/main/res/layout/layout_license.xml" value="0.20677083333333332" /> | |
| 19 | 20 | <entry key="app/src/main/res/layout/layout_license_description.xml" value="0.21927083333333333" /> |
app/src/main/java/eu/lepiller/nani/LicenseActivity.java
| 1 | 1 | package eu.lepiller.nani; | |
| 2 | 2 | ||
| 3 | + | import android.graphics.drawable.Drawable; | |
| 3 | 4 | import android.os.Bundle; | |
| 4 | 5 | import android.widget.ExpandableListAdapter; | |
| 5 | 6 | import android.widget.ExpandableListView; | |
… | |||
| 7 | 8 | ||
| 8 | 9 | import androidx.annotation.Nullable; | |
| 9 | 10 | import androidx.appcompat.app.AppCompatActivity; | |
| 11 | + | import androidx.core.content.res.ResourcesCompat; | |
| 10 | 12 | ||
| 11 | 13 | import java.util.ArrayList; | |
| 12 | 14 | import java.util.List; | |
… | |||
| 17 | 19 | public static class License { | |
| 18 | 20 | private final String name, description, license; | |
| 19 | 21 | private final List<License> subProjects; | |
| 20 | - | License(String name, String description, String license, List<License> subProjects) { | |
| 22 | + | private final Drawable drawable; | |
| 23 | + | ||
| 24 | + | License(String name, Drawable drawable, String description, String license, List<License> subProjects) { | |
| 21 | 25 | this.name = name; | |
| 26 | + | this.drawable = drawable; | |
| 22 | 27 | this.description = description; | |
| 23 | 28 | this.license = license; | |
| 24 | 29 | this.subProjects = subProjects; | |
… | |||
| 40 | 45 | public List<License> getSubProjects() { | |
| 41 | 46 | return subProjects; | |
| 42 | 47 | } | |
| 48 | + | ||
| 49 | + | public Drawable getDrawable() { | |
| 50 | + | return drawable; | |
| 51 | + | } | |
| 43 | 52 | } | |
| 44 | 53 | ||
| 45 | 54 | private static final List<License> licenseInformation = new ArrayList<>(); | |
… | |||
| 51 | 60 | ||
| 52 | 61 | licenseInformation.clear(); | |
| 53 | 62 | 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)); | |
| 63 | + | erdrgLicenses.add(new License(getString(R.string.jmdict_title), null, | |
| 64 | + | getString(R.string.jmdict_descr), getString(R.string.jmdict_license), null)); | |
| 65 | + | erdrgLicenses.add(new License(getString(R.string.radk_title), null, | |
| 66 | + | getString(R.string.radk_descr), getString(R.string.radk_license), null)); | |
| 67 | + | erdrgLicenses.add(new License(getString(R.string.kanjidic_title), null, | |
| 68 | + | getString(R.string.kanjidic_descr), getString(R.string.kanjidic_license), null)); | |
| 57 | 69 | licenseInformation.add( | |
| 58 | - | new License(getString(R.string.erdrg_title), getString(R.string.erdrg_descr), "", | |
| 59 | - | erdrgLicenses)); | |
| 70 | + | new License(getString(R.string.erdrg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_nani_edrdg, getTheme()), | |
| 71 | + | getString(R.string.erdrg_descr), "", erdrgLicenses)); | |
| 60 | 72 | ||
| 61 | 73 | licenseInformation.add( | |
| 62 | - | new License(getString(R.string.kanjivg_title), getString(R.string.kanjivg_descr), getString(R.string.kanjivg_license), null) | |
| 74 | + | new License(getString(R.string.kanjivg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_kanjivg, getTheme()), | |
| 75 | + | getString(R.string.kanjivg_descr), getString(R.string.kanjivg_license), null) | |
| 63 | 76 | ); | |
| 64 | 77 | licenseInformation.add( | |
| 65 | - | new License(getString(R.string.jibiki_title), getString(R.string.jibiki_descr), getString(R.string.jibiki_license), null) | |
| 78 | + | new License(getString(R.string.jibiki_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_jibiki, getTheme()), | |
| 79 | + | getString(R.string.jibiki_descr), getString(R.string.jibiki_license), null) | |
| 66 | 80 | ); | |
| 67 | 81 | licenseInformation.add( | |
| 68 | - | new License(getString(R.string.wadoku_title), getString(R.string.wadoku_descr), getString(R.string.wadoku_license), null) | |
| 82 | + | new License(getString(R.string.wadoku_title), ResourcesCompat.getDrawable(getResources(), R.drawable.wadoku, getTheme()), | |
| 83 | + | getString(R.string.wadoku_descr), getString(R.string.wadoku_license), null) | |
| 69 | 84 | ); | |
| 70 | 85 | licenseInformation.add( | |
| 71 | - | new License(getString(R.string.tatoeba_title), getString(R.string.tatoeba_descr), getString(R.string.tatoeba_license), null) | |
| 86 | + | new License(getString(R.string.tatoeba_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_tatoeba, getTheme()), | |
| 87 | + | getString(R.string.tatoeba_descr), getString(R.string.tatoeba_license), null) | |
| 72 | 88 | ); | |
| 73 | 89 | ||
| 74 | 90 | final ExpandableListView list_view = findViewById(R.id.license_view); | |
app/src/main/java/eu/lepiller/nani/LicenseAdapter.java
| 1 | 1 | package eu.lepiller.nani; | |
| 2 | 2 | ||
| 3 | 3 | import android.content.Context; | |
| 4 | + | import android.graphics.drawable.Drawable; | |
| 5 | + | import android.provider.ContactsContract; | |
| 4 | 6 | import android.view.LayoutInflater; | |
| 5 | 7 | import android.view.View; | |
| 6 | 8 | import android.view.ViewGroup; | |
| 7 | 9 | import android.widget.BaseExpandableListAdapter; | |
| 10 | + | import android.widget.ImageView; | |
| 8 | 11 | import android.widget.TextView; | |
| 9 | 12 | ||
| 10 | 13 | import java.util.List; | |
… | |||
| 64 | 67 | view = layoutInflater.inflate(R.layout.layout_license_name, viewGroup, false); | |
| 65 | 68 | } | |
| 66 | 69 | String name = licenses.get(i).getName(); | |
| 70 | + | Drawable icon = licenses.get(i).getDrawable(); | |
| 67 | 71 | TextView nameView = (TextView) view.findViewById(R.id.license_name); | |
| 72 | + | ImageView iconView = (ImageView) view.findViewById(R.id.icon_view); | |
| 73 | + | ImageView arrowView = (ImageView) view.findViewById(R.id.arrow_view); | |
| 68 | 74 | nameView.setText(name); | |
| 75 | + | iconView.setImageDrawable(icon); | |
| 76 | + | arrowView.setImageResource(b? android.R.drawable.arrow_up_float: android.R.drawable.arrow_down_float); | |
| 69 | 77 | return view; | |
| 70 | 78 | } | |
| 71 | 79 | ||
app/src/main/res/layout/activity_license.xml
| 14 | 14 | android:textColor="@color/colorTitle" | |
| 15 | 15 | android:textSize="@dimen/title_size" /> | |
| 16 | 16 | ||
| 17 | + | <TextView | |
| 18 | + | android:layout_width="wrap_content" | |
| 19 | + | android:layout_height="wrap_content" | |
| 20 | + | android:layout_gravity="center" | |
| 21 | + | android:text="@string/data_intro" /> | |
| 22 | + | ||
| 17 | 23 | <ExpandableListView | |
| 18 | 24 | android:id="@+id/license_view" | |
| 19 | 25 | android:layout_width="match_parent" |
app/src/main/res/layout/layout_license_name.xml
| 2 | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | 3 | android:layout_width="match_parent" | |
| 4 | 4 | android:layout_height="match_parent" | |
| 5 | - | android:orientation="vertical"> | |
| 5 | + | xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | + | android:orientation="horizontal"> | |
| 7 | + | ||
| 8 | + | <ImageView | |
| 9 | + | android:id="@+id/icon_view" | |
| 10 | + | android:layout_width="64dp" | |
| 11 | + | android:layout_height="64dp" | |
| 12 | + | android:layout_gravity="center" | |
| 13 | + | android:layout_margin="16dp" | |
| 14 | + | android:contentDescription="@string/alt_text_icon" | |
| 15 | + | android:layout_weight="0" | |
| 16 | + | app:srcCompat="@android:drawable/ic_menu_close_clear_cancel" /> | |
| 17 | + | ||
| 6 | 18 | <TextView | |
| 7 | 19 | android:id="@+id/license_name" | |
| 8 | 20 | android:layout_width="match_parent" | |
| 9 | 21 | android:layout_height="wrap_content" | |
| 22 | + | android:layout_weight="1" | |
| 10 | 23 | android:layout_marginTop="16dp" | |
| 11 | 24 | android:textColor="@color/colorSubtitle" | |
| 12 | 25 | android:textSize="@dimen/title_size"/> | |
| 26 | + | ||
| 27 | + | <ImageView | |
| 28 | + | android:id="@+id/arrow_view" | |
| 29 | + | android:layout_width="16dp" | |
| 30 | + | android:layout_height="16dp" | |
| 31 | + | android:layout_gravity="center" | |
| 32 | + | android:layout_margin="16dp" | |
| 33 | + | android:contentDescription="@string/alt_text_icon" | |
| 34 | + | android:layout_weight="0" | |
| 35 | + | app:srcCompat="@android:drawable/arrow_down_float" /> | |
| 13 | 36 | </LinearLayout> | |
| 13 | 36 | = | |
| 14 | 37 | = | \ No newline at end of file |