Dbrant has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/203494

Change subject: [WIP] Link previews (prototype 2)
......................................................................

[WIP] Link previews (prototype 2)

Bug: T95723
Change-Id: I89ad1d8b4be7b8d1967129cf8c0d4dfbbb71cf18
---
A wikipedia/res/drawable/link_preview_gradient.xml
M wikipedia/res/layout/dialog_link_preview.xml
M wikipedia/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
3 files changed, 111 insertions(+), 71 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/94/203494/1

diff --git a/wikipedia/res/drawable/link_preview_gradient.xml 
b/wikipedia/res/drawable/link_preview_gradient.xml
new file mode 100644
index 0000000..12b9a6d
--- /dev/null
+++ b/wikipedia/res/drawable/link_preview_gradient.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android";
+    android:shape="rectangle">
+    <gradient
+        android:startColor="#a0000000"
+        android:endColor="#60000000"
+        android:angle="90"/>
+</shape>
\ No newline at end of file
diff --git a/wikipedia/res/layout/dialog_link_preview.xml 
b/wikipedia/res/layout/dialog_link_preview.xml
index d9bc514..d19f0cd 100755
--- a/wikipedia/res/layout/dialog_link_preview.xml
+++ b/wikipedia/res/layout/dialog_link_preview.xml
@@ -1,89 +1,109 @@
 <?xml version="1.0" encoding="utf-8"?>
 
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android";
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
     xmlns:tools="http://schemas.android.com/tools";
     android:layout_width="match_parent"
     android:layout_height="256dp"
-    android:orientation="horizontal"
-    android:background="?attr/window_background_color">
+    android:orientation="vertical">
 
-    <LinearLayout
+    <FrameLayout
+        android:id="@+id/link_preview_container"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="match_parent">
 
-        <LinearLayout
+        <ImageView
+            android:id="@+id/link_preview_image"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-            <TextView
-                android:id="@+id/link_preview_title"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:padding="12dp"
-                android:textSize="18sp"
-                android:fontFamily="serif"
-                android:lineSpacingMultiplier="0.8"
-                android:maxLines="2"
-                android:ellipsize="end"
-                android:textColor="?attr/link_color"
-                tools:text="Lorem ipsum"/>
-            <!-- TODO: replace with correct icon: -->
-            <ImageView
-                android:layout_width="48dp"
-                android:layout_height="48dp"
-                android:padding="12dp"
-                android:src="@drawable/close"
-                android:background="@drawable/selectable_item_background"
-                android:clickable="true"
-                android:scaleType="fitCenter"/>
-        </LinearLayout>
-
+            android:layout_height="match_parent"
+            android:src="?attr/lead_image_drawable"
+            android:contentDescription="@null"
+            android:scaleType="centerCrop"/>
         <View
             android:layout_width="match_parent"
-            android:layout_height="0.5dp"
-            android:background="@color/list_separator_light"/>
+            android:layout_height="match_parent"
+            android:background="@drawable/link_preview_gradient"/>
 
         <LinearLayout
-            android:id="@+id/link_preview_container"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1"
-            android:orientation="horizontal"
-            android:background="?attr/window_background_color">
+            android:layout_height="match_parent"
+            android:padding="12dp"
+            android:orientation="vertical">
 
-            <TextView
-                android:id="@+id/link_preview_extract"
-                android:layout_width="190dp"
-                android:layout_height="match_parent"
-                android:paddingTop="8dp"
-                android:paddingBottom="12dp"
-                android:paddingStart="12dp"
-                android:paddingLeft="12dp"
-                android:paddingEnd="6dp"
-                android:paddingRight="6dp"
-                android:scrollbars="vertical"
-                android:scrollbarStyle="insideInset"
-                tools:text="Lorem ipsum"/>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+                <LinearLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:orientation="vertical"
+                    android:layout_marginRight="36dp"
+                    android:layout_marginEnd="36dp">
+                    <TextView
+                        android:id="@+id/link_preview_title"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_gravity="center_vertical"
+                        android:paddingBottom="8dp"
+                        android:textSize="26sp"
+                        android:lineSpacingMultiplier="0.8"
+                        android:maxLines="2"
+                        android:ellipsize="end"
+                        android:textColor="@android:color/white"
+                        tools:text="Lorem ipsum"/>
+                    <TextView
+                        android:id="@+id/link_preview_description"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:textSize="12dp"
+                        android:lineSpacingMultiplier="0.9"
+                        android:maxLines="2"
+                        android:ellipsize="end"
+                        android:textColor="@android:color/white"
+                        tools:text="Lorem ipsum"/>
 
-            <ImageView
-                android:id="@+id/link_preview_image"
-                android:layout_width="0dp"
-                android:layout_height="match_parent"
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
                 android:layout_weight="1"
-                android:src="?attr/lead_image_drawable"
-                android:contentDescription="@null"
-                android:scaleType="centerCrop"/>
+                android:orientation="horizontal"
+                android:paddingTop="12dp">
+
+                <TextView
+                    android:id="@+id/link_preview_extract"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:textColor="@android:color/white"
+                    android:scrollbars="vertical"
+                    android:scrollbarStyle="insideInset"
+                    tools:text="Lorem ipsum"/>
+
+            </LinearLayout>
 
         </LinearLayout>
 
-    </LinearLayout>
+        <ProgressBar
+            android:id="@+id/link_preview_progress"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"/>
 
-    <ProgressBar
-        android:id="@+id/link_preview_progress"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"/>
+        <!-- TODO: replace with correct icon: -->
+        <ImageView
+            android:id="@+id/link_preview_close_button"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:layout_gravity="top|right"
+            android:padding="12dp"
+            android:src="@drawable/ic_close_white"
+            android:background="@drawable/selectable_item_background"
+            android:clickable="true"
+            android:scaleType="fitCenter"/>
 
-</FrameLayout>
\ No newline at end of file
+    </FrameLayout>
+</LinearLayout>
\ No newline at end of file
diff --git 
a/wikipedia/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java 
b/wikipedia/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
index b83c2de..2fcfae9 100755
--- 
a/wikipedia/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
+++ 
b/wikipedia/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
@@ -37,6 +37,7 @@
     private View previewContainer;
     private ProgressBar progressBar;
     private TextView titleText;
+    private TextView descriptionText;
     private TextView extractText;
     private ImageView previewImage;
 
@@ -57,6 +58,7 @@
         previewContainer = rootView.findViewById(R.id.link_preview_container);
         progressBar = (ProgressBar) 
rootView.findViewById(R.id.link_preview_progress);
         titleText = (TextView) rootView.findViewById(R.id.link_preview_title);
+        descriptionText = (TextView) 
rootView.findViewById(R.id.link_preview_description);
 
         extractText = (TextView) 
rootView.findViewById(R.id.link_preview_extract);
         extractText.setMovementMethod(new ScrollingMovementMethod());
@@ -72,8 +74,14 @@
             }
         });
 
-        // to begin, hide the container, and show the progress bar while we 
load content.
-        previewContainer.setVisibility(View.INVISIBLE);
+        
rootView.findViewById(R.id.link_preview_close_button).setOnClickListener(new 
View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                getDialog().dismiss();
+            }
+        });
+
+        // show the progress bar while we load content.
         progressBar.setVisibility(View.VISIBLE);
 
         pageTitle = getArguments().getParcelable("title");
@@ -105,7 +113,6 @@
         }.execute();
 
         LinearLayout.LayoutParams lp = new 
LinearLayout.LayoutParams(inflater.getContext().getResources().getDisplayMetrics().widthPixels,
 (int)(inflater.getContext().getResources().getDisplayMetrics().density * 
DIALOG_HEIGHT));
-        lp.gravity = Gravity.BOTTOM;
         previewContainer.setLayoutParams(lp);
 
         return rootView;
@@ -130,8 +137,13 @@
     }
 
     private void layoutPreview(LinkPreviewContents contents) {
-        previewContainer.setVisibility(View.VISIBLE);
         titleText.setText(contents.getTitle().getDisplayText());
+        if (TextUtils.isEmpty(contents.getTitle().getDescription())) {
+            descriptionText.setVisibility(View.GONE);
+        } else {
+            descriptionText.setText(contents.getTitle().getDescription());
+            descriptionText.setVisibility(View.VISIBLE);
+        }
         extractText.setText(contents.getExtract());
         if (!TextUtils.isEmpty(contents.getTitle().getThumbUrl()) && 
app.showImages()) {
             Picasso.with(getActivity())

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I89ad1d8b4be7b8d1967129cf8c0d4dfbbb71cf18
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to