diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:49 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:49 -0800 |
commit | 8611831e36b71c844a14788998728f3cd625b833 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/com/android/browser/HistoryItem.java | |
parent | 1658a9bc00a3bd692908dcd5b9eb550a49f8f5ec (diff) | |
download | packages_apps_Browser-8611831e36b71c844a14788998728f3cd625b833.zip packages_apps_Browser-8611831e36b71c844a14788998728f3cd625b833.tar.gz packages_apps_Browser-8611831e36b71c844a14788998728f3cd625b833.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'src/com/android/browser/HistoryItem.java')
-rw-r--r-- | src/com/android/browser/HistoryItem.java | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/src/com/android/browser/HistoryItem.java b/src/com/android/browser/HistoryItem.java deleted file mode 100644 index 55e43f0..0000000 --- a/src/com/android/browser/HistoryItem.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.android.browser; - -import android.content.ContentResolver; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.net.Uri; -import android.provider.Browser; -import android.util.Log; -import android.view.View; -import android.webkit.WebIconDatabase; -import android.widget.CompoundButton; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import java.util.Date; - -/** - * Layout representing a history item in the classic history viewer. - */ -/* package */ class HistoryItem extends BookmarkItem { - - private CompoundButton mStar; // Star for bookmarking - private CompoundButton.OnCheckedChangeListener mListener; - /** - * Create a new HistoryItem. - * @param context Context for this HistoryItem. - */ - /* package */ HistoryItem(Context context) { - super(context); - - mStar = (CompoundButton) findViewById(R.id.star); - mStar.setVisibility(View.VISIBLE); - mListener = new CompoundButton.OnCheckedChangeListener() { - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - ContentResolver cr = mContext.getContentResolver(); - Cursor cursor = cr.query( - Browser.BOOKMARKS_URI, - Browser.HISTORY_PROJECTION, - "url = ?", - new String[] { mUrl }, - null); - boolean first = cursor.moveToFirst(); - // Should be in the database no matter what - if (!first) { - throw new AssertionError("URL is not in the database!"); - } - if (isChecked) { - // Add to bookmarks - // FIXME: Share code with AddBookmarkPage.java - ContentValues map = new ContentValues(); - map.put(Browser.BookmarkColumns.CREATED, - new Date().getTime()); - map.put(Browser.BookmarkColumns.TITLE, getName()); - map.put(Browser.BookmarkColumns.BOOKMARK, 1); - try { - cr.update(Browser.BOOKMARKS_URI, map, - "_id = " + cursor.getInt(0), null); - } catch (IllegalStateException e) { - Log.e("HistoryItem", "no database!"); - } - WebIconDatabase.getInstance().retainIconForPageUrl(mUrl); - // catch IllegalStateException? - Toast.makeText(mContext, R.string.added_to_bookmarks, - Toast.LENGTH_LONG).show(); - } else { - // Remove from bookmarks - // FIXME: This code should be shared with - // BrowserBookmarksAdapter.java - WebIconDatabase.getInstance().releaseIconForPageUrl(mUrl); - Uri uri = ContentUris.withAppendedId(Browser.BOOKMARKS_URI, - cursor.getInt(Browser.HISTORY_PROJECTION_ID_INDEX)); - // It is no longer a bookmark, but it is still a visited - // site. - ContentValues values = new ContentValues(); - values.put(Browser.BookmarkColumns.BOOKMARK, 0); - try { - cr.update(uri, values, null, null); - } catch (IllegalStateException e) { - Log.e("HistoryItem", "no database!"); - } - Toast.makeText(mContext, R.string.removed_from_bookmarks, - Toast.LENGTH_LONG).show(); - } - cursor.deactivate(); - } - }; - } - - void copyTo(HistoryItem item) { - item.mTextView.setText(mTextView.getText()); - item.mUrlText.setText(mUrlText.getText()); - item.setIsBookmark(mStar.isChecked()); - item.mImageView.setImageDrawable(mImageView.getDrawable()); - } - - /** - * Set whether or not this represents a bookmark, and make sure the star - * behaves appropriately. - */ - void setIsBookmark(boolean isBookmark) { - mStar.setOnCheckedChangeListener(null); - mStar.setChecked(isBookmark); - mStar.setOnCheckedChangeListener(mListener); - } -} |