Bug 695165 - Hook up Forward to UI [r=sriram]
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 31 Oct 2011 11:02:34 -0400
changeset 83328 7f8a9ba22b1021daf66e2390c7d5a4a04386d017
parent 83327 21fd85f89ad94f8375b6963547122be7f0c28bdd
child 83329 591ac51b83591651bacaf0dd854fbe3a07b1730d
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs695165
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 695165 - Hook up Forward to UI [r=sriram] Add a menu item to allow the user to go forward in history. The menu item automatically enables/disables based on whether the action is available.
embedding/android/GeckoApp.java
embedding/android/Tab.java
embedding/android/locales/en-US/android_strings.dtd
embedding/android/resources/layout/gecko_menu.xml
embedding/android/strings.xml.in
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -438,35 +438,40 @@ abstract public class GeckoApp
                     }
                 }
                 mi.setOnMenuItemClickListener(item);
             }
         }
 
         Tab tab = Tabs.getInstance().getSelectedTab();
         MenuItem bookmark = aMenu.findItem(R.id.bookmark);
+        MenuItem forward = aMenu.findItem(R.id.forward);
 
         if (tab == null) {
             bookmark.setVisible(false);
+            forward.setVisible(false);
             return true;
         }
         
         bookmark.setVisible(true);
         bookmark.setCheckable(true);
         
         if (tab.isBookmark()) {
             bookmark.setChecked(true);
             bookmark.setIcon(R.drawable.bookmark_remove);
             bookmark.setTitle(R.string.bookmark_remove);
         } else {
             bookmark.setChecked(false);
             bookmark.setIcon(R.drawable.bookmark_add);
             bookmark.setTitle(R.string.bookmark_add);
         }
 
+        forward.setVisible(true);
+        forward.setEnabled(tab.canDoForward());
+
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         Tab tab = null;
         Tab.HistoryEntry he = null;
         Intent intent = null;
@@ -499,16 +504,19 @@ abstract public class GeckoApp
                if (he != null) {
                    GeckoAppShell.openUriExternal(he.mUri, "text/plain", "", "",
                                                  Intent.ACTION_SEND, he.mTitle);
                }
                return true;
            case R.id.reload:
                doReload();
                return true;
+           case R.id.forward:
+               doForward();
+               return true;
            case R.id.saveaspdf:
                GeckoAppShell.sendEventToGecko(new GeckoEvent("SaveAs:PDF", null));
                return true;
            case R.id.preferences:
                intent = new Intent(this, GeckoPreferences.class);
                startActivity(intent);
                return true;
            case R.id.addons:
@@ -1537,16 +1545,25 @@ abstract public class GeckoApp
         Log.i(LOG_NAME, "Reload requested");
         Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab == null)
             return false;
 
         return tab.doReload();
     }
 
+    public boolean doForward() {
+        Log.i(LOG_NAME, "Forward requested");
+        Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab == null)
+            return false;
+
+        return tab.doForward();
+    }
+
     @Override
     public void onBackPressed() {
         Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab == null || !tab.doBack()) {
             finish();
         }
     }
 
--- a/embedding/android/Tab.java
+++ b/embedding/android/Tab.java
@@ -178,16 +178,20 @@ public class Tab {
         if (mHistoryIndex < 1) {
             return false;
         }
         GeckoEvent e = new GeckoEvent("session-back", "");
         GeckoAppShell.sendEventToGecko(e);
         return true;
     }
 
+    public boolean canDoForward() {
+        return (mHistoryIndex + 1 < mHistory.size());
+    }
+
     public boolean doForward() {
         if (mHistoryIndex + 1 >= mHistory.size()) {
             return false;
         }
         GeckoEvent e = new GeckoEvent("session-forward", "");
         GeckoAppShell.sendEventToGecko(e);
         return true;
     }
--- a/embedding/android/locales/en-US/android_strings.dtd
+++ b/embedding/android/locales/en-US/android_strings.dtd
@@ -30,16 +30,17 @@
 <!ENTITY bookmark_removed "Bookmark removed">
 
 <!ENTITY history_today_section "Today">
 <!ENTITY history_yesterday_section "Yesterday">
 <!ENTITY history_week_section "7 days ago">
 <!ENTITY history_older_section "Older than 7 days">
 
 <!ENTITY reload "Reload">
+<!ENTITY forward "Forward">
 
 <!ENTITY new_tab "New Tab">
 
 <!ENTITY preferences "Preferences">
 <!ENTITY preferences_title "Preferences">
 <!ENTITY pref_category_privacy "Privacy &amp; Security">
 <!ENTITY pref_category_content "Content">
 <!ENTITY pref_do_not_track "Tell sites not to track me">
--- a/embedding/android/resources/layout/gecko_menu.xml
+++ b/embedding/android/resources/layout/gecko_menu.xml
@@ -1,14 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
 
     <item android:id="@+id/reload"
           android:title="@string/reload"/>
 
+    <item android:id="@+id/forward"
+          android:title="@string/forward"/>
+
     <item android:id="@+id/bookmark"
           android:title="@string/bookmark_add"
           android:icon="@drawable/bookmark_add"
           android:showAsAction="ifRoom"/>
 
     <item android:id="@+id/preferences"
           android:icon="@android:drawable/ic_menu_preferences"
           android:enabled="false"
--- a/embedding/android/strings.xml.in
+++ b/embedding/android/strings.xml.in
@@ -61,11 +61,12 @@
   <string name="pref_enable_js">&pref_enable_js;</string>
   <string name="pref_char_encoding">&pref_char_encoding;</string>
   <string name="pref_clear_history">&pref_clear_history;</string>
   <string name="pref_clear_history_confirm">&pref_clear_history_confirm;</string>
   <string name="pref_clear_private_data">&pref_clear_private_data;</string>
   <string name="pref_clear_private_data_confirm">&pref_clear_private_data_confirm;</string>
 
   <string name="reload">&reload;</string>
+  <string name="forward">&forward;</string>
   <string name="new_tab">&new_tab;</string>
   <string name="addons">&addons;</string>
 </resources>