Merge "Refactor FingerprintEnrollEnrolling to fragment" into udc-dev am: 98d2e83c3d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21508164
Change-Id: I4f7b42e2cadbed273b94e91207d1dfa4f8b89464
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3efb218..6c268aa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10894,10 +10894,13 @@
<!-- [CHAR LIMIT=32] Name of MTE page in "Developer Options" and heading of page. -->
<string name="development_memtag_page_title">Memory Tagging Extension</string>
- <!-- [CHAR LIMIT=52] Label for button to turn on / off MTE protection.-->
+ <!-- [CHAR LIMIT=NONE] Explanation shown under heading of the page.-->
<string name="development_memtag_intro">Memory Tagging Extension (MTE) makes it easier to find memory safety issues in your app and make native code in it more secure.</string>
+ <!-- [CHAR LIMIT=NONE] Further explanation shown at the bottom of the page.-->
<string name="development_memtag_footer">Turning on MTE might cause slower device performance.</string>
+ <!-- [CHAR LIMIT=NONE] String for link to learn more about MTE.-->
<string name="development_memtag_learn_more">Learn more about MTE</string>
+ <!-- [CHAR LIMIT=52] Label for button to turn on / off MTE protection.-->
<string name="development_memtag_toggle">Enable MTE until you turn it off</string>
<!-- [CHAR LIMIT=NONE] Message shown in dialog prompting user to reboot device to turn on MTE.-->
<string name="development_memtag_reboot_message_on">You\u0027ll need to restart your device to turn on MTE.</string>
diff --git a/src/com/android/settings/datausage/DataSaverSummary.java b/src/com/android/settings/datausage/DataSaverSummary.java
index 9bd862a..67644a6 100644
--- a/src/com/android/settings/datausage/DataSaverSummary.java
+++ b/src/com/android/settings/datausage/DataSaverSummary.java
@@ -78,11 +78,7 @@
addPreferencesFromResource(R.xml.data_saver);
mUnrestrictedAccess = findPreference(KEY_UNRESTRICTED_ACCESS);
- mApplicationsState = ApplicationsState.getInstance(
- (Application) getContext().getApplicationContext());
mDataSaverBackend = new DataSaverBackend(getContext());
- mDataUsageBridge = new AppStateDataUsageBridge(mApplicationsState, this, mDataSaverBackend);
- mSession = mApplicationsState.newSession(this, getSettingsLifecycle());
}
@Override
diff --git a/src/com/android/settings/spa/SettingsSpaEnvironment.kt b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
index 55c0f83..f1ac3ea 100644
--- a/src/com/android/settings/spa/SettingsSpaEnvironment.kt
+++ b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
@@ -17,6 +17,7 @@
package com.android.settings.spa
import android.content.Context
+import com.android.settings.spa.about.AboutPhonePageProvider
import com.android.settings.spa.app.AllAppListPageProvider
import com.android.settings.spa.app.AppsMainPageProvider
import com.android.settings.spa.app.appinfo.AppInfoSettingsProvider
@@ -81,6 +82,7 @@
BackgroundInstalledAppsPageProvider,
CloneAppInfoSettingsProvider,
NetworkAndInternetPageProvider,
+ AboutPhonePageProvider,
) + togglePermissionAppListTemplate.createPageProviders(),
rootPages = listOf(
SettingsPage.create(HomePageProvider.name),
diff --git a/src/com/android/settings/spa/about/AboutPhone.kt b/src/com/android/settings/spa/about/AboutPhone.kt
new file mode 100644
index 0000000..7343da0
--- /dev/null
+++ b/src/com/android/settings/spa/about/AboutPhone.kt
@@ -0,0 +1,67 @@
+/*
+ * 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.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.settings.spa.about
+
+import android.os.Bundle
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.outlined.PermDeviceInformation
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import com.android.settings.R
+import com.android.settingslib.spa.framework.common.SettingsEntryBuilder
+import com.android.settingslib.spa.framework.common.SettingsPageProvider
+import com.android.settingslib.spa.framework.common.SpaEnvironmentFactory
+import com.android.settingslib.spa.framework.common.createSettingsPage
+import com.android.settingslib.spa.framework.compose.navigator
+import com.android.settingslib.spa.framework.compose.toState
+import com.android.settingslib.spa.widget.preference.Preference
+import com.android.settingslib.spa.widget.preference.PreferenceModel
+import com.android.settingslib.spa.widget.scaffold.RegularScaffold
+import com.android.settingslib.spa.widget.ui.SettingsIcon
+
+object AboutPhonePageProvider : SettingsPageProvider {
+ override val name = "AboutPhone"
+ private val owner = createSettingsPage()
+
+ @Composable
+ override fun Page(arguments: Bundle?) {
+ RegularScaffold(title = getTitle(arguments)) {
+ BasicInfoCategory.CategoryItems()
+ }
+ }
+
+ override fun getTitle(arguments: Bundle?): String =
+ SpaEnvironmentFactory.instance.appContext.getString(R.string.about_settings)
+
+ fun buildInjectEntry(): SettingsEntryBuilder {
+ return SettingsEntryBuilder.createInject(owner = owner)
+ .setUiLayoutFn {
+ val context = LocalContext.current
+ val deviceNamePresenter = remember { DeviceNamePresenter(context) }
+ Preference(object : PreferenceModel {
+ override val title = stringResource(R.string.about_settings)
+ override val summary = deviceNamePresenter.deviceName.toState()
+ override val onClick = navigator(name)
+ override val icon = @Composable {
+ SettingsIcon(imageVector = Icons.Outlined.PermDeviceInformation)
+ }
+ })
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/spa/about/BasicInfoCategory.kt b/src/com/android/settings/spa/about/BasicInfoCategory.kt
new file mode 100644
index 0000000..d382f51
--- /dev/null
+++ b/src/com/android/settings/spa/about/BasicInfoCategory.kt
@@ -0,0 +1,31 @@
+/*
+ * 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.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.settings.spa.about
+
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.res.stringResource
+import com.android.settings.R
+import com.android.settingslib.spa.widget.ui.Category
+
+object BasicInfoCategory {
+ @Composable
+ fun CategoryItems() {
+ Category(title = stringResource(R.string.my_device_info_basic_info_category_title)) {
+ DeviceNamePreference.EntryItem()
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/spa/about/DeviceName.kt b/src/com/android/settings/spa/about/DeviceName.kt
new file mode 100644
index 0000000..c481e32
--- /dev/null
+++ b/src/com/android/settings/spa/about/DeviceName.kt
@@ -0,0 +1,67 @@
+/*
+ * 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.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.settings.spa.about
+
+import android.content.Context
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import com.android.settings.R
+import com.android.settings.deviceinfo.DeviceNamePreferenceController
+import com.android.settingslib.spa.framework.compose.toState
+import com.android.settingslib.spa.widget.dialog.AlertDialogButton
+import com.android.settingslib.spa.widget.dialog.rememberAlertDialogPresenter
+import com.android.settingslib.spa.widget.preference.Preference
+import com.android.settingslib.spa.widget.preference.PreferenceModel
+
+object DeviceNamePreference {
+
+ @Composable
+ fun EntryItem() {
+ val context = LocalContext.current
+ val deviceNamePresenter = remember { DeviceNamePresenter(context) }
+ // TODO: Instead of a AlertDialog, it should be a dialog that accepts text input.
+ val dialogPresenter = rememberAlertDialogPresenter(
+ confirmButton = AlertDialogButton(
+ stringResource(R.string.okay), onClick = DeviceNamePreference::confirmChange
+ ),
+ dismissButton = AlertDialogButton(stringResource(R.string.cancel)),
+ title = stringResource(R.string.my_device_info_device_name_preference_title),
+ text = { Text(deviceNamePresenter.deviceName) },
+ )
+ Preference(object : PreferenceModel {
+ override val title =
+ stringResource(R.string.my_device_info_device_name_preference_title)
+ override val summary = deviceNamePresenter.deviceName.toState()
+ override val onClick = dialogPresenter::open
+ })
+
+ }
+
+ private fun confirmChange() {
+ // TODO: Save the change of the device name.
+ }
+}
+
+class DeviceNamePresenter(val context: Context) {
+ private val deviceNamePreferenceController =
+ DeviceNamePreferenceController(context, "unused_key")
+
+ val deviceName: String get() = deviceNamePreferenceController.summary.toString()
+}
diff --git a/src/com/android/settings/spa/home/HomePage.kt b/src/com/android/settings/spa/home/HomePage.kt
index d2416f4..be3e015 100644
--- a/src/com/android/settings/spa/home/HomePage.kt
+++ b/src/com/android/settings/spa/home/HomePage.kt
@@ -18,6 +18,7 @@
import android.os.Bundle
import com.android.settings.R
+import com.android.settings.spa.about.AboutPhonePageProvider
import com.android.settings.spa.app.AppsMainPageProvider
import com.android.settings.spa.network.NetworkAndInternetPageProvider
import com.android.settings.spa.notification.NotificationMainPageProvider
@@ -38,6 +39,7 @@
AppsMainPageProvider.buildInjectEntry().setLink(fromPage = owner).build(),
NotificationMainPageProvider.buildInjectEntry().setLink(fromPage = owner).build(),
SystemMainPageProvider.buildInjectEntry().setLink(fromPage = owner).build(),
+ AboutPhonePageProvider.buildInjectEntry().setLink(fromPage = owner).build(),
)
}