Bug 881802: TopBookmarks should use EditBookmark dialog. [r=wesj]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 10 Jul 2013 16:39:54 -0700
changeset 151381 276d77c4e049462be5ac22e0c90c212d0ef8ee1d
parent 151380 36e84501201e92cb5eb9afe24ccaf6b72a36fc30
child 151382 2f7174f6521f019ff4eb55731bf641691cadbcf2
push idunknown
push userunknown
push dateunknown
reviewerswesj
bugs881802
milestone25.0a1
Bug 881802: TopBookmarks should use EditBookmark dialog. [r=wesj]
mobile/android/base/home/HomeFragment.java
--- a/mobile/android/base/home/HomeFragment.java
+++ b/mobile/android/base/home/HomeFragment.java
@@ -1,40 +1,37 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
+import org.mozilla.gecko.EditBookmarkDialog;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.gfx.BitmapUtils;
 import org.mozilla.gecko.home.HomeListView.HomeContextMenuInfo;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.UiAsyncTask;
 
 import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.support.v4.app.Fragment;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
-import android.view.LayoutInflater;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
-import android.widget.EditText;
 import android.widget.Toast;
 
 /**
  * HomeFragment is an empty fragment that can be added to the HomePager.
  * Subclasses can add their own views. 
  */
 class HomeFragment extends Fragment {
     // Log Tag.
@@ -139,58 +136,17 @@ class HomeFragment extends Fragment {
                     flags |= Tabs.LOADURL_PRIVATE;
 
                 Tabs.getInstance().loadUrl(info.url, flags);
                 Toast.makeText(activity, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
                 return true;
             }
 
             case R.id.edit_bookmark: {
-                AlertDialog.Builder editPrompt = new AlertDialog.Builder(activity);
-                final View editView = LayoutInflater.from(activity).inflate(R.layout.bookmark_edit, null);
-                editPrompt.setTitle(R.string.bookmark_edit_title);
-                editPrompt.setView(editView);
-
-                final EditText nameText = ((EditText) editView.findViewById(R.id.edit_bookmark_name));
-                final EditText locationText = ((EditText) editView.findViewById(R.id.edit_bookmark_location));
-                final EditText keywordText = ((EditText) editView.findViewById(R.id.edit_bookmark_keyword));
-                nameText.setText(info.title);
-                locationText.setText(info.url);
-                keywordText.setText(info.keyword);
-
-                final int rowId = info.rowId;
-                editPrompt.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int whichButton) {
-                        (new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
-                            @Override
-                            public Void doInBackground(Void... params) {
-                                String newUrl = locationText.getText().toString().trim();
-                                String newKeyword = keywordText.getText().toString().trim();
-                                BrowserDB.updateBookmark(activity.getContentResolver(), rowId, newUrl, nameText.getText().toString(), newKeyword);
-                                return null;
-                            }
-
-                            @Override
-                            public void onPostExecute(Void result) {
-                                Toast.makeText(activity, R.string.bookmark_updated, Toast.LENGTH_SHORT).show();
-                            }
-                        }).execute();
-                    }
-                });
-
-                editPrompt.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int whichButton) {
-                          // do nothing
-                      }
-                });
-
-                final AlertDialog dialog = editPrompt.create();
-                dialog.show();
+                new EditBookmarkDialog(activity).show(info.url);
                 return true;
             }
 
             case R.id.remove_bookmark: {
                 final int rowId = info.rowId;
                 (new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
                     @Override
                     public Void doInBackground(Void... params) {