blob: 7016dc020336f65c52536f5b17708b857340a2cc [file] [log] [blame]
Leon Scroggins571b3762010-05-26 10:25:01 -04001/*
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
17package com.android.browser;
18
19import android.content.Context;
20import android.graphics.Bitmap;
21import android.graphics.Color;
22import android.graphics.drawable.BitmapDrawable;
23import android.graphics.drawable.Drawable;
24import android.graphics.drawable.LayerDrawable;
25import android.graphics.drawable.PaintDrawable;
26import android.view.View;
27import android.widget.ImageView;
28import android.widget.LinearLayout;
29
30/**
31 * Base class for a title bar used by the browser.
32 */
33public class TitleBarBase extends LinearLayout {
34 // These need to be set by the subclass.
35 protected ImageView mFavicon;
36 protected ImageView mLockIcon;
37
Michael Kolbfe251992010-07-08 15:41:55 -070038 protected Drawable mGenericFavicon;
Leon Scroggins571b3762010-05-26 10:25:01 -040039
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}