summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml4
-rw-r--r--res/drawable-nodpi/bg_browser.pngbin49620 -> 0 bytes
-rw-r--r--res/layout/bookmarks_history.xml4
-rw-r--r--res/menu-sw600dp/combined.xml (renamed from res/menu-w720dp/bookmark.xml)20
-rw-r--r--res/menu-sw600dp/history.xml23
-rw-r--r--res/menu-w500dp/bookmark.xml40
-rw-r--r--res/menu/bookmark.xml39
-rw-r--r--res/menu/combined.xml (renamed from res/layout-sw600dp/bookmarks_history.xml)9
-rw-r--r--res/menu/history.xml11
-rw-r--r--src/com/android/browser/BaseUi.java59
-rw-r--r--src/com/android/browser/BookmarkUtils.java2
-rw-r--r--src/com/android/browser/BrowserActivity.java7
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java86
-rw-r--r--src/com/android/browser/BrowserHistoryPage.java84
-rw-r--r--src/com/android/browser/BrowserSnapshotPage.java10
-rw-r--r--src/com/android/browser/CombinedBookmarkHistoryView.java117
-rw-r--r--src/com/android/browser/ComboViewActivity.java110
-rw-r--r--src/com/android/browser/Controller.java107
-rw-r--r--src/com/android/browser/IntentHandler.java1
-rw-r--r--src/com/android/browser/NavigationBarTablet.java2
-rw-r--r--src/com/android/browser/PhoneUi.java20
-rw-r--r--src/com/android/browser/ShortcutActivity.java3
-rw-r--r--src/com/android/browser/UI.java2
-rw-r--r--src/com/android/browser/UiController.java10
-rw-r--r--src/com/android/browser/XLargeUi.java10
25 files changed, 270 insertions, 510 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 26ea91e..9a8a73b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -192,6 +192,10 @@
</intent-filter>
</activity>
+ <activity android:name="ComboViewActivity"
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize">
+ </activity>
+
<!-- Bookmark thumbnail homescreen widget -->
<receiver
android:name=".widget.BookmarkThumbnailWidgetProvider"
diff --git a/res/drawable-nodpi/bg_browser.png b/res/drawable-nodpi/bg_browser.png
deleted file mode 100644
index c7907d7..0000000
--- a/res/drawable-nodpi/bg_browser.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/bookmarks_history.xml b/res/layout/bookmarks_history.xml
index 826fe49..5ec310c 100644
--- a/res/layout/bookmarks_history.xml
+++ b/res/layout/bookmarks_history.xml
@@ -17,6 +17,4 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg_browser"
- android:paddingTop="?android:attr/actionBarSize" />
+ android:layout_height="match_parent" />
diff --git a/res/menu-w720dp/bookmark.xml b/res/menu-sw600dp/combined.xml
index 0adadac..97abc8d 100644
--- a/res/menu-w720dp/bookmark.xml
+++ b/res/menu-sw600dp/combined.xml
@@ -16,22 +16,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
- android:id="@+id/add_bookmark"
- android:icon="@drawable/ic_bookmark_off_holo_dark"
- android:title="@string/add_new_bookmark"
- android:showAsAction="always|withText" />
- <item
- android:id="@+id/go_home"
- android:icon="@drawable/ic_home_holo_dark"
- android:showAsAction="always" />
- <item
- android:id="@+id/thumbnail_view"
- android:title="@string/bookmark_thumbnail_view"/>
- <item
- android:id="@+id/list_view"
- android:title="@string/bookmark_list_view"/>
- <item
android:id="@+id/preferences_menu_id"
android:title="@string/menu_preferences"
- android:alphabeticShortcut="p" />
+ android:icon="@drawable/ic_settings_holo_dark"
+ android:alphabeticShortcut="p"
+ android:showAsAction="ifRoom"
+ android:orderInCategory="1000" />
</menu>
diff --git a/res/menu-sw600dp/history.xml b/res/menu-sw600dp/history.xml
new file mode 100644
index 0000000..36ae6e4
--- /dev/null
+++ b/res/menu-sw600dp/history.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/clear_history_menu_id"
+ android:title="@string/clear_history"
+ android:icon="@android:drawable/ic_menu_close_clear_cancel"
+ android:showAsAction="ifRoom"
+ android:orderInCategory="1" />
+</menu>
diff --git a/res/menu-w500dp/bookmark.xml b/res/menu-w500dp/bookmark.xml
deleted file mode 100644
index a951373..0000000
--- a/res/menu-w500dp/bookmark.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@+id/add_bookmark"
- android:icon="@drawable/ic_bookmark_off_holo_dark"
- android:title="@string/add_new_bookmark"
- android:showAsAction="always" />
- <item
- android:id="@+id/go_home"
- android:icon="@drawable/ic_home_holo_dark"
- android:showAsAction="always" />
- <item
- android:id="@+id/thumbnail_view"
- android:title="@string/bookmark_thumbnail_view"
- android:icon="@drawable/ic_thumbnail_view_holo_dark" />
- <item
- android:id="@+id/list_view"
- android:title="@string/bookmark_list_view"
- android:icon="@drawable/ic_list_view_holo_dark" />
- <item
- android:id="@+id/preferences_menu_id"
- android:title="@string/menu_preferences"
- android:icon="@drawable/ic_settings_holo_dark"
- android:alphabeticShortcut="p" />
-</menu>
diff --git a/res/menu/bookmark.xml b/res/menu/bookmark.xml
deleted file mode 100644
index eee1706..0000000
--- a/res/menu/bookmark.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@+id/add_bookmark"
- android:icon="@drawable/ic_bookmark_off_holo_dark"
- android:title="@string/add_new_bookmark" />
- <item
- android:id="@+id/go_home"
- android:title="@string/go_home"
- android:icon="@drawable/ic_home_holo_dark" />
- <item
- android:id="@+id/thumbnail_view"
- android:title="@string/bookmark_thumbnail_view"
- android:icon="@drawable/ic_thumbnail_view_holo_dark" />
- <item
- android:id="@+id/list_view"
- android:title="@string/bookmark_list_view"
- android:icon="@drawable/ic_list_view_holo_dark" />
- <item
- android:id="@+id/preferences_menu_id"
- android:title="@string/menu_preferences"
- android:icon="@drawable/ic_settings_holo_dark"
- android:alphabeticShortcut="p" />
-</menu>
diff --git a/res/layout-sw600dp/bookmarks_history.xml b/res/menu/combined.xml
index ae5e19b..559bb74 100644
--- a/res/layout-sw600dp/bookmarks_history.xml
+++ b/res/menu/combined.xml
@@ -13,9 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg_browser" />
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+</menu>
diff --git a/res/menu/history.xml b/res/menu/history.xml
index 5b029b5..a8c1b29 100644
--- a/res/menu/history.xml
+++ b/res/menu/history.xml
@@ -4,9 +4,9 @@
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.
@@ -15,11 +15,4 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/clear_history_menu_id"
- android:title="@string/clear_history"
- android:icon="@android:drawable/ic_menu_close_clear_cancel" />
- <item android:id="@+id/preferences_menu_id"
- android:title="@string/menu_preferences"
- android:icon="@drawable/ic_settings_holo_dark"
- android:alphabeticShortcut="p" />
</menu>
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 858e13e..d1445d8 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.app.Activity;
+import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -93,8 +94,6 @@ public abstract class BaseUi implements UI, OnTouchListener {
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private int mOriginalOrientation;
- private CombinedBookmarkHistoryView mComboView;
-
private LinearLayout mErrorConsoleContainer = null;
private Toast mStopToast;
@@ -183,12 +182,6 @@ public abstract class BaseUi implements UI, OnTouchListener {
@Override
public boolean onBackKey() {
- if (mComboView != null) {
- if (!mComboView.onBackPressed()) {
- mUiController.removeComboView();
- }
- return true;
- }
if (mCustomView != null) {
mUiController.hideCustomView();
return true;
@@ -497,45 +490,16 @@ public abstract class BaseUi implements UI, OnTouchListener {
@Override
public void showComboView(ComboViews startingView, Bundle extras) {
- if (mComboView != null) {
- return;
- }
- mComboView = new CombinedBookmarkHistoryView(mActivity,
- mUiController,
- startingView,
- extras);
- FrameLayout wrapper =
- (FrameLayout) mContentView.findViewById(R.id.webview_wrapper);
- wrapper.setVisibility(View.GONE);
- mNavigationBar.stopEditingUrl();
- dismissIME();
- hideTitleBar();
- if (mActiveTab != null) {
- mActiveTab.putInBackground();
- }
- mContentView.addView(mComboView, COVER_SCREEN_PARAMS);
- }
-
- public boolean isComboViewShowing() {
- return (mComboView != null);
- }
-
- /**
- * dismiss the ComboPage
- */
- @Override
- public void hideComboView() {
- if (mComboView != null) {
- mContentView.removeView(mComboView);
- FrameLayout wrapper =
- (FrameLayout) mContentView.findViewById(R.id.webview_wrapper);
- wrapper.setVisibility(View.VISIBLE);
- mComboView = null;
- }
- if (mActiveTab != null) {
- mActiveTab.putInForeground();
+ Intent intent = new Intent(mActivity, ComboViewActivity.class);
+ intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name());
+ intent.putExtra(ComboViewActivity.EXTRA_COMBO_ARGS, extras);
+ Tab t = getActiveTab();
+ if (t != null) {
+ intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl());
}
- mActivity.invalidateOptionsMenu();
+ intent.putExtra(ComboViewActivity.EXTRA_BOOKMARK_PAGE,
+ mUiController.createBookmarkCurrentPageIntent(false));
+ mActivity.startActivityForResult(intent, Controller.COMBO_VIEW);
}
@Override
@@ -594,8 +558,7 @@ public abstract class BaseUi implements UI, OnTouchListener {
@Override
public boolean showsWeb() {
- return mCustomView == null
- && mComboView == null;
+ return mCustomView == null;
}
@Override
diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java
index 23765f4..2e96613 100644
--- a/src/com/android/browser/BookmarkUtils.java
+++ b/src/com/android/browser/BookmarkUtils.java
@@ -22,7 +22,6 @@ import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -38,7 +37,6 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.net.Uri;
import android.os.Message;
-import android.preference.PreferenceManager;
import android.provider.Browser;
import android.provider.BrowserContract;
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index b6d269d..b2a83e1 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -16,15 +16,10 @@
package com.android.browser;
-import com.google.common.annotations.VisibleForTesting;
-
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.PixelFormat;
import android.os.Bundle;
import android.util.Log;
import android.view.ActionMode;
@@ -38,6 +33,8 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
+import com.google.common.annotations.VisibleForTesting;
+
public class BrowserActivity extends Activity {
public static final String ACTION_SHOW_BOOKMARKS = "show_bookmarks";
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index b6a50da..241eb1d 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -26,8 +26,6 @@ import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.content.Loader;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
@@ -36,7 +34,6 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.provider.BrowserContract;
import android.provider.BrowserContract.Accounts;
import android.provider.BrowserContract.ChromeSyncColumns;
@@ -53,7 +50,6 @@ import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.Toast;
import com.android.browser.BookmarkDragHandler.BookmarkDragController;
@@ -67,7 +63,7 @@ interface BookmarksPageCallbacks {
// Return true if handled
boolean onBookmarkSelected(Cursor c, boolean isFolder);
// Return true if handled
- boolean onOpenInNewWindow(Cursor c);
+ boolean onOpenInNewWindow(String... urls);
}
/**
@@ -75,7 +71,7 @@ interface BookmarksPageCallbacks {
*/
public class BrowserBookmarksPage extends Fragment implements View.OnCreateContextMenuListener,
LoaderManager.LoaderCallbacks<Cursor>, BreadCrumbView.Controller,
- OnMenuItemClickListener, OnChildClickListener {
+ OnChildClickListener {
public static class ExtraDragState {
public int childPosition;
@@ -94,7 +90,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
public static final int VIEW_THUMBNAILS = 1;
public static final int VIEW_LIST = 2;
- static final String PREF_SELECTED_VIEW = "bookmarks_view";
BookmarksPageCallbacks mCallbacks;
View mRoot;
@@ -102,7 +97,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
boolean mDisableNewWindow;
boolean mEnableContextMenu = true;
View mEmptyView;
- int mCurrentView;
View mHeader;
HashMap<Integer, BrowserBookmarksAdapter> mBookmarkAdapters = new HashMap<Integer, BrowserBookmarksAdapter>();
BookmarkDragHandler mDragHandler;
@@ -142,7 +136,7 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
args.putString(ACCOUNT_NAME, accountName);
args.putString(ACCOUNT_TYPE, accountType);
BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter(
- getActivity(), mCurrentView);
+ getActivity(), VIEW_THUMBNAILS);
mBookmarkAdapters.put(id, adapter);
mGrid.addAccount(accountName, adapter);
lm.restartLoader(id, args, this);
@@ -252,11 +246,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
};
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- inflater.inflate(R.menu.bookmark, menu);
- }
-
- @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo;
BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition);
@@ -319,13 +308,8 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(getActivity());
- mCurrentView = prefs.getInt(PREF_SELECTED_VIEW, getDefaultView());
-
Bundle args = getArguments();
mDisableNewWindow = args == null ? false : args.getBoolean(EXTRA_DISABLE_WINDOW, false);
-
setHasOptionsMenu(true);
}
@@ -350,13 +334,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
return mRoot;
}
- private int getDefaultView() {
- if (BrowserActivity.isTablet(getActivity())) {
- return VIEW_THUMBNAILS;
- }
- return VIEW_LIST;
- }
-
@Override
public void onDestroyView() {
super.onDestroyView();
@@ -425,7 +402,7 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
long id = c.getLong(BookmarksLoader.COLUMN_INDEX_ID);
new OpenAllInTabsTask(id).execute();
} else {
- mCallbacks.onOpenInNewWindow(c);
+ mCallbacks.onOpenInNewWindow(BrowserBookmarksPage.getUrl(c));
}
}
}
@@ -447,10 +424,13 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
@Override
protected void onPostExecute(Cursor result) {
- if (mCallbacks != null) {
+ if (mCallbacks != null && result.getCount() > 0) {
+ String[] urls = new String[result.getCount()];
+ int i = 0;
while (result.moveToNext()) {
- mCallbacks.onOpenInNewWindow(result);
+ urls[i++] = BrowserBookmarksPage.getUrl(result);
}
+ mCallbacks.onOpenInNewWindow(urls);
}
}
@@ -505,19 +485,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.thumbnail_view:
- selectView(VIEW_THUMBNAILS);
- return true;
- case R.id.list_view:
- selectView(VIEW_LIST);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Resources res = getActivity().getResources();
@@ -527,28 +494,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
getActivity().invalidateOptionsMenu();
}
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
- menu.findItem(R.id.list_view).setVisible(mCurrentView != VIEW_LIST);
- menu.findItem(R.id.thumbnail_view).setVisible(mCurrentView != VIEW_THUMBNAILS);
- }
-
- void selectView(int view) {
- if (view == mCurrentView) {
- return;
- }
- mCurrentView = view;
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
- Editor edit = prefs.edit();
- edit.putInt(PREF_SELECTED_VIEW, mCurrentView);
- edit.apply();
- if (mEmptyView.getVisibility() == View.VISIBLE) {
- return;
- }
- mGrid.selectView(mCurrentView);
- }
-
/**
* BreadCrumb controller callback
*/
@@ -575,19 +520,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
loader.forceLoad();
}
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.list_view:
- selectView(BrowserBookmarksPage.VIEW_LIST);
- return true;
- case R.id.thumbnail_view:
- selectView(BrowserBookmarksPage.VIEW_THUMBNAILS);
- return true;
- }
- return false;
- }
-
public boolean onBackPressed() {
return false;
}
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index bcc33e2..5d106ce 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -29,7 +29,6 @@ import android.content.CursorLoader;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
-import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
@@ -38,9 +37,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.provider.Browser;
import android.provider.BrowserContract;
import android.provider.BrowserContract.Combined;
@@ -66,6 +63,8 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
+import com.android.browser.CombinedBookmarkHistoryView.CombinedBookmarksCallbacks;
+
/**
* Activity for displaying the browser's history, divided into
* days of viewing.
@@ -76,7 +75,7 @@ public class BrowserHistoryPage extends Fragment
static final int LOADER_HISTORY = 1;
static final int LOADER_MOST_VISITED = 2;
- BookmarksHistoryCallbacks mCallbacks;
+ CombinedBookmarksCallbacks mCallback;
HistoryAdapter mAdapter;
HistoryChildWrapper mChildWrapper;
boolean mDisableNewWindow;
@@ -125,17 +124,15 @@ public class BrowserHistoryPage extends Fragment
cm.setText(text);
}
- static BrowserHistoryPage newInstance(BookmarksHistoryCallbacks cb, Bundle args) {
+ static BrowserHistoryPage newInstance(CombinedBookmarksCallbacks cb, Bundle args) {
BrowserHistoryPage bhp = new BrowserHistoryPage();
- bhp.mCallbacks = cb;
+ bhp.mCallback = cb;
bhp.setArguments(args);
return bhp;
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(
- getActivity());
Uri.Builder combinedBuilder = Combined.CONTENT_URI.buildUpon();
switch (id) {
@@ -289,14 +286,14 @@ public class BrowserHistoryPage extends Fragment
@Override
public void onItemClick(
AdapterView<?> parent, View view, int position, long id) {
- mCallbacks.onUrlSelected(((HistoryItem) view).getUrl(), false);
+ mCallback.openUrl(((HistoryItem) view).getUrl());
}
};
@Override
public boolean onChildClick(ExpandableListView parent, View view,
int groupPosition, int childPosition, long id) {
- mCallbacks.onUrlSelected(((HistoryItem) view).getUrl(), false);
+ mCallback.openUrl(((HistoryItem) view).getUrl());
return true;
}
@@ -310,56 +307,49 @@ public class BrowserHistoryPage extends Fragment
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.history, menu);
}
+ void promptToClearHistory() {
+ final ContentResolver resolver = getActivity().getContentResolver();
+ final ClearHistoryTask clear = new ClearHistoryTask(resolver);
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.clear)
+ .setMessage(R.string.pref_privacy_clear_history_dlg)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setNegativeButton(R.string.cancel, null)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ clear.start();
+ }
+ }
+ });
+ final Dialog dialog = builder.create();
+ dialog.show();
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.clear_history_menu_id:
- final ContentResolver resolver = getActivity().getContentResolver();
- final ClearHistoryTask clear = new ClearHistoryTask(resolver, mCallbacks);
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
- .setTitle(R.string.clear)
- .setMessage(R.string.pref_privacy_clear_history_dlg)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setNegativeButton(R.string.cancel, null)
- .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- clear.execute();
- }
- }
- });
- final Dialog dialog = builder.create();
- dialog.show();
- return true;
-
- default:
- break;
+ if (item.getItemId() == R.id.clear_history_menu_id) {
+ promptToClearHistory();
+ return true;
}
return super.onOptionsItemSelected(item);
}
- static class ClearHistoryTask extends AsyncTask<Void, Void, Void> {
+ static class ClearHistoryTask extends Thread {
ContentResolver mResolver;
- BookmarksHistoryCallbacks mCallbacks;
- public ClearHistoryTask(ContentResolver resolver,
- BookmarksHistoryCallbacks callbacks) {
+ public ClearHistoryTask(ContentResolver resolver) {
mResolver = resolver;
- mCallbacks = callbacks;
- }
- @Override
- protected Void doInBackground(Void... params) {
- Browser.clearHistory(mResolver);
- return null;
}
@Override
- protected void onPostExecute(Void result) {
- mCallbacks.onRemoveParentChildRelationships();
+ public void run() {
+ Browser.clearHistory(mResolver);
}
}
@@ -427,10 +417,10 @@ public class BrowserHistoryPage extends Fragment
Activity activity = getActivity();
switch (item.getItemId()) {
case R.id.open_context_menu_id:
- mCallbacks.onUrlSelected(url, false);
+ mCallback.openUrl(url);
return true;
case R.id.new_window_context_menu_id:
- mCallbacks.onUrlSelected(url, true);
+ mCallback.openInNewTab(url);
return true;
case R.id.save_to_bookmarks_menu_id:
if (historyItem.isBookmark()) {
diff --git a/src/com/android/browser/BrowserSnapshotPage.java b/src/com/android/browser/BrowserSnapshotPage.java
index 44c419e..a0ec5e9 100644
--- a/src/com/android/browser/BrowserSnapshotPage.java
+++ b/src/com/android/browser/BrowserSnapshotPage.java
@@ -43,6 +43,7 @@ import android.widget.ImageView;
import android.widget.ResourceCursorAdapter;
import android.widget.TextView;
+import com.android.browser.CombinedBookmarkHistoryView.CombinedBookmarksCallbacks;
import com.android.browser.provider.SnapshotProvider.Snapshots;
import java.text.DateFormat;
@@ -73,12 +74,12 @@ public class BrowserSnapshotPage extends Fragment implements
GridView mGrid;
View mEmpty;
SnapshotAdapter mAdapter;
- UiController mUiController;
+ CombinedBookmarksCallbacks mCallback;
- public static BrowserSnapshotPage newInstance(UiController uiController,
+ public static BrowserSnapshotPage newInstance(CombinedBookmarksCallbacks cb,
Bundle extras) {
BrowserSnapshotPage instance = new BrowserSnapshotPage();
- instance.mUiController = uiController;
+ instance.mCallback = cb;
instance.setArguments(extras);
return instance;
}
@@ -194,8 +195,7 @@ public class BrowserSnapshotPage extends Fragment implements
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
- mUiController.removeComboView();
- mUiController.createNewSnapshotTab(id, true);
+ mCallback.openSnapshot(id);
}
private static class SnapshotAdapter extends ResourceCursorAdapter {
diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java
index 4b3e6d8..191368f 100644
--- a/src/com/android/browser/CombinedBookmarkHistoryView.java
+++ b/src/com/android/browser/CombinedBookmarkHistoryView.java
@@ -17,17 +17,13 @@
package com.android.browser;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
-import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.AsyncTask;
@@ -35,8 +31,6 @@ import android.os.Bundle;
import android.provider.Browser;
import android.view.Gravity;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
@@ -51,13 +45,8 @@ import com.android.browser.UI.ComboViews;
import java.util.HashMap;
import java.util.Vector;
-interface BookmarksHistoryCallbacks {
- public void onUrlSelected(String url, boolean newWindow);
- public void onRemoveParentChildRelationships();
-}
-
public class CombinedBookmarkHistoryView extends LinearLayout
- implements OnTouchListener, TabListener, OptionsMenuHandler {
+ implements OnTouchListener, TabListener {
final static String STARTING_FRAGMENT = "fragment";
@@ -66,7 +55,6 @@ public class CombinedBookmarkHistoryView extends LinearLayout
final static int FRAGMENT_ID_HISTORY = 2;
final static int FRAGMENT_ID_SNAPSHOTS = 3;
- private UiController mUiController;
private Activity mActivity;
private ActionBar mActionBar;
@@ -82,7 +70,14 @@ public class CombinedBookmarkHistoryView extends LinearLayout
BrowserBookmarksPage mBookmarks;
BrowserHistoryPage mHistory;
BrowserSnapshotPage mSnapshots;
- boolean mIsAnimating;
+ CombinedBookmarksCallbacks mCallback;
+
+ public static interface CombinedBookmarksCallbacks {
+ void openUrl(String url);
+ void openInNewTab(String... urls);
+ void openSnapshot(long id);
+ void close();
+ }
static class IconListenerSet implements IconListener {
// Used to store favicons as we get them from the database
@@ -121,19 +116,18 @@ public class CombinedBookmarkHistoryView extends LinearLayout
return sIconListenerSet;
}
- public CombinedBookmarkHistoryView(Activity activity, UiController controller,
- ComboViews startingView, Bundle extras) {
+ public CombinedBookmarkHistoryView(Activity activity,
+ CombinedBookmarksCallbacks cb, ComboViews startingView,
+ Bundle extras) {
super(activity);
- mUiController = controller;
mActivity = activity;
mExtras = extras;
mActionBar = mActivity.getActionBar();
+ mCallback = cb;
View v = LayoutInflater.from(activity).inflate(R.layout.bookmarks_history, this);
v.setOnTouchListener(this);
-// setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
-
mBookmarksHeader = new FrameLayout(mActivity);
mBookmarksHeader.setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
@@ -158,29 +152,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
}
}).execute();
- mIsAnimating = true;
- setAlpha(0f);
- Resources res = mActivity.getResources();
- animate().alpha(1f)
- .setDuration(res.getInteger(R.integer.comboViewFadeInDuration))
- .setListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- mIsAnimating = false;
- if (mActionBar == null) {
- // We were destroyed, return
- return;
- }
- FragmentManager fm = mActivity.getFragmentManager();
- FragmentTransaction ft = fm.beginTransaction();
- onTabSelected(mActionBar.getSelectedTab(), ft);
- ft.commit();
- }
- });
-
setupActionBar(startingView);
- mUiController.registerOptionsMenuHandler(this);
}
void setupActionBar(ComboViews startingView) {
@@ -228,15 +200,15 @@ public class CombinedBookmarkHistoryView extends LinearLayout
// Warning, ugly hack below
// This is done because history uses orientation-specific padding
FragmentManager fm = mActivity.getFragmentManager();
- mHistory = BrowserHistoryPage.newInstance(mUiController, mHistory.getArguments());
+ mHistory = BrowserHistoryPage.newInstance(mCallback, mHistory.getArguments());
fm.beginTransaction().replace(R.id.fragment, mHistory).commit();
}
}
private BookmarksPageCallbacks mBookmarkCallbackWrapper = new BookmarksPageCallbacks() {
@Override
- public boolean onOpenInNewWindow(Cursor c) {
- mUiController.onUrlSelected(BrowserBookmarksPage.getUrl(c), true);
+ public boolean onOpenInNewWindow(String... urls) {
+ mCallback.openInNewTab(urls);
return true;
}
@@ -245,7 +217,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
if (isFolder) {
return false;
}
- mUiController.onUrlSelected(BrowserBookmarksPage.getUrl(c), false);
+ mCallback.openUrl(BrowserBookmarksPage.getUrl(c));
return true;
}
};
@@ -253,8 +225,8 @@ public class CombinedBookmarkHistoryView extends LinearLayout
private void initFragments(Bundle extras) {
mBookmarks = BrowserBookmarksPage.newInstance(mBookmarkCallbackWrapper,
extras, mBookmarksHeader);
- mHistory = BrowserHistoryPage.newInstance(mUiController, extras);
- mSnapshots = BrowserSnapshotPage.newInstance(mUiController, extras);
+ mHistory = BrowserHistoryPage.newInstance(mCallback, extras);
+ mSnapshots = BrowserSnapshotPage.newInstance(mCallback, extras);
}
private void loadFragment(int id, FragmentTransaction ft) {
@@ -300,16 +272,12 @@ public class CombinedBookmarkHistoryView extends LinearLayout
}
mCurrentFragment = INVALID_ID;
}
- mUiController.unregisterOptionsMenuHandler(this);
}
/**
* callback for back key presses
*/
boolean onBackPressed() {
- if (mIsAnimating) {
- return true;
- }
if (mCurrentFragment == FRAGMENT_ID_BOOKMARKS) {
return mBookmarks.onBackPressed();
}
@@ -332,13 +300,6 @@ public class CombinedBookmarkHistoryView extends LinearLayout
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
- if (mIsAnimating) {
- // We delay set while animating (smooth animations)
- // TODO: Signal to the fragment in advance so that it can start
- // loading its data asynchronously
- return;
- }
-
if (tab == mTabBookmarks) {
loadFragment(FRAGMENT_ID_BOOKMARKS, ft);
} else if (tab == mTabHistory) {
@@ -353,44 +314,4 @@ public class CombinedBookmarkHistoryView extends LinearLayout
// Ignore
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Handled by fragment
- return false;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- // Handled by fragment
- return false;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- mUiController.getUi().onBackKey();
- return true;
- case R.id.go_home:
- BrowserSettings settings = BrowserSettings.getInstance();
- mUiController.onUrlSelected(settings.getHomePage(), false);
- return true;
- case R.id.add_bookmark:
- mUiController.bookmarkCurrentPage(false);
- return true;
- case R.id.preferences_menu_id:
- Intent intent = new Intent(mActivity, BrowserPreferencesPage.class);
- intent.putExtra(BrowserPreferencesPage.CURRENT_PAGE,
- mUiController.getCurrentTopWebView().getUrl());
- mActivity.startActivityForResult(intent, Controller.PREFERENCES_PAGE);
- return true;
- }
-
- switch (mCurrentFragment) {
- case FRAGMENT_ID_BOOKMARKS:
- return mBookmarks.onOptionsItemSelected(item);
- case FRAGMENT_ID_HISTORY:
- return mHistory.onOptionsItemSelected(item);
- }
- return false;
- }
}
diff --git a/src/com/android/browser/ComboViewActivity.java b/src/com/android/browser/ComboViewActivity.java
new file mode 100644
index 0000000..cea1884
--- /dev/null
+++ b/src/com/android/browser/ComboViewActivity.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2011 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.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.android.browser.CombinedBookmarkHistoryView.CombinedBookmarksCallbacks;
+import com.android.browser.UI.ComboViews;
+
+public class ComboViewActivity extends Activity implements CombinedBookmarksCallbacks {
+
+ public static final String EXTRA_COMBO_ARGS = "combo_args";
+ public static final String EXTRA_INITIAL_VIEW = "initial_view";
+
+ public static final String EXTRA_OPEN_SNAPSHOT = "snapshot_id";
+ public static final String EXTRA_OPEN_ALL = "open_all";
+ public static final String EXTRA_CURRENT_URL = "url";
+ public static final String EXTRA_BOOKMARK_PAGE = "create_bookmark";
+
+ private CombinedBookmarkHistoryView mComboView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setResult(RESULT_CANCELED);
+ Bundle extras = getIntent().getExtras();
+ Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
+ String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
+ ComboViews startingView = svStr != null
+ ? ComboViews.valueOf(svStr)
+ : ComboViews.Bookmarks;
+ mComboView = new CombinedBookmarkHistoryView(this, this,
+ startingView, args);
+ setContentView(mComboView);
+ }
+
+ @Override
+ public void openUrl(String url) {
+ Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ setResult(RESULT_OK, i);
+ finish();
+ }
+
+ @Override
+ public void openInNewTab(String... urls) {
+ Intent i = new Intent();
+ i.putExtra(EXTRA_OPEN_ALL, urls);
+ setResult(RESULT_OK, i);
+ finish();
+ }
+
+ @Override
+ public void close() {
+ finish();
+ }
+
+ @Override
+ public void openSnapshot(long id) {
+ Intent i = new Intent();
+ i.putExtra(EXTRA_OPEN_SNAPSHOT, id);
+ setResult(RESULT_OK, i);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (!mComboView.onBackPressed()) {
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.combined, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ } else if (item.getItemId() == R.id.preferences_menu_id) {
+ String url = getIntent().getStringExtra(EXTRA_CURRENT_URL);
+ Intent intent = new Intent(this, BrowserPreferencesPage.class);
+ intent.putExtra(BrowserPreferencesPage.CURRENT_PAGE, url);
+ startActivityForResult(intent, Controller.PREFERENCES_PAGE);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 9659063..9b81870 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -118,6 +118,7 @@ public class Controller
private static final int EMPTY_MENU = -1;
// activity requestCode
+ final static int COMBO_VIEW = 1;
final static int PREFERENCES_PAGE = 3;
final static int FILE_SELECTED = 4;
final static int AUTOFILL_SETUP = 5;
@@ -145,7 +146,6 @@ public class Controller
private TabControl mTabControl;
private BrowserSettings mSettings;
private WebViewFactory mFactory;
- private OptionsMenuHandler mOptionsMenuHandler = null;
private WakeLock mWakeLock;
@@ -1152,6 +1152,30 @@ public class Controller
mAutoFillSetupMessage = null;
}
break;
+ case COMBO_VIEW:
+ if (intent == null || resultCode != Activity.RESULT_OK) {
+ break;
+ }
+ if (Intent.ACTION_VIEW.equals(intent.getAction())) {
+ Tab t = getCurrentTab();
+ Uri uri = intent.getData();
+ loadUrl(t, uri.toString());
+ } else if (intent.hasExtra(ComboViewActivity.EXTRA_OPEN_ALL)) {
+ String[] urls = intent.getStringArrayExtra(
+ ComboViewActivity.EXTRA_OPEN_ALL);
+ Tab parent = getCurrentTab();
+ for (String url : urls) {
+ parent = openTab(url, parent,
+ !mSettings.openInBackground(), true);
+ }
+ } else if (intent.hasExtra(ComboViewActivity.EXTRA_OPEN_SNAPSHOT)) {
+ long id = intent.getLongExtra(
+ ComboViewActivity.EXTRA_OPEN_SNAPSHOT, -1);
+ if (id >= 0) {
+ createNewSnapshotTab(id, true);
+ }
+ }
+ break;
default:
break;
}
@@ -1189,34 +1213,6 @@ public class Controller
mTabControl.removeParentChildRelationShips();
}
- /**
- * callback from ComboPage when bookmark/history selection
- */
- @Override
- public void onUrlSelected(String url, boolean newTab) {
- removeComboView();
- if (!TextUtils.isEmpty(url)) {
- if (newTab) {
- final Tab parent = mTabControl.getCurrentTab();
- openTab(url,
- (parent != null) && parent.isPrivateBrowsingEnabled(),
- !mSettings.openInBackground(),
- true);
- } else {
- final Tab currentTab = mTabControl.getCurrentTab();
- loadUrl(currentTab, url);
- }
- }
- }
-
- /**
- * dismiss the ComboPage
- */
- @Override
- public void removeComboView() {
- mUi.hideComboView();
- }
-
// key handling
protected void onBackKey() {
if (!mUi.onBackKey()) {
@@ -1241,10 +1237,6 @@ public class Controller
// TODO: maybe put into separate handler
protected boolean onCreateOptionsMenu(Menu menu) {
- if (mOptionsMenuHandler != null) {
- return mOptionsMenuHandler.onCreateOptionsMenu(menu);
- }
-
if (mMenuState == EMPTY_MENU) {
return false;
}
@@ -1437,9 +1429,6 @@ public class Controller
}
boolean onPrepareOptionsMenu(Menu menu) {
- if (mOptionsMenuHandler != null) {
- return mOptionsMenuHandler.onPrepareOptionsMenu(menu);
- }
// Note: setVisible will decide whether an item is visible; while
// setEnabled() will decide whether an item is enabled, which also means
// whether the matching shortcut key will function.
@@ -1513,16 +1502,6 @@ public class Controller
}
public boolean onOptionsItemSelected(MenuItem item) {
- if (mOptionsMenuHandler != null &&
- mOptionsMenuHandler.onOptionsItemSelected(item)) {
- return true;
- }
-
- if (item.getGroupId() != R.id.CONTEXT_MENU) {
- // menu remains active, so ensure comboview is dismissed
- // if main menu option is selected
- removeComboView();
- }
if (null == getCurrentTopWebView()) {
return false;
}
@@ -1552,7 +1531,7 @@ public class Controller
break;
case R.id.add_bookmark_menu_id:
- bookmarkCurrentPage(false);
+ mActivity.startActivity(createBookmarkCurrentPageIntent(false));
break;
case R.id.stop_reload_menu_id:
@@ -1853,13 +1832,13 @@ public class Controller
/**
* add the current page as a bookmark to the given folder id
* @param folderId use -1 for the default folder
- * @param canBeAnEdit If true, check to see whether the site is already
+ * @param editExisting If true, check to see whether the site is already
* bookmarked, and if it is, edit that bookmark. If false, and
* the site is already bookmarked, do not attempt to edit the
* existing bookmark.
*/
@Override
- public void bookmarkCurrentPage(boolean canBeAnEdit) {
+ public Intent createBookmarkCurrentPageIntent(boolean editExisting) {
Intent i = new Intent(mActivity,
AddBookmarkPage.class);
WebView w = getCurrentTopWebView();
@@ -1878,13 +1857,13 @@ public class Controller
createScreenshot(w, getDesiredThumbnailWidth(mActivity),
getDesiredThumbnailHeight(mActivity)));
i.putExtra(BrowserContract.Bookmarks.FAVICON, w.getFavicon());
- if (canBeAnEdit) {
+ if (editExisting) {
i.putExtra(AddBookmarkPage.CHECK_FOR_DUPE, true);
}
// Put the dialog at the upper right of the screen, covering the
// star on the title bar.
i.putExtra("gravity", Gravity.RIGHT | Gravity.TOP);
- mActivity.startActivity(i);
+ return i;
}
// file chooser
@@ -2278,8 +2257,6 @@ public class Controller
*/
@Override
public boolean switchToTab(Tab tab) {
- // hide combo view if open
- removeComboView();
Tab currentTab = mTabControl.getCurrentTab();
if (tab == null || tab == currentTab) {
return false;
@@ -2290,8 +2267,6 @@ public class Controller
@Override
public void closeCurrentTab() {
- // hide combo view if open
- removeComboView();
if (mTabControl.getTabCount() == 1) {
CrashRecoveryHandler.clearState(mActivity);
mActivity.finish();
@@ -2318,8 +2293,6 @@ public class Controller
*/
@Override
public void closeTab(Tab tab) {
- // hide combo view if open
- removeComboView();
removeTab(tab);
}
@@ -2490,12 +2463,8 @@ public class Controller
// Even if MENU is already held down, we need to call to super to open
// the IME on long press.
if (KeyEvent.KEYCODE_MENU == keyCode) {
- if (mOptionsMenuHandler != null) {
- return false;
- } else {
- event.startTracking();
- return true;
- }
+ event.startTracking();
+ return true;
}
if (!noModifiers
&& ((KeyEvent.KEYCODE_MENU == keyCode)
@@ -2659,18 +2628,6 @@ public class Controller
}
@Override
- public void registerOptionsMenuHandler(OptionsMenuHandler handler) {
- mOptionsMenuHandler = handler;
- }
-
- @Override
- public void unregisterOptionsMenuHandler(OptionsMenuHandler handler) {
- if (mOptionsMenuHandler == handler) {
- mOptionsMenuHandler = null;
- }
- }
-
- @Override
public void registerDropdownChangeListener(DropdownChangeListener d) {
mUi.registerDropdownChangeListener(d);
}
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java
index 1a72a23..6ed5b72 100644
--- a/src/com/android/browser/IntentHandler.java
+++ b/src/com/android/browser/IntentHandler.java
@@ -88,7 +88,6 @@ public class IntentHandler {
mController.bookmarksOrHistoryPicker(false);
return;
}
- mController.removeComboView();
// In case the SearchDialog is open.
((SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE))
diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java
index 1aeb35b..9cb8ff2 100644
--- a/src/com/android/browser/NavigationBarTablet.java
+++ b/src/com/android/browser/NavigationBarTablet.java
@@ -156,7 +156,7 @@ public class NavigationBarTablet extends NavigationBarBase {
} else if (mForwardButton == v) {
mUiController.getCurrentTab().goForward();
} else if (mStar == v) {
- mUiController.bookmarkCurrentPage(true);
+ getContext().startActivity(mUiController.createBookmarkCurrentPageIntent(true));
} else if (mAllButton == v) {
mUiController.bookmarksOrHistoryPicker(false);
} else if (mSearchButton == v) {
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 7c3641c..6c484db 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -56,12 +56,6 @@ public class PhoneUi extends BaseUi {
}
@Override
- public void hideComboView() {
- super.hideComboView();
- mActivity.getActionBar().hide();
- }
-
- @Override
public void onDestroy() {
hideTitleBar();
}
@@ -85,22 +79,16 @@ public class PhoneUi extends BaseUi {
@Override
public boolean onMenuKey() {
- if (!isComboViewShowing()) {
- if (mNavScreen == null) {
- showNavScreen();
- } else {
- mNavScreen.close();
- }
- return true;
+ if (mNavScreen == null) {
+ showNavScreen();
} else {
- return false;
+ mNavScreen.close();
}
+ return true;
}
@Override
public boolean dispatchKey(int code, KeyEvent event) {
- if (!isComboViewShowing()) {
- }
return false;
}
diff --git a/src/com/android/browser/ShortcutActivity.java b/src/com/android/browser/ShortcutActivity.java
index af1788d..134bf23 100644
--- a/src/com/android/browser/ShortcutActivity.java
+++ b/src/com/android/browser/ShortcutActivity.java
@@ -19,7 +19,6 @@ package com.android.browser;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
-import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
@@ -59,7 +58,7 @@ public class ShortcutActivity extends Activity
}
@Override
- public boolean onOpenInNewWindow(Cursor c) {
+ public boolean onOpenInNewWindow(String... urls) {
return false;
}
diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java
index fdd2b93..4b58872 100644
--- a/src/com/android/browser/UI.java
+++ b/src/com/android/browser/UI.java
@@ -85,8 +85,6 @@ public interface UI {
public void showComboView(ComboViews startingView, Bundle extra);
- public void hideComboView();
-
public void showCustomView(View view, int requestedOrientation,
CustomViewCallback callback);
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 10821cd..14d498c 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -29,7 +29,7 @@ import java.util.List;
/**
* UI aspect of the controller
*/
-public interface UiController extends BookmarksHistoryCallbacks {
+public interface UiController {
UI getUi();
@@ -60,7 +60,7 @@ public interface UiController extends BookmarksHistoryCallbacks {
void stopLoading();
- void bookmarkCurrentPage(boolean canBeAnEdit);
+ Intent createBookmarkCurrentPageIntent(boolean canBeAnEdit);
void bookmarksOrHistoryPicker(boolean openHistory);
@@ -76,8 +76,6 @@ public interface UiController extends BookmarksHistoryCallbacks {
boolean shouldShowErrorConsole();
- void removeComboView();
-
void hideCustomView();
void attachSubWindow(Tab tab);
@@ -90,10 +88,6 @@ public interface UiController extends BookmarksHistoryCallbacks {
void shareCurrentPage();
- void registerOptionsMenuHandler(OptionsMenuHandler handler);
-
- void unregisterOptionsMenuHandler(OptionsMenuHandler handler);
-
void updateMenuState(Tab tab, Menu menu);
void registerDropdownChangeListener(DropdownChangeListener d);
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index 73375e0..73821bf 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -73,16 +73,6 @@ public class XLargeUi extends BaseUi {
}
@Override
- public void hideComboView() {
- if (isComboViewShowing()) {
- super.hideComboView();
- // ComboView changes the action bar, set it back up to what we want
- setupActionBar();
- checkTabCount();
- }
- }
-
- @Override
public void setUseQuickControls(boolean useQuickControls) {
mUseQuickControls = useQuickControls;
mTitleBar.setUseQuickControls(mUseQuickControls);