Merge "Set display size to all displays" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0066afbe15
@@ -18,9 +18,7 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.view.Display;
|
|
||||||
|
|
||||||
import com.android.settingslib.display.DisplayDensityConfiguration;
|
|
||||||
import com.android.settingslib.display.DisplayDensityUtils;
|
import com.android.settingslib.display.DisplayDensityUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -31,11 +29,13 @@ import java.util.stream.Collectors;
|
|||||||
* Data class for storing the configurations related to the display size.
|
* Data class for storing the configurations related to the display size.
|
||||||
*/
|
*/
|
||||||
class DisplaySizeData extends PreviewSizeData<Integer> {
|
class DisplaySizeData extends PreviewSizeData<Integer> {
|
||||||
|
private final DisplayDensityUtils mDensity;
|
||||||
|
|
||||||
DisplaySizeData(Context context) {
|
DisplaySizeData(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
|
mDensity = new DisplayDensityUtils(getContext());
|
||||||
final int initialIndex = density.getCurrentIndex();
|
final int initialIndex = mDensity.getCurrentIndexForDefaultDisplay();
|
||||||
if (initialIndex < 0) {
|
if (initialIndex < 0) {
|
||||||
// Failed to obtain default density, which means we failed to
|
// Failed to obtain default density, which means we failed to
|
||||||
// connect to the window manager service. Just use the current
|
// connect to the window manager service. Just use the current
|
||||||
@@ -46,9 +46,10 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
|
|||||||
setInitialIndex(0);
|
setInitialIndex(0);
|
||||||
setValues(Collections.singletonList(densityDpi));
|
setValues(Collections.singletonList(densityDpi));
|
||||||
} else {
|
} else {
|
||||||
setDefaultValue(density.getDefaultDensity());
|
setDefaultValue(mDensity.getDefaultDensityForDefaultDisplay());
|
||||||
setInitialIndex(initialIndex);
|
setInitialIndex(initialIndex);
|
||||||
setValues(Arrays.stream(density.getValues()).boxed().collect(Collectors.toList()));
|
setValues(Arrays.stream(mDensity.getDefaultDisplayDensityValues()).boxed()
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,10 +57,9 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
|
|||||||
void commit(int currentProgress) {
|
void commit(int currentProgress) {
|
||||||
final int densityDpi = getValues().get(currentProgress);
|
final int densityDpi = getValues().get(currentProgress);
|
||||||
if (densityDpi == getDefaultValue()) {
|
if (densityDpi == getDefaultValue()) {
|
||||||
DisplayDensityConfiguration.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
|
mDensity.clearForcedDisplayDensity();
|
||||||
} else {
|
} else {
|
||||||
DisplayDensityConfiguration.setForcedDisplayDensity(Display.DEFAULT_DISPLAY,
|
mDensity.setForcedDisplayDensity(currentProgress);
|
||||||
densityDpi);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -192,9 +192,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean shouldShowLottie() {
|
protected boolean shouldShowLottie() {
|
||||||
DisplayDensityUtils displayDensity = new DisplayDensityUtils(getApplicationContext());
|
DisplayDensityUtils displayDensity = new DisplayDensityUtils(getApplicationContext());
|
||||||
int currentDensityIndex = displayDensity.getCurrentIndex();
|
int currentDensityIndex = displayDensity.getCurrentIndexForDefaultDisplay();
|
||||||
final int currentDensity = displayDensity.getValues()[currentDensityIndex];
|
final int currentDensity = displayDensity.getDefaultDisplayDensityValues()
|
||||||
final int defaultDensity = displayDensity.getDefaultDensity();
|
[currentDensityIndex];
|
||||||
|
final int defaultDensity = displayDensity.getDefaultDensityForDefaultDisplay();
|
||||||
return defaultDensity == currentDensity;
|
return defaultDensity == currentDensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -307,10 +307,11 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||||
final int currentIndex = density.getCurrentIndex();
|
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||||
final int defaultDensity = density.getDefaultDensity();
|
final int defaultDensity = density.getDefaultDensityForDefaultDisplay();
|
||||||
|
|
||||||
if (density.getValues()[mCurrentIndex] == density.getDefaultDensity()) {
|
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
||||||
|
== density.getDefaultDensityForDefaultDisplay()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,17 +352,17 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
|||||||
|
|
||||||
private void restoreDensity() {
|
private void restoreDensity() {
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||||
if (density.getValues()[mCurrentIndex] != density.getDefaultDensity()) {
|
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
||||||
DisplayDensityUtils.setForcedDisplayDensity(
|
!= density.getDefaultDensityForDefaultDisplay()) {
|
||||||
Display.DEFAULT_DISPLAY, density.getValues()[mCurrentIndex]);
|
density.setForcedDisplayDensity(mCurrentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDefaultDensity = density.getDefaultDensity();
|
mDefaultDensity = density.getDefaultDensityForDefaultDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDensityChanged() {
|
private boolean isDensityChanged() {
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||||
if (density.getDefaultDensity() == mDefaultDensity) {
|
if (density.getDefaultDensityForDefaultDisplay() == mDefaultDensity) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,13 +36,13 @@ public class ScreenZoomPreference extends Preference {
|
|||||||
android.R.attr.preferenceStyle));
|
android.R.attr.preferenceStyle));
|
||||||
|
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(context);
|
final DisplayDensityUtils density = new DisplayDensityUtils(context);
|
||||||
final int defaultIndex = density.getCurrentIndex();
|
final int defaultIndex = density.getCurrentIndexForDefaultDisplay();
|
||||||
if (defaultIndex < 0) {
|
if (defaultIndex < 0) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
} else if (TextUtils.isEmpty(getSummary())) {
|
} else if (TextUtils.isEmpty(getSummary())) {
|
||||||
final String[] entries = density.getEntries();
|
final String[] entries = density.getDefaultDisplayDensityEntries();
|
||||||
final int currentIndex = density.getCurrentIndex();
|
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||||
setSummary(entries[currentIndex]);
|
setSummary(entries[currentIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,11 +21,9 @@ import android.app.settings.SettingsEnums;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Display;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.display.DisplayDensityConfiguration;
|
|
||||||
import com.android.settingslib.display.DisplayDensityUtils;
|
import com.android.settingslib.display.DisplayDensityUtils;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
@@ -37,6 +35,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
|
|||||||
|
|
||||||
private int mDefaultDensity;
|
private int mDefaultDensity;
|
||||||
private int[] mValues;
|
private int[] mValues;
|
||||||
|
private DisplayDensityUtils mDensity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getActivityLayoutResId() {
|
protected int getActivityLayoutResId() {
|
||||||
@@ -58,9 +57,9 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
|
|||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
|
mDensity = new DisplayDensityUtils(getContext());
|
||||||
|
|
||||||
final int initialIndex = density.getCurrentIndex();
|
final int initialIndex = mDensity.getCurrentIndexForDefaultDisplay();
|
||||||
if (initialIndex < 0) {
|
if (initialIndex < 0) {
|
||||||
// Failed to obtain default density, which means we failed to
|
// Failed to obtain default density, which means we failed to
|
||||||
// connect to the window manager service. Just use the current
|
// connect to the window manager service. Just use the current
|
||||||
@@ -71,10 +70,10 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
|
|||||||
mInitialIndex = 0;
|
mInitialIndex = 0;
|
||||||
mDefaultDensity = densityDpi;
|
mDefaultDensity = densityDpi;
|
||||||
} else {
|
} else {
|
||||||
mValues = density.getValues();
|
mValues = mDensity.getDefaultDisplayDensityValues();
|
||||||
mEntries = density.getEntries();
|
mEntries = mDensity.getDefaultDisplayDensityEntries();
|
||||||
mInitialIndex = initialIndex;
|
mInitialIndex = initialIndex;
|
||||||
mDefaultDensity = density.getDefaultDensity();
|
mDefaultDensity = mDensity.getDefaultDensityForDefaultDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().setTitle(R.string.screen_zoom_title);
|
getActivity().setTitle(R.string.screen_zoom_title);
|
||||||
@@ -95,9 +94,9 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
|
|||||||
protected void commit() {
|
protected void commit() {
|
||||||
final int densityDpi = mValues[mCurrentIndex];
|
final int densityDpi = mValues[mCurrentIndex];
|
||||||
if (densityDpi == mDefaultDensity) {
|
if (densityDpi == mDefaultDensity) {
|
||||||
DisplayDensityConfiguration.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
|
mDensity.clearForcedDisplayDensity();
|
||||||
} else {
|
} else {
|
||||||
DisplayDensityConfiguration.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, densityDpi);
|
mDensity.setForcedDisplayDensity(densityDpi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user