Merge "Show options greyed out inactive display" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
57265d3575
@@ -444,17 +444,13 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
if (isUseDisplaySettingEnabled(mInjector)) {
|
if (isUseDisplaySettingEnabled(mInjector)) {
|
||||||
addUseDisplayPreferenceForDisplay(context, refresh, display, isEnabled, position);
|
addUseDisplayPreferenceForDisplay(context, refresh, display, isEnabled, position);
|
||||||
}
|
}
|
||||||
if (!isEnabled) {
|
|
||||||
// Skip all other settings
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final var displayRotation = getDisplayRotation(display.getDisplayId());
|
final var displayRotation = getDisplayRotation(display.getDisplayId());
|
||||||
if (includeV1Helpers) {
|
if (includeV1Helpers && isEnabled) {
|
||||||
addIllustrationImage(context, refresh, displayRotation);
|
addIllustrationImage(context, refresh, displayRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
addResolutionPreference(context, refresh, display, position);
|
addResolutionPreference(context, refresh, display, position, isEnabled);
|
||||||
addRotationPreference(context, refresh, display, displayRotation, position);
|
addRotationPreference(context, refresh, display, displayRotation, position, isEnabled);
|
||||||
if (isResolutionSettingEnabled(mInjector)) {
|
if (isResolutionSettingEnabled(mInjector)) {
|
||||||
// Do not show the footer about changing resolution affecting apps. This is not in the
|
// 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
|
// UX design for v2, and there is no good place to put it, since (a) if it is on the
|
||||||
@@ -466,13 +462,13 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
// inconsistent with the topology pane, which shows that display.
|
// 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
|
// TODO(b/352648432): probably remove footer once the pane and rest of v2 UI is in
|
||||||
// place.
|
// place.
|
||||||
if (includeV1Helpers) {
|
if (includeV1Helpers && isEnabled) {
|
||||||
addFooterPreference(
|
addFooterPreference(
|
||||||
context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE);
|
context, refresh, EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDisplaySizeSettingEnabled(mInjector)) {
|
if (isDisplaySizeSettingEnabled(mInjector)) {
|
||||||
addSizePreference(context, refresh, display.getDisplayId(), position);
|
addSizePreference(context, refresh, display.getDisplayId(), position, isEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,8 +558,8 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRotationPreference(final Context context,
|
private void addRotationPreference(final Context context, PrefRefresh refresh,
|
||||||
PrefRefresh refresh, final Display display, final int displayRotation, int position) {
|
final Display display, final int displayRotation, int position, boolean isEnabled) {
|
||||||
var pref = reuseRotationPreference(context, refresh, position);
|
var pref = reuseRotationPreference(context, refresh, position);
|
||||||
if (mRotationEntries == null || mRotationEntriesValues == null) {
|
if (mRotationEntries == null || mRotationEntriesValues == null) {
|
||||||
mRotationEntries = new String[] {
|
mRotationEntries = new String[] {
|
||||||
@@ -587,11 +583,11 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
pref.setValueIndex(rotation);
|
pref.setValueIndex(rotation);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
pref.setEnabled(isRotationSettingEnabled(mInjector));
|
pref.setEnabled(isEnabled && isRotationSettingEnabled(mInjector));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addResolutionPreference(final Context context, PrefRefresh refresh,
|
private void addResolutionPreference(final Context context, PrefRefresh refresh,
|
||||||
final Display display, int position) {
|
final Display display, int position, boolean isEnabled) {
|
||||||
var pref = reuseResolutionPreference(context, refresh, position);
|
var pref = reuseResolutionPreference(context, refresh, position);
|
||||||
pref.setSummary(display.getMode().getPhysicalWidth() + " x "
|
pref.setSummary(display.getMode().getPhysicalWidth() + " x "
|
||||||
+ display.getMode().getPhysicalHeight());
|
+ display.getMode().getPhysicalHeight());
|
||||||
@@ -600,11 +596,11 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
launchResolutionSelector(context, display.getDisplayId());
|
launchResolutionSelector(context, display.getDisplayId());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
pref.setEnabled(isResolutionSettingEnabled(mInjector));
|
pref.setEnabled(isEnabled && isResolutionSettingEnabled(mInjector));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSizePreference(final Context context, PrefRefresh refresh, int displayId,
|
private void addSizePreference(final Context context, PrefRefresh refresh, int displayId,
|
||||||
int position) {
|
int position, boolean isEnabled) {
|
||||||
var pref = reuseSizePreference(context, refresh, displayId, position);
|
var pref = reuseSizePreference(context, refresh, displayId, position);
|
||||||
pref.setSummary(EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE);
|
pref.setSummary(EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE);
|
||||||
pref.setOnPreferenceClickListener(
|
pref.setOnPreferenceClickListener(
|
||||||
@@ -612,6 +608,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
|||||||
writePreferenceClickMetric(p);
|
writePreferenceClickMetric(p);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
pref.setEnabled(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDisplayRotation(int displayId) {
|
private int getDisplayRotation(int displayId) {
|
||||||
|
@@ -25,6 +25,7 @@ import static com.android.settings.flags.Flags.FLAG_DISPLAY_SIZE_CONNECTED_DISPL
|
|||||||
import static com.android.settings.flags.Flags.FLAG_DISPLAY_TOPOLOGY_PANE_IN_DISPLAY_LIST;
|
import static com.android.settings.flags.Flags.FLAG_DISPLAY_TOPOLOGY_PANE_IN_DISPLAY_LIST;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
@@ -161,6 +162,34 @@ public class ExternalDisplayPreferenceFragmentTest extends ExternalDisplayTestBa
|
|||||||
assertThat(listPref).isNull();
|
assertThat(listPref).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void testShowDisplayControlsDisabled() {
|
||||||
|
doReturn(new Display[] {mDisplays[0], mDisplays[2]}).when(mMockedInjector)
|
||||||
|
.getEnabledDisplays();
|
||||||
|
doReturn(true).when(mMockedInjector).isDisplayEnabled(mDisplays[0]);
|
||||||
|
doReturn(false).when(mMockedInjector).isDisplayEnabled(mDisplays[1]);
|
||||||
|
doReturn(true).when(mMockedInjector).isDisplayEnabled(mDisplays[2]);
|
||||||
|
initFragment();
|
||||||
|
mHandler.flush();
|
||||||
|
|
||||||
|
assertDisplayListCount(2);
|
||||||
|
Preference pref;
|
||||||
|
for (int disp = 0; disp < 2; disp++) {
|
||||||
|
pref = mPreferenceScreen.findPreference(
|
||||||
|
PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.keyForNth(disp));
|
||||||
|
assertWithMessage("resolution " + disp).that(pref.isEnabled()).isEqualTo(disp == 1);
|
||||||
|
|
||||||
|
pref = mPreferenceScreen.findPreference(
|
||||||
|
PrefBasics.EXTERNAL_DISPLAY_ROTATION.keyForNth(disp));
|
||||||
|
assertWithMessage("rotation " + disp).that(pref.isEnabled()).isEqualTo(disp == 1);
|
||||||
|
|
||||||
|
pref = mPreferenceScreen.findPreference(
|
||||||
|
PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(disp));
|
||||||
|
assertWithMessage("size " + disp).that(pref.isEnabled()).isEqualTo(disp == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void testLaunchDisplaySettingFromList() {
|
public void testLaunchDisplaySettingFromList() {
|
||||||
@@ -280,13 +309,13 @@ public class ExternalDisplayPreferenceFragmentTest extends ExternalDisplayTestBa
|
|||||||
assertThat(mainPref.isEnabled()).isTrue();
|
assertThat(mainPref.isEnabled()).isTrue();
|
||||||
assertThat(mainPref.getOnPreferenceChangeListener()).isNotNull();
|
assertThat(mainPref.getOnPreferenceChangeListener()).isNotNull();
|
||||||
var pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.keyForNth(0));
|
var pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.keyForNth(0));
|
||||||
assertThat(pref).isNull();
|
assertThat(pref.isEnabled()).isFalse();
|
||||||
pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.keyForNth(0));
|
pref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.keyForNth(0));
|
||||||
assertThat(pref).isNull();
|
assertThat(pref.isEnabled()).isFalse();
|
||||||
var footerPref = category.findPreference(PrefBasics.FOOTER.key);
|
var footerPref = category.findPreference(PrefBasics.FOOTER.key);
|
||||||
assertThat(footerPref).isNull();
|
assertThat(footerPref).isNull();
|
||||||
var sizePref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(0));
|
var sizePref = category.findPreference(PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(0));
|
||||||
assertThat(sizePref).isNull();
|
assertThat(sizePref.isEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user