summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArham Jamal <arhamjamal@gmail.com>2012-04-28 05:01:12 +0200
committerSteve Kondik <steve@cyngn.com>2015-11-07 13:57:35 -0800
commit1fd4bec1891e40dfe2e04c1ffe0bbd9f4e649cee (patch)
treec599a877c3b6b2d4a49102d97d8909f4862181c9 /src
parentcfc55f1967f309ab077eded9aa6afa542cd4f00a (diff)
downloadpackages_apps_Browser-1fd4bec1891e40dfe2e04c1ffe0bbd9f4e649cee.zip
packages_apps_Browser-1fd4bec1891e40dfe2e04c1ffe0bbd9f4e649cee.tar.gz
packages_apps_Browser-1fd4bec1891e40dfe2e04c1ffe0bbd9f4e649cee.tar.bz2
Browser: New navbar buttons
Added 2 new buttons to navigation bar: - New Incognito Tab - Goto home screen Signed-off-by: Arham Jamal <arhamjamal@gmail.com> Change-Id: I4c4b611ccc7fc3de4fa4bc7c855e4481de440a87
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/NavScreen.java66
-rw-r--r--src/com/android/browser/NavTabView.java5
2 files changed, 65 insertions, 6 deletions
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index 85eaa41..277df18 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -19,6 +19,7 @@ package com.android.browser;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -26,6 +27,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -42,6 +44,7 @@ import com.android.browser.TabControl.OnThumbnailUpdatedListener;
import com.android.browser.UI.ComboViews;
import java.util.HashMap;
+import java.util.List;
public class NavScreen extends RelativeLayout
implements OnClickListener, OnMenuItemClickListener, OnThumbnailUpdatedListener {
@@ -56,6 +59,8 @@ public class NavScreen extends RelativeLayout
ImageButton mForward;
ImageButton mBookmarks;
ImageButton mMore;
+ ImageButton mHomeTab;
+ ImageButton mNewIncognitoTab;
ImageButton mNewTab;
FrameLayout mHolder;
@@ -67,6 +72,7 @@ public class NavScreen extends RelativeLayout
NavTabScroller mScroller;
TabAdapter mAdapter;
int mOrientation;
+ Point mSize;
HashMap<Tab, View> mTabViews;
public NavScreen(Activity activity, UiController ctl, PhoneUi ui) {
@@ -75,6 +81,9 @@ public class NavScreen extends RelativeLayout
mUiController = ctl;
mUi = ui;
mOrientation = activity.getResources().getConfiguration().orientation;
+ WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
+ mSize = new Point();
+ wm.getDefaultDisplay().getSize(mSize);
init();
}
@@ -118,9 +127,13 @@ public class NavScreen extends RelativeLayout
setContentDescription(mContext.getResources().getString(
R.string.accessibility_transition_navscreen));
mBookmarks = (ImageButton) findViewById(R.id.bookmarks);
+ mHomeTab = (ImageButton) findViewById(R.id.gotohome);
+ mNewIncognitoTab = (ImageButton) findViewById(R.id.newincognitotab);
mNewTab = (ImageButton) findViewById(R.id.newtab);
mMore = (ImageButton) findViewById(R.id.more);
mBookmarks.setOnClickListener(this);
+ mHomeTab.setOnClickListener(this);
+ mNewIncognitoTab.setOnClickListener(this);
mNewTab.setOnClickListener(this);
mMore.setOnClickListener(this);
mScroller = (NavTabScroller) findViewById(R.id.scroller);
@@ -143,7 +156,7 @@ public class NavScreen extends RelativeLayout
new View.OnClickListener() {
@Override
public void onClick(View v) {
- openNewTab();
+ openNewTab(false);
}
});
}
@@ -152,8 +165,10 @@ public class NavScreen extends RelativeLayout
public void onClick(View v) {
if (mBookmarks == v) {
mUiController.bookmarksOrHistoryPicker(ComboViews.Bookmarks);
- } else if (mNewTab == v) {
- openNewTab();
+ } else if (mNewIncognitoTab == v || mNewTab == v) {
+ openNewTab(mNewIncognitoTab == v);
+ } else if (mHomeTab == v) {
+ gotoHomePage();
} else if (mMore == v) {
showMenu();
}
@@ -170,10 +185,12 @@ public class NavScreen extends RelativeLayout
}
}
- private void openNewTab() {
+ private void openNewTab(boolean incognito) {
// need to call openTab explicitely with setactive false
- final Tab tab = mUiController.openTab(BrowserSettings.getInstance().getHomePage(),
- false, false, false);
+ final Tab tab = incognito ?
+ mUiController.openIncognitoTab() :
+ mUiController.openTab(BrowserSettings.getInstance().getHomePage(),
+ false, false, false);
if (tab != null) {
mUiController.setBlockEvents(true);
final int tix = mUi.mTabControl.getTabPosition(tab);
@@ -191,6 +208,43 @@ public class NavScreen extends RelativeLayout
}
}
+ private void gotoHomePage() {
+ final Tab tab = findCenteredTab();
+ if (tab != null) {
+ mUiController.setBlockEvents(true);
+ final int tix = mUi.mTabControl.getTabPosition(tab);
+ mScroller.setOnLayoutListener(new OnLayoutListener() {
+ @Override
+ public void onLayout(int l, int t, int r, int b) {
+ mUi.hideNavScreen(tix, true);
+ switchToTab(tab);
+ }
+ });
+ mScroller.handleDataChanged(tix);
+ mUiController.setBlockEvents(false);
+ mUiController.loadUrl(tab,
+ BrowserSettings.getInstance().getHomePage());
+ }
+ }
+
+ private Tab findCenteredTab(){
+ View v = mOrientation == Configuration.ORIENTATION_LANDSCAPE ?
+ mScroller.findViewAt(mSize.y/2, mSize.x/2):
+ mScroller.findViewAt(mSize.x/2, mSize.y/2);
+ if( v != null && v instanceof NavTabView ){
+ Long tabId = ((NavTabView)v).getWebViewId();
+ if( tabId != null ){
+ List<Tab> tabs = mUiController.getTabs();
+ for( int i=0; i<tabs.size(); i++ ){
+ if( tabs.get(i).getId() == tabId.longValue() ) {
+ return tabs.get(i);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
private void switchToTab(Tab tab) {
if (tab != mUi.getActiveTab()) {
mUiController.setActiveTab(tab);
diff --git a/src/com/android/browser/NavTabView.java b/src/com/android/browser/NavTabView.java
index 91f074c..de50317 100644
--- a/src/com/android/browser/NavTabView.java
+++ b/src/com/android/browser/NavTabView.java
@@ -107,6 +107,11 @@ public class NavTabView extends LinearLayout {
return mHighlighted;
}
+ protected Long getWebViewId(){
+ if(mTab == null) return null;
+ return new Long(mTab.getId());
+ }
+
protected void setWebView(Tab tab) {
mTab = tab;
setTitle();