Browse Source

set gradient via imageview for markdown previews

Fixes #6034

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 years ago
parent
commit
94b31a0a37

BIN
screenshots/gplay/debug/richworkspaces_dark.png


BIN
screenshots/gplay/debug/richworkspaces_light.png


+ 0 - 11
src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -348,17 +348,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
 
             PreviewTextFragment.setText(headerViewHolder.headerText, text, null, activity, true, true);
             headerViewHolder.headerView.setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked());
-
-            Shader shader = new LinearGradient(0,
-                                               headerViewHolder.headerText.getHeight()-20,
-                                               0,
-                                               headerViewHolder.headerText.getHeight() - 100,
-                                               activity.getResources().getColor(R.color.bg_default),
-                                               activity.getResources().getColor(R.color.text_color),
-                                               Shader.TileMode.CLAMP
-            );
-
-            headerViewHolder.headerText.getPaint().setShader(shader);
         } else {
             OCFileListGridImageViewHolder gridViewHolder = (OCFileListGridImageViewHolder) holder;
 

+ 13 - 0
src/main/res/drawable-night/preview_markdown_gradient_shape.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <gradient
+        android:angle="270"
+        android:endColor="#121212"
+        android:startColor="#00121212"
+        android:centerColor="#00121212" />
+
+    <corners android:radius="0dp" />
+
+</shape>

+ 13 - 0
src/main/res/drawable/preview_markdown_gradient_shape.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <gradient
+        android:angle="270"
+        android:endColor="#FFFFFF"
+        android:startColor="#00FFFFFF"
+        android:centerColor="#00FFFFFF" />
+
+    <corners android:radius="0dp" />
+
+</shape>

+ 9 - 3
src/main/res/layout/list_header.xml

@@ -19,7 +19,7 @@
   along with this program. If not, see <https://www.gnu.org/licenses/>.
   -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/headerView"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -30,9 +30,15 @@
         android:id="@+id/headerText"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:paddingTop="@dimen/standard_padding"
         android:paddingLeft="@dimen/standard_padding"
+        android:paddingTop="@dimen/standard_padding"
         android:paddingRight="@dimen/standard_padding"
         android:paddingBottom="@dimen/zero"
         android:textColor="@color/text_color" />
-</LinearLayout>
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:contentDescription="@null"
+        android:src="@drawable/preview_markdown_gradient_shape" />
+</FrameLayout>