Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-app browser integration #17

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android-app/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions android-app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
android:exported="true" />
<!-- WebViewClient -->
<activity
android:name=".webviewclient.WebViewClientActivity"
android:name=".webviewclient.CustomTabActivity"
android:exported="true"
android:label="@string/webview_client" />
android:label="@string/custom_tabs" />
<activity
android:name=".webviewclient.TrustlyWebViewClientRedirectActivity"
android:exported="true">
Expand All @@ -42,23 +42,6 @@
<data android:scheme="web-view-client-redirect" />
</intent-filter>
</activity>
<!-- WebChromeClient -->
<activity
android:name=".webchromeclient.WebChromeClientActivity"
android:exported="true"
android:label="@string/webchrome_client" />
<activity
android:name=".webchromeclient.TrustlyWebChromeClientRedirectActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="web-chrome-client-redirect" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@ import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import net.trustly.inappbrowserandroid.webchromeclient.WebChromeClientActivity
import net.trustly.inappbrowserandroid.webviewclient.WebViewClientActivity
import net.trustly.inappbrowserandroid.webviewclient.CustomTabActivity

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val webViewClientButton = findViewById<Button>(R.id.webViewClientButton)
webViewClientButton.setOnClickListener {
startActivity(Intent(this, WebViewClientActivity::class.java))
}

val webViewChromeButton = findViewById<Button>(R.id.webViewChromeButton)
webViewChromeButton.setOnClickListener {
startActivity(Intent(this, WebChromeClientActivity::class.java))
val customTabButton = findViewById<Button>(R.id.customTabsButton)
customTabButton.setOnClickListener {
startActivity(Intent(this, CustomTabActivity::class.java))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package net.trustly.inappbrowserandroid

object TrustlyConstants {

const val TRUSTLY_URL = "http://localhost:3000?integrationContext=InAppBrowser&urlScheme="
const val TRUSTLY_URL = "http://10.200.206.238:3001?integrationContext=FullInAppBrowser&urlScheme="
const val OAUTH_LOGIN_PATH = "/oauth/login"
const val TRUSTLY_PROCEED_TO_CHOOSE_ACCOUNT_SCRIPT = "javascript:window.Trustly.proceedToChooseAccount();"

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.trustly.inappbrowserandroid.webviewclient

import android.annotation.SuppressLint
import android.content.Context
import android.net.Uri
import android.os.Bundle
import androidx.browser.customtabs.CustomTabsIntent
import net.trustly.inappbrowserandroid.TrustlyConstants
import net.trustly.inappbrowserandroid.WebViewBaseActivity

class CustomTabActivity : WebViewBaseActivity() {

@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
launchUrl(this@CustomTabActivity, TrustlyConstants.TRUSTLY_URL + "web-view-client-redirect")
}

private fun launchUrl(context: Context, url: String) {
val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(context, Uri.parse(url))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TrustlyWebViewClientRedirectActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Intent(this, WebViewClientActivity::class.java).apply {
Intent(this, CustomTabActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
}.run { startActivity(this) }
finish()
Expand Down

This file was deleted.

14 changes: 2 additions & 12 deletions android-app/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/webViewClientButton"
android:id="@+id/customTabsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/webview_client"
android:text="@string/custom_tabs"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/webViewChromeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/webchrome_client"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/webViewClientButton" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 1 addition & 2 deletions android-app/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name">InAppBrowserAndroid</string>
<string name="webchrome_client">WebChromeClient</string>
<string name="webview_client">WebViewClient</string>
<string name="custom_tabs">Custom Tabs</string>
</resources>
Loading