diff options
-rw-r--r-- | res/drawable/url_background.xml | 25 | ||||
-rw-r--r-- | res/layout/tab_title.xml | 2 | ||||
-rw-r--r-- | res/layout/url_bar.xml | 11 | ||||
-rw-r--r-- | res/menu-xlarge/browser.xml | 10 | ||||
-rw-r--r-- | res/menu/browser.xml | 11 | ||||
-rw-r--r-- | src/com/android/browser/BaseUi.java | 4 | ||||
-rw-r--r-- | src/com/android/browser/BrowserActivity.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 66 | ||||
-rw-r--r-- | src/com/android/browser/PhoneUi.java | 6 | ||||
-rw-r--r-- | src/com/android/browser/UI.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/XLargeUi.java | 21 |
11 files changed, 82 insertions, 79 deletions
diff --git a/res/drawable/url_background.xml b/res/drawable/url_background.xml new file mode 100644 index 0000000..f719c29 --- /dev/null +++ b/res/drawable/url_background.xml @@ -0,0 +1,25 @@ +<?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. +--> + +<selector + xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@drawable/textfield_active_holo_dark" /> + <item + android:state_focused="false" + android:drawable="@drawable/textfield_default_holo_dark" /> +</selector>
\ No newline at end of file diff --git a/res/layout/tab_title.xml b/res/layout/tab_title.xml index 0f500c7..62ef2f3 100644 --- a/res/layout/tab_title.xml +++ b/res/layout/tab_title.xml @@ -53,8 +53,6 @@ android:textColor="@color/white" android:gravity="center_vertical" android:scrollHorizontally="true" - android:fadingEdge="horizontal" - android:fadingEdgeLength="24dip" android:lines="1" android:singleLine="true" /> <ImageButton diff --git a/res/layout/url_bar.xml b/res/layout/url_bar.xml index 3a4e4bb..20081f0 100644 --- a/res/layout/url_bar.xml +++ b/res/layout/url_bar.xml @@ -35,7 +35,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" style="@style/HoloButton" /> - <ImageView + <ImageButton android:id="@+id/stop" android:layout_width="wrap_content" android:layout_height="match_parent" @@ -50,7 +50,7 @@ android:layout_marginLeft="8dip" android:layout_marginRight="8dip" android:orientation="horizontal" - android:background="@drawable/textfield_default_holo_dark"> + android:background="@drawable/url_background"> <ImageView android:id="@+id/voice_icon" android:layout_width="wrap_content" @@ -66,6 +66,7 @@ android:visibility="gone" /> <com.android.browser.UrlInputView android:id="@+id/url_focused" + android:focusable="true" android:layout_width="0dip" android:layout_weight="1.0" android:layout_height="match_parent" @@ -83,13 +84,13 @@ android:inputType="textUri" android:imeOptions="actionGo" style="@style/Suggestions" /> - <ImageView + <ImageButton android:id="@+id/star" android:src="@drawable/btn_imageview_star" android:layout_width="wrap_content" android:layout_height="match_parent" style="@style/HoloButton" /> - <ImageView + <ImageButton android:id="@+id/clear" android:src="@drawable/ic_stop_holo_dark" android:layout_width="wrap_content" @@ -104,7 +105,7 @@ android:visibility="gone" android:gravity="center_vertical" style="@style/HoloButton" /> - <ImageView + <ImageButton android:id="@+id/voicesearch" android:src="@drawable/ic_voice_search_holo_dark" android:layout_width="wrap_content" diff --git a/res/menu-xlarge/browser.xml b/res/menu-xlarge/browser.xml index bd255ae..1b52c9a 100644 --- a/res/menu-xlarge/browser.xml +++ b/res/menu-xlarge/browser.xml @@ -39,7 +39,7 @@ <item android:id="@+id/view_downloads_menu_id" android:title="@string/menu_view_download" android:icon="@drawable/ic_downloads_holo_dark" - android:alphabeticShortcut="d" /> + android:alphabeticShortcut="j" /> <item android:id="@+id/preferences_menu_id" android:title="@string/menu_preferences" android:icon="@drawable/ic_settings_holo_dark" @@ -77,14 +77,12 @@ android:alphabeticShortcut="7" /> <item android:id="@+id/window_eight_menu_id" android:alphabeticShortcut="8" /> - <item android:id="@+id/back_menu_id" - android:alphabeticShortcut="j" /> - <item android:id="@+id/forward_menu_id" - android:alphabeticShortcut="k" /> + <item android:id="@+id/back_menu_id" /> + <item android:id="@+id/forward_menu_id" /> <item android:id="@+id/bookmarks_menu_id" android:alphabeticShortcut="b" /> <item android:id="@+id/add_bookmark_menu_id" - android:alphabeticShortcut="a" /> + android:alphabeticShortcut="d" /> <item android:id="@+id/stop_reload_menu_id" android:alphabeticShortcut="r" /> <item android:id="@+id/goto_menu_id" diff --git a/res/menu/browser.xml b/res/menu/browser.xml index 594681a..beaa8f3 100644 --- a/res/menu/browser.xml +++ b/res/menu/browser.xml @@ -23,8 +23,7 @@ <item android:id="@+id/bookmarks_menu_id" android:title="@string/bookmarks" android:alphabeticShortcut="b" - android:icon="@drawable/ic_bookmarks_holo_dark" - /> + android:icon="@drawable/ic_bookmarks_holo_dark" /> <item android:id="@+id/active_tabs_menu_id" android:title="@string/active_tabs" android:icon="@drawable/ic_windows_holo_dark" @@ -33,12 +32,11 @@ android:alphabeticShortcut="r" /> <item android:id="@+id/forward_menu_id" android:title="@string/forward" - android:alphabeticShortcut="k" android:icon="@*android:drawable/ic_menu_forward" /> <item android:id="@+id/add_bookmark_menu_id" android:title="@string/save_to_bookmarks" android:icon="@drawable/ic_bookmark_on_holo_dark" - android:alphabeticShortcut="a" /> + android:alphabeticShortcut="d" /> <item android:id="@+id/find_menu_id" android:title="@*android:string/find_on_page" android:icon="@*android:drawable/ic_menu_find" @@ -54,7 +52,7 @@ <item android:id="@+id/view_downloads_menu_id" android:title="@string/menu_view_download" android:icon="@drawable/ic_downloads_holo_dark" - android:alphabeticShortcut="d" /> + android:alphabeticShortcut="j" /> <item android:id="@+id/preferences_menu_id" android:title="@string/menu_preferences" android:icon="@drawable/ic_settings_holo_dark" @@ -92,8 +90,7 @@ android:alphabeticShortcut="7" /> <item android:id="@+id/window_eight_menu_id" android:alphabeticShortcut="8" /> - <item android:id="@+id/back_menu_id" - android:alphabeticShortcut="j" /> + <item android:id="@+id/back_menu_id" /> <item android:id="@+id/goto_menu_id" android:alphabeticShortcut="l" /> <item android:id="@+id/close_menu_id" diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 568a7e9..02d9199 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; +import android.view.View.OnKeyListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; @@ -113,7 +114,6 @@ public abstract class BaseUi implements UI, WebViewFactory { mCustomViewContainer = (FrameLayout) mBrowserFrameLayout .findViewById(R.id.fullscreen_custom_content); frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); - } /** @@ -286,6 +286,8 @@ public abstract class BaseUi implements UI, WebViewFactory { Log.w(LOGTAG, "mContainer is already attached to content in" + " attachTabToContentView!"); } + mainView.setNextFocusUpId(R.id.url_focused); + mainView.setNextFocusDownId(R.id.url_focused); mUiController.attachSubWindow(tab); } diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index a67b4e6..527f025 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -94,8 +94,6 @@ public class BrowserActivity extends Activity { if (((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE)) .isEnabled()) { setDefaultKeyMode(DEFAULT_KEYS_DISABLE); - } else { - setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); } mController = new Controller(this); diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 6c6fe0b..16c57c6 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -63,7 +63,6 @@ import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Gravity; import android.view.KeyEvent; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -78,7 +77,6 @@ import android.webkit.WebChromeClient; import android.webkit.WebIconDatabase; import android.webkit.WebSettings; import android.webkit.WebView; -import android.widget.TextView; import java.io.ByteArrayOutputStream; import java.io.File; @@ -2020,7 +2018,6 @@ public class Controller } protected void reuseTab(Tab appTab, String appId, UrlData urlData) { - Log.i(LOGTAG, "Reusing tab for " + appId); // Dismiss the subwindow if applicable. dismissSubWindow(appTab); // Since we might kill the WebView, remove it from the @@ -2413,67 +2410,28 @@ public class Controller return true; } break; - case KeyEvent.KEYCODE_B: - if (ctrl) { - bookmarksOrHistoryPicker(false); - return true; - } - break; +// case KeyEvent.KEYCODE_B: // menu case KeyEvent.KEYCODE_C: if (ctrl) { webView.copySelection(); return true; } break; - case KeyEvent.KEYCODE_D: - if (ctrl) { - bookmarkCurrentPage(AddBookmarkPage.DEFAULT_FOLDER_ID); - return true; - } - break; +// case KeyEvent.KEYCODE_D: // menu // case KeyEvent.KEYCODE_E: // in Chrome: puts '?' in URL bar - case KeyEvent.KEYCODE_F: - if (ctrl) { - webView.showFindDialog(null, true); - return true; - } - break; +// case KeyEvent.KEYCODE_F: // menu // case KeyEvent.KEYCODE_G: // in Chrome: finds next match - case KeyEvent.KEYCODE_H: - if (ctrl) { - bookmarksOrHistoryPicker(true); - return true; - } - break; +// case KeyEvent.KEYCODE_H: // menu // case KeyEvent.KEYCODE_I: // unused - case KeyEvent.KEYCODE_J: - if (ctrl) { - viewDownloads(); - return true; - } - break; +// case KeyEvent.KEYCODE_J: // menu // case KeyEvent.KEYCODE_K: // in Chrome: puts '?' in URL bar - case KeyEvent.KEYCODE_L: - if (ctrl) { - editUrl(); - return true; - } - break; +// case KeyEvent.KEYCODE_L: // menu // case KeyEvent.KEYCODE_M: // unused // case KeyEvent.KEYCODE_N: // in Chrome: new window // case KeyEvent.KEYCODE_O: // in Chrome: open file // case KeyEvent.KEYCODE_P: // in Chrome: print page // case KeyEvent.KEYCODE_Q: // unused - case KeyEvent.KEYCODE_R: - if (ctrl) { - if (mInLoad) { - stopLoading(); - } else { - webView.reload(); - } - return true; - } - break; +// case KeyEvent.KEYCODE_R: // case KeyEvent.KEYCODE_S: // in Chrome: saves page case KeyEvent.KEYCODE_T: if (ctrl) { @@ -2487,17 +2445,13 @@ public class Controller break; // case KeyEvent.KEYCODE_U: // in Chrome: opens source of page // case KeyEvent.KEYCODE_V: // text view intercepts to paste - case KeyEvent.KEYCODE_W: - if (ctrl) { - closeCurrentTab(); - return true; - } - break; +// case KeyEvent.KEYCODE_W: // menu // case KeyEvent.KEYCODE_X: // text view intercepts to cut // case KeyEvent.KEYCODE_Y: // unused // case KeyEvent.KEYCODE_Z: // unused } - return false; + // if we get here, it is a regular key and webview is not null + return mUi.dispatchKey(keyCode, event); } boolean onKeyUp(int keyCode, KeyEvent event) { diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index 99fc4a0..4119c29 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -22,6 +22,7 @@ import android.graphics.PixelFormat; import android.util.Log; import android.view.ActionMode; import android.view.Gravity; +import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.ViewGroup; @@ -269,4 +270,9 @@ public class PhoneUi extends BaseUi { hideFakeTitleBar(); } + @Override + public boolean dispatchKey(int code, KeyEvent event) { + return false; + } + } diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java index 4738522..8de2b19 100644 --- a/src/com/android/browser/UI.java +++ b/src/com/android/browser/UI.java @@ -20,6 +20,7 @@ import android.content.res.Configuration; import android.graphics.Bitmap; import android.os.Bundle; import android.view.ActionMode; +import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.webkit.WebChromeClient.CustomViewCallback; @@ -117,4 +118,6 @@ public interface UI { void showMaxTabsWarning(); + boolean dispatchKey(int code, KeyEvent event); + } diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index a9cc9fe..2f27aa1 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.util.Log; import android.view.ActionMode; import android.view.Gravity; +import android.view.KeyEvent; import android.view.View; import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebView; @@ -396,4 +397,24 @@ public class XLargeUi extends BaseUi implements ScrollListener { mActivity.getActionBar().show(); } } + + @Override + public boolean dispatchKey(int code, KeyEvent event) { + WebView web = getActiveTab().getWebView(); + switch (code) { + case KeyEvent.KEYCODE_TAB: + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_LEFT: + if ((web != null) && web.hasFocus()) { + editUrl(true); + return true; + } + } + if (event.isPrintingKey() && !mFakeTitleBar.isEditingUrl()) { + editUrl(true); + return mContentView.dispatchKeyEvent(event); + } + return false; + } + } |