Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.browser; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.graphics.Bitmap; |
| 21 | import android.graphics.Color; |
| 22 | import android.graphics.drawable.BitmapDrawable; |
| 23 | import android.graphics.drawable.Drawable; |
| 24 | import android.graphics.drawable.LayerDrawable; |
| 25 | import android.graphics.drawable.PaintDrawable; |
| 26 | import android.view.View; |
| 27 | import android.widget.ImageView; |
| 28 | import android.widget.LinearLayout; |
| 29 | |
| 30 | /** |
| 31 | * Base class for a title bar used by the browser. |
| 32 | */ |
| 33 | public class TitleBarBase extends LinearLayout { |
| 34 | // These need to be set by the subclass. |
| 35 | protected ImageView mFavicon; |
| 36 | protected ImageView mLockIcon; |
| 37 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 38 | protected Drawable mGenericFavicon; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 39 | |
| 40 | public TitleBarBase(Context context) { |
| 41 | super(context, null); |
| 42 | mGenericFavicon = context.getResources().getDrawable( |
| 43 | R.drawable.app_web_browser_sm); |
| 44 | } |
| 45 | |
| 46 | /* package */ void setProgress(int newProgress) {} |
| 47 | /* package */ void setDisplayTitle(String title) {} |
| 48 | |
| 49 | /* package */ void setLock(Drawable d) { |
| 50 | assert mLockIcon != null; |
| 51 | if (null == d) { |
| 52 | mLockIcon.setVisibility(View.GONE); |
| 53 | } else { |
| 54 | mLockIcon.setImageDrawable(d); |
| 55 | mLockIcon.setVisibility(View.VISIBLE); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /* package */ void setFavicon(Bitmap icon) { |
| 60 | assert mFavicon != null; |
| 61 | Drawable[] array = new Drawable[3]; |
| 62 | array[0] = new PaintDrawable(Color.BLACK); |
| 63 | PaintDrawable p = new PaintDrawable(Color.WHITE); |
| 64 | array[1] = p; |
| 65 | if (icon == null) { |
| 66 | array[2] = mGenericFavicon; |
| 67 | } else { |
| 68 | array[2] = new BitmapDrawable(icon); |
| 69 | } |
| 70 | LayerDrawable d = new LayerDrawable(array); |
| 71 | d.setLayerInset(1, 1, 1, 1, 1); |
| 72 | d.setLayerInset(2, 2, 2, 2, 2); |
| 73 | mFavicon.setImageDrawable(d); |
| 74 | } |
| 75 | |
| 76 | /* package */ void setInVoiceMode(boolean inVoiceMode) {} |
| 77 | |
| 78 | } |