diff options
| -rw-r--r-- | res/drawable/ic_menu_hideurl.png | bin | 0 -> 1222 bytes | |||
| -rw-r--r-- | res/layout/tab_bar.xml | 24 | ||||
| -rw-r--r-- | res/layout/tab_title.xml | 4 | ||||
| -rw-r--r-- | res/layout/url_bar.xml | 8 | ||||
| -rw-r--r-- | res/menu-xlarge/browser.xml | 9 | ||||
| -rw-r--r-- | res/values-xlarge/styles.xml | 44 | ||||
| -rw-r--r-- | res/values/styles.xml | 18 | ||||
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 33 | ||||
| -rw-r--r-- | src/com/android/browser/ScrollWebView.java | 4 | ||||
| -rw-r--r-- | src/com/android/browser/TabBar.java | 108 | ||||
| -rw-r--r-- | src/com/android/browser/TitleBarXLarge.java | 6 | ||||
| -rw-r--r-- | src/com/android/browser/UrlInputView.java | 17 |
12 files changed, 166 insertions, 109 deletions
diff --git a/res/drawable/ic_menu_hideurl.png b/res/drawable/ic_menu_hideurl.png Binary files differnew file mode 100644 index 000000000..571457b99 --- /dev/null +++ b/res/drawable/ic_menu_hideurl.png diff --git a/res/layout/tab_bar.xml b/res/layout/tab_bar.xml index 60f08efea..0b3fae136 100644 --- a/res/layout/tab_bar.xml +++ b/res/layout/tab_bar.xml @@ -15,28 +15,20 @@ android:id="@+id/tabbarcontent" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="#ffdddddd" + style="@style/ActionBarStyle" android:orientation="horizontal"> - <com.android.browser.TabScrollView - android:id="@+id/tabs" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1.0" - android:orientation="horizontal" /> <ImageButton android:id="@+id/showurl" android:src="@drawable/ic_menu_showurl" android:layout_width="48dip" android:layout_height="48dip" - android:layout_marginLeft="6dip" + android:layout_marginLeft="3dip" android:background="@drawable/browserbarbutton" - android:visibility="invisible" /> - <ImageButton - android:id="@+id/newtab" - android:src="@drawable/ic_menu_new_window" - android:layout_width="48dip" + android:visibility="gone" /> + <com.android.browser.TabScrollView + android:id="@+id/tabs" + android:layout_width="0dp" android:layout_height="48dip" - android:layout_marginLeft="6dip" - android:layout_marginRight="6dip" - android:background="@drawable/browserbarbutton" /> + android:layout_weight="1.0" + android:orientation="horizontal" /> </LinearLayout> diff --git a/res/layout/tab_title.xml b/res/layout/tab_title.xml index 6166d2455..9fdddeb14 100644 --- a/res/layout/tab_title.xml +++ b/res/layout/tab_title.xml @@ -10,7 +10,7 @@ the specific language governing permissions and limitations under the License. --> -<LinearLayout +<merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="0dip" android:layout_weight="1.0" @@ -46,4 +46,4 @@ android:layout_height="wrap_content" android:layout_marginLeft="6dip" android:src="@drawable/btn_close_window" /> -</LinearLayout> +</merge> diff --git a/res/layout/url_bar.xml b/res/layout/url_bar.xml index 9bf617dda..a8e5a8da3 100644 --- a/res/layout/url_bar.xml +++ b/res/layout/url_bar.xml @@ -96,14 +96,6 @@ android:background="@drawable/browserbarbutton" /> </LinearLayout> <ImageButton - android:id="@+id/menu" - android:src="@drawable/ic_menu" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_marginLeft="6dip" - android:layout_marginRight="6dip" - android:background="@drawable/browserbarbutton" /> - <ImageButton android:id="@+id/all_btn" android:layout_width="wrap_content" android:layout_height="match_parent" diff --git a/res/menu-xlarge/browser.xml b/res/menu-xlarge/browser.xml index 0fc20bec8..191f99fec 100644 --- a/res/menu-xlarge/browser.xml +++ b/res/menu-xlarge/browser.xml @@ -16,14 +16,11 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:id="@+id/MAIN_MENU"> - <item android:id="@+id/new_tab_menu_id" - android:title="@string/new_tab" + <item android:id="@+id/newtab" android:icon="@drawable/ic_menu_new_window" + android:title="@string/new_tab" + android:showAsAction="always" android:alphabeticShortcut="n" /> - <item android:id="@+id/active_tabs_menu_id" - android:title="@string/active_tabs" - android:icon="@drawable/ic_menu_windows" - android:alphabeticShortcut="t" /> <item android:id="@+id/find_menu_id" android:title="@string/find_dot" android:icon="@drawable/ic_menu_find" diff --git a/res/values-xlarge/styles.xml b/res/values-xlarge/styles.xml new file mode 100644 index 000000000..844f54f8b --- /dev/null +++ b/res/values-xlarge/styles.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* + * + * Copyright 2006,2007,2008 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. + */ +--> +<resources> + <style name="BrowserTheme" parent="@android:Theme.Black"> + <item name="android:windowBackground">@color/white</item> + <item name="android:colorBackground">#FFFFFFFF</item> + <item name="android:windowActionBar">true</item> + <item name="android:windowNoTitle">false</item> + <item name="android:windowActionBarStyle">@style/ActionBarStyle</item> + <item name="android:windowContentOverlay">@null</item> + </style> + <style name="BookmarkTheme" parent="@android:Theme.Black"> + <item name="android:windowNoTitle">true</item> + <item name="android:windowContentOverlay">@null</item> + </style> + <style name="ActionBarStyle"> + <item name="android:background">#ffdddddd</item> + <item name="android:height">48dip</item> + <item name="android:padding">0dip</item> + <item name="android:displayOptions">hideHome</item> + </style> + <style name="TitleBar"> + <item name="android:windowEnterAnimation">@anim/title_bar_enter</item> + <item name="android:windowExitAnimation">@anim/title_bar_exit</item> + </style> +</resources> + diff --git a/res/values/styles.xml b/res/values/styles.xml index 2e8510a0a..a339b5709 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* +/* * * Copyright 2006,2007,2008 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 + * 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 + * 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 + * 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. */ --> diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index d6f7177b6..ee231a740 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -16,6 +16,7 @@ package com.android.browser; +import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; @@ -199,6 +200,13 @@ public class BrowserActivity extends Activity mMixLockIcon = Resources.getSystem().getDrawable( android.R.drawable.ic_partial_secure); + // Create the tab control and our initial tab + mTabControl = new TabControl(this); + + mXLargeScreenSize = (getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) + == Configuration.SCREENLAYOUT_SIZE_XLARGE; + FrameLayout frameLayout = (FrameLayout) getWindow().getDecorView() .findViewById(com.android.internal.R.id.content); mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(this) @@ -210,28 +218,19 @@ public class BrowserActivity extends Activity mCustomViewContainer = (FrameLayout) mBrowserFrameLayout .findViewById(R.id.fullscreen_custom_content); frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); - mXLargeScreenSize = (getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) - == Configuration.SCREENLAYOUT_SIZE_XLARGE; - // Create the tab control and our initial tab - mTabControl = new TabControl(this); if (mXLargeScreenSize) { mTitleBar = new TitleBarXLarge(this); mTitleBar.setProgress(100); mFakeTitleBar = new TitleBarXLarge(this); + ActionBar actionBar = getActionBar(); mTabBar = new TabBar(this, mTabControl, (TitleBarXLarge) mFakeTitleBar); - LinearLayout layout = (LinearLayout) mBrowserFrameLayout. - findViewById(R.id.vertical_layout); - layout.addView(mTabBar, 0, new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); + actionBar.setCustomNavigationMode(mTabBar); } else { mTitleBar = new TitleBar(this); // mTitleBar will be always be shown in the fully loaded mode on // phone mTitleBar.setProgress(100); - // Fake title bar is not needed in xlarge layout mFakeTitleBar = new TitleBar(this); } @@ -1341,6 +1340,12 @@ public class BrowserActivity extends Activity @Override public boolean onOptionsItemSelected(MenuItem item) { + // check the action bar button before mCanChord check, as the prepare call + // doesn't come for action bar buttons + if (item.getItemId() == R.id.newtab) { + bookmarksOrHistoryPicker(false, true); + return true; + } if (!mCanChord) { // The user has already fired a shortcut with this hold down of the // menu key. @@ -1630,8 +1635,10 @@ public class BrowserActivity extends Activity final MenuItem forward = menu.findItem(R.id.forward_menu_id); forward.setEnabled(canGoForward); - final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id); - newtab.setEnabled(mTabControl.canCreateNewTab()); + if (!mXLargeScreenSize) { + final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id); + newtab.setEnabled(mTabControl.canCreateNewTab()); + } // decide whether to show the share link option PackageManager pm = getPackageManager(); diff --git a/src/com/android/browser/ScrollWebView.java b/src/com/android/browser/ScrollWebView.java index 16404aa83..97bd2c7a1 100644 --- a/src/com/android/browser/ScrollWebView.java +++ b/src/com/android/browser/ScrollWebView.java @@ -68,6 +68,10 @@ public class ScrollWebView extends WebView { super(context); } + void hideEmbeddedTitleBar() { + scrollBy(0, getVisibleTitleHeight()); + } + @Override public void setEmbeddedTitleBar(final View title) { super.setEmbeddedTitleBar(title); diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index da1861431..6fc919e23 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -25,11 +25,13 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.PaintDrawable; import android.view.ContextMenu; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; import android.view.View.OnClickListener; import android.webkit.WebView; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -48,19 +50,18 @@ public class TabBar extends LinearLayout private static final int PROGRESS_MAX = 100; - private static final int TAB_WIDTH_SELECTED = 300; - private static final int TAB_WIDTH_UNSELECTED = 300; - private BrowserActivity mBrowserActivity; - private final float mTabWidthSelected; - private final float mTabWidthUnselected; + private final int mTabWidthSelected; + private final int mTabWidthUnselected; + + private final Drawable mShowUrlDrawable; + private final Drawable mHideUrlDrawable; private TitleBarXLarge mTitleBar; private TabScrollView mTabs; - private View mNewButton; - private View mShowUrlButton; + private ImageButton mShowUrlButton; private TabControl mControl; private Map<Tab, TabViewData> mTabMap; @@ -68,12 +69,15 @@ public class TabBar extends LinearLayout private float mDensityScale; private boolean mUserRequestedUrlbar; private boolean mTitleVisible; + private boolean mShowUrlMode; public TabBar(BrowserActivity context, TabControl tabcontrol, TitleBarXLarge titlebar) { super(context); Resources res = context.getResources(); - mTabWidthSelected = res.getDimension(R.dimen.tab_width_selected); - mTabWidthUnselected = res.getDimension(R.dimen.tab_width_unselected); + mTabWidthSelected = (int) res.getDimension(R.dimen.tab_width_selected); + mTabWidthUnselected = (int) res.getDimension(R.dimen.tab_width_unselected); + mShowUrlDrawable = res.getDrawable(R.drawable.ic_menu_showurl); + mHideUrlDrawable = res.getDrawable(R.drawable.ic_menu_hideurl); mTitleBar = titlebar; mTitleBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, @@ -86,13 +90,11 @@ public class TabBar extends LinearLayout LayoutInflater factory = LayoutInflater.from(context); factory.inflate(R.layout.tab_bar, this); mTabs = (TabScrollView) findViewById(R.id.tabs); - mNewButton = findViewById(R.id.newtab); - mShowUrlButton = findViewById(R.id.showurl); + mShowUrlButton = (ImageButton) findViewById(R.id.showurl); // TODO: Change enabled states based on whether you can go // back/forward. Probably should be done inside onPageStarted. - mNewButton.setOnClickListener(this); mShowUrlButton.setOnClickListener(this); // build tabs @@ -112,14 +114,21 @@ public class TabBar extends LinearLayout public void onClick(View view) { if (mShowUrlButton == view) { - mBrowserActivity.stopScrolling(); - mBrowserActivity.showFakeTitleBar(); - mUserRequestedUrlbar = true; - } else if (mNewButton == view) { - mBrowserActivity.bookmarksOrHistoryPicker(false, true); + if (mShowUrlMode) { + showUrlBar(); + } else if (!isLoading()) { + ScrollWebView swv = (ScrollWebView) mControl.getCurrentWebView(); + swv.hideEmbeddedTitleBar(); + mBrowserActivity.hideFakeTitleBar(); + } } else if (mTabs.getSelectedTab() == view) { - mBrowserActivity.showFakeTitleBar(); - mTitleBar.requestUrlInputFocus(); + if (mBrowserActivity.isFakeTitleBarShowing() && !isLoading()) { + mBrowserActivity.hideFakeTitleBar(); + } else { + showUrlBar(); + } + // temporarily disabled + // mTitleBar.requestUrlInputFocus(); } else { TabViewData data = (TabViewData) view.getTag(); int ix = mControl.getTabIndex(data.mTab); @@ -128,18 +137,48 @@ public class TabBar extends LinearLayout } } + private void showUrlBar() { + mBrowserActivity.stopScrolling(); + mBrowserActivity.showFakeTitleBar(); + mUserRequestedUrlbar = true; + } + + private void setShowUrlMode(boolean showUrl) { + mShowUrlMode = showUrl; + Drawable newDrawable = mShowUrlMode ? mShowUrlDrawable : mHideUrlDrawable; + mShowUrlButton.setImageDrawable(newDrawable); + } + + // callback after fake titlebar is shown void onShowTitleBar() { - mShowUrlButton.setVisibility(View.INVISIBLE); + setShowUrlMode(false); } + // callback after fake titlebar is hidden void onHideTitleBar() { - mShowUrlButton.setVisibility(mTitleVisible ? View.INVISIBLE : View.VISIBLE); + setShowUrlMode(!mTitleVisible); Tab tab = mControl.getCurrentTab(); tab.getWebView().requestFocus(); mUserRequestedUrlbar = false; } - // UrlInputListener implementation + // webview scroll listener + + @Override + public void onScroll(boolean titleVisible) { + mTitleVisible = titleVisible; + if (!mShowUrlMode && !mTitleVisible && !isLoading()) { + if (mUserRequestedUrlbar) { + mBrowserActivity.hideFakeTitleBar(); + } else { + setShowUrlMode(true); + } + } else if (mTitleVisible && !isLoading()) { + if (mShowUrlMode) { + setShowUrlMode(false); + } + } + } @Override public void createContextMenu(ContextMenu menu) { @@ -182,8 +221,11 @@ public class TabBar extends LinearLayout public TabView(Context context, TabViewData tab) { super(context); mTabData = tab; + setGravity(Gravity.CENTER_VERTICAL); + setOrientation(LinearLayout.HORIZONTAL); + setBackgroundResource(R.drawable.tab_background); LayoutInflater inflater = LayoutInflater.from(mContext); - mTabContent = inflater.inflate(R.layout.tab_title, this); + mTabContent = inflater.inflate(R.layout.tab_title, this, true); mTitle = (TextView) mTabContent.findViewById(R.id.title); mIconView = (ImageView) mTabContent.findViewById(R.id.favicon); mLock = (ImageView) mTabContent.findViewById(R.id.lock); @@ -226,8 +268,7 @@ public class TabBar extends LinearLayout mTitle.setTextColor(mSelected ? Color.BLACK : Color.GRAY); super.setSelected(selected); setLayoutParams(new LayoutParams(selected ? - (int) (TAB_WIDTH_SELECTED * mDensityScale) - : (int) (TAB_WIDTH_UNSELECTED * mDensityScale), + mTabWidthSelected : mTabWidthUnselected, LayoutParams.MATCH_PARENT)); } @@ -355,7 +396,6 @@ public class TabBar extends LinearLayout public void onNewTab(Tab tab) { TabViewData tvd = buildTab(tab); buildView(tvd); - mShowUrlButton.setVisibility(View.INVISIBLE); } @Override @@ -397,20 +437,4 @@ public class TabBar extends LinearLayout return mTabMap.get(mControl.getCurrentTab()).mTabView.mInLoad; } - // webview scroll listener - - @Override - public void onScroll(boolean titleVisible) { - mTitleVisible = titleVisible; - boolean buttonVisible = (mShowUrlButton.getVisibility() == View.VISIBLE); - if (!buttonVisible && !mTitleVisible && !isLoading()) { - mShowUrlButton.setVisibility(View.VISIBLE); - if (mUserRequestedUrlbar) { - mBrowserActivity.hideFakeTitleBar(); - } - } else if (mTitleVisible && !isLoading()) { - mShowUrlButton.setVisibility(View.INVISIBLE); - } - } - } diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java index c1fdee3a1..f858e2ea9 100644 --- a/src/com/android/browser/TitleBarXLarge.java +++ b/src/com/android/browser/TitleBarXLarge.java @@ -49,7 +49,6 @@ public class TitleBarXLarge extends TitleBarBase private View mStar; private View mSearchButton; private ImageView mStopButton; - private View mMenu; private View mAllButton; private ImageView mProgressView; private UrlInputView mUrlView; @@ -76,7 +75,6 @@ public class TitleBarXLarge extends TitleBarBase mBackButton = findViewById(R.id.back); mForwardButton = findViewById(R.id.forward); mStar = findViewById(R.id.star); - mMenu = findViewById(R.id.menu); mStopButton = (ImageView) findViewById(R.id.stop); mSearchButton = findViewById(R.id.search); mLockIcon = (ImageView) findViewById(R.id.lock); @@ -89,7 +87,6 @@ public class TitleBarXLarge extends TitleBarBase mAllButton.setOnClickListener(this); mStopButton.setOnClickListener(this); mSearchButton.setOnClickListener(this); - mMenu.setOnClickListener(this); mUrlView.setUrlInputListener(this); } @@ -101,8 +98,6 @@ public class TitleBarXLarge extends TitleBarBase mBrowserActivity.getTopWindow().goForward(); } else if (mStar == v) { mBrowserActivity.promptAddOrInstallBookmark(); - } else if (mMenu == v) { - mBrowserActivity.openOptionsMenu(); } else if (mAllButton == v) { mBrowserActivity.bookmarksOrHistoryPicker(false, false); } else if (mSearchButton == v) { @@ -135,6 +130,7 @@ public class TitleBarXLarge extends TitleBarBase public void onDismiss() { mBrowserActivity.getTabControl().getCurrentTopWebView().requestFocus(); mBrowserActivity.hideFakeTitleBar(); + mUrlView.setText(mBrowserActivity.getTabControl().getCurrentWebView().getUrl()); } @Override diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java index f564d6aa3..77d7dafdd 100644 --- a/src/com/android/browser/UrlInputView.java +++ b/src/com/android/browser/UrlInputView.java @@ -35,13 +35,14 @@ import android.widget.CursorAdapter; import android.widget.Filterable; import android.widget.ImageView; import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; /** * url/search input view * handling suggestions */ public class UrlInputView extends AutoCompleteTextView - implements OnFocusChangeListener, OnItemClickListener { + implements OnFocusChangeListener, OnItemClickListener, OnEditorActionListener { private UrlInputListener mListener; private InputMethodManager mInputManager; @@ -66,13 +67,7 @@ public class UrlInputView extends AutoCompleteTextView private void init(Context ctx) { mFocusDrawable = ctx.getResources().getDrawable(R.drawable.textfield_stroke); mInputManager = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE); - setOnEditorActionListener(new OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - finishInput(getText().toString()); - return true; - } - }); + setOnEditorActionListener(this); setOnFocusChangeListener(this); final ContentResolver cr = mContext.getContentResolver(); mAdapter = new SuggestionsAdapter(mContext, @@ -83,6 +78,12 @@ public class UrlInputView extends AutoCompleteTextView } @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + finishInput(getText().toString()); + return true; + } + + @Override public void onFocusChange(View v, boolean hasFocus) { setBackgroundDrawable(hasFocus ? mFocusDrawable : null); if (hasFocus) { |
