diff options
author | 2024-10-29 15:57:41 +1100 | |
---|---|---|
committer | 2024-10-31 15:55:12 +1100 | |
commit | ec686c197ff56c15257c15a4defbb3aaa3ad48cb (patch) | |
tree | f9a0c5515f7768d8124412491cd4b9b78e89fd90 /compose | |
parent | 3bdd0fbfc08550544464b2bb34b6b84993358241 (diff) |
Support Hilt DI on DocumentsUICompose
Bug: 376167559
Test: m DocumentsUICompose
Flag: EXEMPT development only change
Change-Id: I90001c46ed26c29de447869bdddf7e2c52822f4d
Diffstat (limited to 'compose')
-rw-r--r-- | compose/Android.bp | 2 | ||||
-rw-r--r-- | compose/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | compose/src/com/android/documentsui/compose/DocumentsUIApplication.kt | 23 | ||||
-rw-r--r-- | compose/src/com/android/documentsui/compose/MainActivity.kt | 11 |
4 files changed, 32 insertions, 5 deletions
diff --git a/compose/Android.bp b/compose/Android.bp index 072aa167d..f00bf4c20 100644 --- a/compose/Android.bp +++ b/compose/Android.bp @@ -37,8 +37,10 @@ android_library { "androidx.compose.runtime_runtime", "androidx.compose.ui_ui", "androidx.core_core-ktx", + "androidx.hilt_hilt-navigation-compose", "androidx.lifecycle_lifecycle-runtime-compose", "androidx.lifecycle_lifecycle-runtime-ktx", + "hilt_android", "modules-utils-build_system", ], diff --git a/compose/AndroidManifest.xml b/compose/AndroidManifest.xml index 49f5629f4..dbed77310 100644 --- a/compose/AndroidManifest.xml +++ b/compose/AndroidManifest.xml @@ -41,6 +41,7 @@ <uses-permission android:name="android.permission.READ_DEVICE_CONFIG"/> <application + android:name=".DocumentsUIApplication" android:label="@string/app_label" android:supportsRtl="true" android:allowBackup="true" diff --git a/compose/src/com/android/documentsui/compose/DocumentsUIApplication.kt b/compose/src/com/android/documentsui/compose/DocumentsUIApplication.kt new file mode 100644 index 000000000..f6e0e811e --- /dev/null +++ b/compose/src/com/android/documentsui/compose/DocumentsUIApplication.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2024 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.0 + * + * 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.documentsui.compose + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp(Application::class) +class DocumentsUIApplication : Hilt_DocumentsUIApplication() diff --git a/compose/src/com/android/documentsui/compose/MainActivity.kt b/compose/src/com/android/documentsui/compose/MainActivity.kt index 4f0fd644d..8db5140f2 100644 --- a/compose/src/com/android/documentsui/compose/MainActivity.kt +++ b/compose/src/com/android/documentsui/compose/MainActivity.kt @@ -19,15 +19,18 @@ package com.android.documentsui.compose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Column +import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.ui.Modifier +import dagger.hilt.android.AndroidEntryPoint -class MainActivity : ComponentActivity() { +@AndroidEntryPoint(ComponentActivity::class) +class MainActivity : Hilt_MainActivity() { override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() super.onCreate(savedInstanceState) setContent { @@ -36,9 +39,7 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - Column { - Text(text = "DocumentsUI Compose") - } + Text(text = "DocumentsUI Compose") } } } |