Skip to content

Commit

Permalink
Merge pull request #5634 from nextcloud/previewGradient
Browse files Browse the repository at this point in the history
Add gradient to preview images in toolbar
  • Loading branch information
AndyScherzinger authored Mar 12, 2020
2 parents 7ab1377 + ed8ef97 commit 6df2d58
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand All @@ -49,6 +50,7 @@
public abstract class ToolbarActivity extends BaseActivity {
private ProgressBar mProgressBar;
private ImageView mPreviewImage;
private FrameLayout mPreviewImageContainer;
private LinearLayout mInfoBox;
private TextView mInfoBoxMessage;

Expand Down Expand Up @@ -79,6 +81,7 @@ protected void setupToolbar(boolean useBackgroundImage) {
mInfoBoxMessage = findViewById(R.id.info_box_message);

mPreviewImage = findViewById(R.id.preview_image);
mPreviewImageContainer = findViewById(R.id.preview_image_frame);

ThemeUtils.colorStatusBar(this, primaryColor);

Expand Down Expand Up @@ -191,8 +194,8 @@ public void setProgressBarVisibility(int visibility) {
* @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);
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/res/drawable/preview_image_gradient_shape.xml
Original file line number Diff line number Diff line change
@@ -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>
21 changes: 16 additions & 5 deletions src/main/res/layout/toolbar_standard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6df2d58

Please sign in to comment.