summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/com/android/browser/BaseUi.java8
-rw-r--r--src/com/android/browser/Controller.java21
-rw-r--r--src/com/android/browser/UI.java3
4 files changed, 29 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c6adaef..1c8b71c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -879,4 +879,8 @@
<!-- Menu item to share URL selection [CHAR LIMIT=30] -->
<string name="menu_share_url">Share</string>
+ <!-- Toast to inform the user that the maximum number of tabs has been
+ reached. [CHAR LIMIT=50] -->
+ <string name="max_tabs_warning">No more tabs available</string>
+
</resources>
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index b9ccd72..b7c5a82 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -932,4 +932,12 @@ public class BaseUi implements UI, WebViewFactory {
return mVideoProgressView;
}
+ @Override
+ public void showMaxTabsWarning() {
+ Toast warning = Toast.makeText(mActivity,
+ mActivity.getString(R.string.max_tabs_warning),
+ Toast.LENGTH_SHORT);
+ warning.show();
+ }
+
}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index e4b0982..4b341da 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2107,9 +2107,19 @@ public class Controller
}
}
+ @Override
+ public Tab openTabToHomePage() {
+ // check for max tabs
+ if (mTabControl.canCreateNewTab()) {
+ return openTabAndShow(mSettings.getHomePage(), false, null);
+ } else {
+ mUi.showMaxTabsWarning();
+ return null;
+ }
+ }
+
// A wrapper function of {@link #openTabAndShow(UrlData, boolean, String)}
// that accepts url as string.
-
protected Tab openTabAndShow(String url, boolean closeOnExit, String appId) {
return openTabAndShow(new UrlData(url), closeOnExit, appId);
}
@@ -2166,8 +2176,10 @@ public class Controller
addTab(tab);
setActiveTab(tab);
return tab;
+ } else {
+ mUi.showMaxTabsWarning();
+ return null;
}
- return null;
}
/**
@@ -2191,11 +2203,6 @@ public class Controller
}
@Override
- public Tab openTabToHomePage() {
- return openTabAndShow(mSettings.getHomePage(), false, null);
- }
-
- @Override
public void closeCurrentTab() {
// hide combo view if open
removeComboView();
diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java
index 2bfec44..b56ba30 100644
--- a/src/com/android/browser/UI.java
+++ b/src/com/android/browser/UI.java
@@ -131,4 +131,7 @@ public interface UI extends ScrollListener {
View getVideoLoadingProgressView();
void bookmarkedStatusHasChanged(Tab tab);
+
+ void showMaxTabsWarning();
+
}