Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4c4f6cb authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

[2/n] Add aspect ratio app list page under apps

Apps > General > Screen Size

To enable feature:
adb shell device_config put window_manager enable_app_compat_user_aspect_ratio_settings true
adb shell am force-stop com.android.settings

Fix: 287448088
Test: Manual
      atest AspectRatioAppsPageProviderTest
      atest AspectRatioUtilsTest
      All CUJs passed in go/settings-cujs
Change-Id: I4de6c3cbdbdfbc79ed839ec149fb633344dcd3a7
parent a94cfc7b
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -611,6 +611,28 @@
        <item>3</item>
    </integer-array>

    <!-- TODO(b/287448187): add USER_MIN_ASPECT_RATIO_DISPLAY_SIZE entry -->
    <!-- App screen size settings screen, User aspect ratio override options. Must be the same
         length and order as config_userAspectRatioOverrideValues below. -->
    <string-array name="config_userAspectRatioOverrideEntries" translatable="false">
        <item>@string/user_aspect_ratio_app_default</item>
        <item>@string/user_aspect_ratio_half_screen</item>
        <item>@string/user_aspect_ratio_16_9</item>
        <item>@string/user_aspect_ratio_4_3</item>
        <item>@string/user_aspect_ratio_3_2</item>
    </string-array>

    <!-- App screen size settings screen, User aspect ratio override options. Must be the same
         length and order as config_userAspectRatioOverrideEntries above. The values must
         correspond to PackageManager.UserMinAspectRatio -->
    <integer-array name="config_userAspectRatioOverrideValues" translatable="false">
        <item>0</item> <!-- USER_MIN_ASPECT_RATIO_UNSET -->
        <item>1</item> <!-- USER_MIN_ASPECT_RATIO_SPLIT_SCREEN -->
        <item>4</item> <!-- USER_MIN_ASPECT_RATIO_16_9 -->
        <item>3</item> <!-- USER_MIN_ASPECT_RATIO_4_3 -->
        <item>5</item> <!-- USER_MIN_ASPECT_RATIO_3_2 -->
    </integer-array>

    <!-- The settings/preference description for each settable device state defined in the array
         "config_perDeviceStateRotationLockDefaults".
         The item in position "i" describes the auto-rotation setting for the device state also in
+20 −0
Original line number Diff line number Diff line
@@ -12081,6 +12081,26 @@
    other {Apps installed more than # months ago}
    }</string>
    <!-- App Screen Size (User Aspect Ratio Override) -->
    <!-- [CHAR LIMIT=60] Screen size app list title setting to choose aspect ratio -->
    <string name="screen_size_title">Screen size</string>
    <!-- [CHAR LIMIT=NONE] Screen size setting summary to choose aspect ratio for apps unoptimized for device -->
    <string name="screen_size_summary">Choose an aspect ratio for apps if they haven’t been optimized for your <xliff:g id="device_name">%1$s</xliff:g></string>
    <!-- [CHAR LIMIT=NONE] Aspect ratio suggested apps filter label -->
    <string name="user_aspect_ratio_suggested_apps_label">Suggested apps</string>
    <!-- [CHAR LIMIT=NONE] Filter label for apps that have user aspect ratio override applied -->
    <string name="user_aspect_ratio_overridden_apps_label">Apps you have overridden</string>
    <!-- [CHAR LIMIT=NONE] App default aspect ratio entry -->
    <string name="user_aspect_ratio_app_default">App default</string>
    <!-- [CHAR LIMIT=NONE] Half-screen aspect ratio entry -->
    <string name="user_aspect_ratio_half_screen">Half-screen</string>
    <!-- [CHAR LIMIT=NONE] 16:9 aspect ratio entry -->
    <string name="user_aspect_ratio_16_9">16:9</string>
    <!-- [CHAR LIMIT=NONE] 3:2 aspect ratio entry -->
    <string name="user_aspect_ratio_3_2">3:2</string>
    <!-- [CHAR LIMIT=NONE] 4:3 aspect ratio entry -->
    <string name="user_aspect_ratio_4_3">4:3</string>
    <!-- Accessibility label for fingerprint sensor [CHAR LIMIT=NONE] -->
    <string name="accessibility_fingerprint_label">Fingerprint sensor</string>
+11 −0
Original line number Diff line number Diff line
@@ -79,6 +79,17 @@
        android:key="dashboard_tile_placeholder"
        android:order="10"/>

    <Preference
        android:key="aspect_ratio_apps"
        android:title="@string/screen_size_title"
        android:summary="@string/summary_placeholder"
        android:order="14"
        settings:controller="com.android.settings.applications.appcompat.UserAspectRatioAppsPreferenceController"
        android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
        <extra android:name="classname"
               android:value="com.android.settings.Settings$UserAspectRatioAppListActivity"/>
    </Preference>

    <Preference
        android:key="hibernated_apps"
        android:title="@string/unused_apps"
+2 −0
Original line number Diff line number Diff line
@@ -378,6 +378,8 @@ public class Settings extends SettingsActivity {
    public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
    /** Activity to manage Cloned Apps page */
    public static class ClonedAppsListActivity extends SettingsActivity { /* empty */ }
    /** Activity to manage Aspect Ratio app list page */
    public static class UserAspectRatioAppListActivity extends SettingsActivity { /* empty */ }
    public static class NotificationReviewPermissionsActivity extends SettingsActivity { /* empty */ }
    public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
    public static class ChannelNotificationSettingsActivity extends SettingsActivity { /* empty */ }
+48 −0
Original line number Diff line number Diff line
/*
 * 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.applications.appcompat;

import android.content.Context;
import android.os.Build;

import androidx.annotation.NonNull;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

/**
 * Preference controller for
 * {@link com.android.settings.spa.app.appcompat.UserAspectRatioAppsPageProvider}
 */
public class UserAspectRatioAppsPreferenceController extends BasePreferenceController {

    public UserAspectRatioAppsPreferenceController(@NonNull Context context,
            @NonNull String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return UserAspectRatioManager.isFeatureEnabled(mContext)
                ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public CharSequence getSummary() {
        return mContext.getResources().getString(R.string.screen_size_summary, Build.MODEL);
    }
}
Loading