Skip to content

Commit 9a4d9c1

Browse files
committed
Updated gradle from Groovy to Kotlin and added Spotless
1 parent 3299a66 commit 9a4d9c1

23 files changed

+514
-170
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://editorconfig.org/
2+
# This configuration is used by ktlint when spotless invokes it
3+
4+
[*.{kt,kts}]
5+
ij_kotlin_allow_trailing_comma=true
6+
ij_kotlin_allow_trailing_comma_on_call_site=true
7+
ktlint_function_naming_ignore_when_annotated_with=Composable, Test
8+
ktlint_standard_backing-property-naming = disabled
9+
ktlint_standard_binary-expression-wrapping = disabled
10+
ktlint_standard_chain-method-continuation = disabled
11+
ktlint_standard_class-signature = disabled
12+
ktlint_standard_condition-wrapping = disabled
13+
ktlint_standard_function-expression-body = disabled
14+
ktlint_standard_function-literal = disabled
15+
ktlint_standard_function-type-modifier-spacing = disabled
16+
ktlint_standard_multiline-loop = disabled
17+
ktlint_standard_function-signature = disabled

WebView/WebkitWebView/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Webkit Web View Sample
2+
This is a sample app which uses the [Webkit library](https://developer.android.com/jetpack/androidx/releases/webkit#1.12.0)
3+
to implement passkey creation in WebView. It's a simple app that supports passkey creation and
4+
deletion via a webpage and server hosted on glitch.me.
5+
16
# Set Up Instructions
27
Assuming the GlitchMe site and server is up and running (the glitch me site can
38
be found [here](https://glitch.com/edit/#!/alder-sunny-bicycle)), this app should
@@ -11,7 +16,16 @@ signature is known to the server, which will be in the steps below.
1116
3. Double check there is a 'debug.keystore' file at the root. This is important
1217
as the server expects your app to have the SHA256 from this keystore.
1318
4. 'Run' the app via the 'run' button (the green play triangle).
14-
5. Enjoy!
19+
5. Wait for the webpage to load, and then try creating and deleting passkeys.
20+
21+
## Using the app
22+
1. Enter a username to register with the app. This can be any username you want to use.
23+
2. Tap through the password screen as the password will not be used in this sample.
24+
3. On the next screen, tap "Create a passkey" to go initiate the passkey creation process and go
25+
through the authentication process.
26+
4. If successful, a passkey will show up under "Your registered passkeys." Note that you can only
27+
create one passkey per platform for each user.
28+
5. You can delete passkeys from the list once they are created by selecting the delete icon.
1529

1630
## Running your own server
1731
If you'd like to manage a server directly, you can choose to Remix this project on glitch.me which
Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
/build
1+
# built application files
2+
*.apk
3+
*.ap_
4+
5+
# Mac files
6+
.DS_Store
7+
8+
# files for the dex VM
9+
*.dex
10+
11+
# Java class files
12+
*.class
13+
14+
# generated files
15+
bin/
16+
gen/
17+
18+
# Ignore gradle files
19+
.gradle/
20+
build/
21+
22+
# Local configuration file (sdk path, etc)
23+
local.properties
24+
25+
# Proguard folder generated by Eclipse
26+
proguard/
27+
proguard-project.txt
28+
29+
# Eclipse files
30+
.project
31+
.classpath
32+
.settings/
33+
34+
# Android Studio/IDEA
35+
*.iml
36+
.idea

WebView/WebkitWebView/app/build.gradle

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.io.FileInputStream
17+
import java.util.Properties
18+
19+
plugins {
20+
alias(libs.plugins.android.application)
21+
alias(libs.plugins.kotlin.android)
22+
}
23+
24+
// Load keystore properties for our signing key
25+
// (see developer.android.com/studio/publish/app-signing)
26+
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
27+
val keystoreProperties = Properties()
28+
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
29+
30+
android {
31+
namespace = "com.google.webkit.webviewsample"
32+
compileSdk = 35
33+
34+
defaultConfig {
35+
applicationId = "com.google.webkit.webviewsample"
36+
minSdk = 29
37+
targetSdk = 35
38+
versionCode = 1
39+
versionName = "1.0"
40+
41+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
42+
vectorDrawables {
43+
useSupportLibrary = true
44+
}
45+
buildConfigField("String", "API_BASE_URL", "\"https://alder-sunny-bicycle.glitch.me/auth\"")
46+
resValue("string", "host", "https://alder-sunny-bicycle.glitch.me")
47+
}
48+
49+
signingConfigs {
50+
create("config") {
51+
keyAlias = keystoreProperties["keyAlias"].toString()
52+
keyPassword = keystoreProperties["keyPassword"].toString()
53+
storeFile = file(keystoreProperties["storeFile"].toString())
54+
storePassword = keystoreProperties["storePassword"].toString()
55+
}
56+
}
57+
58+
buildTypes {
59+
release {
60+
isMinifyEnabled = false
61+
proguardFiles(
62+
getDefaultProguardFile("proguard-android-optimize.txt"),
63+
"proguard-rules.pro"
64+
)
65+
signingConfig = signingConfigs.getByName("config")
66+
}
67+
68+
debug {
69+
signingConfig = signingConfigs.getByName("config")
70+
}
71+
}
72+
compileOptions {
73+
sourceCompatibility = JavaVersion.VERSION_1_8
74+
targetCompatibility = JavaVersion.VERSION_1_8
75+
}
76+
kotlinOptions {
77+
jvmTarget = "1.8"
78+
}
79+
buildFeatures {
80+
compose = true
81+
buildConfig = true
82+
}
83+
composeOptions {
84+
kotlinCompilerExtensionVersion = "1.5.1"
85+
}
86+
packaging {
87+
resources {
88+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
89+
}
90+
}
91+
}
92+
93+
dependencies {
94+
implementation(libs.core.ktx)
95+
implementation(libs.lifecycle.runtime.ktx)
96+
implementation(libs.activity.compose)
97+
implementation(platform(libs.compose.bom))
98+
implementation(libs.compose.ui)
99+
implementation(libs.compose.graphics)
100+
implementation(libs.compose.tooling.preview)
101+
implementation(libs.compose.material)
102+
implementation(libs.webkit)
103+
testImplementation(libs.junit)
104+
androidTestImplementation(libs.junit)
105+
androidTestImplementation(libs.espresso.core)
106+
androidTestImplementation(platform(libs.compose.bom))
107+
debugImplementation(libs.compose.ui.tooling)
108+
debugImplementation(libs.compose.ui.test.manifest)
109+
}

WebView/WebkitWebView/app/proguard-rules.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add project specific ProGuard rules here.
22
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
3+
# proguardFiles setting in build.gradle.kts.
44
#
55
# For more details, see
66
# http://developer.android.com/guide/developing/tools/proguard.html

WebView/WebkitWebView/app/src/main/AndroidManifest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2024 Google LLC
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
218
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
319
xmlns:tools="http://schemas.android.com/tools">
420
<uses-permission android:name="android.permission.INTERNET" />
Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.google.webkit.webviewsample
217

318
import android.os.Bundle
@@ -14,7 +29,6 @@ import androidx.webkit.WebSettingsCompat
1429
import androidx.webkit.WebViewFeature
1530
import com.google.webkit.webviewsample.theme.WebViewSampleTheme
1631

17-
1832
/**
1933
* Generates a WebView that uses the Webkit API to handle WebView passkey authentication requests.
2034
*/
@@ -26,40 +40,31 @@ class MainActivity : ComponentActivity() {
2640
WebViewSampleTheme {
2741
Surface(
2842
modifier = Modifier.fillMaxSize(),
29-
color = MaterialTheme.colors.background
43+
color = MaterialTheme.colors.background,
3044
) {
31-
AndroidView(factory = {
32-
WebView(it).apply {
33-
settings.javaScriptEnabled = true
34-
webViewClient = WebViewClientImpl()
35-
}
36-
},
45+
AndroidView(
46+
factory = {
47+
WebView(it).apply {
48+
settings.javaScriptEnabled = true
49+
webViewClient = WebViewClientImpl()
50+
}
51+
},
3752
update = { webView ->
3853
run {
3954
webView.loadUrl(url)
4055
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_AUTHENTICATION)) {
41-
Log.e("WebViewPasskeyDemo", "WebView supports passkeys.")
4256
WebSettingsCompat.setWebAuthenticationSupport(
4357
webView.settings,
4458
WebSettingsCompat.WEB_AUTHENTICATION_SUPPORT_FOR_APP,
4559
)
46-
Log.e(
47-
"WebViewPasskeyDemo",
48-
"getWebAuthenticationSupport result: " +
49-
WebSettingsCompat.getWebAuthenticationSupport(
50-
webView.settings
51-
),
52-
)
5360
} else {
54-
Log.e(
55-
"WebViewPasskeyDemo",
56-
"WebView does not support passkeys."
57-
)
61+
// App does not support passkeys in WebView.
5862
}
5963
}
60-
})
64+
},
65+
)
6166
}
6267
}
6368
}
6469
}
65-
}
70+
}

0 commit comments

Comments
 (0)