Bug 1366648 - Fix reload button color problem draft
authorJulian_Chu <walkingice0204@gmail.com>
Tue, 23 May 2017 11:13:06 +0800
changeset 582827 f90f612ea627e9ef93b5882fddc20c0c802fae3a
parent 582730 5bc1c758ab57c1885dceab4e7837e58af27b998c
child 629867 68b76171d594d16489cdf8e817a1307780096032
push id60190
push userbmo:walkingice0204@gmail.com
push dateTue, 23 May 2017 06:11:24 +0000
bugs1366648
milestone55.0a1
Bug 1366648 - Fix reload button color problem configuration: Nexus 5 + Android Hammerhead 5.1.1 LMY48M In CustomTabsActivity, the menu reload-button use a LevelListDrawable. On some configurations, icon's state won't be set to Enabled by system, hence the color of icon is incorrect. We have to enable it manually. MozReview-Commit-ID: JB9t35OyatY
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -410,16 +410,22 @@ public class CustomTabsActivity extends 
             final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://"));
             final ResolveInfo info = getPackageManager()
                     .resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY);
             final String name = info.loadLabel(getPackageManager()).toString();
             openItem.setTitle(getString(R.string.custom_tabs_menu_item_open_in, name));
         }
 
         menuItemControl = geckoMenu.findItem(R.id.custom_tabs_menu_control);
+        // on some configurations(ie. Android 5.1.1 + Nexus 5), no idea why the state not be enabled
+        // if the Drawable is a LevelListDrawable, then the icon color is incorrect.
+        final Drawable icon = menuItemControl.getIcon();
+        if (icon != null && !icon.isStateful()) {
+            icon.setState(new int[]{android.R.attr.state_enabled});
+        }
 
         geckoMenu.addFooterView(
                 getLayoutInflater().inflate(R.layout.customtabs_options_menu_footer, geckoMenu, false),
                 null,
                 false);
 
         return popupMenu;
     }