summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/Controller.java25
-rw-r--r--src/com/android/browser/TitleBarXLarge.java32
-rw-r--r--src/com/android/browser/UiController.java2
-rw-r--r--src/com/android/browser/UrlInputView.java18
-rw-r--r--src/com/android/browser/UrlSelectionActionMode.java61
5 files changed, 97 insertions, 41 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index b4699e3..75dd913 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -493,6 +493,22 @@ public class Controller
}
+ @Override
+ public void shareCurrentPage() {
+ shareCurrentPage(mTabControl.getCurrentTab());
+ }
+
+ private void shareCurrentPage(Tab tab) {
+ if (tab != null) {
+ tab.populatePickerData();
+ sharePage(mActivity, tab.getTitle(),
+ tab.getUrl(), tab.getFavicon(),
+ createScreenshot(tab.getWebView(),
+ getDesiredThumbnailWidth(mActivity),
+ getDesiredThumbnailHeight(mActivity)));
+ }
+ }
+
/**
* Share a page, providing the title, url, favicon, and a screenshot. Uses
* an {@link Intent} to launch the Activity chooser.
@@ -599,7 +615,7 @@ public class Controller
}
/**
- * resume all WebView timers using the WebView instance of the given tab
+ * resume all WebView timers using the WebView instance of the given tab
* @param tab guaranteed non-null
*/
private void resumeWebViewTimers(Tab tab) {
@@ -1581,12 +1597,7 @@ public class Controller
mCanChord = false;
return false;
}
- currentTab.populatePickerData();
- sharePage(mActivity, currentTab.getTitle(),
- currentTab.getUrl(), currentTab.getFavicon(),
- createScreenshot(currentTab.getWebView(),
- getDesiredThumbnailWidth(mActivity),
- getDesiredThumbnailHeight(mActivity)));
+ shareCurrentPage(currentTab);
break;
case R.id.dump_nav_menu_id:
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 7e54710..0aa09db 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -26,12 +26,9 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
-import android.view.ContextMenu;
import android.view.LayoutInflater;
-import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.View.OnFocusChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
@@ -39,11 +36,10 @@ import android.widget.TextView;
* tabbed title bar for xlarge screen browser
*/
public class TitleBarXLarge extends TitleBarBase
- implements UrlInputListener, OnClickListener, OnFocusChangeListener {
+ implements UrlInputListener, OnClickListener {
private static final int PROGRESS_MAX = 100;
- private Activity mActivity;
private UiController mUiController;
private Drawable mStopDrawable;
@@ -67,7 +63,6 @@ public class TitleBarXLarge extends TitleBarBase
public TitleBarXLarge(Activity activity, UiController controller) {
super(activity);
- mActivity = activity;
mUiController = controller;
Resources resources = activity.getResources();
mStopDrawable = resources.getDrawable(R.drawable.ic_stop_normal);
@@ -106,25 +101,15 @@ public class TitleBarXLarge extends TitleBarBase
mGoButton.setOnClickListener(this);
mClearButton.setOnClickListener(this);
mUrlFocused.setUrlInputListener(this);
- mUrlUnfocused.setOnFocusChangeListener(this);
mUrlFocused.setContainer(mFocusContainer);
+ mUrlFocused.setController(mUiController);
mUnfocusContainer.setOnClickListener(this);
}
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- setUrlMode(true);
- mUrlFocused.selectAll();
- mUrlFocused.requestFocus();
- mUrlFocused.setDropDownWidth(mUnfocusContainer.getWidth());
- mUrlFocused.setDropDownHorizontalOffset(-mUrlFocused.getLeft());
- }
- }
-
@Override
public void onClick(View v) {
if (mUnfocusContainer == v) {
- mUrlUnfocused.requestFocus();
+ setUrlMode(true);
} else if (mBackButton == v) {
mUiController.getCurrentTopWebView().goBack();
} else if (mForwardButton == v) {
@@ -190,6 +175,10 @@ public class TitleBarXLarge extends TitleBarBase
private void setUrlMode(boolean focused) {
swapUrlContainer(focused);
if (focused) {
+ mUrlFocused.selectAll();
+ mUrlFocused.requestFocus();
+ mUrlFocused.setDropDownWidth(mUnfocusContainer.getWidth());
+ mUrlFocused.setDropDownHorizontalOffset(-mUrlFocused.getLeft());
mSearchButton.setVisibility(View.GONE);
mGoButton.setVisibility(View.VISIBLE);
} else {
@@ -203,13 +192,6 @@ public class TitleBarXLarge extends TitleBarBase
mFocusContainer.setVisibility(focus ? View.VISIBLE : View.GONE);
}
- @Override
- public void createContextMenu(ContextMenu menu) {
- MenuInflater inflater = mActivity.getMenuInflater();
- inflater.inflate(R.menu.title_context, menu);
- mActivity.onCreateContextMenu(menu, this, null);
- }
-
private void search() {
setDisplayTitle("");
mUrlUnfocused.requestFocus();
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index dffebba..c74d74e 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -75,4 +75,6 @@ public interface UiController extends BookmarksHistoryCallbacks {
void endActionMode();
+ void shareCurrentPage();
+
}
diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java
index 9c85616..a4c2be3 100644
--- a/src/com/android/browser/UrlInputView.java
+++ b/src/com/android/browser/UrlInputView.java
@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
@@ -36,7 +35,8 @@ import android.widget.TextView.OnEditorActionListener;
* handling suggestions
*/
public class UrlInputView extends AutoCompleteTextView
- implements OnFocusChangeListener, OnEditorActionListener, CompletionListener {
+ implements OnFocusChangeListener, OnEditorActionListener,
+ CompletionListener {
private UrlInputListener mListener;
private InputMethodManager mInputManager;
@@ -66,11 +66,17 @@ public class UrlInputView extends AutoCompleteTextView
super.setOnFocusChangeListener(this);
mAdapter = new SuggestionsAdapter(ctx, this);
setAdapter(mAdapter);
- setSelectAllOnFocus(false);
+ setSelectAllOnFocus(true);
onConfigurationChanged(ctx.getResources().getConfiguration());
setThreshold(1);
}
+ void setController(UiController controller) {
+ UrlSelectionActionMode urlSelectionMode
+ = new UrlSelectionActionMode(controller);
+ setCustomSelectionActionModeCallback(urlSelectionMode);
+ }
+
void setContainer(View container) {
mContainer = container;
}
@@ -109,12 +115,6 @@ public class UrlInputView extends AutoCompleteTextView
}
@Override
- public ActionMode startActionMode(ActionMode.Callback callback) {
- // suppress selection action mode
- return null;
- }
-
- @Override
public void setOnFocusChangeListener(OnFocusChangeListener focusListener) {
mWrappedFocusListener = focusListener;
}
diff --git a/src/com/android/browser/UrlSelectionActionMode.java b/src/com/android/browser/UrlSelectionActionMode.java
new file mode 100644
index 0000000..5636388
--- /dev/null
+++ b/src/com/android/browser/UrlSelectionActionMode.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+package com.android.browser;
+
+import android.view.ActionMode;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class UrlSelectionActionMode implements ActionMode.Callback {
+
+ private UiController mUiController;
+
+ public UrlSelectionActionMode(UiController controller) {
+ mUiController = controller;
+ }
+
+ // ActionMode.Callback implementation
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ mode.getMenuInflater().inflate(R.menu.url_selection, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.share:
+ mUiController.shareCurrentPage();
+ mode.finish();
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return true;
+ }
+
+}