Dbrant has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/393601 )
Change subject: Update design of feed content customization. ...................................................................... Update design of feed content customization. Bug: T141397 Change-Id: I11b1646ec78750dd9757a9983a16f4ba287c1e27 --- M app/src/main/java/org/wikipedia/feed/FeedContentType.java M app/src/main/java/org/wikipedia/feed/configure/ConfigureFragment.java M app/src/main/java/org/wikipedia/feed/configure/ConfigureItemView.java R app/src/main/res/drawable/ic_reorder_black_24dp.xml M app/src/main/res/layout/fragment_feed_configure.xml M app/src/main/res/layout/item_feed_content_type.xml M app/src/main/res/layout/view_explore_overflow.xml M app/src/main/res/menu/menu_feed_configure.xml M app/src/main/res/values-qq/strings.xml M app/src/main/res/values/strings.xml 10 files changed, 124 insertions(+), 57 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/01/393601/1 diff --git a/app/src/main/java/org/wikipedia/feed/FeedContentType.java b/app/src/main/java/org/wikipedia/feed/FeedContentType.java index 0731980..afc94cf 100644 --- a/app/src/main/java/org/wikipedia/feed/FeedContentType.java +++ b/app/src/main/java/org/wikipedia/feed/FeedContentType.java @@ -22,63 +22,63 @@ import static org.wikipedia.util.ReleaseUtil.isPreBetaRelease; public enum FeedContentType implements EnumCode { - NEWS(0, R.string.view_card_news_title) { + NEWS(0, R.string.view_card_news_title, R.string.feed_item_type_news) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && age == 0 && isOnline ? new AggregatedFeedContentClient.InTheNews(aggregatedClient) : null; } }, - FEATURED_ARTICLE(1, R.string.view_featured_article_card_title) { + FEATURED_ARTICLE(1, R.string.view_featured_article_card_title, R.string.feed_item_type_featured_article) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && isOnline ? new AggregatedFeedContentClient.FeaturedArticle(aggregatedClient) : null; } }, - TRENDING_ARTICLES(2, R.string.most_read_list_card_title) { + TRENDING_ARTICLES(2, R.string.most_read_list_card_title, R.string.feed_item_type_trending) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && isOnline ? new AggregatedFeedContentClient.TrendingArticles(aggregatedClient) : null; } }, - FEATURED_IMAGE(3, R.string.view_featured_image_card_title) { + FEATURED_IMAGE(3, R.string.view_featured_image_card_title, R.string.feed_item_type_featured_image) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && isOnline ? new AggregatedFeedContentClient.FeaturedImage(aggregatedClient) : null; } }, - ON_THIS_DAY(4, R.string.on_this_day_card_title) { + ON_THIS_DAY(4, R.string.on_this_day_card_title, R.string.feed_item_type_on_this_day) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && isOnline && isPreBetaRelease() ? new OnThisDayClient() : null; } }, - CONTINUE_READING(5, R.string.view_continue_reading_card_title) { + CONTINUE_READING(5, R.string.view_continue_reading_card_title, R.string.feed_item_type_continue_reading) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() ? new ContinueReadingClient() : null; } }, - BECAUSE_YOU_READ(6, R.string.view_because_you_read_card_title) { + BECAUSE_YOU_READ(6, R.string.view_because_you_read_card_title, R.string.feed_item_type_because_you_read) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && isOnline ? new BecauseYouReadClient() : null; } }, - MAIN_PAGE(7, R.string.view_main_page_card_title) { + MAIN_PAGE(7, R.string.view_main_page_card_title, R.string.feed_item_type_main_page) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { return isEnabled() && age == 0 ? new MainPageClient() : null; } }, - RANDOM(8, R.string.view_random_card_title) { + RANDOM(8, R.string.view_random_card_title, R.string.feed_item_type_randomizer) { @Nullable @Override public FeedClient newClient(AggregatedFeedContentClient aggregatedClient, int age, boolean isOnline) { @@ -90,6 +90,7 @@ = new EnumCodeMap<>(FeedContentType.class); private final int code; @StringRes private final int titleId; + @StringRes private final int subtitleId; private int order; private boolean enabled = true; @@ -105,8 +106,12 @@ return code; } - public int titleId() { + @StringRes public int titleId() { return titleId; + } + + @StringRes public int subtitleId() { + return subtitleId; } public boolean isEnabled() { @@ -125,10 +130,11 @@ this.order = order; } - FeedContentType(int code, @StringRes int titleId) { + FeedContentType(int code, @StringRes int titleId, @StringRes int subtitleId) { this.code = code; this.order = code; this.titleId = titleId; + this.subtitleId = subtitleId; } public static void saveState() { diff --git a/app/src/main/java/org/wikipedia/feed/configure/ConfigureFragment.java b/app/src/main/java/org/wikipedia/feed/configure/ConfigureFragment.java index 340021e..8cd4173 100644 --- a/app/src/main/java/org/wikipedia/feed/configure/ConfigureFragment.java +++ b/app/src/main/java/org/wikipedia/feed/configure/ConfigureFragment.java @@ -18,7 +18,7 @@ import org.wikipedia.feed.FeedContentType; import org.wikipedia.settings.Prefs; import org.wikipedia.views.DefaultViewHolder; -import org.wikipedia.views.HeaderMarginItemDecoration; +import org.wikipedia.views.DrawableItemDecoration; import java.util.ArrayList; import java.util.Arrays; @@ -76,11 +76,25 @@ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case R.id.menu_feed_configure_select_all: + for (FeedContentType type : FeedContentType.values()) { + type.setEnabled(true); + } + touch(); + recyclerView.getAdapter().notifyDataSetChanged(); + return true; + case R.id.menu_feed_configure_deselect_all: + for (FeedContentType type : FeedContentType.values()) { + type.setEnabled(false); + } + touch(); + recyclerView.getAdapter().notifyDataSetChanged(); + return true; case R.id.menu_feed_configure_reset: Prefs.resetFeedCustomizations(); FeedContentType.restoreState(); prepareContentTypeList(); - getActivity().setResult(ConfigureActivity.CONFIGURATION_CHANGED_RESULT); + touch(); recyclerView.getAdapter().notifyDataSetChanged(); return true; default: @@ -100,10 +114,7 @@ ConfigureItemAdapter adapter = new ConfigureItemAdapter(); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - - recyclerView.addItemDecoration(new HeaderMarginItemDecoration(getContext(), - R.dimen.view_feed_padding_top, - R.dimen.view_feed_padding_top)); + recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable)); itemTouchHelper = new ItemTouchHelper(new RearrangeableItemTouchHelperCallback(adapter)); itemTouchHelper.attachToRecyclerView(recyclerView); @@ -111,17 +122,21 @@ @Override public void onCheckedChanged(FeedContentType contentType, boolean checked) { - getActivity().setResult(ConfigureActivity.CONFIGURATION_CHANGED_RESULT); + touch(); contentType.setEnabled(checked); } private void updateItemOrder() { - getActivity().setResult(ConfigureActivity.CONFIGURATION_CHANGED_RESULT); + touch(); for (int i = 0; i < orderedContentTypes.size(); i++) { orderedContentTypes.get(i).setOrder(i); } } + private void touch() { + getActivity().setResult(ConfigureActivity.CONFIGURATION_CHANGED_RESULT); + } + private class ConfigureItemHolder extends DefaultViewHolder<ConfigureItemView> { ConfigureItemHolder(ConfigureItemView itemView) { super(itemView); diff --git a/app/src/main/java/org/wikipedia/feed/configure/ConfigureItemView.java b/app/src/main/java/org/wikipedia/feed/configure/ConfigureItemView.java index 4e6bfe4..47ccc79 100644 --- a/app/src/main/java/org/wikipedia/feed/configure/ConfigureItemView.java +++ b/app/src/main/java/org/wikipedia/feed/configure/ConfigureItemView.java @@ -7,6 +7,7 @@ import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.FrameLayout; +import android.widget.TextView; import org.wikipedia.R; import org.wikipedia.feed.FeedContentType; @@ -20,7 +21,9 @@ void onCheckedChanged(FeedContentType contentType, boolean checked); } - @BindView(R.id.feed_content_type_checkbox) CheckBox titleView; + @BindView(R.id.feed_content_type_checkbox) CheckBox checkBox; + @BindView(R.id.feed_content_type_title) TextView titleView; + @BindView(R.id.feed_content_type_subtitle) TextView subtitleView; @BindView(R.id.feed_content_type_drag_handle) View dragHandleView; @Nullable private Callback callback; private FeedContentType contentType; @@ -47,7 +50,8 @@ public void setContents(FeedContentType contentType) { this.contentType = contentType; titleView.setText(contentType.titleId()); - titleView.setChecked(contentType.isEnabled()); + subtitleView.setText(contentType.subtitleId()); + checkBox.setChecked(contentType.isEnabled()); } public void setDragHandleTouchListener(OnTouchListener listener) { diff --git a/app/src/main/res/drawable/ic_drag_handle_black_24dp.xml b/app/src/main/res/drawable/ic_reorder_black_24dp.xml similarity index 70% rename from app/src/main/res/drawable/ic_drag_handle_black_24dp.xml rename to app/src/main/res/drawable/ic_reorder_black_24dp.xml index 68a7190..2b87cd8 100644 --- a/app/src/main/res/drawable/ic_drag_handle_black_24dp.xml +++ b/app/src/main/res/drawable/ic_reorder_black_24dp.xml @@ -5,5 +5,5 @@ android:viewportHeight="24.0"> <path android:fillColor="#FF000000" - android:pathData="M20,9H4v2h16V9zM4,15h16v-2H4v2z"/> + android:pathData="M3,15h18v-2L3,13v2zM3,19h18v-2L3,17v2zM3,11h18L21,9L3,9v2zM3,5v2h18L21,5L3,5z"/> </vector> diff --git a/app/src/main/res/layout/fragment_feed_configure.xml b/app/src/main/res/layout/fragment_feed_configure.xml index 42d7eeb..0a8ceb8 100644 --- a/app/src/main/res/layout/fragment_feed_configure.xml +++ b/app/src/main/res/layout/fragment_feed_configure.xml @@ -10,8 +10,6 @@ android:id="@+id/content_types_recycler" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginLeft="@dimen/activity_horizontal_margin" - android:layout_marginRight="@dimen/activity_horizontal_margin" android:scrollbars="vertical" /> </LinearLayout> diff --git a/app/src/main/res/layout/item_feed_content_type.xml b/app/src/main/res/layout/item_feed_content_type.xml index dc62ce4..6618ce9 100644 --- a/app/src/main/res/layout/item_feed_content_type.xml +++ b/app/src/main/res/layout/item_feed_content_type.xml @@ -1,41 +1,56 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.v7.widget.CardView +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="64dp" - app:cardBackgroundColor="?attr/paper_color" - app:cardUseCompatPadding="true"> + android:layout_height="match_parent" + android:background="?attr/paper_color"> + + <CheckBox + android:id="@+id/feed_content_type_checkbox" + android:layout_width="48dp" + android:layout_height="48dp" + android:layout_marginStart="12dp" + android:layout_gravity="center_vertical"/> <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:orientation="vertical" + android:layout_gravity="center_vertical"> - <CheckBox - android:id="@+id/feed_content_type_checkbox" - android:layout_width="0dp" + <TextView + android:id="@+id/feed_content_type_title" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_gravity="center_vertical" - android:layout_marginStart="8dp" - android:layout_marginEnd="8dp" - android:drawablePadding="8dp" - style="@style/RtlAwareTextView" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="?attr/secondary_text_color" + style="@style/MaterialListTitle" + android:textAppearance="@style/RtlAwareTextView" tools:text="Lorem ipsum"/> - <ImageView - android:id="@+id/feed_content_type_drag_handle" - android:layout_width="48dp" - android:layout_height="match_parent" - app:srcCompat="@drawable/ic_drag_handle_black_24dp" - android:scaleType="center" - android:tint="?attr/secondary_text_color" - android:contentDescription="@null"/> + <org.wikipedia.views.GoneIfEmptyTextView + android:id="@+id/feed_content_type_subtitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="2dp" + style="@style/MaterialListSubtitle" + android:textAppearance="@style/RtlAwareTextView" + tools:text="Lorem ipsum"/> </LinearLayout> -</android.support.v7.widget.CardView> + <ImageView + android:id="@+id/feed_content_type_drag_handle" + android:layout_width="56dp" + android:layout_height="match_parent" + app:srcCompat="@drawable/ic_reorder_black_24dp" + android:scaleType="center" + android:tint="?attr/secondary_text_color" + android:contentDescription="@null"/> + +</LinearLayout> diff --git a/app/src/main/res/layout/view_explore_overflow.xml b/app/src/main/res/layout/view_explore_overflow.xml index bc89dca..4dfa55c 100644 --- a/app/src/main/res/layout/view_explore_overflow.xml +++ b/app/src/main/res/layout/view_explore_overflow.xml @@ -48,7 +48,7 @@ <TextView android:id="@+id/explore_overflow_configure_cards" style="@style/OverflowMenuItem" - android:text="@string/feed_configure_menu_title"/> + android:text="@string/feed_configure_activity_title"/> <TextView android:id="@+id/explore_overflow_compilations" diff --git a/app/src/main/res/menu/menu_feed_configure.xml b/app/src/main/res/menu/menu_feed_configure.xml index 93bcd19..a2cc8f0 100644 --- a/app/src/main/res/menu/menu_feed_configure.xml +++ b/app/src/main/res/menu/menu_feed_configure.xml @@ -3,7 +3,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:ignore="AlwaysShowAction"> + <item android:id="@+id/menu_feed_configure_select_all" + android:title="@string/feed_configure_menu_select_all" + app:showAsAction="never"/> + <item android:id="@+id/menu_feed_configure_deselect_all" + android:title="@string/feed_configure_menu_deselect_all" + app:showAsAction="never"/> <item android:id="@+id/menu_feed_configure_reset" android:title="@string/feed_configure_menu_reset" app:showAsAction="never"/> + </menu> diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index 98335dc..9d911df 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -409,9 +409,20 @@ <string name="view_featured_article_card_title">Title shown in the Featured Article card in the Explore feed\n{{Identical|Featured article}}</string> <string name="view_featured_article_footer_save_button_label">Button label for saving the current featured article to a reading list, if it is not already saved.\n{{Identical|Save}}</string> <string name="view_featured_article_footer_saved_button_label">Button label for when the current featured article is already saved to a reading list, but may now be removed from the list, or saved to a different list.\n{{Identical|Saved}}</string> - <string name="feed_configure_menu_title">Menu label for showing the screen where the user configures which cards are shown in the Explore feed.</string> - <string name="feed_configure_activity_title">Title shown at the top of the screen where the user configures which cards are shown in the Explore feed.</string> - <string name="feed_configure_menu_reset">Menu label for resetting the configuration of the Explore feed cards to the original defaults.</string> + <string name="feed_configure_menu_title">Menu label for showing the screen where the user customizes which cards are shown in the Explore feed.</string> + <string name="feed_configure_activity_title">Title shown at the top of the screen where the user customizes which cards are shown in the Explore feed.</string> + <string name="feed_configure_menu_reset">Menu label for resetting the customization of the Explore feed cards to the original defaults.</string> + <string name="feed_configure_menu_select_all">Menu label for selecting all types of Explore feed cards to be shown.</string> + <string name="feed_configure_menu_deselect_all">Menu label for deselecting all types of Explore feed cards from being shown.</string> + <string name="feed_item_type_news">Short description for Explore feed card that contains daily news items</string> + <string name="feed_item_type_on_this_day">Short description for Explore feed card that contains events that occurred on this day in history</string> + <string name="feed_item_type_continue_reading">Short description for Explore feed card that contains a link to previous article(s) read by the user</string> + <string name="feed_item_type_because_you_read">Short description for Explore feed card that contains suggestions based on the browsing history of the user</string> + <string name="feed_item_type_featured_article">Short description for Explore feed card that contains the daily featured article</string> + <string name="feed_item_type_trending">Short description for Explore feed card that contains daily trending articles</string> + <string name="feed_item_type_featured_image">Short description for Explore feed card that contains the daily featured image from Commons</string> + <string name="feed_item_type_main_page">Short description for Explore feed card that contains a link to the Main Page</string> + <string name="feed_item_type_randomizer">Short description for Explore feed card that generates random articles</string> <string name="description_edit_text_hint">Hint text that is shown when the description field is empty.</string> <string name="description_edit_save">Hint for the button that is pressed for saving the new description.\n{{Identical|Publish}}</string> <string name="description_edit_add_description">Label that prompts the user to add a description to an article that does not yet have one.</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c8d4a29..a7cc590 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -444,8 +444,19 @@ <string name="view_featured_article_footer_save_button_label">Save</string> <string name="view_featured_article_footer_saved_button_label">Saved</string> <string name="feed_configure_menu_title">Configure cards</string> - <string name="feed_configure_activity_title">Configure Explore cards</string> - <string name="feed_configure_menu_reset">Reset to defaults</string> + <string name="feed_configure_activity_title">Customize the feed</string> + <string name="feed_configure_menu_reset">Restore default view</string> + <string name="feed_configure_menu_select_all">Select all</string> + <string name="feed_configure_menu_deselect_all">Deselect all</string> + <string name="feed_item_type_news">Articles about current events</string> + <string name="feed_item_type_on_this_day">Events in history on this day</string> + <string name="feed_item_type_continue_reading">Quick link back to reading an open article in one of your tabs</string> + <string name="feed_item_type_because_you_read">Suggestions based on a recently read article from your history</string> + <string name="feed_item_type_featured_article">Daily featured article on Wikipedia</string> + <string name="feed_item_type_trending">Daily most-viewed articles</string> + <string name="feed_item_type_featured_image">Daily featured image from Wikimedia Commons</string> + <string name="feed_item_type_main_page">Main page of Wikipedia with daily featured content</string> + <string name="feed_item_type_randomizer">Generate random articles to read</string> <!-- /The Feed --> <!-- Description editing --> -- To view, visit https://gerrit.wikimedia.org/r/393601 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I11b1646ec78750dd9757a9983a16f4ba287c1e27 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Dbrant <dbr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits