aboutsummaryrefslogtreecommitdiff
path: root/bridge/src/com/android/layoutlib/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/src/com/android/layoutlib/bridge')
-rw-r--r--bridge/src/com/android/layoutlib/bridge/Bridge.java23
-rw-r--r--bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java5
-rw-r--r--bridge/src/com/android/layoutlib/bridge/MockView.java1
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java51
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java45
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java56
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java4
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/support/DrawerLayoutUtil.java4
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/support/FragmentTabHostUtil.java6
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java4
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java4
-rw-r--r--bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java154
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java6
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/Config.java7
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java4
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java8
-rw-r--r--bridge/src/com/android/layoutlib/bridge/bars/ThemePreviewNavigationBar.java58
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java1
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java14
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/Layout.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/PorterDuffUtility.java6
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java6
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java45
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java42
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/binding/AdapterHelper.java11
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java3
-rw-r--r--bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java3
-rw-r--r--bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java2
-rw-r--r--bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java1
31 files changed, 219 insertions, 361 deletions
diff --git a/bridge/src/com/android/layoutlib/bridge/Bridge.java b/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 88298d69e3..aa76e750d9 100644
--- a/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -17,7 +17,7 @@
package com.android.layoutlib.bridge;
import com.android.ide.common.rendering.api.DrawableParams;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.ResourceNamespace;
import com.android.ide.common.rendering.api.ResourceReference;
@@ -33,7 +33,7 @@ import com.android.resources.ResourceType;
import com.android.tools.layoutlib.annotations.Nullable;
import com.android.tools.layoutlib.create.MethodAdapter;
import com.android.tools.layoutlib.create.OverrideMethod;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import android.animation.PropertyValuesHolder;
import android.animation.PropertyValuesHolder_Delegate;
@@ -56,7 +56,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.EnumMap;
-import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -94,7 +93,6 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
/**
* Maps from id to resource type/name. This is for com.android.internal.R
*/
- @SuppressWarnings("deprecation")
private final static Map<Integer, Pair<ResourceType, String>> sRMap = new HashMap<>();
/**
@@ -124,7 +122,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
/**
* A default log than prints to stdout/stderr.
*/
- private final static LayoutLog sDefaultLog = new LayoutLog() {
+ private final static ILayoutLog sDefaultLog = new ILayoutLog() {
@Override
public void error(String tag, String message, Object viewCookie, Object data) {
System.err.println(message);
@@ -145,7 +143,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
/**
* Current log.
*/
- private static LayoutLog sCurrentLog = sDefaultLog;
+ private static ILayoutLog sCurrentLog = sDefaultLog;
public static boolean sIsTypefaceInitialized;
@@ -155,7 +153,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
String nativeLibPath,
String icuDataPath,
Map<String, Map<String, Integer>> enumValueMap,
- LayoutLog log) {
+ ILayoutLog log) {
sPlatformProperties = platformProperties;
sEnumValueMap = enumValueMap;
@@ -208,7 +206,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
continue;
}
String resTypeName = inner.getSimpleName();
- ResourceType resType = ResourceType.getEnum(resTypeName);
+ ResourceType resType = ResourceType.fromClassName(resTypeName);
if (resType != null) {
Map<String, Integer> fullMap = null;
switch (resType) {
@@ -236,7 +234,6 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
Class<?> type = f.getType();
if (!type.isArray()) {
Integer value = (Integer) f.get(null);
- //noinspection deprecation
sRMap.put(value, Pair.of(resType, f.getName()));
fullMap.put(f.getName(), value);
}
@@ -245,7 +242,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
}
} catch (Exception throwable) {
if (log != null) {
- log.error(LayoutLog.TAG_BROKEN,
+ log.error(ILayoutLog.TAG_BROKEN,
"Failed to load com.android.internal.R from the layout library jar",
throwable, null, null);
}
@@ -327,11 +324,9 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
if (arrayValue != null) {
String attrName = name.substring(arrayName.length() + 1);
int attrValue = arrayValue[index];
- //noinspection deprecation
sRMap.put(attrValue, Pair.of(ResourceType.ATTR, attrName));
revRAttrMap.put(attrName, attrValue);
}
- //noinspection deprecation
sRMap.put(index, Pair.of(ResourceType.STYLEABLE, name));
revRStyleableMap.put(name, index);
}
@@ -512,11 +507,11 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
Looper_Accessor.cleanupThread();
}
- public static LayoutLog getLog() {
+ public static ILayoutLog getLog() {
return sCurrentLog;
}
- public static void setLog(LayoutLog log) {
+ public static void setLog(ILayoutLog log) {
// check only the thread currently owning the lock can do this.
if (!sLock.isHeldByCurrentThread()) {
throw new IllegalStateException("scene must be acquired first. see #acquire(long)");
diff --git a/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 442a77bdcd..558470845f 100644
--- a/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -74,11 +74,6 @@ public class BridgeRenderSession extends RenderSession {
}
@Override
- public Map<Object, String> getDefaultStyles() {
- return mSession != null ? mSession.getDefaultStyles() : Collections.emptyMap();
- }
-
- @Override
public Map<Object, ResourceReference> getDefaultNamespacedStyles() {
return mSession != null ? mSession.getDefaultNamespacedStyles() : Collections.emptyMap();
}
diff --git a/bridge/src/com/android/layoutlib/bridge/MockView.java b/bridge/src/com/android/layoutlib/bridge/MockView.java
index 9856cf64c6..a1d1bbc456 100644
--- a/bridge/src/com/android/layoutlib/bridge/MockView.java
+++ b/bridge/src/com/android/layoutlib/bridge/MockView.java
@@ -111,7 +111,6 @@ public class MockView extends FrameLayout {
mView.setText(text);
}
- @SuppressWarnings("WeakerAccess") // This method is used from Studio
public void setGravity(int gravity) {
mView.setGravity(gravity);
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
index ce613e0170..8934b122a3 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
@@ -16,6 +16,7 @@
package com.android.layoutlib.bridge.android;
+import android.content.AttributionSource;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;
@@ -44,7 +45,7 @@ import java.util.ArrayList;
*/
public final class BridgeContentProvider implements IContentProvider {
@Override
- public ContentProviderResult[] applyBatch(String callingPackage, String callingFeatureId,
+ public ContentProviderResult[] applyBatch(AttributionSource attributionSource,
String authority, ArrayList<ContentProviderOperation> arg0)
throws RemoteException, OperationApplicationException {
// TODO Auto-generated method stub
@@ -52,21 +53,21 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public int bulkInsert(String callingPackage, String callingFeatureId, Uri arg0,
+ public int bulkInsert(AttributionSource attributionSource, Uri arg0,
ContentValues[] arg1) throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
@Override
- public Bundle call(String callingPackage, String callingFeatureId, String authority,
+ public Bundle call(AttributionSource attributionSource, String authority,
String arg0, String arg1, Bundle arg2) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
@Override
- public int delete(String callingPackage, String callingFeatureId, Uri arg0, Bundle arg1)
+ public int delete(AttributionSource attributionSource, Uri arg0, Bundle arg1)
throws RemoteException {
// TODO Auto-generated method stub
return 0;
@@ -93,14 +94,14 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public Uri insert(String callingPackage, String callingFeatureId, Uri arg0, ContentValues arg1,
+ public Uri insert(AttributionSource attributionSource, Uri arg0, ContentValues arg1,
Bundle arg2) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
@Override
- public AssetFileDescriptor openAssetFile(String callingPackage, String callingFeatureId,
+ public AssetFileDescriptor openAssetFile(AttributionSource attributionSource,
Uri arg0, String arg1, ICancellationSignal signal)
throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
@@ -108,22 +109,22 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public ParcelFileDescriptor openFile(String callingPackage, String callingFeatureId, Uri arg0,
- String arg1, ICancellationSignal signal, IBinder token)
+ public ParcelFileDescriptor openFile(AttributionSource attributionSource, Uri arg0,
+ String arg1, ICancellationSignal signal)
throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
return null;
}
@Override
- public Cursor query(String callingPackage, String callingFeatureId, Uri arg0, String[] arg1,
+ public Cursor query(AttributionSource attributionSource, Uri arg0, String[] arg1,
Bundle arg3, ICancellationSignal arg4) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
@Override
- public int update(String callingPackage, String callingFeatureId, Uri arg0, ContentValues arg1,
+ public int update(AttributionSource attributionSource, Uri arg0, ContentValues arg1,
Bundle arg2) throws RemoteException {
// TODO Auto-generated method stub
return 0;
@@ -142,7 +143,7 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public AssetFileDescriptor openTypedAssetFile(String callingPackage, String callingFeatureId,
+ public AssetFileDescriptor openTypedAssetFile(AttributionSource attributionSource,
Uri arg0, String arg1, Bundle arg2, ICancellationSignal signal)
throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
@@ -157,20 +158,20 @@ public final class BridgeContentProvider implements IContentProvider {
@Override
- public Uri canonicalize(String callingPkg, String callingFeatureId, Uri uri)
+ public Uri canonicalize(AttributionSource attributionSource, Uri uri)
throws RemoteException {
return null;
}
@SuppressWarnings("deprecation")
@Override
- public void canonicalizeAsync(String callingPkg, String callingFeatureId, Uri uri,
+ public void canonicalizeAsync(AttributionSource attributionSource, Uri uri,
RemoteCallback remoteCallback) {
AsyncTask.SERIAL_EXECUTOR.execute(() -> {
try {
final Bundle bundle = new Bundle();
bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT,
- canonicalize(callingPkg, callingFeatureId, uri));
+ canonicalize(attributionSource, uri));
remoteCallback.sendResult(bundle);
} catch (RemoteException e) {
// Ignore
@@ -179,19 +180,35 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public Uri uncanonicalize(String callingPkg, String callingFeatureId, Uri uri)
+ public Uri uncanonicalize(AttributionSource attributionSource, Uri uri)
throws RemoteException {
return null;
}
+ @SuppressWarnings("deprecation")
+ @Override
+ public void uncanonicalizeAsync(AttributionSource attributionSource, Uri uri,
+ RemoteCallback remoteCallback) {
+ AsyncTask.SERIAL_EXECUTOR.execute(() -> {
+ try {
+ final Bundle bundle = new Bundle();
+ bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT,
+ uncanonicalize(attributionSource, uri));
+ remoteCallback.sendResult(bundle);
+ } catch (RemoteException e) {
+ // Ignore
+ }
+ });
+ }
+
@Override
- public boolean refresh(String callingPkg, String callingFeatureId, Uri url, Bundle args,
+ public boolean refresh(AttributionSource attributionSource, Uri url, Bundle args,
ICancellationSignal cancellationSignal) throws RemoteException {
return false;
}
@Override
- public int checkUriPermission(String callingPkg, String callingFeatureId, Uri uri, int uid,
+ public int checkUriPermission(AttributionSource attributionSource, Uri uri, int uid,
int modeFlags) throws RemoteException {
return PackageManager.PERMISSION_DENIED;
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index e1e61508a9..73a73d0381 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -18,8 +18,8 @@ package com.android.layoutlib.bridge.android;
import com.android.SdkConstants;
import com.android.ide.common.rendering.api.AssetRepository;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceNamespace;
@@ -30,21 +30,23 @@ import com.android.ide.common.rendering.api.ResourceValueImpl;
import com.android.ide.common.rendering.api.StyleResourceValue;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
-import com.android.layoutlib.bridge.android.view.WindowManagerImpl;
import com.android.layoutlib.bridge.impl.ParserFactory;
import com.android.layoutlib.bridge.impl.ResourceHelper;
import com.android.layoutlib.bridge.impl.Stack;
import com.android.resources.ResourceType;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.app.ActivityManager;
+import android.app.ActivityManager_Accessor;
import android.app.SystemServiceRegistry;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
+import android.content.ComponentCallbacks;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -69,6 +71,7 @@ import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
+import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -90,6 +93,7 @@ import android.view.DisplayAdjustments;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.WindowManagerImpl;
import android.view.accessibility.AccessibilityManager;
import android.view.autofill.AutofillManager;
import android.view.autofill.IAutoFillManager.Default;
@@ -116,7 +120,6 @@ import static com.android.layoutlib.bridge.android.RenderParamsFlags.FLAG_KEY_AP
/**
* Custom implementation of Context/Activity to handle non compiled resources.
*/
-@SuppressWarnings("deprecation") // For use of Pair.
public class BridgeContext extends Context {
private static final String PREFIX_THEME_APPCOMPAT = "Theme.AppCompat";
@@ -166,6 +169,8 @@ public class BridgeContext extends Context {
private final DisplayManager mDisplayManager;
private final AutofillManager mAutofillManager;
private final ClipboardManager mClipboardManager;
+ private final ActivityManager mActivityManager;
+ private final ConnectivityManager mConnectivityManager;
private final HashMap<View, Integer> mScrollYPos = new HashMap<>();
private final HashMap<View, Integer> mScrollXPos = new HashMap<>();
@@ -253,6 +258,8 @@ public class BridgeContext extends Context {
mDisplayManager = new DisplayManager(this);
mAutofillManager = new AutofillManager(this, new Default());
mClipboardManager = new ClipboardManager(this, null);
+ mActivityManager = ActivityManager_Accessor.getActivityManagerInstance(this);
+ mConnectivityManager = new ConnectivityManager(this, null);
if (mLayoutlibCallback.isResourceNamespacingRequired()) {
if (mLayoutlibCallback.hasAndroidXAppCompat()) {
@@ -522,18 +529,18 @@ public class BridgeContext extends Context {
popParser();
}
} else {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
String.format("File %s is missing!", path), null, null);
}
} catch (XmlPullParserException e) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Failed to parse file " + path, e, null, null /*data*/);
// we'll return null below.
} finally {
mBridgeInflater.setResourceReference(null);
}
} else {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
String.format("Layout %s%s does not exist.", isPlatformLayout ? "android:" : "",
layout.getName()), null, null);
}
@@ -648,6 +655,12 @@ public class BridgeContext extends Context {
case CLIPBOARD_SERVICE:
return mClipboardManager;
+ case ACTIVITY_SERVICE:
+ return mActivityManager;
+
+ case CONNECTIVITY_SERVICE:
+ return mConnectivityManager;
+
case AUDIO_SERVICE:
case TEXT_CLASSIFICATION_SERVICE:
case CONTENT_CAPTURE_MANAGER_SERVICE:
@@ -685,7 +698,7 @@ public class BridgeContext extends Context {
}
if (style == null) {
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_RESOLVE,
"Failed to find style with " + resId, null, null);
return null;
}
@@ -754,7 +767,7 @@ public class BridgeContext extends Context {
resolver = Resolver.EMPTY_RESOLVER;
} else if (set != null) {
// really this should not be happening since its instantiated in Bridge
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Parser is not a BridgeXmlBlockParser!", null, null);
return null;
} else {
@@ -793,7 +806,7 @@ public class BridgeContext extends Context {
// This should be rare. Happens trying to map R.style.foo to @style/foo fails.
// This will happen if the user explicitly used a non existing int value for
// defStyleAttr or there's something wrong with the project structure/build.
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_RESOLVE,
"Failed to find the style corresponding to the id " + defStyleAttr, null,
null);
} else {
@@ -952,7 +965,7 @@ public class BridgeContext extends Context {
if (reference != null) {
val = reference.getResourceUrl().toString();
}
- Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR,
+ Bridge.getLog().warning(ILayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR,
String.format("Failed to find '%s' in current theme.", val),
null, val);
}
@@ -1005,6 +1018,12 @@ public class BridgeContext extends Context {
return mPackageManager;
}
+ @Override
+ public void registerComponentCallbacks(ComponentCallbacks callback) {}
+
+ @Override
+ public void unregisterComponentCallbacks(ComponentCallbacks callback) {}
+
// ------------- private new methods
/**
@@ -1186,7 +1205,7 @@ public class BridgeContext extends Context {
public IBinder getBinder() {
if (mBinder == null) {
- // create a dummy binder. We only need it be not null.
+ // create a no-op binder. We only need it be not null.
mBinder = new IBinder() {
@Override
public String getInterfaceDescriptor() throws RemoteException {
@@ -1965,7 +1984,7 @@ public class BridgeContext extends Context {
@Override
public File getObbDir() {
- Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null, null);
+ Bridge.getLog().error(ILayoutLog.TAG_UNSUPPORTED, "OBB not supported", null, null);
return null;
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 584e8c204e..41e4e2dfd9 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -17,6 +17,7 @@
package com.android.layoutlib.bridge.android;
import android.os.BatterySaverPolicyConfig;
+import android.os.ParcelDuration;
import android.os.IBinder;
import android.os.IPowerManager;
import android.os.PowerManager;
@@ -46,6 +47,16 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
+ public BatterySaverPolicyConfig getFullPowerSavePolicy() {
+ return new BatterySaverPolicyConfig.Builder().build();
+ }
+
+ @Override
+ public boolean setFullPowerSavePolicy(BatterySaverPolicyConfig config) {
+ return false;
+ }
+
+ @Override
public boolean setDynamicPowerSaveHint(boolean powerSaveHint, int disableThreshold)
throws RemoteException {
return false;
@@ -72,25 +83,44 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
+ public void setBatteryDischargePrediction(ParcelDuration timeRemaining,
+ boolean isPersonalized) {
+ // pass for now
+ }
+
+ @Override
+ public ParcelDuration getBatteryDischargePrediction() {
+ return null;
+ }
+
+ @Override
+ public boolean isBatteryDischargePredictionPersonalized() {
+ return false;
+ }
+
+ @Override
public IBinder asBinder() {
// pass for now.
return null;
}
@Override
- public void acquireWakeLock(IBinder arg0, int arg1, String arg2, String arg2_5, WorkSource arg3, String arg4)
+ public void acquireWakeLock(IBinder arg0, int arg1, String arg2, String arg2_5, WorkSource arg3,
+ String arg4, int arg5)
throws RemoteException {
// pass for now.
}
@Override
- public void acquireWakeLockWithUid(IBinder arg0, int arg1, String arg2, String arg2_5, int arg3)
- throws RemoteException {
+ public void acquireWakeLockAsync(IBinder arg0, int arg1, String arg2, String arg2_5,
+ WorkSource arg3, String arg4) throws RemoteException {
// pass for now.
}
@Override
- public void powerHint(int hintId, int data) {
+ public void acquireWakeLockWithUid(IBinder arg0, int arg1, String arg2, String arg2_5,
+ int arg3, int arg4)
+ throws RemoteException {
// pass for now.
}
@@ -150,11 +180,21 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
+ public void releaseWakeLockAsync(IBinder arg0, int arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
public void updateWakeLockUids(IBinder arg0, int[] arg1) throws RemoteException {
// pass for now.
}
@Override
+ public void updateWakeLockUidsAsync(IBinder arg0, int[] arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
public void setAttentionLight(boolean arg0, int arg1) throws RemoteException {
// pass for now.
}
@@ -176,7 +216,8 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public void userActivity(long time, int event, int flags) throws RemoteException {
+ public void userActivity(int displayId, long time, int event, int flags)
+ throws RemoteException {
// pass for now.
}
@@ -237,6 +278,11 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
+ public boolean isAmbientDisplaySuppressedForTokenByApp(String token, int appUid) {
+ return false;
+ }
+
+ @Override
public boolean isAmbientDisplaySuppressed() {
return false;
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java b/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java
index 5f785f5092..92693c69be 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/support/DesignLibUtil.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.android.support;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;
@@ -61,7 +61,7 @@ public class DesignLibUtil {
try {
invoke(getMethod(view.getClass(), "setTitle", CharSequence.class), view, title);
} catch (ReflectionException e) {
- Bridge.getLog().warning(LayoutLog.TAG_INFO,
+ Bridge.getLog().warning(ILayoutLog.TAG_INFO,
"Error occurred while trying to set title.", null, e);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/support/DrawerLayoutUtil.java b/bridge/src/com/android/layoutlib/bridge/android/support/DrawerLayoutUtil.java
index c41bcae5b4..08e7419a42 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/support/DrawerLayoutUtil.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/support/DrawerLayoutUtil.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.android.support;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;
@@ -59,7 +59,7 @@ public class DrawerLayoutUtil {
invoke(getMethod(drawerLayout.getClass(), "openDrawer", int.class), drawerLayout,
gravity);
} catch (ReflectionException e) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to open navigation drawer",
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, "Unable to open navigation drawer",
getCause(e), null, null);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/support/FragmentTabHostUtil.java b/bridge/src/com/android/layoutlib/bridge/android/support/FragmentTabHostUtil.java
index c77cb572c5..a426b27a12 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/support/FragmentTabHostUtil.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/support/FragmentTabHostUtil.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.android.support;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.util.ReflectionUtils.ReflectionException;
@@ -59,7 +59,7 @@ public class FragmentTabHostUtil {
}
if (fragmentManager == null) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Unable to find FragmentManager.", null, null);
return;
}
@@ -70,7 +70,7 @@ public class FragmentTabHostUtil {
android.R.id.tabcontent);
} catch (ReflectionException e) {
Throwable cause = getCause(e);
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Error occurred while trying to setup FragmentTabHost.", cause, null, null);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java b/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java
index 6fc8009b31..ff20fbf6a2 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/support/RecyclerViewUtil.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.android.support;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
@@ -72,7 +72,7 @@ public class RecyclerViewUtil {
}
} catch (ReflectionException e) {
Throwable cause = getCause(e);
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Error occurred while trying to setup RecyclerView.", cause, null, null);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java b/bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java
index 171edb9095..f195a5e593 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/support/SupportPreferencesUtil.java
@@ -298,8 +298,8 @@ public class SupportPreferencesUtil {
preferenceGroupAdapter);
ScrollView scrollView = new ScrollView(context);
- scrollView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT));
+ scrollView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
scrollView.addView(listView);
if (root != null) {
diff --git a/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java b/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java
deleted file mode 100644
index 3cd95befa9..0000000000
--- a/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.layoutlib.bridge.android.view;
-
-import android.app.ResourcesManager;
-import android.content.Context;
-import android.graphics.Insets;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.graphics.Region;
-import android.os.RemoteException;
-import android.util.DisplayMetrics;
-import android.util.Size;
-import android.view.Display;
-import android.view.Display.Mode;
-import android.view.DisplayAdjustments;
-import android.view.DisplayCutout;
-import android.view.DisplayInfo;
-import android.view.InsetsState;
-import android.view.View;
-import android.view.WindowInsets;
-import android.view.WindowManager;
-import android.view.WindowManagerGlobal;
-import android.view.WindowMetrics;
-
-public class WindowManagerImpl implements WindowManager {
-
- private final Context mContext;
- private final DisplayMetrics mMetrics;
- private final Display mDisplay;
-
- public WindowManagerImpl(Context context, DisplayMetrics metrics) {
- mContext = context;
- mMetrics = metrics;
-
- DisplayInfo info = new DisplayInfo();
- info.logicalHeight = mMetrics.heightPixels;
- info.logicalWidth = mMetrics.widthPixels;
- info.supportedModes = new Mode[] {
- new Mode(0, mMetrics.widthPixels, mMetrics.heightPixels, 60f)
- };
- info.logicalDensityDpi = mMetrics.densityDpi;
- mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info,
- DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
- }
-
- @Override
- public Display getDefaultDisplay() {
- return mDisplay;
- }
-
-
- @Override
- public void addView(View arg0, android.view.ViewGroup.LayoutParams arg1) {
- // pass
- }
-
- @Override
- public void removeView(View arg0) {
- // pass
- }
-
- @Override
- public void updateViewLayout(View arg0, android.view.ViewGroup.LayoutParams arg1) {
- // pass
- }
-
-
- @Override
- public void removeViewImmediate(View arg0) {
- // pass
- }
-
- @Override
- public void requestAppKeyboardShortcuts(
- KeyboardShortcutsReceiver receiver, int deviceId) {
- }
-
- @Override
- public Region getCurrentImeTouchRegion() {
- return null;
- }
-
- @Override
- public void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
- // pass
- }
-
- @Override
- public void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
- // pass
- }
-
- @Override
- public void setShouldShowIme(int displayId, boolean shouldShow) {
- // pass
- }
-
- @Override
- public WindowMetrics getCurrentWindowMetrics() {
- final Rect bound = getCurrentBounds(mContext);
-
- return new WindowMetrics(bound, computeWindowInsets());
- }
-
- private static Rect getCurrentBounds(Context context) {
- synchronized (ResourcesManager.getInstance()) {
- return context.getResources().getConfiguration().windowConfiguration.getBounds();
- }
- }
-
- @Override
- public WindowMetrics getMaximumWindowMetrics() {
- return new WindowMetrics(getMaximumBounds(), computeWindowInsets());
- }
-
- private Rect getMaximumBounds() {
- final Point displaySize = new Point();
- mDisplay.getRealSize(displaySize);
- return new Rect(0, 0, displaySize.x, displaySize.y);
- }
-
- private WindowInsets computeWindowInsets() {
- try {
- final Rect systemWindowInsets = new Rect();
- final Rect stableInsets = new Rect();
- final DisplayCutout.ParcelableWrapper displayCutout =
- new DisplayCutout.ParcelableWrapper();
- final InsetsState insetsState = new InsetsState();
- WindowManagerGlobal.getWindowManagerService().getWindowInsets(
- new WindowManager.LayoutParams(), mContext.getDisplayId(), systemWindowInsets,
- stableInsets, displayCutout, insetsState);
- return new WindowInsets.Builder()
- .setSystemWindowInsets(Insets.of(systemWindowInsets))
- .setStableInsets(Insets.of(stableInsets))
- .setDisplayCutout(displayCutout.get()).build();
- } catch (RemoteException ignore) {
- }
- return null;
- }
-}
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java b/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
index ab88f15222..8ca809e516 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/AppCompatActionBar.java
@@ -15,7 +15,7 @@
*/
package com.android.layoutlib.bridge.bars;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceReference;
@@ -118,7 +118,7 @@ public class AppCompatActionBar extends BridgeActionBar {
setupActionBar();
getContentRoot().setId(id.content);
} catch (Exception e) {
- Bridge.getLog().warning(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().warning(ILayoutLog.TAG_BROKEN,
"Failed to load AppCompat ActionBar with unknown error.", null, e);
}
}
@@ -201,7 +201,7 @@ public class AppCompatActionBar extends BridgeActionBar {
if (menuIds.size() > 1) {
// Supporting multiple menus means that we would need to instantiate our own supportlib
// MenuInflater instances using reflection
- Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
+ Bridge.getLog().fidelityWarning(ILayoutLog.TAG_UNSUPPORTED,
"Support Toolbar does not currently support multiple menus in the preview.",
null, null, null);
}
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java b/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
index 8790cb531f..1f7b187ec7 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/BridgeActionBar.java
@@ -45,7 +45,7 @@ public abstract class BridgeActionBar {
private final View mDecorContent;
private final ActionBarCallback mCallback;
- @SuppressWarnings("NullableProblems") // Should be initialized by subclasses.
+ @SuppressWarnings("NotNullFieldNotInitialized") // Should be initialized by subclasses.
@NonNull private FrameLayout mContentRoot;
public BridgeActionBar(@NonNull BridgeContext context, @NonNull SessionParams params) {
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/Config.java b/bridge/src/com/android/layoutlib/bridge/bars/Config.java
index 7813844133..a49a6643a5 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/Config.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/Config.java
@@ -92,8 +92,8 @@ public class Config {
}
public static String getTime(int platformVersion) {
- if (isGreaterOrEqual(platformVersion, Q)) {
- return "10:00";
+ if (isGreaterOrEqual(platformVersion, R)) {
+ return "11:00";
}
if (platformVersion < GINGERBREAD) {
return "2:20";
@@ -134,6 +134,9 @@ public class Config {
if (platformVersion < Q) {
return "9:00";
}
+ if (platformVersion < R) {
+ return "10:00";
+ }
// Should never happen.
return "4:04";
}
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
index 3a5f6331e6..0bb72ed851 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.bars;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.StyleResourceValue;
@@ -256,7 +256,7 @@ abstract class CustomBar extends LinearLayout {
return ResourceHelper.getColor(resource.getValue());
} catch (NumberFormatException e) {
// Conversion failed.
- Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT,
+ Bridge.getLog().warning(ILayoutLog.TAG_RESOURCES_FORMAT,
"Theme attribute @android:" + attr +
" does not reference a color, instead is '" +
resource.getValue() + "'.", null, resource);
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java b/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
index 230094e2c2..e08f5238ea 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/FrameworkActionBar.java
@@ -191,7 +191,7 @@ public class FrameworkActionBar extends BridgeActionBar {
// Copied from com.android.internal.view.menu.MenuPopHelper.measureContentWidth()
private int measureContentWidth(@NonNull ListAdapter adapter) {
- // Menus don't tend to be long, so this is more sane than it looks.
+ // Menus don't tend to be long, so this is shouldn't be a problem
int maxWidth = 0;
View itemView = null;
int itemType = 0;
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java b/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
index f58443a6b6..dc823f7e37 100644
--- a/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
+++ b/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.bars;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.ResourceNamespace;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
@@ -90,7 +90,7 @@ public class StatusBar extends CustomBar {
}
if (icons.size() != 2 || clockView == null) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to initialize statusbar", null,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, "Unable to initialize statusbar", null,
null, null);
return;
}
@@ -126,10 +126,10 @@ public class StatusBar extends CustomBar {
imageView.setImageDrawable(
Drawable.createFromXml(mContext.getResources(), parser));
} catch (XmlPullParserException e) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to draw wifi icon", e,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, "Unable to draw wifi icon", e,
null, null);
} catch (IOException e) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to draw wifi icon", e,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, "Unable to draw wifi icon", e,
null, null);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/bars/ThemePreviewNavigationBar.java b/bridge/src/com/android/layoutlib/bridge/bars/ThemePreviewNavigationBar.java
deleted file mode 100644
index 523f14010a..0000000000
--- a/bridge/src/com/android/layoutlib/bridge/bars/ThemePreviewNavigationBar.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.layoutlib.bridge.bars;
-
-import com.android.layoutlib.bridge.android.BridgeContext;
-import com.android.resources.Density;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-
-/**
- * Navigation Bar for the Theme Editor preview.
- *
- * For small bars, it is identical to {@link NavigationBar}.
- * But wide bars from {@link NavigationBar} are too wide for the Theme Editor preview.
- * To solve that problem, {@link ThemePreviewNavigationBar} use the layout for small bars,
- * and have no padding on the sides. That way, they have a similar look as the true ones,
- * and they fit in the Theme Editor preview.
- */
-public class ThemePreviewNavigationBar extends NavigationBar {
- private static final int PADDING_WIDTH_SW600 = 0;
-
- @SuppressWarnings("unused")
- public ThemePreviewNavigationBar(Context context, AttributeSet attrs) {
- super((BridgeContext) context,
- Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
- LinearLayout.HORIZONTAL, // In this mode, it doesn't need to be render vertically
- ((BridgeContext) context).getConfiguration().getLayoutDirection() ==
- View.LAYOUT_DIRECTION_RTL,
- (context.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0,
- 0, LAYOUT_XML, false);
- }
-
- @Override
- protected int getSidePadding(float sw) {
- if (sw >= 600) {
- return PADDING_WIDTH_SW600;
- }
- return super.getSidePadding(sw);
- }
-}
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java b/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
index b71a0e28bf..5991eb0721 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/DelegateManager.java
@@ -111,7 +111,6 @@ public final class DelegateManager<T> {
@GuardedBy("sNativeAllocations")
private static long sNativeAllocationsCount = 0;
- @SuppressWarnings("FieldCanBeLocal")
private final Class<T> mClass;
public DelegateManager(Class<T> theClass) {
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java b/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
index 959ba77f6a..f3ebd40706 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
@@ -16,12 +16,7 @@
package com.android.layoutlib.bridge.impl;
-import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
-import static java.awt.image.BufferedImage.TYPE_INT_RGB;
-import static java.lang.Math.min;
-import static java.lang.Math.max;
-
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.layoutlib.bridge.Bridge;
import android.graphics.Bitmap_Delegate;
@@ -51,6 +46,11 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
+import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
+import static java.lang.Math.max;
+import static java.lang.Math.min;
+
/**
* Class representing a graphics context snapshot, as well as a context stack as a linked list.
* <p>
@@ -846,7 +846,7 @@ public class GcSnapshot {
g.setPaint(shaderPaint);
return;
} else {
- Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER,
+ Bridge.getLog().fidelityWarning(ILayoutLog.TAG_SHADER,
shaderDelegate.getSupportMessage(), null, null, null);
}
}
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
index 45accb9a2b..c2fb3e1ac7 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/Layout.java
@@ -543,7 +543,6 @@ class Layout extends FrameLayout {
}
}
- @SuppressWarnings("SameParameterValue")
private int getDimension(@NonNull ResourceReference attrRef, int defaultValue) {
ResourceValue value = mResources.findItemInTheme(attrRef);
value = mResources.resolveResValue(value);
@@ -557,7 +556,6 @@ class Layout extends FrameLayout {
return defaultValue;
}
- @SuppressWarnings("SameParameterValue")
private int getFrameworkAttrDimension(@NonNull String attr, int defaultValue) {
return getDimension(BridgeContext.createFrameworkAttrReference(attr), defaultValue);
}
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/PorterDuffUtility.java b/bridge/src/com/android/layoutlib/bridge/impl/PorterDuffUtility.java
index dcbd272960..86f80fee23 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/PorterDuffUtility.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/PorterDuffUtility.java
@@ -16,7 +16,7 @@
package com.android.layoutlib.bridge.impl;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.layoutlib.bridge.Bridge;
import android.graphics.BlendComposite;
@@ -47,7 +47,7 @@ public final class PorterDuffUtility {
if (porterDuffMode >= 0 && porterDuffMode < MODES_COUNT) {
return PorterDuff.intToMode(porterDuffMode);
}
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
String.format("Unknown PorterDuff.Mode: %1$d", porterDuffMode), null, null);
assert false;
return Mode.SRC_OVER;
@@ -97,7 +97,7 @@ public final class PorterDuffUtility {
case OVERLAY:
return BlendComposite.getInstance(BlendingMode.OVERLAY, alpha1);
default:
- Bridge.getLog().fidelityWarning(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().fidelityWarning(ILayoutLog.TAG_BROKEN,
String.format("Unsupported PorterDuff Mode: %1$s", mode.name()),
null, null, null /*data*/);
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index b24c3833fd..2ab0509b6a 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -17,7 +17,7 @@
package com.android.layoutlib.bridge.impl;
import com.android.ide.common.rendering.api.HardwareConfig;
-import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.RenderParams;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.Result;
@@ -252,7 +252,7 @@ public abstract class RenderAction<T extends RenderParams> {
getContext().getMetrics(), Surface.ROTATION_0, hasNavigationBar);
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
- LayoutLog currentLog = mParams.getLog();
+ ILayoutLog currentLog = mParams.getLog();
Bridge.setLog(currentLog);
mContext.getRenderResources().setLogger(currentLog);
}
@@ -307,7 +307,7 @@ public abstract class RenderAction<T extends RenderParams> {
* Returns the log associated with the session.
* @return the log or null if there are none.
*/
- public LayoutLog getLog() {
+ public ILayoutLog getLog() {
if (mParams != null) {
return mParams.getLog();
}
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 1338c1700d..93d3df8640 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -18,8 +18,8 @@ package com.android.layoutlib.bridge.impl;
import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.HardwareConfig;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.ResourceReference;
@@ -46,16 +46,14 @@ import com.android.layoutlib.bridge.android.support.FragmentTabHostUtil;
import com.android.layoutlib.bridge.android.support.SupportPreferencesUtil;
import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
-import com.android.tools.layoutlib.java.System_Delegate;
-import com.android.tools.idea.validator.ValidatorResult;
import com.android.tools.idea.validator.LayoutValidator;
import com.android.tools.idea.validator.ValidatorResult;
import com.android.tools.idea.validator.ValidatorResult.Builder;
-import com.android.util.Pair;
+import com.android.tools.layoutlib.java.System_Delegate;
+import com.android.utils.Pair;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.app.Fragment_Delegate;
import android.graphics.Bitmap;
import android.graphics.Bitmap_Delegate;
import android.graphics.Canvas;
@@ -93,6 +91,8 @@ import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
+import com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchyAndroid_ViewElementClassNamesAndroid_Delegate;
+
import static com.android.ide.common.rendering.api.Result.Status.ERROR_INFLATION;
import static com.android.ide.common.rendering.api.Result.Status.ERROR_NOT_INFLATED;
import static com.android.ide.common.rendering.api.Result.Status.ERROR_UNKNOWN;
@@ -119,7 +119,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
private Canvas mCanvas;
private int mMeasuredScreenWidth = -1;
private int mMeasuredScreenHeight = -1;
- private boolean mIsAlphaChannelImage;
/** If >= 0, a frame will be executed */
private long mElapsedFrameTimeNanos = -1;
/** True if one frame has been already executed to start the animations */
@@ -175,11 +174,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
SessionParams params = getParams();
BridgeContext context = getContext();
- // use default of true in case it's not found to use alpha by default
- mIsAlphaChannelImage =
- ResourceHelper.getBooleanThemeFrameworkAttrValue(params.getResources(),
- "windowIsFloating", true);
-
mLayoutBuilder = new Layout.Builder(params, context);
// build the inflater and parser.
@@ -209,10 +203,10 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
mMeasuredScreenHeight = hardwareConfig.getScreenHeight();
if (renderingMode != RenderingMode.NORMAL) {
- int widthMeasureSpecMode = renderingMode.isHorizExpand() ?
+ int widthMeasureSpecMode = renderingMode.getHorizAction() == SizeAction.EXPAND ?
MeasureSpec.UNSPECIFIED // this lets us know the actual needed size
: MeasureSpec.EXACTLY;
- int heightMeasureSpecMode = renderingMode.isVertExpand() ?
+ int heightMeasureSpecMode = renderingMode.getVertAction() == SizeAction.EXPAND ?
MeasureSpec.UNSPECIFIED // this lets us know the actual needed size
: MeasureSpec.EXACTLY;
@@ -233,7 +227,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
// first measure the full layout, with EXACTLY to get the size of the
// content as it is inside the decor/dialog
- @SuppressWarnings("deprecation")
Pair<Integer, Integer> exactMeasure = measureView(
mViewRoot, measuredView,
mMeasuredScreenWidth, MeasureSpec.EXACTLY,
@@ -241,7 +234,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
// now measure the content only using UNSPECIFIED (where applicable, based on
// the rendering mode). This will give us the size the content needs.
- @SuppressWarnings("deprecation")
Pair<Integer, Integer> neededMeasure = measureView(
mContentRoot, mContentRoot.getChildAt(0),
mMeasuredScreenWidth, widthMeasureSpecMode,
@@ -303,14 +295,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
if (Bridge.isLocaleRtl(params.getLocale())) {
if (!params.isRtlSupported()) {
- Bridge.getLog().warning(LayoutLog.TAG_RTL_NOT_ENABLED,
+ Bridge.getLog().warning(ILayoutLog.TAG_RTL_NOT_ENABLED,
"You are using a right-to-left " +
"(RTL) locale but RTL is not enabled", null, null);
} else if (params.getSimulatedPlatformVersion() !=0 &&
params.getSimulatedPlatformVersion() < 17) {
// This will render ok because we are using the latest layoutlib but at least
// warn the user that this might fail in a real device.
- Bridge.getLog().warning(LayoutLog.TAG_RTL_NOT_SUPPORTED, "You are using a " +
+ Bridge.getLog().warning(ILayoutLog.TAG_RTL_NOT_SUPPORTED, "You are using a " +
"right-to-left " +
"(RTL) locale but RTL is not supported for API level < 17", null, null);
}
@@ -505,11 +497,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
newImage = true;
}
- if (params.isBgColorOverridden()) {
+ if (params.isTransparentBackground()) {
// since we override the content, it's the same as if it was a new image.
newImage = true;
Graphics2D gc = mImage.createGraphics();
- gc.setColor(new Color(params.getOverrideBgColor(), true));
+ gc.setColor(new Color(0, true));
gc.setComposite(AlphaComposite.Src);
gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight);
gc.dispose();
@@ -580,6 +572,9 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
params.getFlag(RenderParamsFlags.FLAG_ENABLE_LAYOUT_VALIDATOR_IMAGE_CHECK));
if (enableLayoutValidation && !getViewInfos().isEmpty()) {
+ AccessibilityHierarchyAndroid_ViewElementClassNamesAndroid_Delegate.sLayoutlibCallback =
+ getContext().getLayoutlibCallback();
+
BufferedImage imageToPass =
enableLayoutValidationImageCheck ? getImage() : null;
ValidatorResult validatorResult =
@@ -590,6 +585,8 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
ValidatorResult.Builder builder = new Builder();
builder.mMetric.mErrorMessage = e.getMessage();
setValidatorResult(builder.build());
+ } finally {
+ AccessibilityHierarchyAndroid_ViewElementClassNamesAndroid_Delegate.sLayoutlibCallback = null;
}
// success!
@@ -620,7 +617,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
* @param heightMode the MeasureSpec mode to use for the height.
* @return the measured width/height if measuredView is non-null, null otherwise.
*/
- @SuppressWarnings("deprecation") // For the use of Pair
private static Pair<Integer, Integer> measureView(ViewGroup viewToMeasure, View measuredView,
int width, int widthMode, int height, int heightMode) {
int w_spec = MeasureSpec.makeMeasureSpec(width, widthMode);
@@ -644,7 +640,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
* @param layoutlibCallback callback to the project.
* @param skip the view and it's children are not processed.
*/
- @SuppressWarnings("deprecation") // For the use of Pair
private void postInflateProcess(View view, LayoutlibCallback layoutlibCallback, View skip)
throws PostInflateException {
if (view == skip) {
@@ -872,7 +867,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
if (count == 0) {
- // Create a dummy child to get a single tab
+ // Create a placeholder child to get a single tab
TabSpec spec = tabHost.newTabSpec("tag")
.setIndicator("Tab Label", tabHost.getResources()
.getDrawable(android.R.drawable.ic_menu_info_details, null))
@@ -883,9 +878,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
for (int i = 0 ; i < count ; i++) {
View child = content.getChildAt(i);
String tabSpec = String.format("tab_spec%d", i+1);
- @SuppressWarnings("ConstantConditions") // child cannot be null.
int id = child.getId();
- @SuppressWarnings("deprecation")
ResourceReference resource = layoutlibCallback.resolveResourceId(id);
String name;
if (resource != null) {
@@ -1123,10 +1116,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
return mImage;
}
- public boolean isAlphaChannelImage() {
- return mIsAlphaChannelImage;
- }
-
public List<ViewInfo> getViewInfos() {
return mViewInfoList;
}
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 8e2ecd6ea5..0a363590a7 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -18,8 +18,8 @@ package com.android.layoutlib.bridge.impl;
import com.android.SdkConstants;
import com.android.ide.common.rendering.api.AssetRepository;
import com.android.ide.common.rendering.api.DensityBasedResourceValue;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceNamespace;
@@ -161,10 +161,16 @@ public final class ResourceHelper {
}
// try to load the color state list from an int
- try {
- int color = getColor(value);
- return ColorStateList.valueOf(color);
- } catch (NumberFormatException ignored) {
+ if (value.trim().startsWith("#")) {
+ try {
+ int color = getColor(value);
+ return ColorStateList.valueOf(color);
+ } catch (NumberFormatException e) {
+ Bridge.getLog().warning(ILayoutLog.TAG_RESOURCES_FORMAT,
+ String.format("\"%1$s\" cannot be interpreted as a color.", value),
+ null, null);
+ return null;
+ }
}
try {
@@ -202,13 +208,13 @@ public final class ResourceHelper {
}
}
} catch (XmlPullParserException e) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN,
"Failed to configure parser for " + value, e, null,null /*data*/);
// we'll return null below.
} catch (Exception e) {
// this is an error and not warning since the file existence is
// checked before attempting to parse it.
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_READ,
"Failed to parse file " + value, e, null, null /*data*/);
return null;
@@ -311,12 +317,17 @@ public final class ResourceHelper {
return null;
}
- String lowerCaseValue = stringValue.toLowerCase();
// try the simple case first. Attempt to get a color from the value
- try {
- int color = getColor(stringValue);
- return new ColorDrawable(color);
- } catch (NumberFormatException ignore) {
+ if (stringValue.trim().startsWith("#")) {
+ try {
+ int color = getColor(stringValue);
+ return new ColorDrawable(color);
+ } catch (NumberFormatException e) {
+ Bridge.getLog().warning(ILayoutLog.TAG_RESOURCES_FORMAT,
+ String.format("\"%1$s\" cannot be interpreted as a color.", stringValue),
+ null, null);
+ return null;
+ }
}
Density density = Density.MEDIUM;
@@ -327,12 +338,13 @@ public final class ResourceHelper {
}
}
+ String lowerCaseValue = stringValue.toLowerCase();
if (lowerCaseValue.endsWith(NinePatch.EXTENSION_9PATCH)) {
try {
return getNinePatchDrawable(density, value.isFramework(), stringValue, context);
} catch (IOException e) {
// failed to read the file, we'll return null below.
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_READ,
"Failed to load " + stringValue, e, null, null /*data*/);
}
@@ -393,7 +405,7 @@ public final class ResourceHelper {
return new BitmapDrawable(context.getResources(), bitmap);
} catch (IOException e) {
// we'll return null below
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_READ,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_READ,
"Failed to load " + stringValue, e, null, null /*data*/);
}
}
@@ -633,7 +645,7 @@ public final class ResourceHelper {
applyUnit(sUnitNames[1], outValue, sFloatOut);
computeTypedValue(outValue, f, sFloatOut[0]);
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE,
+ Bridge.getLog().error(ILayoutLog.TAG_RESOURCES_RESOLVE,
String.format(
"Dimension \"%1$s\" in attribute \"%2$s\" is missing unit!",
value, attribute),
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/binding/AdapterHelper.java b/bridge/src/com/android/layoutlib/bridge/impl/binding/AdapterHelper.java
index 76c5942217..b7f59c4994 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/binding/AdapterHelper.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/binding/AdapterHelper.java
@@ -17,14 +17,14 @@
package com.android.layoutlib.bridge.impl.binding;
import com.android.ide.common.rendering.api.DataBindingItem;
+import com.android.ide.common.rendering.api.ILayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
-import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback.ViewAttribute;
import com.android.ide.common.rendering.api.ResourceReference;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.layoutlib.bridge.impl.RenderAction;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import android.view.View;
import android.view.ViewGroup;
@@ -38,7 +38,6 @@ import android.widget.TextView;
*/
public class AdapterHelper {
- @SuppressWarnings("deprecation")
static Pair<View, Boolean> getView(AdapterItem item, AdapterItem parentItem, ViewGroup parent,
LayoutlibCallback callback, ResourceReference adapterRef, boolean skipCallbackParser) {
// we don't care about recycling here because we never scroll.
@@ -93,7 +92,7 @@ public class AdapterHelper {
resolvedRef, ViewAttribute.TEXT, tv.getText().toString());
if (value != null) {
if (value.getClass() != ViewAttribute.TEXT.getAttributeClass()) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, String.format(
"Wrong Adapter Item value class for TEXT. Expected String, got %s",
value.getClass().getName()), null, null);
} else {
@@ -113,7 +112,7 @@ public class AdapterHelper {
resolvedRef, ViewAttribute.IS_CHECKED, cb.isChecked());
if (value != null) {
if (value.getClass() != ViewAttribute.IS_CHECKED.getAttributeClass()) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, String.format(
"Wrong Adapter Item value class for IS_CHECKED. Expected Boolean, got %s",
value.getClass().getName()), null, null);
} else {
@@ -133,7 +132,7 @@ public class AdapterHelper {
resolvedRef, ViewAttribute.SRC, iv.getDrawable());
if (value != null) {
if (value.getClass() != ViewAttribute.SRC.getAttributeClass()) {
- Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format(
+ Bridge.getLog().error(ILayoutLog.TAG_BROKEN, String.format(
"Wrong Adapter Item value class for SRC. Expected Boolean, got %s",
value.getClass().getName()), null, null);
} else {
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java b/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
index 142eac1725..83ff28d05f 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
@@ -20,7 +20,7 @@ import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.DataBindingItem;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.ResourceReference;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import android.view.View;
import android.view.ViewGroup;
@@ -110,7 +110,6 @@ public class FakeAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
// we don't care about recycling here because we never scroll.
AdapterItem item = mItems.get(position);
- @SuppressWarnings("deprecation")
Pair<View, Boolean> pair = AdapterHelper.getView(item, null, parent, mCallback,
mAdapterRef, mSkipCallbackParser);
mSkipCallbackParser = pair.getSecond();
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java b/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
index 344b17eab0..21679f726e 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
@@ -20,7 +20,7 @@ import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.DataBindingItem;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.ResourceReference;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import android.database.DataSetObserver;
import android.view.View;
@@ -31,7 +31,6 @@ import android.widget.HeterogeneousExpandableList;
import java.util.ArrayList;
import java.util.List;
-@SuppressWarnings("deprecation")
public class FakeExpandableAdapter implements ExpandableListAdapter, HeterogeneousExpandableList {
private final LayoutlibCallback mCallback;
diff --git a/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java b/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java
index 161bf4155a..16aa058b76 100644
--- a/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java
+++ b/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java
@@ -17,7 +17,7 @@
package com.android.layoutlib.bridge.util;
import com.android.resources.ResourceType;
-import com.android.util.Pair;
+import com.android.utils.Pair;
import android.annotation.NonNull;
import android.util.SparseArray;
diff --git a/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java b/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
index a2a8aa96b1..dd06e80e60 100644
--- a/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
+++ b/bridge/src/com/android/layoutlib/bridge/util/SparseWeakArray.java
@@ -133,6 +133,7 @@ public class SparseWeakArray<E> {
if (i != o) {
keys[o] = keys[i];
values[o] = val;
+ values[i] = null;
}
o++;