Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/bookmarkimport/ImportBookmarksProgressDialog.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.bookmarkimport;
6
7 import android.app.Activity;
8 import android.app.Dialog;
9 import android.app.DialogFragment;
10 import android.app.ProgressDialog;
11 import android.content.Intent;
12 import android.net.Uri;
13 import android.os.Bundle;
14
15 import com.google.android.apps.chrome.R;
16
17 import org.chromium.chrome.browser.UrlConstants;
18 import org.chromium.chrome.browser.document.ChromeLauncherActivity;
19 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils;
20
21 /**
22 * Show the progress dialog and import bookmarks from other browsers.
23 */
24 public class ImportBookmarksProgressDialog extends DialogFragment
25 implements BookmarkImporter.OnBookmarksImportedListener {
26 private ProgressDialog mProgressDialog;
27 private Activity mActivity;
28 private BookmarkImporter mImporter;
29
30 @Override
31 public Dialog onCreateDialog(Bundle savedInstanceState) {
32 mActivity = getActivity();
33 mProgressDialog = ProgressDialog.show(mActivity,
34 mActivity.getString(R.string.import_bookmarks_progress_header),
35 mActivity.getString(R.string.import_bookmarks_progress_message),
36 true, true);
37 mImporter = new AndroidBrowserImporter(mActivity);
38 mImporter.importBookmarks(this);
39 return mProgressDialog;
40 }
41
42 @Override
43 public void onBookmarksImported(BookmarkImporter.ImportResults results) {
44 if (mProgressDialog != null && mProgressDialog.isShowing()) mProgressDia log.dismiss();
45 if (results != null && results.numImported == results.newBookmarks) {
46 if (!EnhancedBookmarkUtils.showEnhancedBookmarkIfEnabled(mActivity)) {
47 // Since the most probable use after importing bookmarks is to n avigate them it
48 // makes more sense to use the normal tab view instead of the em bedded one for
49 // preferences.
50 Intent intent = new Intent(Intent.ACTION_VIEW);
51 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
52 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
53 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
54 intent.setData(Uri.parse(UrlConstants.BOOKMARKS_FOLDER_URL + res ults.rootFolderId));
55 intent.setPackage(mActivity.getPackageName());
56 intent.setClassName(mActivity.getApplicationContext().getPackage Name(),
57 ChromeLauncherActivity.class.getName());
58 mActivity.startActivity(intent);
59 }
60
61 } else {
62 ImportBookmarksRetryDialog retryDialog = new ImportBookmarksRetryDia log();
63 retryDialog.show(mActivity.getFragmentManager(), null);
64 }
65 }
66
67 @Override
68 public void onStop() {
69 super.onStop();
70 // Cancel the import task.
71 if (mImporter != null) mImporter.cancel();
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698