jenkins-bot has submitted this change and it was merged.

Change subject: Add actions to page action tab layout
......................................................................


Add actions to page action tab layout

Bug: T135295
Change-Id: Ia2d754b10238d6a9e63cda7cee538122ad173eb9
---
A app/src/main/java/org/wikipedia/page/PageActionTab.java
M app/src/main/java/org/wikipedia/page/PageFragment.java
M app/src/main/res/layout/fragment_page.xml
3 files changed, 101 insertions(+), 9 deletions(-)

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



diff --git a/app/src/main/java/org/wikipedia/page/PageActionTab.java 
b/app/src/main/java/org/wikipedia/page/PageActionTab.java
new file mode 100644
index 0000000..fcc6161
--- /dev/null
+++ b/app/src/main/java/org/wikipedia/page/PageActionTab.java
@@ -0,0 +1,62 @@
+package org.wikipedia.page;
+
+import android.support.annotation.NonNull;
+
+import org.wikipedia.model.EnumCode;
+import org.wikipedia.model.EnumCodeMap;
+
+public enum PageActionTab implements EnumCode {
+    ADD_TO_READING_LIST() {
+        @Override
+        public void select(@NonNull Callback cb) {
+            cb.onAddToReadingListTabSelected();
+        }
+    },
+    SHARE() {
+        @Override
+        public void select(@NonNull Callback cb) {
+            cb.onSharePageTabSelected();
+        }
+    },
+    CHOOSE_LANGUAGE() {
+        @Override
+        public void select(@NonNull Callback cb) {
+            cb.onChooseLangTabSelected();
+        }
+    },
+    FIND_IN_PAGE() {
+        @Override
+        public void select(@NonNull Callback cb) {
+            cb.onFindInPageTabSelected();
+        }
+    },
+    VIEW_TOC() {
+        @Override
+        public void select(@NonNull Callback cb) {
+            cb.onViewToCTabSelected();
+        }
+    };
+
+    private static final EnumCodeMap<PageActionTab> MAP = new 
EnumCodeMap<>(PageActionTab.class);
+
+    @NonNull
+    public static PageActionTab of(int code) {
+        return MAP.get(code);
+    }
+
+    public abstract void select(@NonNull Callback cb);
+
+    @Override public int code() {
+        // This enumeration is not marshalled so tying declaration order to 
presentation order is
+        // convenient and consistent.
+        return ordinal();
+    }
+
+    public interface Callback {
+        void onAddToReadingListTabSelected();
+        void onSharePageTabSelected();
+        void onChooseLangTabSelected();
+        void onFindInPageTabSelected();
+        void onViewToCTabSelected();
+    }
+}
diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java 
b/app/src/main/java/org/wikipedia/page/PageFragment.java
index 7cb4512..d52c303 100755
--- a/app/src/main/java/org/wikipedia/page/PageFragment.java
+++ b/app/src/main/java/org/wikipedia/page/PageFragment.java
@@ -178,7 +178,7 @@
             = new TabLayout.OnTabSelectedListener() {
         @Override
         public void onTabSelected(TabLayout.Tab tab) {
-
+            PageActionTab.of(tab.getPosition()).select(pageActionTabsCallback);
         }
 
         @Override
@@ -188,7 +188,34 @@
 
         @Override
         public void onTabReselected(TabLayout.Tab tab) {
+            onTabSelected(tab);
+        }
+    };
 
+    private PageActionTab.Callback pageActionTabsCallback = new 
PageActionTab.Callback() {
+        @Override
+        public void onAddToReadingListTabSelected() {
+            
addToReadingList(AddToReadingListDialog.InvokeSource.BOOKMARK_BUTTON);
+        }
+
+        @Override
+        public void onSharePageTabSelected() {
+            sharePageLink();
+        }
+
+        @Override
+        public void onChooseLangTabSelected() {
+            startLangLinksActivity();
+        }
+
+        @Override
+        public void onFindInPageTabSelected() {
+            showFindInPage();
+        }
+
+        @Override
+        public void onViewToCTabSelected() {
+            toggleToC(TOC_ACTION_TOGGLE);
         }
     };
 
@@ -698,12 +725,7 @@
                 // TODO SEARCH: add up navigation, see also 
http://developer.android.com/training/implementing-navigation/ancestral.html
                 return true;
             case R.id.menu_page_other_languages:
-                Intent langIntent = new Intent();
-                langIntent.setClass(getActivity(), LangLinksActivity.class);
-                
langIntent.setAction(LangLinksActivity.ACTION_LANGLINKS_FOR_TITLE);
-                langIntent.putExtra(LangLinksActivity.EXTRA_PAGETITLE, 
model.getTitle());
-                getActivity().startActivityForResult(langIntent,
-                                                     
MainActivity.ACTIVITY_REQUEST_LANGLINKS);
+                startLangLinksActivity();
                 return true;
             case R.id.menu_page_share:
                 sharePageLink();
@@ -1315,6 +1337,14 @@
         }
     }
 
+    private void startLangLinksActivity() {
+        Intent langIntent = new Intent();
+        langIntent.setClass(getActivity(), LangLinksActivity.class);
+        langIntent.setAction(LangLinksActivity.ACTION_LANGLINKS_FOR_TITLE);
+        langIntent.putExtra(LangLinksActivity.EXTRA_PAGETITLE, 
model.getTitle());
+        getActivity().startActivityForResult(langIntent, 
MainActivity.ACTIVITY_REQUEST_LANGLINKS);
+    }
+
     @Nullable
     public Callback callback() {
         return FragmentUtil.getCallback(this, Callback.class);
diff --git a/app/src/main/res/layout/fragment_page.xml 
b/app/src/main/res/layout/fragment_page.xml
index bc5a420..fe0fe1c 100644
--- a/app/src/main/res/layout/fragment_page.xml
+++ b/app/src/main/res/layout/fragment_page.xml
@@ -125,8 +125,8 @@
                     android:layout_gravity="bottom"
                     app:tabGravity="fill"
                     android:background="#37393d"
-                    app:tabSelectedTextColor="@color/gray_disabled"
-                    app:tabIndicatorColor="@color/gray_disabled">
+                    app:tabSelectedTextColor="#37393d"
+                    app:tabIndicatorColor="#37393d">
                     <android.support.design.widget.TabItem
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2d754b10238d6a9e63cda7cee538122ad173eb9
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@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