mirror of
https://github.com/readrops/Readrops.git
synced 2024-12-31 19:07:35 +01:00
WebViewActivity : set feed color to toolbar and hide it on scrolling down
This commit is contained in:
parent
097a5a7aae
commit
ed7293e1d8
@ -17,7 +17,9 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||
<activity android:name=".activities.WebViewActivity"></activity>
|
||||
<activity
|
||||
android:name=".activities.WebViewActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<service android:name=".utils.feedscolors.FeedsColorsIntentService" />
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.readrops.app.activities.WebViewActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/web_view"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/activity_web_view_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_scrollFlags="scroll|enterAlways" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/web_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user