blob: 24a8cd5f56262ae28c837c824bf19634cc0480f5 [file] [log] [blame]
The Android Open Source Project0c908882009-03-03 19:32:16 -08001/*
2 * Copyright (C) 2006 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
Leon Scroggins25230d72010-09-28 20:09:25 -040019import com.android.browser.provider.BrowserProvider2;
20
The Android Open Source Project0c908882009-03-03 19:32:16 -080021import android.app.Activity;
Leon Scroggins III052ce662010-09-13 14:44:16 -040022import android.app.LoaderManager;
The Android Open Source Project0c908882009-03-03 19:32:16 -080023import android.content.ContentResolver;
Michael Kolbd40ac1a2010-09-29 00:23:46 -070024import android.content.ContentUris;
Leon Scroggins III052ce662010-09-13 14:44:16 -040025import android.content.ContentValues;
26import android.content.Context;
27import android.content.CursorLoader;
Leon Scroggins III052ce662010-09-13 14:44:16 -040028import android.content.Loader;
Leon Scroggins25230d72010-09-28 20:09:25 -040029import android.content.SharedPreferences;
The Android Open Source Project0c908882009-03-03 19:32:16 -080030import android.content.res.Resources;
Patrick Scott3918d442009-08-04 13:22:29 -040031import android.database.Cursor;
Ben Murdochaac7aa62009-09-17 16:57:40 +010032import android.graphics.Bitmap;
Leon Scroggins02081942010-11-01 17:52:42 -040033import android.graphics.drawable.Drawable;
The Android Open Source Project0c908882009-03-03 19:32:16 -080034import android.net.ParseException;
Michael Kolbd40ac1a2010-09-29 00:23:46 -070035import android.net.Uri;
The Android Open Source Project0c908882009-03-03 19:32:16 -080036import android.net.WebAddress;
John Reckc8490812010-11-22 14:15:36 -080037import android.os.AsyncTask;
The Android Open Source Project0c908882009-03-03 19:32:16 -080038import android.os.Bundle;
Ben Murdoch1794fe22009-09-29 18:14:30 +010039import android.os.Handler;
40import android.os.Message;
Leon Scroggins25230d72010-09-28 20:09:25 -040041import android.preference.PreferenceManager;
Leon Scroggins III052ce662010-09-13 14:44:16 -040042import android.provider.BrowserContract;
Leon Scroggins25230d72010-09-28 20:09:25 -040043import android.text.TextUtils;
Leon Scroggins III052ce662010-09-13 14:44:16 -040044import android.view.KeyEvent;
45import android.view.LayoutInflater;
Leon Scroggins88d08032010-10-21 15:17:10 -040046import android.view.MenuItem;
The Android Open Source Project0c908882009-03-03 19:32:16 -080047import android.view.View;
Leon Scroggins III052ce662010-09-13 14:44:16 -040048import android.view.ViewGroup;
The Android Open Source Project0c908882009-03-03 19:32:16 -080049import android.view.Window;
Leon Scroggins III76a0e9c2010-10-05 16:10:01 -040050import android.view.WindowManager;
Leon Scroggins III052ce662010-09-13 14:44:16 -040051import android.view.inputmethod.EditorInfo;
52import android.view.inputmethod.InputMethodManager;
53import android.widget.AdapterView;
54import android.widget.CursorAdapter;
The Android Open Source Project0c908882009-03-03 19:32:16 -080055import android.widget.EditText;
Leon Scroggins III052ce662010-09-13 14:44:16 -040056import android.widget.ListView;
Leon Scroggins88d08032010-10-21 15:17:10 -040057import android.widget.PopupMenu;
The Android Open Source Project0c908882009-03-03 19:32:16 -080058import android.widget.TextView;
59import android.widget.Toast;
60
Cary Clarkf2407c62009-09-04 12:25:10 -040061import java.net.URI;
62import java.net.URISyntaxException;
Leon Scroggins74dbe012010-10-15 10:54:27 -040063import java.util.Stack;
Leon Scroggins III052ce662010-09-13 14:44:16 -040064
65public class AddBookmarkPage extends Activity
66 implements View.OnClickListener, TextView.OnEditorActionListener,
Leon Scroggins74dbe012010-10-15 10:54:27 -040067 AdapterView.OnItemClickListener, LoaderManager.LoaderCallbacks<Cursor>,
Leon Scroggins88d08032010-10-21 15:17:10 -040068 BreadCrumbView.Controller, PopupMenu.OnMenuItemClickListener {
The Android Open Source Project0c908882009-03-03 19:32:16 -080069
Michael Kolb370a4f32010-10-06 10:45:32 -070070 public static final long DEFAULT_FOLDER_ID = -1;
Leon Scrogginsbc922852010-10-22 12:15:27 -040071 public static final String TOUCH_ICON_URL = "touch_icon_url";
72 // Place on an edited bookmark to remove the saved thumbnail
73 public static final String REMOVE_THUMBNAIL = "remove_thumbnail";
74 public static final String USER_AGENT = "user_agent";
Michael Kolb370a4f32010-10-06 10:45:32 -070075
John Reckc8490812010-11-22 14:15:36 -080076 /* package */ static final String EXTRA_EDIT_BOOKMARK = "bookmark";
77 /* package */ static final String EXTRA_IS_FOLDER = "is_folder";
78
Leon Scroggins74dbe012010-10-15 10:54:27 -040079 private static final int MAX_CRUMBS_SHOWN = 2;
80
The Android Open Source Project0c908882009-03-03 19:32:16 -080081 private final String LOGTAG = "Bookmarks";
Leon Scroggins74dbe012010-10-15 10:54:27 -040082 // Set to true to see the crash on the code I would like to run.
83 private final boolean DEBUG_CRASH = false;
The Android Open Source Project0c908882009-03-03 19:32:16 -080084
Leon Scroggins III052ce662010-09-13 14:44:16 -040085 // IDs for the CursorLoaders that are used.
86 private final int LOADER_ID_FOLDER_CONTENTS = 0;
87 private final int LOADER_ID_ALL_FOLDERS = 1;
88
The Android Open Source Project0c908882009-03-03 19:32:16 -080089 private EditText mTitle;
90 private EditText mAddress;
91 private TextView mButton;
92 private View mCancelButton;
93 private boolean mEditingExisting;
John Reckc8490812010-11-22 14:15:36 -080094 private boolean mEditingFolder;
The Android Open Source Project0c908882009-03-03 19:32:16 -080095 private Bundle mMap;
Patrick Scott3918d442009-08-04 13:22:29 -040096 private String mTouchIconUrl;
Ben Murdochaac7aa62009-09-17 16:57:40 +010097 private String mOriginalUrl;
Leon Scroggins III052ce662010-09-13 14:44:16 -040098 private TextView mFolder;
99 private View mDefaultView;
100 private View mFolderSelector;
101 private EditText mFolderNamer;
102 private View mAddNewFolder;
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400103 private View mAddSeparator;
Leon Scroggins III052ce662010-09-13 14:44:16 -0400104 private long mCurrentFolder = 0;
105 private FolderAdapter mAdapter;
Leon Scroggins74dbe012010-10-15 10:54:27 -0400106 private BreadCrumbView mCrumbs;
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400107 private TextView mFakeTitle;
108 private View mCrumbHolder;
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400109 private ListView mListView;
Leon Scroggins88d08032010-10-21 15:17:10 -0400110 private boolean mSaveToHomeScreen;
Leon Scroggins02081942010-11-01 17:52:42 -0400111 private long mRootFolder;
Leon Scroggins III052ce662010-09-13 14:44:16 -0400112
113 private static class Folder {
114 String Name;
115 long Id;
116 Folder(String name, long id) {
117 Name = name;
118 Id = id;
119 }
120 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800121
Ben Murdoch1794fe22009-09-29 18:14:30 +0100122 // Message IDs
123 private static final int SAVE_BOOKMARK = 100;
Leon Scroggins88d08032010-10-21 15:17:10 -0400124 private static final int TOUCH_ICON_DOWNLOADED = 101;
Ben Murdoch1794fe22009-09-29 18:14:30 +0100125
126 private Handler mHandler;
127
Bjorn Bringertb1402a52010-10-12 10:53:12 +0100128 private InputMethodManager getInputMethodManager() {
129 return (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
130 }
131
Leon Scroggins III052ce662010-09-13 14:44:16 -0400132 @Override
Leon Scroggins74dbe012010-10-15 10:54:27 -0400133 public void onTop(int level, Object data) {
134 if (null == data) return;
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400135 Folder folderData = (Folder) data;
136 long folder = folderData.Id;
137 Uri uri = BrowserContract.Bookmarks.buildFolderUri(folder);
Leon Scroggins74dbe012010-10-15 10:54:27 -0400138 LoaderManager manager = getLoaderManager();
139 CursorLoader loader = (CursorLoader) ((Loader) manager.getLoader(
140 LOADER_ID_FOLDER_CONTENTS));
141 loader.setUri(uri);
142 loader.forceLoad();
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400143 if (mFolderNamer.getVisibility() == View.VISIBLE) {
144 completeOrCancelFolderNaming(true);
145 }
Leon Scroggins74dbe012010-10-15 10:54:27 -0400146 }
147
Leon Scroggins74dbe012010-10-15 10:54:27 -0400148 @Override
Leon Scroggins III052ce662010-09-13 14:44:16 -0400149 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
150 if (v == mFolderNamer) {
151 if (v.getText().length() > 0) {
152 if (actionId == EditorInfo.IME_NULL) {
153 // Only want to do this once.
154 if (event.getAction() == KeyEvent.ACTION_UP) {
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400155 completeOrCancelFolderNaming(false);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400156 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400157 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800158 }
Michael Kolb31829b92010-10-01 11:50:21 -0700159 // Steal the key press; otherwise a newline will be added
160 return true;
The Android Open Source Project0c908882009-03-03 19:32:16 -0800161 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400162 return false;
163 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800164
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400165 private void switchToDefaultView(boolean changedFolder) {
166 mFolderSelector.setVisibility(View.GONE);
167 mDefaultView.setVisibility(View.VISIBLE);
168 mCrumbHolder.setVisibility(View.GONE);
169 mFakeTitle.setVisibility(View.VISIBLE);
170 if (changedFolder) {
171 Object data = mCrumbs.getTopData();
172 if (data != null) {
173 Folder folder = (Folder) data;
174 mCurrentFolder = folder.Id;
Leon Scroggins02081942010-11-01 17:52:42 -0400175 int resource = mCurrentFolder == mRootFolder ?
176 R.drawable.ic_menu_bookmarks :
177 com.android.internal.R.drawable.ic_menu_archive;
178 Drawable drawable = getResources().getDrawable(resource);
179 updateFolderLabel(folder.Name, drawable);
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400180 }
181 }
182 }
183
Leon Scroggins III052ce662010-09-13 14:44:16 -0400184 @Override
185 public void onClick(View v) {
186 if (v == mButton) {
187 if (mFolderSelector.getVisibility() == View.VISIBLE) {
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400188 // We are showing the folder selector.
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700189 if (mFolderNamer.getVisibility() == View.VISIBLE) {
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400190 completeOrCancelFolderNaming(false);
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700191 } else {
192 // User has selected a folder. Go back to the opening page
Leon Scroggins88d08032010-10-21 15:17:10 -0400193 mSaveToHomeScreen = false;
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400194 switchToDefaultView(true);
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700195 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400196 } else if (save()) {
197 finish();
198 }
199 } else if (v == mCancelButton) {
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700200 if (mFolderNamer.getVisibility() == View.VISIBLE) {
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400201 completeOrCancelFolderNaming(true);
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400202 } else if (mFolderSelector.getVisibility() == View.VISIBLE) {
203 switchToDefaultView(false);
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700204 } else {
205 finish();
206 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400207 } else if (v == mFolder) {
Leon Scroggins26318a12010-11-08 10:08:40 -0500208 PopupMenu popup = new PopupMenu(this, mFolder);
Leon Scroggins88d08032010-10-21 15:17:10 -0400209 popup.getMenuInflater().inflate(R.menu.folder_choice,
210 popup.getMenu());
John Reckc8490812010-11-22 14:15:36 -0800211 if (mEditingFolder) {
212 popup.getMenu().removeItem(R.id.home_screen);
213 }
Leon Scroggins88d08032010-10-21 15:17:10 -0400214 popup.setOnMenuItemClickListener(this);
215 popup.show();
Leon Scroggins III052ce662010-09-13 14:44:16 -0400216 } else if (v == mAddNewFolder) {
217 mFolderNamer.setVisibility(View.VISIBLE);
218 mFolderNamer.setText(R.string.new_folder);
219 mFolderNamer.requestFocus();
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400220 updateList();
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700221 mAddNewFolder.setVisibility(View.GONE);
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400222 mAddSeparator.setVisibility(View.GONE);
Bjorn Bringertb1402a52010-10-12 10:53:12 +0100223 getInputMethodManager().showSoftInput(mFolderNamer,
Leon Scroggins III052ce662010-09-13 14:44:16 -0400224 InputMethodManager.SHOW_IMPLICIT);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800225 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400226 }
227
Leon Scroggins88d08032010-10-21 15:17:10 -0400228 @Override
229 public boolean onMenuItemClick(MenuItem item) {
230 switch(item.getItemId()) {
231 case R.id.bookmarks:
Leon Scroggins02081942010-11-01 17:52:42 -0400232 mCurrentFolder = mRootFolder;
233 updateFolderLabel(item.getTitle(), item.getIcon());
Leon Scroggins88d08032010-10-21 15:17:10 -0400234 mSaveToHomeScreen = false;
235 break;
236 case R.id.home_screen:
237 // Create a short cut to the home screen
238 mSaveToHomeScreen = true;
Leon Scroggins02081942010-11-01 17:52:42 -0400239 updateFolderLabel(item.getTitle(), item.getIcon());
Leon Scroggins88d08032010-10-21 15:17:10 -0400240 break;
241 case R.id.other:
242 switchToFolderSelector();
243 break;
244 default:
245 return false;
246 }
247 return true;
248 }
249
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400250 // Refresh the ListView to hide or show the empty view, as necessary.
251 // Should be called after mFolderNamer is shown or hidden.
252 private void updateList() {
253 if (mAdapter.getCount() == 0) {
254 // XXX: Is there a better way to refresh the ListView?
255 mListView.setAdapter(mAdapter);
256 }
257 }
258
259 private void completeOrCancelFolderNaming(boolean cancel) {
260 if (!cancel && !TextUtils.isEmpty(mFolderNamer.getText())) {
Michael Kolb31829b92010-10-01 11:50:21 -0700261 String name = mFolderNamer.getText().toString();
262 long id = addFolderToCurrent(mFolderNamer.getText().toString());
263 descendInto(name, id);
Michael Kolb31829b92010-10-01 11:50:21 -0700264 }
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400265 mFolderNamer.setVisibility(View.GONE);
266 mAddNewFolder.setVisibility(View.VISIBLE);
267 mAddSeparator.setVisibility(View.VISIBLE);
268 getInputMethodManager().hideSoftInputFromWindow(
269 mFolderNamer.getWindowToken(), 0);
270 updateList();
Michael Kolb31829b92010-10-01 11:50:21 -0700271 }
272
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700273 private long addFolderToCurrent(String name) {
274 // Add the folder to the database
275 ContentValues values = new ContentValues();
276 values.put(BrowserContract.Bookmarks.TITLE,
277 name);
278 values.put(BrowserContract.Bookmarks.IS_FOLDER, 1);
John Recke89daa92010-11-05 14:39:39 -0700279 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
280 String accountType = prefs.getString(BrowserBookmarksPage.PREF_ACCOUNT_TYPE, null);
281 String accountName = prefs.getString(BrowserBookmarksPage.PREF_ACCOUNT_NAME, null);
282 if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) {
283 values.put(BrowserContract.Bookmarks.ACCOUNT_TYPE, accountType);
284 values.put(BrowserContract.Bookmarks.ACCOUNT_NAME, accountName);
285 }
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400286 long currentFolder;
287 Object data = mCrumbs.getTopData();
288 if (data != null) {
289 currentFolder = ((Folder) data).Id;
290 } else {
Leon Scroggins02081942010-11-01 17:52:42 -0400291 currentFolder = mRootFolder;
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400292 }
293 values.put(BrowserContract.Bookmarks.PARENT, currentFolder);
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700294 Uri uri = getContentResolver().insert(
295 BrowserContract.Bookmarks.CONTENT_URI, values);
296 if (uri != null) {
297 return ContentUris.parseId(uri);
298 } else {
299 return -1;
300 }
301 }
302
Leon Scroggins III052ce662010-09-13 14:44:16 -0400303 private void switchToFolderSelector() {
304 mDefaultView.setVisibility(View.GONE);
305 mFolderSelector.setVisibility(View.VISIBLE);
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400306 mCrumbHolder.setVisibility(View.VISIBLE);
307 mFakeTitle.setVisibility(View.GONE);
308 mAddNewFolder.setVisibility(View.VISIBLE);
309 mAddSeparator.setVisibility(View.VISIBLE);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400310 }
311
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700312 private void descendInto(String foldername, long id) {
Michael Kolb370a4f32010-10-06 10:45:32 -0700313 if (id != DEFAULT_FOLDER_ID) {
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400314 mCrumbs.pushView(foldername, new Folder(foldername, id));
Leon Scroggins74dbe012010-10-15 10:54:27 -0400315 mCrumbs.notifyController();
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700316 }
317 }
318
Leon Scroggins III052ce662010-09-13 14:44:16 -0400319 @Override
320 public Loader<Cursor> onCreateLoader(int id, Bundle args) {
321 String[] projection;
322 switch (id) {
323 case LOADER_ID_ALL_FOLDERS:
324 projection = new String[] {
325 BrowserContract.Bookmarks._ID,
326 BrowserContract.Bookmarks.PARENT,
327 BrowserContract.Bookmarks.TITLE,
328 BrowserContract.Bookmarks.IS_FOLDER
329 };
330 return new CursorLoader(this,
331 BrowserContract.Bookmarks.CONTENT_URI,
332 projection,
333 BrowserContract.Bookmarks.IS_FOLDER + " != 0",
334 null,
335 null);
336 case LOADER_ID_FOLDER_CONTENTS:
337 projection = new String[] {
338 BrowserContract.Bookmarks._ID,
339 BrowserContract.Bookmarks.TITLE,
340 BrowserContract.Bookmarks.IS_FOLDER
341 };
Leon Scroggins III052ce662010-09-13 14:44:16 -0400342 return new CursorLoader(this,
343 BrowserContract.Bookmarks.buildFolderUri(
344 mCurrentFolder),
345 projection,
346 BrowserContract.Bookmarks.IS_FOLDER + " != 0",
347 null,
348 null);
349 default:
350 throw new AssertionError("Asking for nonexistant loader!");
351 }
352 }
353
354 @Override
355 public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
356 switch (loader.getId()) {
357 case LOADER_ID_FOLDER_CONTENTS:
358 mAdapter.changeCursor(cursor);
359 break;
360 case LOADER_ID_ALL_FOLDERS:
361 long parent = mCurrentFolder;
362 int idIndex = cursor.getColumnIndexOrThrow(
363 BrowserContract.Bookmarks._ID);
364 int titleIndex = cursor.getColumnIndexOrThrow(
365 BrowserContract.Bookmarks.TITLE);
366 int parentIndex = cursor.getColumnIndexOrThrow(
367 BrowserContract.Bookmarks.PARENT);
Leon Scroggins74dbe012010-10-15 10:54:27 -0400368 Stack folderStack = new Stack();
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700369 while ((parent != BrowserProvider2.FIXED_ID_ROOT) &&
370 (parent != 0)) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400371 // First, find the folder corresponding to the current
372 // folder
373 if (!cursor.moveToFirst()) {
374 throw new AssertionError("No folders in the database!");
375 }
376 long folder;
377 do {
378 folder = cursor.getLong(idIndex);
379 } while (folder != parent && cursor.moveToNext());
380 if (cursor.isAfterLast()) {
381 throw new AssertionError("Folder(id=" + parent
382 + ") holding this bookmark does not exist!");
383 }
384 String name = cursor.getString(titleIndex);
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400385 if (parent == mCurrentFolder) {
Leon Scroggins02081942010-11-01 17:52:42 -0400386 Drawable draw = getResources().getDrawable(
387 com.android.internal.R.drawable.ic_menu_archive);
388 updateFolderLabel(name, draw);
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400389 }
Leon Scroggins74dbe012010-10-15 10:54:27 -0400390 folderStack.push(new Folder(name, parent));
Leon Scroggins III052ce662010-09-13 14:44:16 -0400391 parent = cursor.getLong(parentIndex);
392 }
Leon Scroggins74dbe012010-10-15 10:54:27 -0400393 while (!folderStack.isEmpty()) {
394 Folder thisFolder = (Folder) folderStack.pop();
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400395 mCrumbs.pushView(thisFolder.Name, thisFolder);
Leon Scroggins74dbe012010-10-15 10:54:27 -0400396 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400397 getLoaderManager().stopLoader(LOADER_ID_ALL_FOLDERS);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400398 break;
399 default:
400 break;
401 }
402 }
403
Leon Scroggins02081942010-11-01 17:52:42 -0400404 /**
405 * Update the name and image to show where the bookmark will be added
406 * @param name Name of the location to save (folder name, bookmarks, or home
407 * screen.
408 * @param drawable Image to show corresponding to the save location.
409 */
410 void updateFolderLabel(CharSequence name, Drawable drawable) {
411 mFolder.setText(name);
412 mFolder.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null,
413 null);
414 }
415
Leon Scroggins III052ce662010-09-13 14:44:16 -0400416 @Override
417 public void onItemClick(AdapterView<?> parent, View view, int position,
418 long id) {
Leon Scrogginsd14cb122010-09-29 16:01:48 -0400419 TextView tv = (TextView) view.findViewById(android.R.id.text1);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400420 // Switch to the folder that was clicked on.
Leon Scrogginsd14cb122010-09-29 16:01:48 -0400421 descendInto(tv.getText().toString(), id);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400422 }
423
424 /**
425 * Shows a list of names of folders.
426 */
427 private class FolderAdapter extends CursorAdapter {
428 public FolderAdapter(Context context) {
429 super(context, null);
430 }
431
432 @Override
433 public void bindView(View view, Context context, Cursor cursor) {
434 ((TextView) view.findViewById(android.R.id.text1)).setText(
435 cursor.getString(cursor.getColumnIndexOrThrow(
436 BrowserContract.Bookmarks.TITLE)));
437 }
438
439 @Override
440 public View newView(Context context, Cursor cursor, ViewGroup parent) {
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700441 View view = LayoutInflater.from(context).inflate(
442 R.layout.folder_list_item, null);
443 view.setBackgroundDrawable(context.getResources().
444 getDrawable(android.R.drawable.list_selector_background));
445 return view;
Leon Scroggins III052ce662010-09-13 14:44:16 -0400446 }
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400447
448 @Override
449 public boolean isEmpty() {
450 // Do not show the empty view if the user is creating a new folder.
451 return super.isEmpty() && mFolderNamer.getVisibility() == View.GONE;
452 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400453 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800454
455 protected void onCreate(Bundle icicle) {
456 super.onCreate(icicle);
Leon Scroggins74dbe012010-10-15 10:54:27 -0400457 if (DEBUG_CRASH) {
458 requestWindowFeature(Window.FEATURE_NO_TITLE);
Leon Scroggins74dbe012010-10-15 10:54:27 -0400459 }
Ben Murdocheecb4e62010-07-06 16:30:38 +0100460
461 mMap = getIntent().getExtras();
Ben Murdocheecb4e62010-07-06 16:30:38 +0100462
Leon Scroggins III052ce662010-09-13 14:44:16 -0400463 setContentView(R.layout.browser_add_bookmark);
Ben Murdocheecb4e62010-07-06 16:30:38 +0100464
Leon Scroggins III76a0e9c2010-10-05 16:10:01 -0400465 Window window = getWindow();
Leon Scroggins74dbe012010-10-15 10:54:27 -0400466 if (!DEBUG_CRASH) {
Leon Scroggins02081942010-11-01 17:52:42 -0400467 setTitle("");
Leon Scroggins74dbe012010-10-15 10:54:27 -0400468 }
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700469
The Android Open Source Project0c908882009-03-03 19:32:16 -0800470 String title = null;
471 String url = null;
Ben Murdocheecb4e62010-07-06 16:30:38 +0100472
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400473 mFakeTitle = (TextView) findViewById(R.id.fake_title);
474
The Android Open Source Project0c908882009-03-03 19:32:16 -0800475 if (mMap != null) {
John Reckc8490812010-11-22 14:15:36 -0800476 Bundle b = mMap.getBundle(EXTRA_EDIT_BOOKMARK);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800477 if (b != null) {
John Reckc8490812010-11-22 14:15:36 -0800478 mEditingFolder = mMap.getBoolean(EXTRA_IS_FOLDER, false);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800479 mMap = b;
480 mEditingExisting = true;
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400481 mFakeTitle.setText(R.string.edit_bookmark);
John Reckc8490812010-11-22 14:15:36 -0800482 if (mEditingFolder) {
483 findViewById(R.id.row_address).setVisibility(View.GONE);
484 }
Leon Scroggins III76a0e9c2010-10-05 16:10:01 -0400485 } else {
486 int gravity = mMap.getInt("gravity", -1);
487 if (gravity != -1) {
488 WindowManager.LayoutParams l = window.getAttributes();
489 l.gravity = gravity;
490 window.setAttributes(l);
491 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800492 }
Leon Scrogginsbc922852010-10-22 12:15:27 -0400493 title = mMap.getString(BrowserContract.Bookmarks.TITLE);
494 url = mOriginalUrl = mMap.getString(BrowserContract.Bookmarks.URL);
495 mTouchIconUrl = mMap.getString(TOUCH_ICON_URL);
Michael Kolb370a4f32010-10-06 10:45:32 -0700496 mCurrentFolder = mMap.getLong(BrowserContract.Bookmarks.PARENT, DEFAULT_FOLDER_ID);
Leon Scroggins25230d72010-09-28 20:09:25 -0400497 }
Leon Scroggins02081942010-11-01 17:52:42 -0400498 mRootFolder = getBookmarksBarId(this);
Michael Kolb370a4f32010-10-06 10:45:32 -0700499 if (mCurrentFolder == DEFAULT_FOLDER_ID) {
Leon Scroggins02081942010-11-01 17:52:42 -0400500 mCurrentFolder = mRootFolder;
The Android Open Source Project0c908882009-03-03 19:32:16 -0800501 }
502
503 mTitle = (EditText) findViewById(R.id.title);
504 mTitle.setText(title);
Ben Murdocheecb4e62010-07-06 16:30:38 +0100505
Leon Scroggins III052ce662010-09-13 14:44:16 -0400506 mAddress = (EditText) findViewById(R.id.address);
507 mAddress.setText(url);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800508
The Android Open Source Project0c908882009-03-03 19:32:16 -0800509 mButton = (TextView) findViewById(R.id.OK);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400510 mButton.setOnClickListener(this);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800511
512 mCancelButton = findViewById(R.id.cancel);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400513 mCancelButton.setOnClickListener(this);
514
515 mFolder = (TextView) findViewById(R.id.folder);
516 mFolder.setOnClickListener(this);
517
518 mDefaultView = findViewById(R.id.default_view);
519 mFolderSelector = findViewById(R.id.folder_selector);
520
521 mFolderNamer = (EditText) findViewById(R.id.folder_namer);
522 mFolderNamer.setOnEditorActionListener(this);
523
524 mAddNewFolder = findViewById(R.id.add_new_folder);
525 mAddNewFolder.setOnClickListener(this);
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400526 mAddSeparator = findViewById(R.id.add_divider);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400527
Leon Scroggins74dbe012010-10-15 10:54:27 -0400528 mCrumbs = (BreadCrumbView) findViewById(R.id.crumbs);
529 mCrumbs.setUseBackButton(true);
530 mCrumbs.setController(this);
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400531 String name = getString(R.string.bookmarks);
532 mCrumbs.pushView(name, false,
533 new Folder(name, BrowserProvider2.FIXED_ID_ROOT));
Leon Scroggins7e5f7352010-10-18 13:25:31 -0400534 mCrumbHolder = findViewById(R.id.crumb_holder);
John Reck89f73c12010-12-01 10:10:14 -0800535 mCrumbs.setMaxVisible(MAX_CRUMBS_SHOWN);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400536
Leon Scroggins III052ce662010-09-13 14:44:16 -0400537 mAdapter = new FolderAdapter(this);
Leon Scroggins6573f9e2010-10-18 17:22:35 -0400538 mListView = (ListView) findViewById(R.id.list);
539 View empty = findViewById(R.id.empty);
540 mListView.setEmptyView(empty);
541 mListView.setAdapter(mAdapter);
542 mListView.setOnItemClickListener(this);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400543 LoaderManager manager = getLoaderManager();
Jeff Hamiltona9bad832010-09-24 11:05:30 -0500544 if (mCurrentFolder != BrowserProvider2.FIXED_ID_ROOT) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400545 // Find all the folders
546 manager.initLoader(LOADER_ID_ALL_FOLDERS, null, this);
547 }
Leon Scroggins52f7daa2010-10-18 16:57:46 -0400548 // Find the contents of the current folder
Leon Scroggins III052ce662010-09-13 14:44:16 -0400549 manager.initLoader(LOADER_ID_FOLDER_CONTENTS, null, this);
550
Michael Kolbd40ac1a2010-09-29 00:23:46 -0700551
Leon Scroggins III76a0e9c2010-10-05 16:10:01 -0400552 if (!window.getDecorView().isInTouchMode()) {
The Android Open Source Project0c908882009-03-03 19:32:16 -0800553 mButton.requestFocus();
554 }
555 }
Ben Murdoch1794fe22009-09-29 18:14:30 +0100556
Leon Scroggins25230d72010-09-28 20:09:25 -0400557 // FIXME: Use a CursorLoader
558 private long getBookmarksBarId(Context context) {
559 SharedPreferences prefs
560 = PreferenceManager.getDefaultSharedPreferences(context);
561 String accountName =
562 prefs.getString(BrowserBookmarksPage.PREF_ACCOUNT_NAME, null);
563 String accountType =
564 prefs.getString(BrowserBookmarksPage.PREF_ACCOUNT_TYPE, null);
565 if (TextUtils.isEmpty(accountName) || TextUtils.isEmpty(accountType)) {
Jeff Hamiltona9bad832010-09-24 11:05:30 -0500566 return BrowserProvider2.FIXED_ID_ROOT;
Leon Scroggins25230d72010-09-28 20:09:25 -0400567 }
568 Cursor cursor = null;
569 try {
570 cursor = context.getContentResolver().query(
571 BrowserContract.Bookmarks.CONTENT_URI,
572 new String[] { BrowserContract.Bookmarks._ID },
573 BrowserContract.ChromeSyncColumns.SERVER_UNIQUE + "=? AND "
574 + BrowserContract.Bookmarks.ACCOUNT_NAME + "=? AND "
575 + BrowserContract.Bookmarks.ACCOUNT_TYPE + "=?",
576 new String[] {
577 BrowserContract.ChromeSyncColumns
578 .FOLDER_NAME_BOOKMARKS_BAR,
579 accountName,
580 accountType },
581 null);
582 if (cursor != null && cursor.moveToFirst()) {
583 return cursor.getLong(0);
584 }
585 } finally {
586 if (cursor != null) cursor.close();
587 }
Jeff Hamiltona9bad832010-09-24 11:05:30 -0500588 return BrowserProvider2.FIXED_ID_ROOT;
Leon Scroggins25230d72010-09-28 20:09:25 -0400589 }
590
Leon Scroggins02065b02010-01-04 14:30:13 -0500591 /**
592 * Runnable to save a bookmark, so it can be performed in its own thread.
593 */
594 private class SaveBookmarkRunnable implements Runnable {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400595 // FIXME: This should be an async task.
Leon Scroggins02065b02010-01-04 14:30:13 -0500596 private Message mMessage;
Henrik Baard980e9952010-09-06 18:13:23 +0200597 private Context mContext;
598 public SaveBookmarkRunnable(Context ctx, Message msg) {
599 mContext = ctx;
Leon Scroggins02065b02010-01-04 14:30:13 -0500600 mMessage = msg;
601 }
602 public void run() {
603 // Unbundle bookmark data.
604 Bundle bundle = mMessage.getData();
Leon Scrogginsbc922852010-10-22 12:15:27 -0400605 String title = bundle.getString(BrowserContract.Bookmarks.TITLE);
606 String url = bundle.getString(BrowserContract.Bookmarks.URL);
607 boolean invalidateThumbnail = bundle.getBoolean(REMOVE_THUMBNAIL);
Leon Scroggins02065b02010-01-04 14:30:13 -0500608 Bitmap thumbnail = invalidateThumbnail ? null
Leon Scrogginsbc922852010-10-22 12:15:27 -0400609 : (Bitmap) bundle.getParcelable(BrowserContract.Bookmarks.THUMBNAIL);
610 String touchIconUrl = bundle.getString(TOUCH_ICON_URL);
Leon Scroggins02065b02010-01-04 14:30:13 -0500611
612 // Save to the bookmarks DB.
613 try {
614 final ContentResolver cr = getContentResolver();
Leon Scroggins III052ce662010-09-13 14:44:16 -0400615 Bookmarks.addBookmark(AddBookmarkPage.this, false, url,
616 title, thumbnail, true, mCurrentFolder);
Leon Scroggins02065b02010-01-04 14:30:13 -0500617 if (touchIconUrl != null) {
Henrik Baard980e9952010-09-06 18:13:23 +0200618 new DownloadTouchIcon(mContext, cr, url).execute(mTouchIconUrl);
Leon Scroggins02065b02010-01-04 14:30:13 -0500619 }
620 mMessage.arg1 = 1;
621 } catch (IllegalStateException e) {
622 mMessage.arg1 = 0;
623 }
624 mMessage.sendToTarget();
625 }
626 }
627
John Reckc8490812010-11-22 14:15:36 -0800628 private static class UpdateBookmarkTask extends AsyncTask<ContentValues, Void, Void> {
629 Context mContext;
630 Long mId;
631
632 public UpdateBookmarkTask(Context context, long id) {
633 mContext = context;
634 mId = id;
635 }
636
637 @Override
638 protected Void doInBackground(ContentValues... params) {
639 if (params.length != 1) {
640 throw new IllegalArgumentException("No ContentValues provided!");
641 }
642 Uri uri = ContentUris.withAppendedId(BookmarkUtils.getBookmarksUri(mContext), mId);
643 mContext.getContentResolver().update(
644 uri,
645 params[0], null, null);
646 return null;
647 }
648 }
649
Ben Murdoch1794fe22009-09-29 18:14:30 +0100650 private void createHandler() {
651 if (mHandler == null) {
652 mHandler = new Handler() {
653 @Override
654 public void handleMessage(Message msg) {
655 switch (msg.what) {
656 case SAVE_BOOKMARK:
Leon Scroggins02065b02010-01-04 14:30:13 -0500657 if (1 == msg.arg1) {
Ben Murdoch1794fe22009-09-29 18:14:30 +0100658 Toast.makeText(AddBookmarkPage.this, R.string.bookmark_saved,
659 Toast.LENGTH_LONG).show();
660 } else {
661 Toast.makeText(AddBookmarkPage.this, R.string.bookmark_not_saved,
662 Toast.LENGTH_LONG).show();
663 }
664 break;
Leon Scroggins88d08032010-10-21 15:17:10 -0400665 case TOUCH_ICON_DOWNLOADED:
666 Bundle b = msg.getData();
667 sendBroadcast(BookmarkUtils.createAddToHomeIntent(
Leon Scrogginsbc922852010-10-22 12:15:27 -0400668 AddBookmarkPage.this,
669 b.getString(BrowserContract.Bookmarks.URL),
670 b.getString(BrowserContract.Bookmarks.TITLE),
671 (Bitmap) b.getParcelable(BrowserContract.Bookmarks.TOUCH_ICON),
672 (Bitmap) b.getParcelable(BrowserContract.Bookmarks.FAVICON)));
Leon Scroggins88d08032010-10-21 15:17:10 -0400673 break;
Ben Murdoch1794fe22009-09-29 18:14:30 +0100674 }
675 }
676 };
677 }
678 }
679
The Android Open Source Project0c908882009-03-03 19:32:16 -0800680 /**
Ben Murdoch1794fe22009-09-29 18:14:30 +0100681 * Parse the data entered in the dialog and post a message to update the bookmarks database.
The Android Open Source Project0c908882009-03-03 19:32:16 -0800682 */
683 boolean save() {
Ben Murdoch1794fe22009-09-29 18:14:30 +0100684 createHandler();
685
The Android Open Source Project0c908882009-03-03 19:32:16 -0800686 String title = mTitle.getText().toString().trim();
Ben Murdocheecb4e62010-07-06 16:30:38 +0100687 String unfilteredUrl;
Michael Kolb8233fac2010-10-26 16:08:53 -0700688 unfilteredUrl = UrlUtils.fixUrl(mAddress.getText().toString());
Ben Murdocheecb4e62010-07-06 16:30:38 +0100689
The Android Open Source Project0c908882009-03-03 19:32:16 -0800690 boolean emptyTitle = title.length() == 0;
691 boolean emptyUrl = unfilteredUrl.trim().length() == 0;
692 Resources r = getResources();
John Reckc8490812010-11-22 14:15:36 -0800693 if (emptyTitle || (emptyUrl && !mEditingFolder)) {
The Android Open Source Project0c908882009-03-03 19:32:16 -0800694 if (emptyTitle) {
695 mTitle.setError(r.getText(R.string.bookmark_needs_title));
696 }
697 if (emptyUrl) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400698 mAddress.setError(r.getText(R.string.bookmark_needs_url));
The Android Open Source Project0c908882009-03-03 19:32:16 -0800699 }
Leon Scroggins III6e3faea2010-09-07 15:22:14 -0400700 return false;
Ben Murdocheecb4e62010-07-06 16:30:38 +0100701
The Android Open Source Project0c908882009-03-03 19:32:16 -0800702 }
Ben Murdochca12cfa2009-11-17 13:57:44 +0000703 String url = unfilteredUrl.trim();
John Reckc8490812010-11-22 14:15:36 -0800704 if (!mEditingFolder) {
705 try {
706 // We allow bookmarks with a javascript: scheme, but these will in most cases
707 // fail URI parsing, so don't try it if that's the kind of bookmark we have.
Ben Murdochca12cfa2009-11-17 13:57:44 +0000708
John Reckc8490812010-11-22 14:15:36 -0800709 if (!url.toLowerCase().startsWith("javascript:")) {
710 URI uriObj = new URI(url);
711 String scheme = uriObj.getScheme();
712 if (!Bookmarks.urlHasAcceptableScheme(url)) {
713 // If the scheme was non-null, let the user know that we
714 // can't save their bookmark. If it was null, we'll assume
715 // they meant http when we parse it in the WebAddress class.
716 if (scheme != null) {
717 mAddress.setError(r.getText(R.string.bookmark_cannot_save_url));
718 return false;
719 }
720 WebAddress address;
721 try {
722 address = new WebAddress(unfilteredUrl);
723 } catch (ParseException e) {
724 throw new URISyntaxException("", "");
725 }
726 if (address.getHost().length() == 0) {
727 throw new URISyntaxException("", "");
728 }
729 url = address.toString();
Ben Murdochca12cfa2009-11-17 13:57:44 +0000730 }
Ben Murdochde353622009-10-12 10:29:00 +0100731 }
John Reckc8490812010-11-22 14:15:36 -0800732 } catch (URISyntaxException e) {
733 mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
734 return false;
The Android Open Source Project0c908882009-03-03 19:32:16 -0800735 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800736 }
Ben Murdochaac7aa62009-09-17 16:57:40 +0100737
Leon Scroggins88d08032010-10-21 15:17:10 -0400738 if (mSaveToHomeScreen) {
739 mEditingExisting = false;
740 }
741
742 boolean urlUnmodified = url.equals(mOriginalUrl);
743
Ben Murdoch1794fe22009-09-29 18:14:30 +0100744 if (mEditingExisting) {
John Reckc8490812010-11-22 14:15:36 -0800745 Long id = mMap.getLong(BrowserContract.Bookmarks._ID);
746 ContentValues values = new ContentValues();
747 values.put(BrowserContract.Bookmarks.TITLE, title);
748 values.put(BrowserContract.Bookmarks.PARENT, mCurrentFolder);
749 if (!mEditingFolder) {
750 values.put(BrowserContract.Bookmarks.URL, url);
751 if (!urlUnmodified) {
752 values.putNull(BrowserContract.Bookmarks.THUMBNAIL);
753 }
754 }
755 if (values.size() > 0) {
756 new UpdateBookmarkTask(getApplicationContext(), id).execute(values);
757 }
758 setResult(RESULT_OK);
Ben Murdoch1794fe22009-09-29 18:14:30 +0100759 } else {
Leon Scroggins88d08032010-10-21 15:17:10 -0400760 Bitmap thumbnail;
761 Bitmap favicon;
762 if (urlUnmodified) {
Leon Scrogginsbc922852010-10-22 12:15:27 -0400763 thumbnail = (Bitmap) mMap.getParcelable(
764 BrowserContract.Bookmarks.THUMBNAIL);
765 favicon = (Bitmap) mMap.getParcelable(
766 BrowserContract.Bookmarks.FAVICON);
Leon Scroggins88d08032010-10-21 15:17:10 -0400767 } else {
768 thumbnail = null;
769 favicon = null;
770 }
771
Ben Murdoch1794fe22009-09-29 18:14:30 +0100772 Bundle bundle = new Bundle();
Leon Scrogginsbc922852010-10-22 12:15:27 -0400773 bundle.putString(BrowserContract.Bookmarks.TITLE, title);
774 bundle.putString(BrowserContract.Bookmarks.URL, url);
775 bundle.putParcelable(BrowserContract.Bookmarks.FAVICON, favicon);
Leon Scroggins88d08032010-10-21 15:17:10 -0400776
777 if (mSaveToHomeScreen) {
778 if (mTouchIconUrl != null && urlUnmodified) {
779 Message msg = Message.obtain(mHandler,
780 TOUCH_ICON_DOWNLOADED);
781 msg.setData(bundle);
782 DownloadTouchIcon icon = new DownloadTouchIcon(this, msg,
Leon Scrogginsbc922852010-10-22 12:15:27 -0400783 mMap.getString(USER_AGENT));
Leon Scroggins88d08032010-10-21 15:17:10 -0400784 icon.execute(mTouchIconUrl);
785 } else {
786 sendBroadcast(BookmarkUtils.createAddToHomeIntent(this, url,
787 title, null /*touchIcon*/, favicon));
788 }
789 } else {
Leon Scrogginsbc922852010-10-22 12:15:27 -0400790 bundle.putParcelable(BrowserContract.Bookmarks.THUMBNAIL, thumbnail);
791 bundle.putBoolean(REMOVE_THUMBNAIL, !urlUnmodified);
792 bundle.putString(TOUCH_ICON_URL, mTouchIconUrl);
Leon Scroggins88d08032010-10-21 15:17:10 -0400793 // Post a message to write to the DB.
794 Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
795 msg.setData(bundle);
796 // Start a new thread so as to not slow down the UI
797 Thread t = new Thread(new SaveBookmarkRunnable(getApplicationContext(), msg));
798 t.start();
799 }
Ben Murdoch1794fe22009-09-29 18:14:30 +0100800 setResult(RESULT_OK);
Kristian Monsen0a1d8382010-02-01 18:41:07 +0000801 LogTag.logBookmarkAdded(url, "bookmarkview");
The Android Open Source Project0c908882009-03-03 19:32:16 -0800802 }
803 return true;
804 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800805}