Merge pull request #5634 from nextcloud/previewGradient

Add gradient to preview images in toolbar
This commit is contained in:
Andy Scherzinger 2020-03-12 08:14:58 +01:00 committed by GitHub
commit 6df2d58de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 7 deletions

View file

@ -27,6 +27,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@ -49,6 +50,7 @@ import androidx.core.content.ContextCompat;
public abstract class ToolbarActivity extends BaseActivity {
private ProgressBar mProgressBar;
private ImageView mPreviewImage;
private FrameLayout mPreviewImageContainer;
private LinearLayout mInfoBox;
private TextView mInfoBoxMessage;
@ -79,6 +81,7 @@ public abstract class ToolbarActivity extends BaseActivity {
mInfoBoxMessage = findViewById(R.id.info_box_message);
mPreviewImage = findViewById(R.id.preview_image);
mPreviewImageContainer = findViewById(R.id.preview_image_frame);
ThemeUtils.colorStatusBar(this, primaryColor);
@ -191,8 +194,8 @@ public abstract class ToolbarActivity extends BaseActivity {
* @param visibility visibility of the preview image
*/
public void setPreviewImageVisibility(int visibility) {
if (mPreviewImage != null) {
mPreviewImage.setVisibility(visibility);
if (mPreviewImage != null && mPreviewImageContainer != null) {
mPreviewImageContainer.setVisibility(visibility);
}
}

View file

@ -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="#00000000"
android:startColor="#00000000"
android:centerColor="#00000000" />
<corners android:radius="0dp" />
</shape>

View file

@ -32,13 +32,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/preview_image"
<FrameLayout
android:id="@+id/preview_image_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:contentDescription="@string/preview_image_description"
android:scaleType="centerCrop"
android:visibility="gone" />
android:visibility="gone">
<ImageView
android:id="@+id/preview_image"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:contentDescription="@string/preview_image_description"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:background="@drawable/preview_image_gradient_shape" />
</FrameLayout>
<androidx.appcompat.widget.Toolbar
android:id="@id/toolbar"