GoogleFragment: Show progress on page load
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -23,10 +23,12 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.webkit.CookieManager
|
import android.webkit.CookieManager
|
||||||
|
import android.webkit.WebChromeClient
|
||||||
import android.webkit.WebSettings
|
import android.webkit.WebSettings
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
@@ -72,6 +74,23 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
|
|||||||
cookieManager.acceptThirdPartyCookies(this)
|
cookieManager.acceptThirdPartyCookies(this)
|
||||||
cookieManager.setAcceptThirdPartyCookies(this, true)
|
cookieManager.setAcceptThirdPartyCookies(this, true)
|
||||||
|
|
||||||
|
webChromeClient = object : WebChromeClient() {
|
||||||
|
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||||
|
super.onProgressChanged(view, newProgress)
|
||||||
|
|
||||||
|
if (newProgress != 0) {
|
||||||
|
binding.progressBar.also {
|
||||||
|
it.isVisible = newProgress < 100
|
||||||
|
it.isIndeterminate = false
|
||||||
|
it.max = 100
|
||||||
|
it.progress = newProgress
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binding.progressBar.isIndeterminate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
webViewClient = object : WebViewClient() {
|
webViewClient = object : WebViewClient() {
|
||||||
override fun onPageFinished(view: WebView, url: String) {
|
override fun onPageFinished(view: WebView, url: String) {
|
||||||
val cookies = CookieManager.getInstance().getCookie(url)
|
val cookies = CookieManager.getInstance().getCookie(url)
|
||||||
@@ -119,6 +138,7 @@ class GoogleFragment : Fragment(R.layout.fragment_google) {
|
|||||||
GoogleFragmentDirections.actionGoogleFragmentToSplashFragment()
|
GoogleFragmentDirections.actionGoogleFragmentToSplashFragment()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.accountFragment -> {
|
R.id.accountFragment -> {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
GoogleFragmentDirections.actionGoogleFragmentToAccountFragment()
|
GoogleFragmentDirections.actionGoogleFragmentToAccountFragment()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
~ Aurora Store
|
~ Aurora Store
|
||||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||||
~
|
~
|
||||||
@@ -18,13 +19,28 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
tools:context=".view.ui.account.GoogleFragment">
|
tools:context=".view.ui.account.GoogleFragment">
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
app:indicatorColor="?android:colorAccent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:trackCornerRadius="10dp"
|
||||||
|
app:trackThickness="5dp" />
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/webview"
|
android:id="@+id/webview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user