Fix layoutlib by avoiding Java7 calls
This change also fixes a NPE in TypedArray caused by changes in the framework. Change-Id: Ie64237c567fa16c35c807db22ce9a4b609ee411d
This commit is contained in:
@ -1625,7 +1625,7 @@ public class Resources {
|
|||||||
|
|
||||||
String locale = null;
|
String locale = null;
|
||||||
if (mConfiguration.locale != null) {
|
if (mConfiguration.locale != null) {
|
||||||
locale = mConfiguration.locale.toLanguageTag();
|
locale = localeToLanguageTag(mConfiguration.locale);
|
||||||
}
|
}
|
||||||
int width, height;
|
int width, height;
|
||||||
if (mMetrics.widthPixels >= mMetrics.heightPixels) {
|
if (mMetrics.widthPixels >= mMetrics.heightPixels) {
|
||||||
@ -1706,6 +1706,12 @@ public class Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Locale.toLanguageTag() is not available in Java6. LayoutLib overrides
|
||||||
|
// this method to enable users to use Java6.
|
||||||
|
private String localeToLanguageTag(Locale locale) {
|
||||||
|
return locale.toLanguageTag();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the system resources configuration if they have previously
|
* Update the system resources configuration if they have previously
|
||||||
* been initialized.
|
* been initialized.
|
||||||
|
@ -58,7 +58,7 @@ public final class BridgeTypedArray extends TypedArray {
|
|||||||
|
|
||||||
public BridgeTypedArray(BridgeResources resources, BridgeContext context, int len,
|
public BridgeTypedArray(BridgeResources resources, BridgeContext context, int len,
|
||||||
boolean platformFile) {
|
boolean platformFile) {
|
||||||
super(null, null, null, 0);
|
super(resources, null, null, 0);
|
||||||
mBridgeResources = resources;
|
mBridgeResources = resources;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPlatformFile = platformFile;
|
mPlatformFile = platformFile;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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 android.content.res;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||||
|
import com.ibm.icu.util.ULocale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delegate used to provide new implementation of a select few methods of {@link Resources}
|
||||||
|
*
|
||||||
|
* Through the layoutlib_create tool, the original methods of Resources have been replaced
|
||||||
|
* by calls to methods of the same name in this delegate class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Resources_Delegate {
|
||||||
|
|
||||||
|
@LayoutlibDelegate
|
||||||
|
/*package*/ static String localeToLanguageTag(Resources res, Locale locale) {
|
||||||
|
return ULocale.forLocale(locale).toLanguageTag();
|
||||||
|
}
|
||||||
|
}
|
@ -125,6 +125,7 @@ public final class CreateInfo implements ICreateInfo {
|
|||||||
"android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
|
"android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
|
||||||
"android.content.res.Resources$Theme#obtainStyledAttributes",
|
"android.content.res.Resources$Theme#obtainStyledAttributes",
|
||||||
"android.content.res.Resources$Theme#resolveAttribute",
|
"android.content.res.Resources$Theme#resolveAttribute",
|
||||||
|
"android.content.res.Resources#localeToLanguageTag",
|
||||||
"android.content.res.TypedArray#getValueAt",
|
"android.content.res.TypedArray#getValueAt",
|
||||||
"android.graphics.BitmapFactory#finishDecode",
|
"android.graphics.BitmapFactory#finishDecode",
|
||||||
"android.os.Handler#sendMessageAtTime",
|
"android.os.Handler#sendMessageAtTime",
|
||||||
|
Reference in New Issue
Block a user