summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge/src/com
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2015-02-13 22:34:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-13 22:34:36 +0000
commitad879adb65ffa577844738522ab6d7d30aba2ead (patch)
treef6b031809da8d0a6785cd01b84cd0df5ef375e3b /tools/layoutlib/bridge/src/com
parent98c3461acd6699ab0448f1785909d0d39cd61b5a (diff)
parentd51834bdfad0cd3142ac464ab3a3b0db14f884c3 (diff)
downloadframeworks_base-ad879adb65ffa577844738522ab6d7d30aba2ead.zip
frameworks_base-ad879adb65ffa577844738522ab6d7d30aba2ead.tar.gz
frameworks_base-ad879adb65ffa577844738522ab6d7d30aba2ead.tar.bz2
Merge "Add Asset management support for fonts." into lmp-dev
Diffstat (limited to 'tools/layoutlib/bridge/src/com')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java11
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java19
2 files changed, 18 insertions, 12 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 2adeb67..7c86f75 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -17,6 +17,7 @@
package com.android.layoutlib.bridge.android;
import com.android.annotations.Nullable;
+import com.android.ide.common.rendering.api.AssetRepository;
import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
@@ -47,6 +48,7 @@ import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
+import android.content.res.BridgeAssetManager;
import android.content.res.BridgeResources;
import android.content.res.BridgeTypedArray;
import android.content.res.Configuration;
@@ -101,6 +103,7 @@ public final class BridgeContext extends Context {
* used to populate the mViewKeyMap.
*/
private final HashMap<Object, Object> mViewKeyHelpMap = new HashMap<Object, Object>();
+ private final BridgeAssetManager mAssets;
private Resources mSystemResources;
private final Object mProjectKey;
private final DisplayMetrics mMetrics;
@@ -140,6 +143,7 @@ public final class BridgeContext extends Context {
*/
public BridgeContext(Object projectKey, DisplayMetrics metrics,
RenderResources renderResources,
+ AssetRepository assets,
IProjectCallback projectCallback,
Configuration config,
int targetSdkVersion,
@@ -150,6 +154,8 @@ public final class BridgeContext extends Context {
mRenderResources = renderResources;
mConfig = config;
+ mAssets = new BridgeAssetManager();
+ mAssets.setAssetRepository(assets);
mApplicationInfo = new ApplicationInfo();
mApplicationInfo.targetSdkVersion = targetSdkVersion;
@@ -1075,9 +1081,8 @@ public final class BridgeContext extends Context {
}
@Override
- public AssetManager getAssets() {
- // pass
- return null;
+ public BridgeAssetManager getAssets() {
+ return mAssets;
}
@Override
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index 60f5331..127cb72 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -35,7 +35,6 @@ import com.android.resources.ScreenSize;
import android.content.res.Configuration;
import android.os.HandlerThread_Delegate;
-import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.ViewConfiguration_Accessor;
import android.view.inputmethod.InputMethodManager;
@@ -71,7 +70,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
/**
* Creates a renderAction.
* <p>
- * This <b>must</b> be followed by a call to {@link RenderAction#init()}, which act as a
+ * This <b>must</b> be followed by a call to {@link RenderAction#init(long)}, which act as a
* call to {@link RenderAction#acquire(long)}
*
* @param params the RenderParams. This must be a copy that the action can keep
@@ -121,8 +120,8 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
// build the context
mContext = new BridgeContext(mParams.getProjectKey(), metrics, resources,
- mParams.getProjectCallback(), getConfiguration(), mParams.getTargetSdkVersion(),
- mParams.isRtlSupported());
+ mParams.getAssets(), mParams.getProjectCallback(), getConfiguration(),
+ mParams.getTargetSdkVersion(), mParams.isRtlSupported());
setUp();
@@ -139,7 +138,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
* The preparation can fail if another rendering took too long and the timeout was elapsed.
*
* More than one call to this from the same thread will have no effect and will return
- * {@link Result#SUCCESS}.
+ * {@link Result.Status#SUCCESS}.
*
* After scene actions have taken place, only one call to {@link #release()} must be
* done.
@@ -173,7 +172,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
* Acquire the lock so that the scene can be acted upon.
* <p>
* This returns null if the lock was just acquired, otherwise it returns
- * {@link Result#SUCCESS} if the lock already belonged to that thread, or another
+ * {@link Result.Status#SUCCESS} if the lock already belonged to that thread, or another
* instance (see {@link Result#getStatus()}) if an error occurred.
*
* @param timeout the time to wait if another rendering is happening.
@@ -184,11 +183,11 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
*/
private Result acquireLock(long timeout) {
ReentrantLock lock = Bridge.getLock();
- if (lock.isHeldByCurrentThread() == false) {
+ if (!lock.isHeldByCurrentThread()) {
try {
boolean acquired = lock.tryLock(timeout, TimeUnit.MILLISECONDS);
- if (acquired == false) {
+ if (!acquired) {
return ERROR_TIMEOUT.createResult();
}
} catch (InterruptedException e) {
@@ -308,7 +307,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
*/
protected void checkLock() {
ReentrantLock lock = Bridge.getLock();
- if (lock.isHeldByCurrentThread() == false) {
+ if (!lock.isHeldByCurrentThread()) {
throw new IllegalStateException("scene must be acquired first. see #acquire(long)");
}
if (sCurrentContext != mContext) {
@@ -347,6 +346,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
if (config.screenHeightDp < config.screenWidthDp) {
+ //noinspection SuspiciousNameCombination
config.smallestScreenWidthDp = config.screenHeightDp;
} else {
config.smallestScreenWidthDp = config.screenWidthDp;
@@ -367,6 +367,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
config.orientation = Configuration.ORIENTATION_LANDSCAPE;
break;
case SQUARE:
+ //noinspection deprecation
config.orientation = Configuration.ORIENTATION_SQUARE;
break;
}