From ed7293e1d8b9329ab688aca70bf6a92f36239d9a Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 20 Oct 2019 19:20:27 +0200 Subject: [PATCH] WebViewActivity : set feed color to toolbar and hide it on scrolling down --- app/src/main/AndroidManifest.xml | 4 ++- .../readrops/app/activities/ItemActivity.java | 1 + .../app/activities/WebViewActivity.kt | 8 ++++- app/src/main/res/layout/activity_web_view.xml | 30 +++++++++++++++---- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 22e9abad..854948e9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,9 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:ignore="AllowBackup,GoogleAppIndexingWarning"> - + diff --git a/app/src/main/java/com/readrops/app/activities/ItemActivity.java b/app/src/main/java/com/readrops/app/activities/ItemActivity.java index bc18683a..e92058bd 100644 --- a/app/src/main/java/com/readrops/app/activities/ItemActivity.java +++ b/app/src/main/java/com/readrops/app/activities/ItemActivity.java @@ -233,6 +233,7 @@ public class ItemActivity extends AppCompatActivity { private void openInWebView() { Intent intent = new Intent(this, WebViewActivity.class); intent.putExtra(WebViewActivity.WEB_URL, itemWithFeed.getItem().getLink()); + intent.putExtra(WebViewActivity.ACTION_BAR_COLOR, itemWithFeed.getColor() != 0 ? itemWithFeed.getColor() : itemWithFeed.getBgColor()); startActivity(intent); } diff --git a/app/src/main/java/com/readrops/app/activities/WebViewActivity.kt b/app/src/main/java/com/readrops/app/activities/WebViewActivity.kt index deec7156..28dc1acd 100644 --- a/app/src/main/java/com/readrops/app/activities/WebViewActivity.kt +++ b/app/src/main/java/com/readrops/app/activities/WebViewActivity.kt @@ -1,6 +1,7 @@ package com.readrops.app.activities import android.annotation.SuppressLint +import android.graphics.drawable.ColorDrawable import android.net.Uri import android.os.Bundle import android.view.MenuItem @@ -9,6 +10,7 @@ import android.webkit.WebSettings import android.webkit.WebView import android.webkit.WebViewClient import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.databinding.DataBindingUtil import com.readrops.app.R import com.readrops.app.databinding.ActivityWebViewBinding @@ -20,9 +22,12 @@ class WebViewActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_web_view) - supportActionBar?.setDisplayHomeAsUpEnabled(true) + setSupportActionBar(binding.activityWebViewToolbar) + supportActionBar?.setDisplayHomeAsUpEnabled(true) title = "" + val actionBarColor = intent.getIntExtra(ACTION_BAR_COLOR, ContextCompat.getColor(this, R.color.colorPrimary)) + supportActionBar?.setBackgroundDrawable(ColorDrawable(actionBarColor)) setWebViewSettings() val url: String = intent.getStringExtra(WEB_URL) @@ -74,5 +79,6 @@ class WebViewActivity : AppCompatActivity() { companion object { const val WEB_URL = "webUrl" + const val ACTION_BAR_COLOR = "actionBarColor" } } diff --git a/app/src/main/res/layout/activity_web_view.xml b/app/src/main/res/layout/activity_web_view.xml index 49f74826..2c99a076 100644 --- a/app/src/main/res/layout/activity_web_view.xml +++ b/app/src/main/res/layout/activity_web_view.xml @@ -1,17 +1,37 @@ - - + android:layout_height="wrap_content" + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> - + + + + + + + + + +