зеркало из https://github.com/mozilla/gecko-dev.git
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.
This commit is contained in:
Родитель
4739274e82
Коммит
dea32173fe
|
@ -443,9 +443,11 @@ abstract public class GeckoApp
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -462,6 +464,9 @@ abstract public class GeckoApp
|
|||
bookmark.setTitle(R.string.bookmark_add);
|
||||
}
|
||||
|
||||
forward.setVisible(true);
|
||||
forward.setEnabled(tab.canDoForward());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -504,6 +509,9 @@ abstract public class GeckoApp
|
|||
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;
|
||||
|
@ -1542,6 +1550,15 @@ abstract public class GeckoApp
|
|||
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();
|
||||
|
|
|
@ -183,6 +183,10 @@ public class Tab {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean canDoForward() {
|
||||
return (mHistoryIndex + 1 < mHistory.size());
|
||||
}
|
||||
|
||||
public boolean doForward() {
|
||||
if (mHistoryIndex + 1 >= mHistory.size()) {
|
||||
return false;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<!ENTITY history_older_section "Older than 7 days">
|
||||
|
||||
<!ENTITY reload "Reload">
|
||||
<!ENTITY forward "Forward">
|
||||
|
||||
<!ENTITY new_tab "New Tab">
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<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"
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<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>
|
||||
|
|
Загрузка…
Ссылка в новой задаче