Skip to content

Commit

Permalink
Display scrollbars in article view
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp committed Jun 15, 2024
1 parent 420c77b commit befc8e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BasilReader"
android:theme="@style/Theme.CapyReader"
android:enableOnBackInvokedCallback="true"
tools:targetApi="33">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.BasilReader">
android:theme="@style/Theme.CapyReader">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/jocmp/capyreader/ui/components/WebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup.LayoutParams
import android.webkit.WebChromeClient
import android.webkit.WebResourceError
Expand All @@ -30,6 +31,7 @@ import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.jocmp.capyreader.R
import com.jocmp.capyreader.ui.components.LoadingState.Finished
import com.jocmp.capyreader.ui.components.LoadingState.Loading
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -195,7 +197,7 @@ fun WebView(

AndroidView(
factory = { context ->
(factory?.invoke(context) ?: WebView(context)).apply {
(factory?.invoke(context) ?: context.inflateWebView()).apply {
onCreated(this)

this.settings.javaScriptEnabled = true
Expand Down Expand Up @@ -677,3 +679,9 @@ val WebStateSaver: Saver<WebViewState, Any> = run {
}
)
}

private fun Context.inflateWebView(): WebView {
return LayoutInflater
.from(this)
.inflate(R.layout.article_webview, null, false) as WebView
}
6 changes: 6 additions & 0 deletions app/src/main/res/layout/article_webview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?><!--<LinearLayout -->
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarThumbVertical="?android:attr/textColorSecondary"
android:scrollbars="vertical" />
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.BasilReader" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.CapyReader" parent="Theme.AppCompat.DayNight.NoActionBar" />
</resources>

0 comments on commit befc8e9

Please sign in to comment.