summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authornewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-11 00:00:22 +0000
committernewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-11 00:00:22 +0000
commita51ec8d0a13ea8499b1e22bec93f09e3939a458b (patch)
treebad8d9550a163edcab6ac2ef837ed7401336c6b0 /base
parentb582760218cffbf9b4aa07618c9546018c32d976 (diff)
downloadchromium_src-a51ec8d0a13ea8499b1e22bec93f09e3939a458b.zip
chromium_src-a51ec8d0a13ea8499b1e22bec93f09e3939a458b.tar.gz
chromium_src-a51ec8d0a13ea8499b1e22bec93f09e3939a458b.tar.bz2
Add workaround for TextView.setCompoundDrawablesRelative() on JB MR1.
Due to a bug, TextView.setCompoundDrawablesRelative() is a no-op on JB MR1 if the text view has ever been measured. This is fixed in JB MR2 onwards, but causes some ugly bugs in Chrome on JB MR1: e.g. the favicons often don't appear on the bookmarks page. BUG=361709 NOTRY=true Review URL: https://codereview.chromium.org/232083005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
index 1e8a143..a544184 100644
--- a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
+++ b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
@@ -8,6 +8,7 @@ import android.app.PendingIntent;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.ViewTreeObserver;
@@ -15,11 +16,16 @@ import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.TextView;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
/**
* Utility class to use new APIs that were added after ICS (API level 14).
*/
public class ApiCompatibilityUtils {
+ private static final String TAG = "ApiCompatibilityUtils";
+
private ApiCompatibilityUtils() {
}
@@ -172,6 +178,24 @@ public class ApiCompatibilityUtils {
public static void setCompoundDrawablesRelative(TextView textView, Drawable start, Drawable top,
Drawable end, Drawable bottom) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ // On JB MR1, setCompoundDrawablesRelative() is a no-op if the view has ever been
+ // measured: due to a bug, it doesn't call resetResolvedDrawables(). Unfortunately,
+ // resetResolvedDrawables() is a hidden method so we can't call it directly. Instead,
+ // we use reflection.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ try {
+ Method resetResolvedDrawables = TextView.class.getDeclaredMethod(
+ "resetResolvedDrawables");
+ resetResolvedDrawables.setAccessible(true);
+ resetResolvedDrawables.invoke(textView);
+ } catch (NoSuchMethodException e) {
+ Log.w(TAG, e);
+ } catch (IllegalAccessException e) {
+ Log.w(TAG, e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
textView.setCompoundDrawablesRelative(start, top, bottom, end);
} else {
textView.setCompoundDrawables(start, top, bottom, end);