Merge "Set the same density to all displays" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
ddef40edd0
@@ -35,7 +35,7 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
|
||||
super(context);
|
||||
|
||||
mDensity = new DisplayDensityUtils(getContext());
|
||||
final int initialIndex = mDensity.getCurrentIndexForDefaultDisplay();
|
||||
final int initialIndex = mDensity.getCurrentIndex();
|
||||
if (initialIndex < 0) {
|
||||
// Failed to obtain default density, which means we failed to
|
||||
// connect to the window manager service. Just use the current
|
||||
@@ -46,9 +46,9 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
|
||||
setInitialIndex(0);
|
||||
setValues(Collections.singletonList(densityDpi));
|
||||
} else {
|
||||
setDefaultValue(mDensity.getDefaultDensityForDefaultDisplay());
|
||||
setDefaultValue(mDensity.getDefaultDensity());
|
||||
setInitialIndex(initialIndex);
|
||||
setValues(Arrays.stream(mDensity.getDefaultDisplayDensityValues()).boxed()
|
||||
setValues(Arrays.stream(mDensity.getValues()).boxed()
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
@@ -207,10 +207,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
@VisibleForTesting
|
||||
protected boolean shouldShowLottie() {
|
||||
DisplayDensityUtils displayDensity = new DisplayDensityUtils(getApplicationContext());
|
||||
int currentDensityIndex = displayDensity.getCurrentIndexForDefaultDisplay();
|
||||
final int currentDensity = displayDensity.getDefaultDisplayDensityValues()
|
||||
[currentDensityIndex];
|
||||
final int defaultDensity = displayDensity.getDefaultDensityForDefaultDisplay();
|
||||
int currentDensityIndex = displayDensity.getCurrentIndex();
|
||||
final int currentDensity = displayDensity.getValues()[currentDensityIndex];
|
||||
final int defaultDensity = displayDensity.getDefaultDensity();
|
||||
|
||||
if (getResources().getConfiguration().fontScale > 1) {
|
||||
return false;
|
||||
|
@@ -42,7 +42,7 @@ interface DisplayDensityInteractor {
|
||||
val fontScale: Flow<Float>
|
||||
|
||||
/** A flow that propagates displayDensity. */
|
||||
val displayDensity: Flow<Int>
|
||||
val displayDensity: Flow<Int?>
|
||||
|
||||
/** A flow that propagates the default display density. */
|
||||
val defaultDisplayDensity: Flow<Int>
|
||||
@@ -67,16 +67,14 @@ class DisplayDensityInteractorImpl(context: Context, scope: CoroutineScope) :
|
||||
|
||||
private val _fontScale = MutableStateFlow(context.resources.configuration.fontScale)
|
||||
private val _displayDensity =
|
||||
MutableStateFlow(
|
||||
displayDensityUtils.defaultDisplayDensityValues[
|
||||
displayDensityUtils.currentIndexForDefaultDisplay]
|
||||
)
|
||||
MutableStateFlow(displayDensityUtils.values?.let{
|
||||
it[displayDensityUtils.currentIndex]
|
||||
})
|
||||
|
||||
override val fontScale: Flow<Float> = _fontScale.asStateFlow()
|
||||
|
||||
override val displayDensity: Flow<Int> = _displayDensity.asStateFlow()
|
||||
override val displayDensity: Flow<Int?> = _displayDensity.asStateFlow()
|
||||
|
||||
override val defaultDisplayDensity: Flow<Int> =
|
||||
flowOf(displayDensityUtils.defaultDensityForDefaultDisplay)
|
||||
.shareIn(scope, SharingStarted.Eagerly, 1)
|
||||
flowOf(displayDensityUtils.defaultDensity).shareIn(scope, SharingStarted.Eagerly, 1)
|
||||
}
|
||||
|
@@ -149,11 +149,11 @@ class FingerprintEnrollmentV2Activity : FragmentActivity() {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
foldStateInteractor.onConfigurationChange(newConfig)
|
||||
val displayDensityUtils = DisplayDensityUtils(applicationContext)
|
||||
val currIndex = displayDensityUtils.currentIndexForDefaultDisplay
|
||||
val currIndex = displayDensityUtils.currentIndex
|
||||
displayDensityInteractor.updateFontScale(resources.configuration.fontScale)
|
||||
displayDensityInteractor.updateDisplayDensity(
|
||||
displayDensityUtils.defaultDisplayDensityValues[currIndex]
|
||||
)
|
||||
displayDensityUtils.values?.let {
|
||||
displayDensityInteractor.updateDisplayDensity(it[currIndex])
|
||||
}
|
||||
}
|
||||
|
||||
private fun onConfirmDevice(resultCode: Int, data: Intent?) {
|
||||
|
@@ -325,11 +325,10 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
||||
}
|
||||
|
||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||
final int defaultDensity = density.getDefaultDensityForDefaultDisplay();
|
||||
final int currentIndex = density.getCurrentIndex();
|
||||
final int defaultDensity = density.getDefaultDensity();
|
||||
|
||||
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
||||
== density.getDefaultDensityForDefaultDisplay()) {
|
||||
if (density.getValues()[mCurrentIndex] == density.getDefaultDensity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,20 +372,19 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
||||
/* If current density is the same as a default density of other resolutions,
|
||||
* then mCurrentIndex may be out of boundary.
|
||||
*/
|
||||
if (density.getDefaultDisplayDensityValues().length <= mCurrentIndex) {
|
||||
mCurrentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||
if (density.getValues().length <= mCurrentIndex) {
|
||||
mCurrentIndex = density.getCurrentIndex();
|
||||
}
|
||||
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
||||
!= density.getDefaultDensityForDefaultDisplay()) {
|
||||
if (density.getValues()[mCurrentIndex] != density.getDefaultDensity()) {
|
||||
density.setForcedDisplayDensity(mCurrentIndex);
|
||||
}
|
||||
|
||||
mDefaultDensity = density.getDefaultDensityForDefaultDisplay();
|
||||
mDefaultDensity = density.getDefaultDensity();
|
||||
}
|
||||
|
||||
private boolean isDensityChanged() {
|
||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||
if (density.getDefaultDensityForDefaultDisplay() == mDefaultDensity) {
|
||||
if (density.getDefaultDensity() == mDefaultDensity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -36,13 +36,13 @@ public class ScreenZoomPreference extends Preference {
|
||||
android.R.attr.preferenceStyle));
|
||||
|
||||
final DisplayDensityUtils density = new DisplayDensityUtils(context);
|
||||
final int defaultIndex = density.getCurrentIndexForDefaultDisplay();
|
||||
final int defaultIndex = density.getCurrentIndex();
|
||||
if (defaultIndex < 0) {
|
||||
setVisible(false);
|
||||
setEnabled(false);
|
||||
} else if (TextUtils.isEmpty(getSummary())) {
|
||||
final String[] entries = density.getDefaultDisplayDensityEntries();
|
||||
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||
final String[] entries = density.getEntries();
|
||||
final int currentIndex = density.getCurrentIndex();
|
||||
setSummary(entries[currentIndex]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user