MDM Adjust bookmarks implementation for new UI

Recent UI changes to bookmarks broke the MDM overlay functionality
because the new Tile based containers do not have a way to get
pre-layout continer metrics.

The solution is to get the metrics from dimen resource (xml).

I also refactored overlayBookmarkBitmap() to take container metrics
as input and perform all pre-scaling calculations internally, which
simplifies calling code.  Also added an overlayMarginX parameter, which
allows side-to side adjustment of the overlay.

Change-Id: I17ea1ea6ca9412d8ab960fdfc4e9ca5fbe5c30c3
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index d0930ff..fc75050 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -89,7 +89,6 @@
         SiteTileView thumb =  (SiteTileView) view.findViewById(R.id.thumb_image);
         TextView tv = (TextView) view.findViewById(R.id.label);
         tv.setText(item.title);
-        int containerWidth = thumb.getWidth() - thumb.getPaddingLeft() - thumb.getPaddingRight();
 
         Bitmap b;
 
@@ -109,24 +108,23 @@
         }
 
         // If the item is managed by mdm or edit bookmark restriction enabled
-        if (containerWidth != 0 && (item.is_mdm_managed ||
-                EditBookmarksRestriction.getInstance().isEnabled())) {
-            int iconResId;
-            float overlayScale, overlayVertPos;
+        if (item.title != null &&
+                (item.is_mdm_managed || EditBookmarksRestriction.getInstance().isEnabled())) {
+            int containerWidth = view.getResources().getDimensionPixelSize(R.dimen.bookmarkThumbnailWidth);
+            int containerHeight = view.getResources().getDimensionPixelSize(R.dimen.bookmarkThumbnailHeight);
+            Bitmap bm;
 
             if (item.is_mdm_managed) {
-                iconResId = R.drawable.img_deco_mdm_badge_bright;
-                overlayScale = 0.6f;
-                overlayVertPos = 100f;
+                bm = BrowserBookmarksPage.overlayBookmarkBitmap(mContext, b,
+                        R.drawable.img_deco_mdm_badge_bright,
+                        containerWidth, containerHeight, 0.6f, 185, 20);
             }
             else {
-                iconResId = R.drawable.ic_deco_secure;
-                overlayScale = 1.2f;
-                overlayVertPos = 75f;
+                bm = BrowserBookmarksPage.overlayBookmarkBitmap(mContext, b,
+                        R.drawable.ic_deco_secure,
+                        containerWidth, containerHeight, 1.7f, 110, 0);
             }
-            float willScale = (float) containerWidth / (float) b.getWidth();
-            Bitmap bm = BrowserBookmarksPage.overlayBookmarkBitmap(b, iconResId, mContext,
-                    overlayScale / willScale, (int) (overlayVertPos / willScale));
+
             thumb.replaceFavicon(bm);
         }
         else {