jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/370684 )

Change subject: Framework for onboarding cards in the Explore feed.
......................................................................


Framework for onboarding cards in the Explore feed.

Bug: T172187
Change-Id: Ic04249a6f655381574dcf2902b36bbd1067f10e1
---
M app/src/main/java/org/wikipedia/feed/FeedCoordinator.java
M app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java
M app/src/main/java/org/wikipedia/feed/FeedFragment.java
M app/src/main/java/org/wikipedia/feed/model/Card.java
A app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCard.java
A app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCardView.java
A app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.java
M app/src/main/java/org/wikipedia/feed/view/FeedAdapter.java
A app/src/main/res/layout/view_card_onboarding.xml
9 files changed, 175 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Mholloway: Looks good to me, approved



diff --git a/app/src/main/java/org/wikipedia/feed/FeedCoordinator.java 
b/app/src/main/java/org/wikipedia/feed/FeedCoordinator.java
index bc1f2d0..5de6cb7 100644
--- a/app/src/main/java/org/wikipedia/feed/FeedCoordinator.java
+++ b/app/src/main/java/org/wikipedia/feed/FeedCoordinator.java
@@ -9,6 +9,7 @@
 import org.wikipedia.feed.continuereading.ContinueReadingClient;
 import org.wikipedia.feed.mainpage.MainPageClient;
 import org.wikipedia.feed.offline.OfflineCompilationClient;
+import org.wikipedia.feed.onboarding.OnboardingClient;
 import org.wikipedia.feed.random.RandomClient;
 import org.wikipedia.feed.searchbar.SearchClient;
 import org.wikipedia.util.DeviceUtil;
@@ -27,6 +28,7 @@
 
         conditionallyAddPendingClient(new SearchClient(), age == 0);
         conditionallyAddPendingClient(new OfflineCompilationClient(), age == 0 
&& !online && isPreBetaRelease());
+        conditionallyAddPendingClient(new OnboardingClient(), age == 0);
         conditionallyAddPendingClient(new AnnouncementClient(), age == 0 && 
online);
         conditionallyAddPendingClient(new AggregatedFeedContentClient(), 
online);
         addPendingClient(new ContinueReadingClient());
diff --git a/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java 
b/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java
index cddf45a..f5fc669 100644
--- a/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java
+++ b/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java
@@ -96,12 +96,14 @@
         int position = cards.indexOf(card);
         addHiddenCard(card);
         removeCard(card, position);
+        card.onDismiss();
         return position;
     }
 
     public void undoDismissCard(@NonNull Card card, int position) {
         unHideCard(card);
         insertCard(card, position);
+        card.onRestore();
     }
 
     void retryFromOffline(@NonNull WikiSite wiki) {
diff --git a/app/src/main/java/org/wikipedia/feed/FeedFragment.java 
b/app/src/main/java/org/wikipedia/feed/FeedFragment.java
index 28b2841..09d2701 100644
--- a/app/src/main/java/org/wikipedia/feed/FeedFragment.java
+++ b/app/src/main/java/org/wikipedia/feed/FeedFragment.java
@@ -27,6 +27,7 @@
 import org.wikipedia.feed.image.FeaturedImageCard;
 import org.wikipedia.feed.model.Card;
 import org.wikipedia.feed.news.NewsItemCard;
+import org.wikipedia.feed.onboarding.OnboardingCard;
 import org.wikipedia.feed.random.RandomCardView;
 import org.wikipedia.feed.view.FeedAdapter;
 import org.wikipedia.feed.view.FeedView;
@@ -421,6 +422,11 @@
         public void onViewCompilations() {
             startActivity(LocalCompilationsActivity.newIntent(getContext()));
         }
+
+        @Override
+        public void onOnboardingPositiveAction(@NonNull Card card, @NonNull 
OnboardingCard.OnboardingAction action) {
+
+        }
     }
 
     private class FeedScrollListener extends RecyclerView.OnScrollListener {
diff --git a/app/src/main/java/org/wikipedia/feed/model/Card.java 
b/app/src/main/java/org/wikipedia/feed/model/Card.java
index 4e325b0..b0dfdc5 100644
--- a/app/src/main/java/org/wikipedia/feed/model/Card.java
+++ b/app/src/main/java/org/wikipedia/feed/model/Card.java
@@ -25,6 +25,12 @@
 
     @NonNull public abstract CardType type();
 
+    public void onDismiss() {
+    }
+
+    public void onRestore() {
+    }
+
     public String getHideKey() {
         return Long.toString(type().code() + dismissHashCode());
     }
diff --git 
a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCard.java 
b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCard.java
new file mode 100644
index 0000000..020fe31
--- /dev/null
+++ b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCard.java
@@ -0,0 +1,24 @@
+package org.wikipedia.feed.onboarding;
+
+import android.net.Uri;
+import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
+
+import org.wikipedia.feed.model.Card;
+
+public abstract class OnboardingCard extends Card {
+    public enum OnboardingAction {
+        OFFLINE_LIBRARY
+    }
+
+    @NonNull public abstract OnboardingAction action();
+
+    @StringRes public abstract int positiveText();
+
+    @StringRes public abstract int headerText();
+
+    @DrawableRes public abstract int headerImage();
+
+    @NonNull public abstract Uri fullImage();
+}
diff --git 
a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCardView.java 
b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCardView.java
new file mode 100644
index 0000000..0a074f1
--- /dev/null
+++ b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingCardView.java
@@ -0,0 +1,51 @@
+package org.wikipedia.feed.onboarding;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.facebook.drawee.view.SimpleDraweeView;
+
+import org.wikipedia.R;
+import org.wikipedia.feed.model.Card;
+import org.wikipedia.feed.view.DefaultFeedCardView;
+import org.wikipedia.views.ItemTouchHelperSwipeAdapter;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+public class OnboardingCardView extends DefaultFeedCardView<OnboardingCard>
+        implements ItemTouchHelperSwipeAdapter.SwipeableView {
+    public interface Callback {
+        void onOnboardingPositiveAction(@NonNull Card card, @NonNull 
OnboardingCard.OnboardingAction action);
+    }
+
+    @BindView(R.id.onboarding_card_image) SimpleDraweeView imageView;
+    @BindView(R.id.onboarding_card_header_image) ImageView headerImageView;
+    @BindView(R.id.onboarding_card_header_title) TextView headerTitleView;
+    @BindView(R.id.onboarding_card_action_positive) TextView 
actionViewPositive;
+
+    public OnboardingCardView(@NonNull Context context) {
+        super(context);
+        inflate(context, R.layout.view_card_onboarding, this);
+        ButterKnife.bind(this);
+    }
+
+    @Override public void setCard(@NonNull OnboardingCard card) {
+        super.setCard(card);
+
+        headerImageView.setImageResource(card.headerImage());
+        headerTitleView.setText(card.headerText());
+        imageView.setImageURI(card.fullImage());
+        actionViewPositive.setText(card.positiveText());
+    }
+
+    @OnClick(R.id.onboarding_card_action_positive)
+    void onPositiveActionClick() {
+        if (getCallback() != null && getCard() != null) {
+            getCallback().onOnboardingPositiveAction(getCard(), 
getCard().action());
+        }
+    }
+}
diff --git 
a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.java 
b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.java
new file mode 100644
index 0000000..88e88fe
--- /dev/null
+++ b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.java
@@ -0,0 +1,22 @@
+package org.wikipedia.feed.onboarding;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+
+import org.wikipedia.dataclient.WikiSite;
+import org.wikipedia.feed.dataclient.FeedClient;
+import org.wikipedia.feed.model.Card;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class OnboardingClient implements FeedClient {
+    @Override public void request(@NonNull Context context, @NonNull WikiSite 
wiki, int age,
+                                  @NonNull FeedClient.Callback cb) {
+        List<Card> cards = new ArrayList<>();
+        // TODO: add onboarding cards conditionally
+        cb.success(cards);
+    }
+
+    @Override public void cancel() { }
+}
diff --git a/app/src/main/java/org/wikipedia/feed/view/FeedAdapter.java 
b/app/src/main/java/org/wikipedia/feed/view/FeedAdapter.java
index 99195f4..0fa1d3f 100644
--- a/app/src/main/java/org/wikipedia/feed/view/FeedAdapter.java
+++ b/app/src/main/java/org/wikipedia/feed/view/FeedAdapter.java
@@ -17,6 +17,7 @@
 import org.wikipedia.feed.news.NewsListCardView;
 import org.wikipedia.feed.offline.OfflineCardView;
 import org.wikipedia.feed.offline.OfflineCompilationCardView;
+import org.wikipedia.feed.onboarding.OnboardingCardView;
 import org.wikipedia.feed.random.RandomCardView;
 import org.wikipedia.feed.searchbar.SearchCardView;
 import org.wikipedia.views.DefaultRecyclerAdapter;
@@ -28,7 +29,8 @@
             ListCardItemView.Callback, CardHeaderView.Callback,
             FeaturedImageCardView.Callback, SearchCardView.Callback, 
NewsListCardView.Callback,
             AnnouncementCardView.Callback, FeaturedArticleCardView.Callback,
-            RandomCardView.Callback, OfflineCompilationCardView.Callback {
+            RandomCardView.Callback, OfflineCompilationCardView.Callback,
+            OnboardingCardView.Callback {
         void onShowCard(@Nullable Card card);
         void onRequestMore();
         void onRetryFromOffline();
diff --git a/app/src/main/res/layout/view_card_onboarding.xml 
b/app/src/main/res/layout/view_card_onboarding.xml
new file mode 100644
index 0000000..561f826
--- /dev/null
+++ b/app/src/main/res/layout/view_card_onboarding.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android";
+    xmlns:tools="http://schemas.android.com/tools";
+    xmlns:app="http://schemas.android.com/apk/res-auto";
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:padding="12dp">
+
+        <android.support.v7.widget.AppCompatImageView
+            android:id="@+id/onboarding_card_header_image"
+            android:layout_width="24dp"
+            android:layout_height="24dp"
+            android:layout_gravity="center"
+            android:layout_marginStart="4dp"
+            android:layout_marginLeft="4dp"
+            android:padding="3dp"
+            app:srcCompat="@drawable/ic_offline_white_24dp"
+            android:tint="@android:color/white"
+            android:background="@drawable/shape_circle"
+            app:backgroundTint="@color/base20"
+            android:contentDescription="@null"/>
+
+        <TextView
+            android:id="@+id/onboarding_card_header_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginStart="8dp"
+            android:layout_marginLeft="8dp"
+            android:fontFamily="sans-serif-medium"
+            android:textColor="?attr/feed_text_secondary_color"
+            tools:text="Lorem ipsum"/>
+
+    </LinearLayout>
+
+    <com.facebook.drawee.view.SimpleDraweeView
+        android:id="@+id/onboarding_card_image"
+        style="@style/SimpleDraweeViewPlaceholder"
+        android:layout_width="match_parent"
+        android:layout_height="178dp"
+        android:contentDescription="@null" />
+
+    <TextView
+        android:id="@+id/onboarding_card_action_positive"
+        style="@style/Widget.AppCompat.Button.Borderless"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:layout_margin="4dp"
+        android:textColor="?attr/feed_text_tertiary_color"
+        tools:text="Lorem ipsum"/>
+
+</LinearLayout>
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/370684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic04249a6f655381574dcf2902b36bbd1067f10e1
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to