blob: 2a252a7661b5b167fa6605868ec2a83f64b13da4 [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
19import android.app.Activity;
Leon Scroggins III052ce662010-09-13 14:44:16 -040020import android.app.LoaderManager;
The Android Open Source Project0c908882009-03-03 19:32:16 -080021import android.content.ContentResolver;
Leon Scroggins III052ce662010-09-13 14:44:16 -040022import android.content.ContentValues;
23import android.content.Context;
24import android.content.CursorLoader;
The Android Open Source Project0c908882009-03-03 19:32:16 -080025import android.content.Intent;
Leon Scroggins III052ce662010-09-13 14:44:16 -040026import android.content.Loader;
The Android Open Source Project0c908882009-03-03 19:32:16 -080027import android.content.res.Resources;
Patrick Scott3918d442009-08-04 13:22:29 -040028import android.database.Cursor;
Ben Murdochaac7aa62009-09-17 16:57:40 +010029import android.graphics.Bitmap;
The Android Open Source Project0c908882009-03-03 19:32:16 -080030import android.net.ParseException;
31import android.net.WebAddress;
32import android.os.Bundle;
Ben Murdoch1794fe22009-09-29 18:14:30 +010033import android.os.Handler;
34import android.os.Message;
Leon Scroggins III052ce662010-09-13 14:44:16 -040035import android.provider.BrowserContract;
36import android.view.KeyEvent;
37import android.view.LayoutInflater;
The Android Open Source Project0c908882009-03-03 19:32:16 -080038import android.view.View;
Leon Scroggins III052ce662010-09-13 14:44:16 -040039import android.view.ViewGroup;
The Android Open Source Project0c908882009-03-03 19:32:16 -080040import android.view.Window;
Leon Scroggins III052ce662010-09-13 14:44:16 -040041import android.view.inputmethod.EditorInfo;
42import android.view.inputmethod.InputMethodManager;
43import android.widget.AdapterView;
44import android.widget.CursorAdapter;
The Android Open Source Project0c908882009-03-03 19:32:16 -080045import android.widget.EditText;
Leon Scroggins III052ce662010-09-13 14:44:16 -040046import android.widget.ListView;
The Android Open Source Project0c908882009-03-03 19:32:16 -080047import android.widget.TextView;
48import android.widget.Toast;
49
Cary Clarkf2407c62009-09-04 12:25:10 -040050import java.net.URI;
51import java.net.URISyntaxException;
Leon Scroggins III052ce662010-09-13 14:44:16 -040052import java.util.ArrayList;
The Android Open Source Project0c908882009-03-03 19:32:16 -080053import java.util.Date;
54
Leon Scroggins III052ce662010-09-13 14:44:16 -040055import android.util.Log;
56
57public class AddBookmarkPage extends Activity
58 implements View.OnClickListener, TextView.OnEditorActionListener,
59 AdapterView.OnItemClickListener, LoaderManager.LoaderCallbacks<Cursor> {
The Android Open Source Project0c908882009-03-03 19:32:16 -080060
61 private final String LOGTAG = "Bookmarks";
62
Leon Scroggins III052ce662010-09-13 14:44:16 -040063 // IDs for the CursorLoaders that are used.
64 private final int LOADER_ID_FOLDER_CONTENTS = 0;
65 private final int LOADER_ID_ALL_FOLDERS = 1;
66
The Android Open Source Project0c908882009-03-03 19:32:16 -080067 private EditText mTitle;
68 private EditText mAddress;
69 private TextView mButton;
70 private View mCancelButton;
71 private boolean mEditingExisting;
72 private Bundle mMap;
Patrick Scott3918d442009-08-04 13:22:29 -040073 private String mTouchIconUrl;
Ben Murdochaac7aa62009-09-17 16:57:40 +010074 private Bitmap mThumbnail;
75 private String mOriginalUrl;
Leon Scroggins III052ce662010-09-13 14:44:16 -040076 private TextView mFolder;
77 private View mDefaultView;
78 private View mFolderSelector;
79 private EditText mFolderNamer;
80 private View mAddNewFolder;
81 private long mCurrentFolder = 0;
82 private FolderAdapter mAdapter;
83 private ArrayList<Folder> mPaths;
84 private TextView mPath;
85
86 private static class Folder {
87 String Name;
88 long Id;
89 Folder(String name, long id) {
90 Name = name;
91 Id = id;
92 }
93 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080094
Ben Murdoch1794fe22009-09-29 18:14:30 +010095 // Message IDs
96 private static final int SAVE_BOOKMARK = 100;
97
98 private Handler mHandler;
99
Leon Scroggins III052ce662010-09-13 14:44:16 -0400100 @Override
101 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
102 if (v == mFolderNamer) {
103 if (v.getText().length() > 0) {
104 if (actionId == EditorInfo.IME_NULL) {
105 // Only want to do this once.
106 if (event.getAction() == KeyEvent.ACTION_UP) {
107 // Add the folder to the database
108 ContentValues values = new ContentValues();
109 values.put(BrowserContract.Bookmarks.TITLE,
110 v.getText().toString());
111 values.put(BrowserContract.Bookmarks.IS_FOLDER, 1);
112 values.put(BrowserContract.Bookmarks.PARENT,
113 mCurrentFolder);
114 getContentResolver().insert(
115 BrowserContract.Bookmarks.CONTENT_URI, values);
116
117 mFolderNamer.setVisibility(View.GONE);
118 InputMethodManager.getInstance(this)
119 .hideSoftInputFromWindow(
120 mFolderNamer.getWindowToken(), 0);
121 }
122 // Steal the key press for both up and down
123 return true;
124 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800125 }
126 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400127 return false;
128 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800129
Leon Scroggins III052ce662010-09-13 14:44:16 -0400130 @Override
131 public void onClick(View v) {
132 if (v == mButton) {
133 if (mFolderSelector.getVisibility() == View.VISIBLE) {
134 // We are showing the folder selector. This means that the user
135 // has selected a folder. Go back to the opening page
136 mFolderSelector.setVisibility(View.GONE);
137 mDefaultView.setVisibility(View.VISIBLE);
138 setTitle(R.string.bookmark_this_page);
139 } else if (save()) {
140 finish();
141 }
142 } else if (v == mCancelButton) {
The Android Open Source Project0c908882009-03-03 19:32:16 -0800143 finish();
Leon Scroggins III052ce662010-09-13 14:44:16 -0400144 } else if (v == mFolder) {
145 switchToFolderSelector();
146 } else if (v == mAddNewFolder) {
147 mFolderNamer.setVisibility(View.VISIBLE);
148 mFolderNamer.setText(R.string.new_folder);
149 mFolderNamer.requestFocus();
150 InputMethodManager.getInstance(this).showSoftInput(mFolderNamer,
151 InputMethodManager.SHOW_IMPLICIT);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800152 }
Leon Scroggins III052ce662010-09-13 14:44:16 -0400153 }
154
155 private void switchToFolderSelector() {
156 mDefaultView.setVisibility(View.GONE);
157 mFolderSelector.setVisibility(View.VISIBLE);
158 setTitle(R.string.containing_folder);
159 }
160
161 @Override
162 public Loader<Cursor> onCreateLoader(int id, Bundle args) {
163 String[] projection;
164 switch (id) {
165 case LOADER_ID_ALL_FOLDERS:
166 projection = new String[] {
167 BrowserContract.Bookmarks._ID,
168 BrowserContract.Bookmarks.PARENT,
169 BrowserContract.Bookmarks.TITLE,
170 BrowserContract.Bookmarks.IS_FOLDER
171 };
172 return new CursorLoader(this,
173 BrowserContract.Bookmarks.CONTENT_URI,
174 projection,
175 BrowserContract.Bookmarks.IS_FOLDER + " != 0",
176 null,
177 null);
178 case LOADER_ID_FOLDER_CONTENTS:
179 projection = new String[] {
180 BrowserContract.Bookmarks._ID,
181 BrowserContract.Bookmarks.TITLE,
182 BrowserContract.Bookmarks.IS_FOLDER
183 };
184
185 return new CursorLoader(this,
186 BrowserContract.Bookmarks.buildFolderUri(
187 mCurrentFolder),
188 projection,
189 BrowserContract.Bookmarks.IS_FOLDER + " != 0",
190 null,
191 null);
192 default:
193 throw new AssertionError("Asking for nonexistant loader!");
194 }
195 }
196
197 @Override
198 public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
199 switch (loader.getId()) {
200 case LOADER_ID_FOLDER_CONTENTS:
201 mAdapter.changeCursor(cursor);
202 break;
203 case LOADER_ID_ALL_FOLDERS:
204 long parent = mCurrentFolder;
205 int idIndex = cursor.getColumnIndexOrThrow(
206 BrowserContract.Bookmarks._ID);
207 int titleIndex = cursor.getColumnIndexOrThrow(
208 BrowserContract.Bookmarks.TITLE);
209 int parentIndex = cursor.getColumnIndexOrThrow(
210 BrowserContract.Bookmarks.PARENT);
211 while (parent != 0) {
212 // First, find the folder corresponding to the current
213 // folder
214 if (!cursor.moveToFirst()) {
215 throw new AssertionError("No folders in the database!");
216 }
217 long folder;
218 do {
219 folder = cursor.getLong(idIndex);
220 } while (folder != parent && cursor.moveToNext());
221 if (cursor.isAfterLast()) {
222 throw new AssertionError("Folder(id=" + parent
223 + ") holding this bookmark does not exist!");
224 }
225 String name = cursor.getString(titleIndex);
226 mPaths.add(1, new Folder(name, parent));
227 parent = cursor.getLong(parentIndex);
228 }
229 getLoaderManager().stopLoader(LOADER_ID_ALL_FOLDERS);
230 updatePathString();
231 break;
232 default:
233 break;
234 }
235 }
236
237 /**
238 * Update the TextViews in both modes to display the full path of the
239 * current location to insert.
240 */
241 private void updatePathString() {
242 String path = mPaths.get(0).Name;
243 int size = mPaths.size();
244 for (int i = 1; i < size; i++) {
245 path += " / " + mPaths.get(i).Name;
246 }
247 mPath.setText(path);
248 mFolder.setText(path);
249 }
250
251 @Override
252 public void onItemClick(AdapterView<?> parent, View view, int position,
253 long id) {
254 // Switch to the folder that was clicked on.
255 mCurrentFolder = id;
256 mPaths.add(new Folder(((TextView) view).getText().toString(), id));
257 updatePathString();
258
259 getLoaderManager().restartLoader(LOADER_ID_FOLDER_CONTENTS, null, this);
260 }
261
262 /**
263 * Shows a list of names of folders.
264 */
265 private class FolderAdapter extends CursorAdapter {
266 public FolderAdapter(Context context) {
267 super(context, null);
268 }
269
270 @Override
271 public void bindView(View view, Context context, Cursor cursor) {
272 ((TextView) view.findViewById(android.R.id.text1)).setText(
273 cursor.getString(cursor.getColumnIndexOrThrow(
274 BrowserContract.Bookmarks.TITLE)));
275 }
276
277 @Override
278 public View newView(Context context, Cursor cursor, ViewGroup parent) {
279 return LayoutInflater.from(context).inflate(
280 android.R.layout.simple_list_item_1, null);
281 }
282 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800283
284 protected void onCreate(Bundle icicle) {
285 super.onCreate(icicle);
286 requestWindowFeature(Window.FEATURE_LEFT_ICON);
Ben Murdocheecb4e62010-07-06 16:30:38 +0100287
288 mMap = getIntent().getExtras();
Ben Murdocheecb4e62010-07-06 16:30:38 +0100289
Leon Scroggins III052ce662010-09-13 14:44:16 -0400290 setContentView(R.layout.browser_add_bookmark);
Ben Murdocheecb4e62010-07-06 16:30:38 +0100291
Leon Scroggins III052ce662010-09-13 14:44:16 -0400292 setTitle(R.string.bookmark_this_page);
Ben Murdocha753d002009-10-01 11:36:19 +0100293 getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_list_bookmark);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800294
295 String title = null;
296 String url = null;
Ben Murdocheecb4e62010-07-06 16:30:38 +0100297
The Android Open Source Project0c908882009-03-03 19:32:16 -0800298 if (mMap != null) {
299 Bundle b = mMap.getBundle("bookmark");
300 if (b != null) {
301 mMap = b;
302 mEditingExisting = true;
303 setTitle(R.string.edit_bookmark);
304 }
305 title = mMap.getString("title");
Ben Murdochaac7aa62009-09-17 16:57:40 +0100306 url = mOriginalUrl = mMap.getString("url");
Patrick Scott3918d442009-08-04 13:22:29 -0400307 mTouchIconUrl = mMap.getString("touch_icon_url");
Ben Murdochaac7aa62009-09-17 16:57:40 +0100308 mThumbnail = (Bitmap) mMap.getParcelable("thumbnail");
Leon Scroggins III052ce662010-09-13 14:44:16 -0400309 mCurrentFolder = mMap.getLong(BrowserContract.Bookmarks.PARENT);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800310 }
311
312 mTitle = (EditText) findViewById(R.id.title);
313 mTitle.setText(title);
Ben Murdocheecb4e62010-07-06 16:30:38 +0100314
Leon Scroggins III052ce662010-09-13 14:44:16 -0400315 mAddress = (EditText) findViewById(R.id.address);
316 mAddress.setText(url);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800317
The Android Open Source Project0c908882009-03-03 19:32:16 -0800318 mButton = (TextView) findViewById(R.id.OK);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400319 mButton.setOnClickListener(this);
The Android Open Source Project0c908882009-03-03 19:32:16 -0800320
321 mCancelButton = findViewById(R.id.cancel);
Leon Scroggins III052ce662010-09-13 14:44:16 -0400322 mCancelButton.setOnClickListener(this);
323
324 mFolder = (TextView) findViewById(R.id.folder);
325 mFolder.setOnClickListener(this);
326
327 mDefaultView = findViewById(R.id.default_view);
328 mFolderSelector = findViewById(R.id.folder_selector);
329
330 mFolderNamer = (EditText) findViewById(R.id.folder_namer);
331 mFolderNamer.setOnEditorActionListener(this);
332
333 mAddNewFolder = findViewById(R.id.add_new_folder);
334 mAddNewFolder.setOnClickListener(this);
335
336 mPath = (TextView) findViewById(R.id.path);
337 ListView list = (ListView) findViewById(R.id.list);
338
339 mPaths = new ArrayList<Folder>();
340 mPaths.add(0, new Folder(getString(R.string.bookmarks), 0));
341 mAdapter = new FolderAdapter(this);
342 list.setAdapter(mAdapter);
343 list.setOnItemClickListener(this);
344 LoaderManager manager = getLoaderManager();
345 if (mCurrentFolder != 0) {
346 // Find all the folders
347 manager.initLoader(LOADER_ID_ALL_FOLDERS, null, this);
348 }
349 manager.initLoader(LOADER_ID_FOLDER_CONTENTS, null, this);
350
The Android Open Source Project0c908882009-03-03 19:32:16 -0800351
352 if (!getWindow().getDecorView().isInTouchMode()) {
353 mButton.requestFocus();
354 }
355 }
Ben Murdoch1794fe22009-09-29 18:14:30 +0100356
Leon Scroggins III052ce662010-09-13 14:44:16 -0400357 @Override
358 public boolean dispatchKeyEvent (KeyEvent event) {
359 if (mFolderSelector.getVisibility() == View.VISIBLE
360 && KeyEvent.KEYCODE_BACK == event.getKeyCode()) {
361 if (KeyEvent.ACTION_UP == event.getAction()) {
362 int size = mPaths.size();
363 if (1 == size) {
364 // We have reached the top level
365 finish();
366 } else {
367 // Go up a level
368 mPaths.remove(size - 1);
369 mCurrentFolder = mPaths.get(size - 2).Id;
370 updatePathString();
371 getLoaderManager().restartLoader(LOADER_ID_FOLDER_CONTENTS,
372 null, this);
373 }
374 }
375 return true;
376 }
377 return super.dispatchKeyEvent(event);
378 }
379
Leon Scroggins02065b02010-01-04 14:30:13 -0500380 /**
381 * Runnable to save a bookmark, so it can be performed in its own thread.
382 */
383 private class SaveBookmarkRunnable implements Runnable {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400384 // FIXME: This should be an async task.
Leon Scroggins02065b02010-01-04 14:30:13 -0500385 private Message mMessage;
386 public SaveBookmarkRunnable(Message msg) {
387 mMessage = msg;
388 }
389 public void run() {
390 // Unbundle bookmark data.
391 Bundle bundle = mMessage.getData();
392 String title = bundle.getString("title");
393 String url = bundle.getString("url");
394 boolean invalidateThumbnail = bundle.getBoolean(
395 "invalidateThumbnail");
396 Bitmap thumbnail = invalidateThumbnail ? null
397 : (Bitmap) bundle.getParcelable("thumbnail");
398 String touchIconUrl = bundle.getString("touchIconUrl");
399
400 // Save to the bookmarks DB.
401 try {
402 final ContentResolver cr = getContentResolver();
Leon Scroggins III052ce662010-09-13 14:44:16 -0400403 Bookmarks.addBookmark(AddBookmarkPage.this, false, url,
404 title, thumbnail, true, mCurrentFolder);
Leon Scroggins02065b02010-01-04 14:30:13 -0500405 if (touchIconUrl != null) {
Ben Murdochccb5de02010-07-19 18:38:17 +0100406 new DownloadTouchIcon(AddBookmarkPage.this, cr, url).execute(mTouchIconUrl);
Leon Scroggins02065b02010-01-04 14:30:13 -0500407 }
408 mMessage.arg1 = 1;
409 } catch (IllegalStateException e) {
410 mMessage.arg1 = 0;
411 }
412 mMessage.sendToTarget();
413 }
414 }
415
Ben Murdoch1794fe22009-09-29 18:14:30 +0100416 private void createHandler() {
417 if (mHandler == null) {
418 mHandler = new Handler() {
419 @Override
420 public void handleMessage(Message msg) {
421 switch (msg.what) {
422 case SAVE_BOOKMARK:
Leon Scroggins02065b02010-01-04 14:30:13 -0500423 if (1 == msg.arg1) {
Ben Murdoch1794fe22009-09-29 18:14:30 +0100424 Toast.makeText(AddBookmarkPage.this, R.string.bookmark_saved,
425 Toast.LENGTH_LONG).show();
426 } else {
427 Toast.makeText(AddBookmarkPage.this, R.string.bookmark_not_saved,
428 Toast.LENGTH_LONG).show();
429 }
430 break;
431 }
432 }
433 };
434 }
435 }
436
The Android Open Source Project0c908882009-03-03 19:32:16 -0800437 /**
Ben Murdoch1794fe22009-09-29 18:14:30 +0100438 * 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 -0800439 */
440 boolean save() {
Ben Murdoch1794fe22009-09-29 18:14:30 +0100441 createHandler();
442
The Android Open Source Project0c908882009-03-03 19:32:16 -0800443 String title = mTitle.getText().toString().trim();
Ben Murdocheecb4e62010-07-06 16:30:38 +0100444 String unfilteredUrl;
Leon Scroggins III052ce662010-09-13 14:44:16 -0400445 unfilteredUrl = BrowserActivity.fixUrl(mAddress.getText().toString());
Ben Murdocheecb4e62010-07-06 16:30:38 +0100446
The Android Open Source Project0c908882009-03-03 19:32:16 -0800447 boolean emptyTitle = title.length() == 0;
448 boolean emptyUrl = unfilteredUrl.trim().length() == 0;
449 Resources r = getResources();
450 if (emptyTitle || emptyUrl) {
451 if (emptyTitle) {
452 mTitle.setError(r.getText(R.string.bookmark_needs_title));
453 }
454 if (emptyUrl) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400455 mAddress.setError(r.getText(R.string.bookmark_needs_url));
The Android Open Source Project0c908882009-03-03 19:32:16 -0800456 }
Leon Scroggins III6e3faea2010-09-07 15:22:14 -0400457 return false;
Ben Murdocheecb4e62010-07-06 16:30:38 +0100458
The Android Open Source Project0c908882009-03-03 19:32:16 -0800459 }
Ben Murdochca12cfa2009-11-17 13:57:44 +0000460 String url = unfilteredUrl.trim();
Cary Clarkf2407c62009-09-04 12:25:10 -0400461 try {
Ben Murdochca12cfa2009-11-17 13:57:44 +0000462 // We allow bookmarks with a javascript: scheme, but these will in most cases
463 // fail URI parsing, so don't try it if that's the kind of bookmark we have.
464
465 if (!url.toLowerCase().startsWith("javascript:")) {
466 URI uriObj = new URI(url);
467 String scheme = uriObj.getScheme();
468 if (!Bookmarks.urlHasAcceptableScheme(url)) {
469 // If the scheme was non-null, let the user know that we
470 // can't save their bookmark. If it was null, we'll assume
471 // they meant http when we parse it in the WebAddress class.
472 if (scheme != null) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400473 mAddress.setError(r.getText(R.string.bookmark_cannot_save_url));
Ben Murdochca12cfa2009-11-17 13:57:44 +0000474 return false;
475 }
476 WebAddress address;
477 try {
478 address = new WebAddress(unfilteredUrl);
479 } catch (ParseException e) {
480 throw new URISyntaxException("", "");
481 }
482 if (address.mHost.length() == 0) {
483 throw new URISyntaxException("", "");
484 }
485 url = address.toString();
Ben Murdochde353622009-10-12 10:29:00 +0100486 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800487 }
Cary Clarkf2407c62009-09-04 12:25:10 -0400488 } catch (URISyntaxException e) {
Leon Scroggins III052ce662010-09-13 14:44:16 -0400489 mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
Cary Clarkf2407c62009-09-04 12:25:10 -0400490 return false;
The Android Open Source Project0c908882009-03-03 19:32:16 -0800491 }
Ben Murdochaac7aa62009-09-17 16:57:40 +0100492
Ben Murdoch1794fe22009-09-29 18:14:30 +0100493 if (mEditingExisting) {
494 mMap.putString("title", title);
495 mMap.putString("url", url);
496 mMap.putBoolean("invalidateThumbnail", !url.equals(mOriginalUrl));
Leon Scroggins III052ce662010-09-13 14:44:16 -0400497 // FIXME: This does not work yet
498 mMap.putLong(BrowserContract.Bookmarks.PARENT, mCurrentFolder);
Ben Murdoch1794fe22009-09-29 18:14:30 +0100499 setResult(RESULT_OK, (new Intent()).setAction(
500 getIntent().toString()).putExtras(mMap));
501 } else {
502 // Post a message to write to the DB.
503 Bundle bundle = new Bundle();
504 bundle.putString("title", title);
505 bundle.putString("url", url);
506 bundle.putParcelable("thumbnail", mThumbnail);
507 bundle.putBoolean("invalidateThumbnail", !url.equals(mOriginalUrl));
508 bundle.putString("touchIconUrl", mTouchIconUrl);
509 Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
510 msg.setData(bundle);
Leon Scroggins02065b02010-01-04 14:30:13 -0500511 // Start a new thread so as to not slow down the UI
512 Thread t = new Thread(new SaveBookmarkRunnable(msg));
513 t.start();
Ben Murdoch1794fe22009-09-29 18:14:30 +0100514 setResult(RESULT_OK);
Kristian Monsen0a1d8382010-02-01 18:41:07 +0000515 LogTag.logBookmarkAdded(url, "bookmarkview");
The Android Open Source Project0c908882009-03-03 19:32:16 -0800516 }
517 return true;
518 }
519}