Merge "Make Configuration.generateDelta() public"
This commit is contained in:
@@ -13301,6 +13301,7 @@ package android.content.res {
|
||||
method public int describeContents();
|
||||
method public int diff(android.content.res.Configuration);
|
||||
method public boolean equals(android.content.res.Configuration);
|
||||
method @NonNull public static android.content.res.Configuration generateDelta(@NonNull android.content.res.Configuration, @NonNull android.content.res.Configuration);
|
||||
method public int getLayoutDirection();
|
||||
method @NonNull public android.os.LocaleList getLocales();
|
||||
method public boolean isLayoutSizeAtLeast(int);
|
||||
|
||||
@@ -2620,10 +2620,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
||||
* {@link #updateFrom(Configuration)} will treat it as a no-op and not update that member.
|
||||
*
|
||||
* This is fine for device configurations as no member is ever undefined.
|
||||
* {@hide}
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static Configuration generateDelta(Configuration base, Configuration change) {
|
||||
@NonNull
|
||||
public static Configuration generateDelta(
|
||||
@NonNull Configuration base, @NonNull Configuration change) {
|
||||
final Configuration delta = new Configuration();
|
||||
if (base.fontScale != change.fontScale) {
|
||||
delta.fontScale = change.fontScale;
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
|
||||
package com.android.settingslib.applications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
|
||||
/**
|
||||
* A class for applying config changes and determing if doing so resulting in any "interesting"
|
||||
* changes.
|
||||
*/
|
||||
public class InterestingConfigChanges {
|
||||
private final Configuration mLastConfiguration = new Configuration();
|
||||
private final int mFlags;
|
||||
@@ -35,6 +40,14 @@ public class InterestingConfigChanges {
|
||||
mFlags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given config change and returns whether an "interesting" change happened.
|
||||
*
|
||||
* @param res The source of the new config to apply
|
||||
*
|
||||
* @return Whether interesting changes occurred
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public boolean applyNewConfig(Resources res) {
|
||||
int configChanges = mLastConfiguration.updateFrom(
|
||||
Configuration.generateDelta(mLastConfiguration, res.getConfiguration()));
|
||||
|
||||
Reference in New Issue
Block a user