diff options
author | Pankaj Garg <pgarg@codeaurora.org> | 2015-07-15 12:07:37 -0700 |
---|---|---|
committer | jrizzoli <joey@cyanogenmoditalia.it> | 2015-08-28 13:15:46 +0200 |
commit | 07b2fd9ac55a9f2096423320f5c0e7fdb9b562d8 (patch) | |
tree | c35e65046ddeb87c0c0806874d59f868361354a6 /src/com/android/browser/view | |
parent | dbdf5aac9750c9cd918be04763480cae48a8b0a0 (diff) | |
download | android_packages_apps_Gello-07b2fd9ac55a9f2096423320f5c0e7fdb9b562d8.tar.gz android_packages_apps_Gello-07b2fd9ac55a9f2096423320f5c0e7fdb9b562d8.tar.bz2 android_packages_apps_Gello-07b2fd9ac55a9f2096423320f5c0e7fdb9b562d8.zip |
Updated Tile view for folder and favicon
- New layouts for folder icons in Bookmarks view.
- Reworked favicon tile views.
- Display of SSL certification information on top of favicon
- Modified logic behind showing counter on top of favicon
Change-Id: Iaacc13be37e7cc65e859b46e0d91d5d5d6b62a9e
Diffstat (limited to 'src/com/android/browser/view')
-rw-r--r-- | src/com/android/browser/view/BookmarkContainer.java | 112 |
1 files changed, 99 insertions, 13 deletions
diff --git a/src/com/android/browser/view/BookmarkContainer.java b/src/com/android/browser/view/BookmarkContainer.java index 730f1278..b36dde2f 100644 --- a/src/com/android/browser/view/BookmarkContainer.java +++ b/src/com/android/browser/view/BookmarkContainer.java @@ -17,15 +17,22 @@ package com.android.browser.view; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.TransitionDrawable; import android.util.AttributeSet; +import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewConfiguration; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; +import com.android.browser.FolderTileView; import com.android.browser.R; import com.android.browser.SiteTileView; @@ -34,6 +41,11 @@ public class BookmarkContainer extends LinearLayout implements OnClickListener { private OnClickListener mClickListener; private boolean mIgnoreRequestLayout = false; + private FrameLayout mTileContainer; + private FolderTileView mFolderTile; + private SiteTileView mSiteTile; + private ImageView mOverlayBadge; + public BookmarkContainer(Context context) { super(context); init(); @@ -44,33 +56,107 @@ public class BookmarkContainer extends LinearLayout implements OnClickListener { init(); } - public BookmarkContainer( - Context context, AttributeSet attrs, int defStyle) { + public BookmarkContainer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } void init() { setFocusable(true); + + if (mSiteTile == null) { + mSiteTile = new SiteTileView(getContext(), (Bitmap)null); + } + + if (mFolderTile == null) { + mFolderTile = new FolderTileView(getContext(), null, null); + mFolderTile.setClickable(true); + } super.setOnClickListener(this); } + public void reConfigureAsFolder(String title, String numItems) { + // hide elements that may have been already created + mSiteTile.setVisibility(View.GONE); + if (mOverlayBadge != null) + mOverlayBadge.setVisibility(View.GONE); + + // reconfigure the existing Folder + mFolderTile.setVisibility(View.VISIBLE); + mFolderTile.setText(title); + mFolderTile.setLabel(numItems); + addTileToContainer(mFolderTile); + } + + public void reConfigureAsSite(Bitmap favicon) { + // hide elements that may have been already created + mFolderTile.setVisibility(View.GONE); + if (mOverlayBadge != null) + mOverlayBadge.setVisibility(View.GONE); + + // reconfigure the existing Site + mSiteTile.setVisibility(View.VISIBLE); + mSiteTile.replaceFavicon(favicon); + addTileToContainer(mSiteTile); + } + + public void setBottomLabelText(String bottomLabel) { + ((TextView) findViewById(R.id.label)).setText(bottomLabel); + } + + public void setOverlayBadge(int imgResId) { + // remove the badge if already existing + if (imgResId == 0) { + if (mOverlayBadge != null) { + mOverlayBadge.setVisibility(View.GONE); + mOverlayBadge.setImageDrawable(null); + } + return; + } + + // create the badge if needed and not present + if (mOverlayBadge == null) { + mOverlayBadge = new ImageView(getContext()); + FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT + ); + lp.gravity = Gravity.BOTTOM | Gravity.END; + FrameLayout frameLayout = (FrameLayout) findViewById(R.id.container); + frameLayout.addView(mOverlayBadge, lp); + } + mOverlayBadge.setVisibility(View.VISIBLE); + mOverlayBadge.bringToFront(); + mOverlayBadge.setImageResource(imgResId); + } + + + private void addTileToContainer(View view) { + if (view.getParent() != null) { + return; + } + + // insert the view in the container, filling it + FrameLayout frameLayout = (FrameLayout) findViewById(R.id.container); + frameLayout.addView(view, 0, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + )); + // common customizations for folders or sites + view.setLongClickable(true); + } + + @Override public void setOnClickListener(OnClickListener l) { mClickListener = l; - View thumb = findViewById(R.id.thumb_image); - if (thumb != null) { - thumb.setOnClickListener(l); - } + mSiteTile.setOnClickListener(l); + mFolderTile.setOnClickListener(l); } @Override public void setTag(int key, final Object tag) { super.setTag(key, tag); - View thumb = findViewById(R.id.thumb_image); - if (thumb != null) { - thumb.setTag(key, tag); - } + mSiteTile.setTag(key, tag); + mFolderTile.setTag(key, tag); } @Override @@ -80,12 +166,12 @@ public class BookmarkContainer extends LinearLayout implements OnClickListener { } void updateTransitionDrawable(boolean pressed) { - final int longPressTimeout = ViewConfiguration.getLongPressTimeout(); Drawable selector = getBackground(); if (selector != null && selector instanceof StateListDrawable) { Drawable d = ((StateListDrawable)selector).getCurrent(); if (d != null && d instanceof TransitionDrawable) { if (pressed && isLongClickable()) { + final int longPressTimeout = ViewConfiguration.getLongPressTimeout(); ((TransitionDrawable) d).startTransition(longPressTimeout); } else { ((TransitionDrawable) d).resetTransition(); @@ -108,8 +194,8 @@ public class BookmarkContainer extends LinearLayout implements OnClickListener { @Override public void requestLayout() { - if (!mIgnoreRequestLayout) { + if (!mIgnoreRequestLayout) super.requestLayout(); - } } + } |