Loading src/com/android/settings/connecteddevice/display/DisplayTopology.kt +0 −3 Original line number Diff line number Diff line Loading @@ -159,8 +159,6 @@ class TopologyScale( } } const val TOPOLOGY_PREFERENCE_KEY = "display_topology_preference" /** Represents a draggable block in the topology pane. */ class DisplayBlock(context : Context) : Button(context) { @VisibleForTesting var mSelectedImage: Drawable = ColorDrawable(Color.BLACK) Loading Loading @@ -240,7 +238,6 @@ class DisplayTopologyPreference(context : Context) // Prevent highlight when hovering with mouse. isSelectable = false key = TOPOLOGY_PREFERENCE_KEY isPersistent = false injector = Injector(context) Loading src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java +90 −51 Original line number Diff line number Diff line Loading @@ -64,33 +64,69 @@ import java.util.List; * The Settings screen for External Displays configuration and connection management. */ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmentBase { @VisibleForTesting enum PrefBasics { DISPLAY_TOPOLOGY(10, "display_topology_preference", null), MIRROR(20, "mirror_preference", null), // If shown, use toggle should be before other per-display settings. EXTERNAL_DISPLAY_USE(30, "external_display_use_preference", R.string.external_display_use_title), ILLUSTRATION(35, "external_display_illustration", null), // If shown, external display size is before other per-display settings. EXTERNAL_DISPLAY_SIZE(40, "external_display_size", R.string.screen_zoom_title), EXTERNAL_DISPLAY_ROTATION(50, "external_display_rotation", R.string.external_display_rotation), EXTERNAL_DISPLAY_RESOLUTION(60, "external_display_resolution", R.string.external_display_resolution_settings_title), // Built-in display link is after per-display settings. BUILTIN_DISPLAY_LIST(70, "builtin_display_list_preference", R.string.builtin_display_settings_category), DISPLAYS_LIST(80, "displays_list_preference", null), // If shown, footer should appear below everything. FOOTER(90, "footer_preference", null); PrefBasics(int order, String key, @Nullable Integer titleResource) { this.order = order; this.key = key; this.titleResource = titleResource; } // Fields must be public to make the linter happy. public final int order; public final String key; @Nullable public final Integer titleResource; void apply(Preference preference) { if (order != -1) { preference.setOrder(order); } if (titleResource != null) { preference.setTitle(titleResource); } preference.setKey(key); preference.setPersistent(false); } } static final int EXTERNAL_DISPLAY_SETTINGS_RESOURCE = R.xml.external_display_settings; static final String DISPLAYS_LIST_PREFERENCE_KEY = "displays_list_preference"; static final String BUILTIN_DISPLAY_LIST_PREFERENCE_KEY = "builtin_display_list_preference"; static final String EXTERNAL_DISPLAY_USE_PREFERENCE_KEY = "external_display_use_preference"; static final String EXTERNAL_DISPLAY_ROTATION_KEY = "external_display_rotation"; static final String EXTERNAL_DISPLAY_RESOLUTION_PREFERENCE_KEY = "external_display_resolution"; static final String EXTERNAL_DISPLAY_SIZE_PREFERENCE_KEY = "external_display_size"; static final int EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE = R.string.external_display_change_resolution_footer_title; static final int EXTERNAL_DISPLAY_LANDSCAPE_DRAWABLE = R.drawable.external_display_mirror_landscape; static final int EXTERNAL_DISPLAY_TITLE_RESOURCE = R.string.external_display_settings_title; static final int EXTERNAL_DISPLAY_USE_TITLE_RESOURCE = R.string.external_display_use_title; static final int EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE = R.string.external_display_not_found_footer_title; static final int EXTERNAL_DISPLAY_PORTRAIT_DRAWABLE = R.drawable.external_display_mirror_portrait; static final int EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE = R.string.external_display_rotation; static final int EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE = R.string.external_display_resolution_settings_title; static final int EXTERNAL_DISPLAY_SIZE_TITLE_RESOURCE = R.string.screen_zoom_title; static final int EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE = R.string.screen_zoom_short_summary; static final int BUILTIN_DISPLAY_SETTINGS_CATEGORY_RESOURCE = R.string.builtin_display_settings_category; @VisibleForTesting static final String PREVIOUSLY_SHOWN_LIST_KEY = "mPreviouslyShownListOfDisplays"; private boolean mStarted; Loading Loading @@ -253,9 +289,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen ListPreference getRotationPreference(@NonNull Context context) { if (mRotationPref == null) { mRotationPref = new ListPreference(context); mRotationPref.setPersistent(false); mRotationPref.setKey(EXTERNAL_DISPLAY_ROTATION_KEY); mRotationPref.setTitle(EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_ROTATION.apply(mRotationPref); } return mRotationPref; } Loading @@ -265,9 +299,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen Preference getResolutionPreference(@NonNull Context context) { if (mResolutionPreference == null) { mResolutionPreference = new Preference(context); mResolutionPreference.setPersistent(false); mResolutionPreference.setKey(EXTERNAL_DISPLAY_RESOLUTION_PREFERENCE_KEY); mResolutionPreference.setTitle(EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.apply(mResolutionPreference); } return mResolutionPreference; } Loading @@ -277,9 +309,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen MainSwitchPreference getUseDisplayPreference(@NonNull Context context) { if (mUseDisplayPref == null) { mUseDisplayPref = new MainSwitchPreference(context); mUseDisplayPref.setPersistent(false); mUseDisplayPref.setKey(EXTERNAL_DISPLAY_USE_PREFERENCE_KEY); mUseDisplayPref.setTitle(EXTERNAL_DISPLAY_USE_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_USE.apply(mUseDisplayPref); } return mUseDisplayPref; } Loading @@ -289,8 +319,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen IllustrationPreference getIllustrationPreference(@NonNull Context context) { if (mImagePreference == null) { mImagePreference = new IllustrationPreference(context); mImagePreference.setPersistent(false); mImagePreference.setKey("external_display_illustration"); PrefBasics.ILLUSTRATION.apply(mImagePreference); } return mImagePreference; } Loading @@ -308,9 +337,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private PreferenceCategory getDisplaysListPreference(@NonNull Context context) { if (mDisplaysPreference == null) { mDisplaysPreference = new PreferenceCategory(context); mDisplaysPreference.setPersistent(false); mDisplaysPreference.setOrder(40); mDisplaysPreference.setKey(DISPLAYS_LIST_PREFERENCE_KEY); PrefBasics.DISPLAYS_LIST.apply(mDisplaysPreference); } return mDisplaysPreference; } Loading @@ -319,10 +346,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private PreferenceCategory getBuiltinDisplayListPreference(@NonNull Context context) { if (mBuiltinDisplayPreference == null) { mBuiltinDisplayPreference = new PreferenceCategory(context); mBuiltinDisplayPreference.setPersistent(false); mBuiltinDisplayPreference.setOrder(30); mBuiltinDisplayPreference.setKey(BUILTIN_DISPLAY_LIST_PREFERENCE_KEY); mBuiltinDisplayPreference.setTitle(BUILTIN_DISPLAY_SETTINGS_CATEGORY_RESOURCE); PrefBasics.BUILTIN_DISPLAY_LIST.apply(mBuiltinDisplayPreference); } return mBuiltinDisplayPreference; } Loading @@ -338,7 +362,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen @NonNull Preference getDisplayTopologyPreference(@NonNull Context context) { if (mDisplayTopologyPreference == null) { mDisplayTopologyPreference = new DisplayTopologyPreference(context); mDisplayTopologyPreference.setOrder(10); PrefBasics.DISPLAY_TOPOLOGY.apply(mDisplayTopologyPreference); } return mDisplayTopologyPreference; } Loading @@ -346,7 +370,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen @NonNull Preference getMirrorPreference(@NonNull Context context) { if (mMirrorPreference == null) { mMirrorPreference = new MirrorPreference(context); mMirrorPreference.setOrder(20); PrefBasics.MIRROR.apply(mMirrorPreference); } return mMirrorPreference; } Loading Loading @@ -386,16 +410,18 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private void updateScreenForDisplayId(final int displayId, @NonNull final PrefRefresh screen, @NonNull Context context) { final boolean forceShowList = displayId == INVALID_DISPLAY && isTopologyPaneEnabled(mInjector); final var displaysToShow = externalDisplaysToShow(displayId); if (!forceShowList && displaysToShow.isEmpty() && displayId == INVALID_DISPLAY) { if (displaysToShow.isEmpty() && displayId == INVALID_DISPLAY) { showTextWhenNoDisplaysToShow(screen, context); } else if (!forceShowList && displaysToShow.size() == 1 } else if (displaysToShow.size() == 1 && ((displayId == INVALID_DISPLAY && !mPreviouslyShownListOfDisplays) || displaysToShow.get(0).getDisplayId() == displayId)) { showDisplaySettings(displaysToShow.get(0), screen, context); if (displayId == INVALID_DISPLAY && isTopologyPaneEnabled(mInjector)) { // Only show the topology pane if the user did not arrive via the displays list. maybeAddV2Components(context, screen); } } else if (displayId == INVALID_DISPLAY) { // If ever shown a list of displays - keep showing it for consistency after // disconnecting one of the displays, and only one display is left. Loading Loading @@ -446,21 +472,30 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen screen.addPreference(updateResolutionPreference(context, display)); screen.addPreference(updateRotationPreference(context, display, displayRotation)); if (isResolutionSettingEnabled(mInjector)) { // Do not show the footer about changing resolution affecting apps. This is not in the // UX design for v2, and there is no good place to put it, since (a) if it is on the // bottom of the screen, the external resolution setting must be below the built-in // display options for the per-display fragment, which is too hidden for the per-display // fragment, or (b) the footer is above the Built-in display settings, rather than the // bottom of the screen, which contradicts the visual style and purpose of the // FooterPreference class, or (c) we must hide the built-in display settings, which is // inconsistent with the topology pane, which shows that display. // TODO(b/352648432): probably remove footer once the pane and rest of v2 UI is in // place. if (!isTopologyPaneEnabled(mInjector)) { screen.addPreference(updateFooterPreference(context, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } } if (isDisplaySizeSettingEnabled(mInjector)) { screen.addPreference(updateSizePreference(context)); } } private void showDisplaysList(@NonNull List<Display> displaysToShow, @NonNull PrefRefresh screen, @NonNull Context context) { private void maybeAddV2Components(Context context, PrefRefresh screen) { if (isTopologyPaneEnabled(mInjector)) { screen.addPreference(getDisplayTopologyPreference(context)); if (!displaysToShow.isEmpty()) { screen.addPreference(getMirrorPreference(context)); } // If topology is shown, we also show a preference for the built-in display for // consistency with the topology. Loading @@ -468,7 +503,11 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen screen.addPreference(builtinCategory); builtinCategory.addPreference(getBuiltinDisplaySizeAndTextPreference(context)); } } private void showDisplaysList(@NonNull List<Display> displaysToShow, @NonNull PrefRefresh screen, @NonNull Context context) { maybeAddV2Components(context, screen); var displayGroupPref = getDisplaysListPreference(context); if (!displaysToShow.isEmpty()) { screen.addPreference(displayGroupPref); Loading Loading @@ -501,8 +540,9 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen groupCleanable.addPreference(category); var prefItem = new DisplayPreference(context, display); prefItem.setTitle(context.getString(EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE) + " | " + context.getString(EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE)); prefItem.setTitle( context.getString(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.titleResource) + " | " + context.getString(PrefBasics.EXTERNAL_DISPLAY_ROTATION.titleResource)); prefItem.setKey(itemKey); category.addPreference(prefItem); Loading Loading @@ -577,6 +617,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private Preference updateFooterPreference(@NonNull final Context context, final int title) { var pref = getFooterPreference(context); pref.setTitle(title); PrefBasics.FOOTER.apply(pref); return pref; } Loading Loading @@ -625,10 +666,8 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private Preference updateSizePreference(@NonNull final Context context) { var pref = (Preference) getSizePreference(context); pref.setKey(EXTERNAL_DISPLAY_SIZE_PREFERENCE_KEY); PrefBasics.EXTERNAL_DISPLAY_SIZE.apply(pref); pref.setSummary(EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE); pref.setPersistent(false); pref.setTitle(EXTERNAL_DISPLAY_SIZE_TITLE_RESOURCE); pref.setOnPreferenceClickListener( (Preference p) -> { writePreferenceClickMetric(p); Loading src/com/android/settings/connecteddevice/display/Mirroring.kt +0 −3 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import androidx.preference.SwitchPreferenceCompat import com.android.settings.R const val MIRROR_PREFERENCE_KEY = "mirror_builtin_display" /** * A switch preference which is backed by the MIRROR_BUILT_IN_DISPLAY global setting. */ Loading @@ -32,7 +30,6 @@ class MirrorPreference(context: Context): SwitchPreferenceCompat(context) { init { setTitle(R.string.external_display_mirroring_title) key = MIRROR_PREFERENCE_KEY isPersistent = false } Loading tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java +53 −65 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/com/android/settings/connecteddevice/display/DisplayTopology.kt +0 −3 Original line number Diff line number Diff line Loading @@ -159,8 +159,6 @@ class TopologyScale( } } const val TOPOLOGY_PREFERENCE_KEY = "display_topology_preference" /** Represents a draggable block in the topology pane. */ class DisplayBlock(context : Context) : Button(context) { @VisibleForTesting var mSelectedImage: Drawable = ColorDrawable(Color.BLACK) Loading Loading @@ -240,7 +238,6 @@ class DisplayTopologyPreference(context : Context) // Prevent highlight when hovering with mouse. isSelectable = false key = TOPOLOGY_PREFERENCE_KEY isPersistent = false injector = Injector(context) Loading
src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java +90 −51 Original line number Diff line number Diff line Loading @@ -64,33 +64,69 @@ import java.util.List; * The Settings screen for External Displays configuration and connection management. */ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmentBase { @VisibleForTesting enum PrefBasics { DISPLAY_TOPOLOGY(10, "display_topology_preference", null), MIRROR(20, "mirror_preference", null), // If shown, use toggle should be before other per-display settings. EXTERNAL_DISPLAY_USE(30, "external_display_use_preference", R.string.external_display_use_title), ILLUSTRATION(35, "external_display_illustration", null), // If shown, external display size is before other per-display settings. EXTERNAL_DISPLAY_SIZE(40, "external_display_size", R.string.screen_zoom_title), EXTERNAL_DISPLAY_ROTATION(50, "external_display_rotation", R.string.external_display_rotation), EXTERNAL_DISPLAY_RESOLUTION(60, "external_display_resolution", R.string.external_display_resolution_settings_title), // Built-in display link is after per-display settings. BUILTIN_DISPLAY_LIST(70, "builtin_display_list_preference", R.string.builtin_display_settings_category), DISPLAYS_LIST(80, "displays_list_preference", null), // If shown, footer should appear below everything. FOOTER(90, "footer_preference", null); PrefBasics(int order, String key, @Nullable Integer titleResource) { this.order = order; this.key = key; this.titleResource = titleResource; } // Fields must be public to make the linter happy. public final int order; public final String key; @Nullable public final Integer titleResource; void apply(Preference preference) { if (order != -1) { preference.setOrder(order); } if (titleResource != null) { preference.setTitle(titleResource); } preference.setKey(key); preference.setPersistent(false); } } static final int EXTERNAL_DISPLAY_SETTINGS_RESOURCE = R.xml.external_display_settings; static final String DISPLAYS_LIST_PREFERENCE_KEY = "displays_list_preference"; static final String BUILTIN_DISPLAY_LIST_PREFERENCE_KEY = "builtin_display_list_preference"; static final String EXTERNAL_DISPLAY_USE_PREFERENCE_KEY = "external_display_use_preference"; static final String EXTERNAL_DISPLAY_ROTATION_KEY = "external_display_rotation"; static final String EXTERNAL_DISPLAY_RESOLUTION_PREFERENCE_KEY = "external_display_resolution"; static final String EXTERNAL_DISPLAY_SIZE_PREFERENCE_KEY = "external_display_size"; static final int EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE = R.string.external_display_change_resolution_footer_title; static final int EXTERNAL_DISPLAY_LANDSCAPE_DRAWABLE = R.drawable.external_display_mirror_landscape; static final int EXTERNAL_DISPLAY_TITLE_RESOURCE = R.string.external_display_settings_title; static final int EXTERNAL_DISPLAY_USE_TITLE_RESOURCE = R.string.external_display_use_title; static final int EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE = R.string.external_display_not_found_footer_title; static final int EXTERNAL_DISPLAY_PORTRAIT_DRAWABLE = R.drawable.external_display_mirror_portrait; static final int EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE = R.string.external_display_rotation; static final int EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE = R.string.external_display_resolution_settings_title; static final int EXTERNAL_DISPLAY_SIZE_TITLE_RESOURCE = R.string.screen_zoom_title; static final int EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE = R.string.screen_zoom_short_summary; static final int BUILTIN_DISPLAY_SETTINGS_CATEGORY_RESOURCE = R.string.builtin_display_settings_category; @VisibleForTesting static final String PREVIOUSLY_SHOWN_LIST_KEY = "mPreviouslyShownListOfDisplays"; private boolean mStarted; Loading Loading @@ -253,9 +289,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen ListPreference getRotationPreference(@NonNull Context context) { if (mRotationPref == null) { mRotationPref = new ListPreference(context); mRotationPref.setPersistent(false); mRotationPref.setKey(EXTERNAL_DISPLAY_ROTATION_KEY); mRotationPref.setTitle(EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_ROTATION.apply(mRotationPref); } return mRotationPref; } Loading @@ -265,9 +299,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen Preference getResolutionPreference(@NonNull Context context) { if (mResolutionPreference == null) { mResolutionPreference = new Preference(context); mResolutionPreference.setPersistent(false); mResolutionPreference.setKey(EXTERNAL_DISPLAY_RESOLUTION_PREFERENCE_KEY); mResolutionPreference.setTitle(EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.apply(mResolutionPreference); } return mResolutionPreference; } Loading @@ -277,9 +309,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen MainSwitchPreference getUseDisplayPreference(@NonNull Context context) { if (mUseDisplayPref == null) { mUseDisplayPref = new MainSwitchPreference(context); mUseDisplayPref.setPersistent(false); mUseDisplayPref.setKey(EXTERNAL_DISPLAY_USE_PREFERENCE_KEY); mUseDisplayPref.setTitle(EXTERNAL_DISPLAY_USE_TITLE_RESOURCE); PrefBasics.EXTERNAL_DISPLAY_USE.apply(mUseDisplayPref); } return mUseDisplayPref; } Loading @@ -289,8 +319,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen IllustrationPreference getIllustrationPreference(@NonNull Context context) { if (mImagePreference == null) { mImagePreference = new IllustrationPreference(context); mImagePreference.setPersistent(false); mImagePreference.setKey("external_display_illustration"); PrefBasics.ILLUSTRATION.apply(mImagePreference); } return mImagePreference; } Loading @@ -308,9 +337,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private PreferenceCategory getDisplaysListPreference(@NonNull Context context) { if (mDisplaysPreference == null) { mDisplaysPreference = new PreferenceCategory(context); mDisplaysPreference.setPersistent(false); mDisplaysPreference.setOrder(40); mDisplaysPreference.setKey(DISPLAYS_LIST_PREFERENCE_KEY); PrefBasics.DISPLAYS_LIST.apply(mDisplaysPreference); } return mDisplaysPreference; } Loading @@ -319,10 +346,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private PreferenceCategory getBuiltinDisplayListPreference(@NonNull Context context) { if (mBuiltinDisplayPreference == null) { mBuiltinDisplayPreference = new PreferenceCategory(context); mBuiltinDisplayPreference.setPersistent(false); mBuiltinDisplayPreference.setOrder(30); mBuiltinDisplayPreference.setKey(BUILTIN_DISPLAY_LIST_PREFERENCE_KEY); mBuiltinDisplayPreference.setTitle(BUILTIN_DISPLAY_SETTINGS_CATEGORY_RESOURCE); PrefBasics.BUILTIN_DISPLAY_LIST.apply(mBuiltinDisplayPreference); } return mBuiltinDisplayPreference; } Loading @@ -338,7 +362,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen @NonNull Preference getDisplayTopologyPreference(@NonNull Context context) { if (mDisplayTopologyPreference == null) { mDisplayTopologyPreference = new DisplayTopologyPreference(context); mDisplayTopologyPreference.setOrder(10); PrefBasics.DISPLAY_TOPOLOGY.apply(mDisplayTopologyPreference); } return mDisplayTopologyPreference; } Loading @@ -346,7 +370,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen @NonNull Preference getMirrorPreference(@NonNull Context context) { if (mMirrorPreference == null) { mMirrorPreference = new MirrorPreference(context); mMirrorPreference.setOrder(20); PrefBasics.MIRROR.apply(mMirrorPreference); } return mMirrorPreference; } Loading Loading @@ -386,16 +410,18 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private void updateScreenForDisplayId(final int displayId, @NonNull final PrefRefresh screen, @NonNull Context context) { final boolean forceShowList = displayId == INVALID_DISPLAY && isTopologyPaneEnabled(mInjector); final var displaysToShow = externalDisplaysToShow(displayId); if (!forceShowList && displaysToShow.isEmpty() && displayId == INVALID_DISPLAY) { if (displaysToShow.isEmpty() && displayId == INVALID_DISPLAY) { showTextWhenNoDisplaysToShow(screen, context); } else if (!forceShowList && displaysToShow.size() == 1 } else if (displaysToShow.size() == 1 && ((displayId == INVALID_DISPLAY && !mPreviouslyShownListOfDisplays) || displaysToShow.get(0).getDisplayId() == displayId)) { showDisplaySettings(displaysToShow.get(0), screen, context); if (displayId == INVALID_DISPLAY && isTopologyPaneEnabled(mInjector)) { // Only show the topology pane if the user did not arrive via the displays list. maybeAddV2Components(context, screen); } } else if (displayId == INVALID_DISPLAY) { // If ever shown a list of displays - keep showing it for consistency after // disconnecting one of the displays, and only one display is left. Loading Loading @@ -446,21 +472,30 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen screen.addPreference(updateResolutionPreference(context, display)); screen.addPreference(updateRotationPreference(context, display, displayRotation)); if (isResolutionSettingEnabled(mInjector)) { // Do not show the footer about changing resolution affecting apps. This is not in the // UX design for v2, and there is no good place to put it, since (a) if it is on the // bottom of the screen, the external resolution setting must be below the built-in // display options for the per-display fragment, which is too hidden for the per-display // fragment, or (b) the footer is above the Built-in display settings, rather than the // bottom of the screen, which contradicts the visual style and purpose of the // FooterPreference class, or (c) we must hide the built-in display settings, which is // inconsistent with the topology pane, which shows that display. // TODO(b/352648432): probably remove footer once the pane and rest of v2 UI is in // place. if (!isTopologyPaneEnabled(mInjector)) { screen.addPreference(updateFooterPreference(context, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE)); } } if (isDisplaySizeSettingEnabled(mInjector)) { screen.addPreference(updateSizePreference(context)); } } private void showDisplaysList(@NonNull List<Display> displaysToShow, @NonNull PrefRefresh screen, @NonNull Context context) { private void maybeAddV2Components(Context context, PrefRefresh screen) { if (isTopologyPaneEnabled(mInjector)) { screen.addPreference(getDisplayTopologyPreference(context)); if (!displaysToShow.isEmpty()) { screen.addPreference(getMirrorPreference(context)); } // If topology is shown, we also show a preference for the built-in display for // consistency with the topology. Loading @@ -468,7 +503,11 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen screen.addPreference(builtinCategory); builtinCategory.addPreference(getBuiltinDisplaySizeAndTextPreference(context)); } } private void showDisplaysList(@NonNull List<Display> displaysToShow, @NonNull PrefRefresh screen, @NonNull Context context) { maybeAddV2Components(context, screen); var displayGroupPref = getDisplaysListPreference(context); if (!displaysToShow.isEmpty()) { screen.addPreference(displayGroupPref); Loading Loading @@ -501,8 +540,9 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen groupCleanable.addPreference(category); var prefItem = new DisplayPreference(context, display); prefItem.setTitle(context.getString(EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE) + " | " + context.getString(EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE)); prefItem.setTitle( context.getString(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.titleResource) + " | " + context.getString(PrefBasics.EXTERNAL_DISPLAY_ROTATION.titleResource)); prefItem.setKey(itemKey); category.addPreference(prefItem); Loading Loading @@ -577,6 +617,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private Preference updateFooterPreference(@NonNull final Context context, final int title) { var pref = getFooterPreference(context); pref.setTitle(title); PrefBasics.FOOTER.apply(pref); return pref; } Loading Loading @@ -625,10 +666,8 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen private Preference updateSizePreference(@NonNull final Context context) { var pref = (Preference) getSizePreference(context); pref.setKey(EXTERNAL_DISPLAY_SIZE_PREFERENCE_KEY); PrefBasics.EXTERNAL_DISPLAY_SIZE.apply(pref); pref.setSummary(EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE); pref.setPersistent(false); pref.setTitle(EXTERNAL_DISPLAY_SIZE_TITLE_RESOURCE); pref.setOnPreferenceClickListener( (Preference p) -> { writePreferenceClickMetric(p); Loading
src/com/android/settings/connecteddevice/display/Mirroring.kt +0 −3 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ import androidx.preference.SwitchPreferenceCompat import com.android.settings.R const val MIRROR_PREFERENCE_KEY = "mirror_builtin_display" /** * A switch preference which is backed by the MIRROR_BUILT_IN_DISPLAY global setting. */ Loading @@ -32,7 +30,6 @@ class MirrorPreference(context: Context): SwitchPreferenceCompat(context) { init { setTitle(R.string.external_display_mirroring_title) key = MIRROR_PREFERENCE_KEY isPersistent = false } Loading
tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java +53 −65 File changed.Preview size limit exceeded, changes collapsed. Show changes