The Android Open Source Project | ba6d7b8 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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.view.LayoutInflater; |
| 21 | import android.widget.ImageView; |
| 22 | import android.widget.LinearLayout; |
| 23 | import android.widget.TextView; |
| 24 | |
| 25 | /** |
| 26 | * Custom layout for an item representing a bookmark in the browser. |
| 27 | */ |
| 28 | // FIXME: Remove BrowserBookmarkItem |
| 29 | class AddNewBookmark extends LinearLayout { |
| 30 | |
| 31 | private TextView mTextView; |
| 32 | private TextView mUrlText; |
| 33 | private ImageView mImageView; |
| 34 | |
| 35 | /** |
| 36 | * Instantiate a bookmark item, including a default favicon. |
| 37 | * |
| 38 | * @param context The application context for the item. |
| 39 | */ |
| 40 | AddNewBookmark(Context context) { |
| 41 | super(context); |
| 42 | |
| 43 | setWillNotDraw(false); |
| 44 | LayoutInflater factory = LayoutInflater.from(context); |
| 45 | factory.inflate(R.layout.add_new_bookmark, this); |
| 46 | mTextView = (TextView) findViewById(R.id.title); |
| 47 | mUrlText = (TextView) findViewById(R.id.url); |
| 48 | mImageView = (ImageView) findViewById(R.id.favicon); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Copy this BookmarkItem to item. |
| 53 | * @param item BookmarkItem to receive the info from this BookmarkItem. |
| 54 | */ |
| 55 | /* package */ void copyTo(AddNewBookmark item) { |
| 56 | item.mTextView.setText(mTextView.getText()); |
| 57 | item.mUrlText.setText(mUrlText.getText()); |
| 58 | item.mImageView.setImageDrawable(mImageView.getDrawable()); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Set the new url for the bookmark item. |
| 63 | * @param url The new url for the bookmark item. |
| 64 | */ |
| 65 | /* package */ void setUrl(String url) { |
The Android Open Source Project | b7775e1 | 2009-02-10 15:44:04 -0800 | [diff] [blame^] | 66 | mUrlText.setText(url); |
The Android Open Source Project | ba6d7b8 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 67 | } |
| 68 | } |