2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.browser;
19 import android.content.Context;
20 import android.graphics.Bitmap;
21 import android.view.LayoutInflater;
22 import android.view.View;
23 import android.widget.ImageView;
24 import android.widget.LinearLayout;
25 import android.widget.TextView;
28 * Custom layout for an item representing a bookmark in the browser.
30 class BookmarkItem extends LinearLayout {
32 protected TextView mTextView;
33 protected TextView mUrlText;
34 protected ImageView mImageView;
35 protected String mUrl;
38 * Instantiate a bookmark item, including a default favicon.
40 * @param context The application context for the item.
42 BookmarkItem(Context context) {
45 LayoutInflater factory = LayoutInflater.from(context);
46 factory.inflate(R.layout.history_item, this);
47 mTextView = (TextView) findViewById(R.id.title);
48 mUrlText = (TextView) findViewById(R.id.url);
49 mImageView = (ImageView) findViewById(R.id.favicon);
50 View star = findViewById(R.id.star);
51 star.setVisibility(View.GONE);
55 * Copy this BookmarkItem to item.
56 * @param item BookmarkItem to receive the info from this BookmarkItem.
58 /* package */ void copyTo(BookmarkItem item) {
59 item.mTextView.setText(mTextView.getText());
60 item.mUrlText.setText(mUrlText.getText());
61 item.mImageView.setImageDrawable(mImageView.getDrawable());
65 * Return the name assigned to this bookmark item.
67 /* package */ String getName() {
68 return mTextView.getText().toString();
72 * Return the TextView which holds the name of this bookmark item.
74 /* package */ TextView getNameTextView() {
78 /* package */ String getUrl() {
83 * Set the favicon for this item.
85 * @param b The new bitmap for this item.
86 * If it is null, will use the default.
88 /* package */ void setFavicon(Bitmap b) {
90 mImageView.setImageBitmap(b);
92 mImageView.setImageResource(R.drawable.app_web_browser_sm);
97 * Set the new name for the bookmark item.
99 * @param name The new name for the bookmark item.
101 /* package */ void setName(String name) {
102 mTextView.setText(name);
106 * Set the new url for the bookmark item.
107 * @param url The new url for the bookmark item.
109 /* package */ void setUrl(String url) {
110 mUrlText.setText(url);