-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PWN-933 - Add terms of service to JS bridge (#2190)
- Loading branch information
1 parent
bdce0fd
commit 98b9311
Showing
7 changed files
with
160 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.p2p.wallet.url | ||
|
||
import androidx.core.view.isVisible | ||
import android.graphics.Bitmap | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import org.p2p.wallet.R | ||
import org.p2p.wallet.common.mvp.BaseMvpFragment | ||
import org.p2p.wallet.common.mvp.MvpView | ||
import org.p2p.wallet.common.mvp.NoOpPresenter | ||
import org.p2p.wallet.databinding.FragmentOpenUrlBinding | ||
import org.p2p.wallet.utils.args | ||
import org.p2p.wallet.utils.popBackStack | ||
import org.p2p.wallet.utils.viewbinding.viewBinding | ||
import org.p2p.wallet.utils.withArgs | ||
|
||
class OpenUrlFragment : BaseMvpFragment<MvpView, NoOpPresenter<MvpView>>( | ||
R.layout.fragment_open_url | ||
) { | ||
|
||
companion object { | ||
private const val ARG_URL = "ARG_URL" | ||
private const val ARG_BACK_ENABLED = "ARG_BACK_ENABLED" | ||
private const val ARG_TITLE = "ARG_TITLE" | ||
fun create( | ||
url: String, | ||
title: String? = null, | ||
isBackEnabled: Boolean = true, | ||
): OpenUrlFragment { | ||
return OpenUrlFragment() | ||
.withArgs( | ||
ARG_URL to url, | ||
ARG_BACK_ENABLED to isBackEnabled, | ||
ARG_TITLE to title | ||
) | ||
} | ||
} | ||
|
||
override val presenter = NoOpPresenter<MvpView>() | ||
|
||
private val binding: FragmentOpenUrlBinding by viewBinding() | ||
|
||
private val webViewClient = object : WebViewClient() { | ||
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) { | ||
binding.progressBar.isVisible = true | ||
super.onPageStarted(view, url, favicon) | ||
} | ||
|
||
override fun onPageFinished(view: WebView?, url: String?) { | ||
if (view?.progress == 100) { | ||
binding.progressBar.isVisible = false | ||
} | ||
super.onPageFinished(view, url) | ||
} | ||
} | ||
|
||
private val toolbarTitle: String? by args(ARG_TITLE) | ||
private val isBackEnabled: Boolean by args(ARG_BACK_ENABLED, true) | ||
private val url: String by args(ARG_URL) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
if (isBackEnabled) { | ||
binding.toolbar.setNavigationOnClickListener { popBackStack() } | ||
} else { | ||
binding.toolbar.navigationIcon = null | ||
} | ||
if (toolbarTitle != null) { | ||
binding.toolbar.title = toolbarTitle | ||
} | ||
|
||
binding.webViewUrl.webViewClient = webViewClient | ||
binding.webViewUrl.loadUrl(url) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
binding.webViewUrl.onResume() | ||
binding.webViewUrl.requestFocus() | ||
} | ||
|
||
override fun onPause() { | ||
binding.webViewUrl.onPause() | ||
super.onPause() | ||
} | ||
|
||
override fun onDestroyView() { | ||
binding.webViewUrl.destroy() | ||
super.onDestroyView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<org.p2p.uikit.organisms.UiKitToolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@color/bg_snow" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:navigationIcon="@drawable/ic_back" | ||
app:title="" /> | ||
|
||
<WebView | ||
android:id="@+id/webViewUrl" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/toolbar" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/progressBar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:indeterminateOnly="true" | ||
android:visibility="gone" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/toolbar" | ||
tools:visibility="visible" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters