Add WearApp with scaffolding for navigation.
Bug: 299580143
Test: N/A only project scaffolding was added
Change-Id: I56f453bb9def0aa4a5e9d3d5d6a74d88adbae9f5
diff --git a/packages/CredentialManager/Android.bp b/packages/CredentialManager/Android.bp
index 233aee2..fe26dc3 100644
--- a/packages/CredentialManager/Android.bp
+++ b/packages/CredentialManager/Android.bp
@@ -50,46 +50,3 @@
proguard_compatibility: false,
},
}
-
-android_app {
- name: "ClockworkCredentialManager",
- defaults: ["platform_app_defaults"],
- certificate: "platform",
- manifest: "wear/AndroidManifest.xml",
- srcs: ["wear/src/**/*.kt"],
- resource_dirs: ["wear/res"],
-
- dex_preopt: {
- profile_guided: true,
- profile: "wear/profile.txt.prof",
- },
-
- static_libs: [
- "PlatformComposeCore",
- "androidx.activity_activity-compose",
- "androidx.appcompat_appcompat",
- "androidx.compose.foundation_foundation",
- "androidx.compose.foundation_foundation-layout",
- "androidx.compose.material_material-icons-core",
- "androidx.compose.material_material-icons-extended",
- "androidx.compose.ui_ui",
- "androidx.core_core-ktx",
- "androidx.credentials_credentials",
- "androidx.lifecycle_lifecycle-extensions",
- "androidx.lifecycle_lifecycle-livedata",
- "androidx.lifecycle_lifecycle-runtime-ktx",
- "androidx.lifecycle_lifecycle-viewmodel-compose",
- "androidx.wear.compose_compose-foundation",
- "androidx.wear.compose_compose-material",
- "kotlinx-coroutines-core",
- ],
-
- platform_apis: true,
- privileged: true,
-
- kotlincflags: ["-Xjvm-default=all"],
-
- optimize: {
- proguard_compatibility: false,
- },
-}
diff --git a/packages/CredentialManager/wear/Android.bp b/packages/CredentialManager/wear/Android.bp
new file mode 100644
index 0000000..639e8d1
--- /dev/null
+++ b/packages/CredentialManager/wear/Android.bp
@@ -0,0 +1,53 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+android_app {
+ name: "ClockworkCredentialManager",
+ defaults: ["platform_app_defaults"],
+ certificate: "platform",
+ manifest: "AndroidManifest.xml",
+ srcs: ["src/**/*.kt"],
+ resource_dirs: ["res"],
+
+ dex_preopt: {
+ profile_guided: true,
+ profile: "profile.txt.prof",
+ },
+
+ static_libs: [
+ "Horologist",
+ "PlatformComposeCore",
+ "androidx.activity_activity-compose",
+ "androidx.appcompat_appcompat",
+ "androidx.compose.foundation_foundation",
+ "androidx.compose.foundation_foundation-layout",
+ "androidx.compose.material_material-icons-core",
+ "androidx.compose.material_material-icons-extended",
+ "androidx.compose.runtime_runtime",
+ "androidx.compose.ui_ui",
+ "androidx.core_core-ktx",
+ "androidx.lifecycle_lifecycle-extensions",
+ "androidx.lifecycle_lifecycle-livedata",
+ "androidx.lifecycle_lifecycle-runtime-ktx",
+ "androidx.lifecycle_lifecycle-viewmodel-compose",
+ "androidx.wear.compose_compose-foundation",
+ "androidx.wear.compose_compose-material",
+ "androidx.wear.compose_compose-navigation",
+ "kotlinx-coroutines-core",
+ ],
+
+ platform_apis: true,
+ privileged: true,
+
+ kotlincflags: ["-Xjvm-default=all"],
+
+ optimize: {
+ proguard_compatibility: false,
+ },
+}
diff --git a/packages/CredentialManager/wear/AndroidManifest.xml b/packages/CredentialManager/wear/AndroidManifest.xml
index 001a56d..90248734 100644
--- a/packages/CredentialManager/wear/AndroidManifest.xml
+++ b/packages/CredentialManager/wear/AndroidManifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
- * Copyright (c) 2017 Google Inc.
+ * Copyright (c) 2023 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.credentialmanager">
+ <uses-feature android:name="android.hardware.type.watch" />
+
<uses-permission android:name="android.permission.LAUNCH_CREDENTIAL_SELECTOR"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
@@ -28,17 +30,15 @@
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:label="@string/app_name"
- android:supportsRtl="true"
- android:theme="@style/Theme.CredentialSelector">
+ android:supportsRtl="true">
<activity
- android:name=".CredentialSelectorActivity"
+ android:name=".ui.CredentialSelectorActivity"
android:exported="true"
android:permission="android.permission.LAUNCH_CREDENTIAL_SELECTOR"
android:launchMode="singleTop"
android:label="@string/app_name"
- android:excludeFromRecents="true"
- android:theme="@style/Theme.CredentialSelector">
+ android:excludeFromRecents="true">
</activity>
</application>
diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/CredentialSelectorActivity.kt
similarity index 68%
rename from packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt
rename to packages/CredentialManager/wear/src/com/android/credentialmanager/ui/CredentialSelectorActivity.kt
index f7b2499..77fffaa 100644
--- a/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt
+++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/CredentialSelectorActivity.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,19 +14,29 @@
* limitations under the License.
*/
+package com.android.credentialmanager.ui
+
import android.os.Bundle
-import androidx.activity.compose.setContent
import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.navigation.NavHostController
import androidx.wear.compose.material.MaterialTheme
-import androidx.wear.compose.material.Text
+import androidx.wear.compose.navigation.rememberSwipeDismissableNavController
class CredentialSelectorActivity : ComponentActivity() {
+
+ lateinit var navController: NavHostController
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ setTheme(android.R.style.Theme_DeviceDefault)
+
setContent {
+ navController = rememberSwipeDismissableNavController()
+
MaterialTheme {
- Text("Credential Manager entry point")
+ WearApp(navController = navController)
}
}
}
diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/Screen.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/Screen.kt
new file mode 100644
index 0000000..ee6ea5e
--- /dev/null
+++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/Screen.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0N
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.credentialmanager.ui
+
+sealed class Screen(
+ val route: String,
+) {
+ object Main : Screen("main")
+}
diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/WearApp.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/WearApp.kt
new file mode 100644
index 0000000..5ec0c8c
--- /dev/null
+++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/WearApp.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0N
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:OptIn(ExperimentalHorologistApi::class)
+
+package com.android.credentialmanager.ui
+
+import androidx.compose.runtime.Composable
+import androidx.navigation.NavHostController
+import androidx.wear.compose.foundation.rememberSwipeToDismissBoxState
+import androidx.wear.compose.navigation.rememberSwipeDismissableNavHostState
+import com.android.credentialmanager.ui.screens.MainScreen
+import com.google.android.horologist.annotations.ExperimentalHorologistApi
+import com.google.android.horologist.compose.navscaffold.WearNavScaffold
+import com.google.android.horologist.compose.navscaffold.composable
+
+@Composable
+fun WearApp(
+ navController: NavHostController
+) {
+ val swipeToDismissBoxState = rememberSwipeToDismissBoxState()
+ val navHostState =
+ rememberSwipeDismissableNavHostState(swipeToDismissBoxState = swipeToDismissBoxState)
+
+ WearNavScaffold(
+ startDestination = Screen.Main.route,
+ navController = navController,
+ state = navHostState,
+ ) {
+ composable(Screen.Main.route) {
+ MainScreen()
+ }
+ }
+}
diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/MainScreen.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/MainScreen.kt
new file mode 100644
index 0000000..662d710
--- /dev/null
+++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/MainScreen.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0N
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.credentialmanager.ui.screens
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.wear.compose.material.Text
+
+@Composable
+fun MainScreen(modifier: Modifier = Modifier) {
+ Box(modifier = modifier, contentAlignment = Alignment.Center) {
+ Text("This is a placeholder for the main screen.")
+ }
+}