Add opt-out properties for aspect ratio settings
Don't display aspect ratio options if app has opted out. If app has opted out only for fullscreen, other aspect ratio options should still be shown. Bug: 292583399 Test: UserAspectRatioManagerTest Change-Id: Ia0b223536407f703826d775468c8f8a0b4822e23
This commit is contained in:
@@ -122,7 +122,7 @@ fun UserAspectRatioAppList(
|
||||
|
||||
data class UserAspectRatioAppListItemModel(
|
||||
override val app: ApplicationInfo,
|
||||
val override: Int,
|
||||
val userOverride: Int,
|
||||
val suggested: Boolean,
|
||||
val canDisplay: Boolean,
|
||||
) : AppRecord
|
||||
@@ -137,7 +137,7 @@ class UserAspectRatioAppListModel(private val context: Context)
|
||||
recordList: List<UserAspectRatioAppListItemModel>
|
||||
): List<SpinnerOption> {
|
||||
val hasSuggested = recordList.any { it.suggested }
|
||||
val hasOverride = recordList.any { it.override != USER_MIN_ASPECT_RATIO_UNSET }
|
||||
val hasOverride = recordList.any { it.userOverride != USER_MIN_ASPECT_RATIO_UNSET }
|
||||
val options = mutableListOf(SpinnerItem.All)
|
||||
// Add suggested filter first as default
|
||||
if (hasSuggested) options.add(0, SpinnerItem.Suggested)
|
||||
@@ -165,7 +165,7 @@ class UserAspectRatioAppListModel(private val context: Context)
|
||||
app = app,
|
||||
suggested = !app.isSystemApp && getPackageAndActivityInfo(
|
||||
app)?.isFixedOrientationOrAspectRatio() == true,
|
||||
override = userAspectRatioManager.getUserMinAspectRatioValue(
|
||||
userOverride = userAspectRatioManager.getUserMinAspectRatioValue(
|
||||
app.packageName, uid),
|
||||
canDisplay = userAspectRatioManager.canDisplayAspectRatioUi(app),
|
||||
)
|
||||
@@ -179,7 +179,7 @@ class UserAspectRatioAppListModel(private val context: Context)
|
||||
): Flow<List<UserAspectRatioAppListItemModel>> = recordListFlow.filterItem(
|
||||
when (SpinnerItem.values().getOrNull(option)) {
|
||||
SpinnerItem.Suggested -> ({ it.canDisplay && it.suggested })
|
||||
SpinnerItem.Overridden -> ({ it.override != USER_MIN_ASPECT_RATIO_UNSET })
|
||||
SpinnerItem.Overridden -> ({ it.userOverride != USER_MIN_ASPECT_RATIO_UNSET })
|
||||
else -> ({ it.canDisplay })
|
||||
}
|
||||
)
|
||||
@@ -187,9 +187,10 @@ class UserAspectRatioAppListModel(private val context: Context)
|
||||
@OptIn(ExperimentalLifecycleComposeApi::class)
|
||||
@Composable
|
||||
override fun getSummary(option: Int, record: UserAspectRatioAppListItemModel) : State<String> =
|
||||
remember(record.override) {
|
||||
remember(record.userOverride) {
|
||||
flow {
|
||||
emit(userAspectRatioManager.getUserMinAspectRatioEntry(record.override))
|
||||
emit(userAspectRatioManager.getUserMinAspectRatioEntry(record.userOverride,
|
||||
record.app.packageName))
|
||||
}.flowOn(Dispatchers.IO)
|
||||
}.collectAsStateWithLifecycle(initialValue = stringResource(R.string.summary_placeholder))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user