From 63469ca5b22e1431b5925fca12dd9029e09be706 Mon Sep 17 00:00:00 2001 From: Tom Lee Date: Wed, 28 Feb 2024 21:08:17 -0800 Subject: [PATCH] More work on Android Quiltthub Webview app Still need to solve below problem: 1. Upon logout and log back in, the hub webapp doesn't get the token 2. Haven't handle token expires --- .idea/gradle.xml | 2 +- app/src/main/AndroidManifest.xml | 26 +++++++++++++++++ .../.gitignore | 0 .../build.gradle.kts | 4 +-- .../proguard-rules.pro | 0 .../ExampleInstrumentedTest.kt | 2 +- .../src/main/AndroidManifest.xml | 14 ++------- .../AppConfig.kt | 2 +- .../MainActivity.kt | 2 +- .../QuilttConnectorActivity.kt | 2 +- .../QuilttHubActivity.kt | 25 ++++++++++++---- .../SharedPreferencesHelper.kt | 2 +- .../ui/theme/Color.kt | 2 +- .../ui/theme/Theme.kt | 2 +- .../ui/theme/Type.kt | 2 +- .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../src/main/res/drawable/quiltt.xml | 0 .../src/main/res/drawable/quiltt_app_icon.xml | 27 ++++++++++++++++++ .../main/res/mipmap-anydpi/ic_launcher.xml | 0 .../res/mipmap-anydpi/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../src/main/res/values/colors.xml | 0 .../src/main/res/values/splash.xml | 0 .../src/main/res/values/strings.xml | 2 +- .../src/main/res/values/themes.xml | 0 .../ExampleUnitTest.kt | 2 +- settings.gradle.kts | 2 +- 37 files changed, 88 insertions(+), 32 deletions(-) rename {app_jetpack_compose => app_quiltthub_webview_example}/.gitignore (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/build.gradle.kts (95%) rename {app_jetpack_compose => app_quiltthub_webview_example}/proguard-rules.pro (100%) rename {app_jetpack_compose/src/androidTest/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/androidTest/java/app/quiltt/app_quiltthub_webview_example}/ExampleInstrumentedTest.kt (92%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/AndroidManifest.xml (72%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/AppConfig.kt (80%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/MainActivity.kt (98%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/QuilttConnectorActivity.kt (98%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/QuilttHubActivity.kt (85%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/SharedPreferencesHelper.kt (91%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/ui/theme/Color.kt (80%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/ui/theme/Theme.kt (97%) rename {app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example}/ui/theme/Type.kt (94%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/drawable/ic_launcher_background.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/drawable/quiltt.xml (100%) create mode 100644 app_quiltthub_webview_example/src/main/res/drawable/quiltt_app_icon.xml rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-anydpi/ic_launcher.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-anydpi/ic_launcher_round.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/values/colors.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/values/splash.xml (100%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/values/strings.xml (75%) rename {app_jetpack_compose => app_quiltthub_webview_example}/src/main/res/values/themes.xml (100%) rename {app_jetpack_compose/src/test/java/app/quiltt/app_jetpack_compose => app_quiltthub_webview_example/src/test/java/app/quiltt/app_quiltthub_webview_example}/ExampleUnitTest.kt (86%) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 0599b91..3805133 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,7 +10,7 @@ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index df6472e..126ca8e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,6 +18,9 @@ android:name=".QuilttConnectorActivity" android:launchMode="singleTop" android:exported="true"> + + + @@ -28,6 +31,29 @@ android:scheme="quilttandroidexample" android:host="open.kotlin.app" /> + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - logout() - startActivity((Intent(this, MainActivity::class.java))) +// startActivity((Intent(this, MainActivity::class.java))) } .setNegativeButton("No", null) .show() @@ -80,7 +85,12 @@ fun QuilttHubContent() { val url = "https://www.quiltthub.com/login?mode=webview&token=$token" Column { TopAppBar( - title = { Text(text = "Quiltt Hub") }, + title = { + Image( + painter = painterResource(id = R.drawable.quiltt_app_icon), + contentDescription = "Quiltt Hub Logo", + modifier = Modifier.size(40.dp)) + }, actions = { Button(onClick = { val intent = Intent(context, QuilttConnectorActivity::class.java) @@ -117,15 +127,18 @@ fun WebViewComposable(url: String) { webViewClient = object : WebViewClient() { val activity = context as QuilttHubActivity override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean { - val url = request?.url.toString() - if (url != null && url.startsWith("https://quiltt.app/mobile/hub/reconnect")) { - val urlComponents = Uri.parse(url.toString()) + val url = request?.url?.toString() + if (url != null && url.startsWith("https://www.quiltthub.com/mobile/hub/reconnect")) { + val urlComponents = Uri.parse(url) val connectionId = urlComponents.getQueryParameter("connectionId") val intent = Intent(context, QuilttConnectorActivity::class.java) intent.putExtra("connectionId", connectionId) activity.startActivity(intent) return true } + if (url != null && url.startsWith("https://www.quiltthub.com")) { + return false + } // TODO: Sometimes connector is publishing Options? if (url != null && url.startsWith("quilttconnector://")) { return true diff --git a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/SharedPreferencesHelper.kt b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/SharedPreferencesHelper.kt similarity index 91% rename from app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/SharedPreferencesHelper.kt rename to app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/SharedPreferencesHelper.kt index 96fa7db..ee55fff 100644 --- a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/SharedPreferencesHelper.kt +++ b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/SharedPreferencesHelper.kt @@ -1,4 +1,4 @@ -package app.quiltt.app_jetpack_compose +package app.quiltt.app_quiltthub_webview_example import android.content.Context import android.content.SharedPreferences diff --git a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Color.kt b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Color.kt similarity index 80% rename from app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Color.kt rename to app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Color.kt index d336c01..ea54166 100644 --- a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Color.kt +++ b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Color.kt @@ -1,4 +1,4 @@ -package app.quiltt.app_jetpack_compose.ui.theme +package app.quiltt.app_quiltthub_webview_example.ui.theme import androidx.compose.ui.graphics.Color diff --git a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Theme.kt b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Theme.kt similarity index 97% rename from app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Theme.kt rename to app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Theme.kt index 6a81000..7fda95f 100644 --- a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Theme.kt +++ b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Theme.kt @@ -1,4 +1,4 @@ -package app.quiltt.app_jetpack_compose.ui.theme +package app.quiltt.app_quiltthub_webview_example.ui.theme import android.app.Activity import android.os.Build diff --git a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Type.kt b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Type.kt similarity index 94% rename from app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Type.kt rename to app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Type.kt index a99d074..9969be1 100644 --- a/app_jetpack_compose/src/main/java/app/quiltt/app_jetpack_compose/ui/theme/Type.kt +++ b/app_quiltthub_webview_example/src/main/java/app/quiltt/app_quiltthub_webview_example/ui/theme/Type.kt @@ -1,4 +1,4 @@ -package app.quiltt.app_jetpack_compose.ui.theme +package app.quiltt.app_quiltthub_webview_example.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle diff --git a/app_jetpack_compose/src/main/res/drawable/ic_launcher_background.xml b/app_quiltthub_webview_example/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from app_jetpack_compose/src/main/res/drawable/ic_launcher_background.xml rename to app_quiltthub_webview_example/src/main/res/drawable/ic_launcher_background.xml diff --git a/app_jetpack_compose/src/main/res/drawable/ic_launcher_foreground.xml b/app_quiltthub_webview_example/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from app_jetpack_compose/src/main/res/drawable/ic_launcher_foreground.xml rename to app_quiltthub_webview_example/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/app_jetpack_compose/src/main/res/drawable/quiltt.xml b/app_quiltthub_webview_example/src/main/res/drawable/quiltt.xml similarity index 100% rename from app_jetpack_compose/src/main/res/drawable/quiltt.xml rename to app_quiltthub_webview_example/src/main/res/drawable/quiltt.xml diff --git a/app_quiltthub_webview_example/src/main/res/drawable/quiltt_app_icon.xml b/app_quiltthub_webview_example/src/main/res/drawable/quiltt_app_icon.xml new file mode 100644 index 0000000..9d9568c --- /dev/null +++ b/app_quiltthub_webview_example/src/main/res/drawable/quiltt_app_icon.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + diff --git a/app_jetpack_compose/src/main/res/mipmap-anydpi/ic_launcher.xml b/app_quiltthub_webview_example/src/main/res/mipmap-anydpi/ic_launcher.xml similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-anydpi/ic_launcher.xml rename to app_quiltthub_webview_example/src/main/res/mipmap-anydpi/ic_launcher.xml diff --git a/app_jetpack_compose/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app_quiltthub_webview_example/src/main/res/mipmap-anydpi/ic_launcher_round.xml similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename to app_quiltthub_webview_example/src/main/res/mipmap-anydpi/ic_launcher_round.xml diff --git a/app_jetpack_compose/src/main/res/mipmap-hdpi/ic_launcher.webp b/app_quiltthub_webview_example/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-hdpi/ic_launcher.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app_quiltthub_webview_example/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-mdpi/ic_launcher.webp b/app_quiltthub_webview_example/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-mdpi/ic_launcher.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app_quiltthub_webview_example/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/app_jetpack_compose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app_quiltthub_webview_example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from app_jetpack_compose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to app_quiltthub_webview_example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/app_jetpack_compose/src/main/res/values/colors.xml b/app_quiltthub_webview_example/src/main/res/values/colors.xml similarity index 100% rename from app_jetpack_compose/src/main/res/values/colors.xml rename to app_quiltthub_webview_example/src/main/res/values/colors.xml diff --git a/app_jetpack_compose/src/main/res/values/splash.xml b/app_quiltthub_webview_example/src/main/res/values/splash.xml similarity index 100% rename from app_jetpack_compose/src/main/res/values/splash.xml rename to app_quiltthub_webview_example/src/main/res/values/splash.xml diff --git a/app_jetpack_compose/src/main/res/values/strings.xml b/app_quiltthub_webview_example/src/main/res/values/strings.xml similarity index 75% rename from app_jetpack_compose/src/main/res/values/strings.xml rename to app_quiltthub_webview_example/src/main/res/values/strings.xml index 8a7caea..8288d6e 100644 --- a/app_jetpack_compose/src/main/res/values/strings.xml +++ b/app_quiltthub_webview_example/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - App Jetpack Compose + Quiltt Hub QuilttConnectorActivity QuilttHubActivity \ No newline at end of file diff --git a/app_jetpack_compose/src/main/res/values/themes.xml b/app_quiltthub_webview_example/src/main/res/values/themes.xml similarity index 100% rename from app_jetpack_compose/src/main/res/values/themes.xml rename to app_quiltthub_webview_example/src/main/res/values/themes.xml diff --git a/app_jetpack_compose/src/test/java/app/quiltt/app_jetpack_compose/ExampleUnitTest.kt b/app_quiltthub_webview_example/src/test/java/app/quiltt/app_quiltthub_webview_example/ExampleUnitTest.kt similarity index 86% rename from app_jetpack_compose/src/test/java/app/quiltt/app_jetpack_compose/ExampleUnitTest.kt rename to app_quiltthub_webview_example/src/test/java/app/quiltt/app_quiltthub_webview_example/ExampleUnitTest.kt index cfa3755..29bcdcb 100644 --- a/app_jetpack_compose/src/test/java/app/quiltt/app_jetpack_compose/ExampleUnitTest.kt +++ b/app_quiltthub_webview_example/src/test/java/app/quiltt/app_quiltthub_webview_example/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package app.quiltt.app_jetpack_compose +package app.quiltt.app_quiltthub_webview_example import org.junit.Test diff --git a/settings.gradle.kts b/settings.gradle.kts index e78607a..7fa68c3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,4 +16,4 @@ dependencyResolutionManagement { rootProject.name = "quiltt-android" include(":app") include(":connector") -include(":app_jetpack_compose") +include(":app_quiltthub_webview_example")