diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index aa9c497f1..a4be9301e 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -7,9 +7,12 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.res.TypedArray; import android.os.Bundle; import android.os.IBinder; import android.preference.PreferenceManager; +import android.support.annotation.AttrRes; +import android.support.annotation.DrawableRes; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -89,7 +92,7 @@ public class MissionsFragment extends Fragment { mEmpty = v.findViewById(R.id.list_empty_view); mList = v.findViewById(R.id.mission_recycler); - // Init + // Init layouts managers mGridManager = new GridLayoutManager(getActivity(), SPAN_SIZE); mGridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override @@ -103,7 +106,6 @@ public class MissionsFragment extends Fragment { } } }); - mLinearManager = new LinearLayoutManager(getActivity()); setHasOptionsMenu(true); @@ -120,7 +122,7 @@ public class MissionsFragment extends Fragment { // Bug: in api< 23 this is never called // so mActivity=null - // so app crashes with nullpointer exception + // so app crashes with null-pointer exception mActivity = activity; } @@ -189,12 +191,21 @@ public class MissionsFragment extends Fragment { mList.setAdapter(mAdapter); if (mSwitch != null) { - mSwitch.setIcon(mLinear ? R.drawable.grid : R.drawable.list); + mSwitch.setIcon(getDrawableFromAttribute(mLinear ? R.attr.ic_grid : R.attr.ic_list)); mSwitch.setTitle(mLinear ? R.string.grid : R.string.list); mPrefs.edit().putBoolean("linear", mLinear).apply(); } } + @DrawableRes + private int getDrawableFromAttribute(@AttrRes int ic) { + TypedArray styledAttributes = mActivity.obtainStyledAttributes(new int[]{ic}); + int resId = styledAttributes.getResourceId(0, -1); + styledAttributes.recycle(); + + return resId; + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); diff --git a/app/src/main/res/drawable-hdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_delete_black_24dp.png new file mode 100644 index 000000000..ba8820363 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_delete_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png new file mode 100644 index 000000000..be2850b3d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_grid_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_grid_black_24dp.png new file mode 100644 index 000000000..2db18582c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_grid_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_grid_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_grid_white_24dp.png new file mode 100644 index 000000000..5cc4722f6 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_grid_white_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_list_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_list_black_24dp.png new file mode 100644 index 000000000..cc7b7a091 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_list_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_list_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_list_white_24dp.png new file mode 100644 index 000000000..5e6e304e3 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_delete_black_24dp.png new file mode 100644 index 000000000..65bc6817d Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_delete_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png new file mode 100644 index 000000000..8f10392ca Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_grid_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_grid_black_24dp.png new file mode 100644 index 000000000..0f878e4ed Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_grid_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_grid_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_grid_white_24dp.png new file mode 100644 index 000000000..0096c9f11 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_grid_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_list_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_list_black_24dp.png new file mode 100644 index 000000000..6fa4e5034 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_list_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_list_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_list_white_24dp.png new file mode 100644 index 000000000..f0d3f5f7c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png new file mode 100644 index 000000000..f080aa9e8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png new file mode 100644 index 000000000..a1b828bf9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_grid_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_grid_black_24dp.png new file mode 100644 index 000000000..bcefc5221 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_grid_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_grid_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_grid_white_24dp.png new file mode 100644 index 000000000..745cb6cb8 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_grid_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_list_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_list_black_24dp.png new file mode 100644 index 000000000..0f7327fad Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_list_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_list_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_list_white_24dp.png new file mode 100644 index 000000000..1de314a57 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png new file mode 100644 index 000000000..4cb4c08e2 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png new file mode 100644 index 000000000..bd11b4c66 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_grid_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_grid_black_24dp.png new file mode 100644 index 000000000..31cd3dc83 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_grid_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_grid_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_grid_white_24dp.png new file mode 100644 index 000000000..ebe059481 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_grid_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_list_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_list_black_24dp.png new file mode 100644 index 000000000..52d0c00a1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_list_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_list_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_list_white_24dp.png new file mode 100644 index 000000000..e5f698298 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png new file mode 100644 index 000000000..ab07ea2ae Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png new file mode 100644 index 000000000..a8358eb71 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_grid_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_grid_black_24dp.png new file mode 100644 index 000000000..fe78d853e Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_grid_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_grid_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_grid_white_24dp.png new file mode 100644 index 000000000..d52610ec8 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_grid_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_list_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_list_black_24dp.png new file mode 100644 index 000000000..b165df44d Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_list_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_list_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_list_white_24dp.png new file mode 100644 index 000000000..053a1a0da Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_list_white_24dp.png differ diff --git a/app/src/main/res/layout-large-land/activity_main_player.xml b/app/src/main/res/layout-large-land/activity_main_player.xml index 7d7e1230e..5f484267b 100644 --- a/app/src/main/res/layout-large-land/activity_main_player.xml +++ b/app/src/main/res/layout-large-land/activity_main_player.xml @@ -239,7 +239,7 @@ android:focusable="true" android:padding="5dp" android:scaleType="fitXY" - android:src="@drawable/list" + android:src="@drawable/ic_list_white_24dp" android:background="?attr/selectableItemBackground" tools:ignore="ContentDescription,RtlHardcoded"/> diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index 3dccc5c4c..8cf9ba32f 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -237,7 +237,7 @@ android:focusable="true" android:padding="5dp" android:scaleType="fitXY" - android:src="@drawable/list" + android:src="@drawable/ic_list_white_24dp" android:background="?attr/selectableItemBackground" tools:ignore="ContentDescription,RtlHardcoded"/> diff --git a/app/src/main/res/menu/download_menu.xml b/app/src/main/res/menu/download_menu.xml index e79367135..4e2b32715 100644 --- a/app/src/main/res/menu/download_menu.xml +++ b/app/src/main/res/menu/download_menu.xml @@ -3,17 +3,17 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - - + android:icon="?attr/ic_delete" + android:title="@string/clear_finished_download" + app:showAsAction="ifRoom" /> + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 7b879fb4c..c0e7fa532 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -38,6 +38,9 @@ + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 87e19cede..da1ae0e38 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -22,7 +22,6 @@ @drawable/ic_info_outline_black_24dp @drawable/ic_bug_report_black_24dp @drawable/ic_headset_black_24dp - @drawable/ic_delete_sweep_white_24dp @drawable/ic_file_download_black_24dp @drawable/ic_share_black_24dp @drawable/ic_cast_black_24dp @@ -54,6 +53,9 @@ @drawable/ic_add_black_24dp @drawable/ic_settings_backup_restore_black_24dp @drawable/ic_blank_page_black_24dp + @drawable/ic_list_black_24dp + @drawable/ic_grid_black_24dp + @drawable/ic_delete_black_24dp @color/light_separator_color @color/light_contrast_background_color @@ -82,7 +84,6 @@ @drawable/ic_headset_white_24dp @drawable/ic_info_outline_white_24dp @drawable/ic_bug_report_white_24dp - @drawable/ic_delete_sweep_black_24dp @drawable/ic_file_download_white_24dp @drawable/ic_share_white_24dp @drawable/ic_cast_white_24dp @@ -114,6 +115,9 @@ @drawable/ic_add_white_24dp @drawable/ic_settings_backup_restore_white_24dp @drawable/ic_blank_page_white_24dp + @drawable/ic_list_white_24dp + @drawable/ic_grid_white_24dp + @drawable/ic_delete_white_24dp @color/dark_separator_color @color/dark_contrast_background_color