diff options
author | John Reck <jreck@google.com> | 2011-02-28 15:47:47 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-02-28 18:10:14 -0800 |
commit | 51d8baddb85b04bf870843399cb40f8713303671 (patch) | |
tree | c879db4666ce89b2545976d4898b4fa8bacb5526 | |
parent | a9496e1ab66fda87ea406f31d5ec4a213e0b6307 (diff) | |
download | packages_apps_Browser-51d8baddb85b04bf870843399cb40f8713303671.zip packages_apps_Browser-51d8baddb85b04bf870843399cb40f8713303671.tar.gz packages_apps_Browser-51d8baddb85b04bf870843399cb40f8713303671.tar.bz2 |
Change "Save Web Archive" to "Save Page"
Bug: 3492152
If WebView fails to save the page as a web archive (which will
happen if the page is not an (X)HTML document), instead of
showing a failure toast we fall back to downloading the URL through
download manager.
Also changes the string "Save Web Archive" to "Save Page" and moves
the menu option to be after "Share page".
Change-Id: Ia4219075ae2585df865b58fa75ad24357150824f
-rw-r--r-- | res/menu-xlarge/browser.xml | 4 | ||||
-rw-r--r-- | res/menu/browser.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 12 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 11 |
4 files changed, 17 insertions, 14 deletions
diff --git a/res/menu-xlarge/browser.xml b/res/menu-xlarge/browser.xml index a791cdd..be4a521 100644 --- a/res/menu-xlarge/browser.xml +++ b/res/menu-xlarge/browser.xml @@ -32,6 +32,8 @@ android:title="@string/share_page" android:icon="@drawable/ic_share_holo_dark" android:alphabeticShortcut="s" /> + <item android:id="@+id/save_webarchive_menu_id" + android:title="@string/menu_save_webarchive" /> <item android:id="@+id/page_info_menu_id" android:title="@string/page_info" android:icon="@drawable/ic_pageinfo_holo_dark" @@ -44,8 +46,6 @@ android:title="@string/menu_preferences" android:icon="@drawable/ic_settings_holo_dark" android:alphabeticShortcut="p" /> - <item android:id="@+id/save_webarchive_menu_id" - android:title="@string/menu_save_webarchive" /> <!-- followings are debug only --> <item android:id="@+id/dump_nav_menu_id" android:title="@string/dump_nav" diff --git a/res/menu/browser.xml b/res/menu/browser.xml index 7a59ffd..abe3716 100644 --- a/res/menu/browser.xml +++ b/res/menu/browser.xml @@ -45,6 +45,8 @@ android:title="@string/share_page" android:icon="@drawable/ic_share_holo_dark" android:alphabeticShortcut="s" /> + <item android:id="@+id/save_webarchive_menu_id" + android:title="@string/menu_save_webarchive" /> <item android:id="@+id/page_info_menu_id" android:title="@string/page_info" android:icon="@drawable/ic_pageinfo_holo_dark" @@ -57,8 +59,6 @@ android:title="@string/menu_preferences" android:icon="@drawable/ic_settings_holo_dark" android:alphabeticShortcut="p" /> - <item android:id="@+id/save_webarchive_menu_id" - android:title="@string/menu_save_webarchive" /> <!-- followings are debug only --> <item android:id="@+id/dump_nav_menu_id" android:title="@string/dump_nav" diff --git a/res/values/strings.xml b/res/values/strings.xml index 8005e14..0aeffca 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -235,12 +235,12 @@ <string name="copy_page_url">Copy page url</string> <!-- Menu item --> <string name="share_page">Share page</string> - <!-- Menu item for saving a page as a web archive. --> - <string name="menu_save_webarchive">Save as Web Archive</string> - <!-- Toast informing the user that the page has been saved. --> - <string name="webarchive_saved">Web archive saved.</string> - <!-- Toast informing the user that saving the page has failed. --> - <string name="webarchive_failed">Failed to save web archive.</string> + <!-- Menu item for saving a page. [CHAR LIMIT=30] --> + <string name="menu_save_webarchive">Save page</string> + <!-- Toast informing the user that the page has been saved. [CHAR LIMIT=50] --> + <string name="webarchive_saved">Page saved.</string> + <!-- Toast informing the user that saving the page has failed. [CHAR LIMIT=50] --> + <string name="webarchive_failed">Failed to save page.</string> <!-- The number of bookmarks in a folder [CHAR LIMT=50] --> <string name="contextheader_folder_bookmarkcount"><xliff:g id="bookmark_count">%d</xliff:g> bookmarks</string> <!-- No bookmarks in the folder [CHAR LIMIT=50] --> diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index c1f1313..fd966de 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -1468,8 +1468,10 @@ public class Controller newtab.setEnabled(getTabControl().canCreateNewTab()); MenuItem archive = menu.findItem(R.id.save_webarchive_menu_id); - String url = w != null ? w.getUrl() : null; - archive.setVisible(url != null && !url.endsWith(".webarchivexml")); + Tab tab = getTabControl().getCurrentTab(); + String url = tab != null ? tab.getUrl() : null; + archive.setVisible(!TextUtils.isEmpty(url) + && !url.endsWith(".webarchivexml")); break; } mCurrentMenuState = mMenuState; @@ -1591,6 +1593,7 @@ public class Controller } WebView topWebView = getCurrentTopWebView(); final String title = topWebView.getTitle(); + final String url = topWebView.getUrl(); topWebView.saveWebArchive(directory, true, new ValueCallback<String>() { @Override @@ -1614,8 +1617,8 @@ public class Controller return; } } - Toast.makeText(mActivity, - R.string.webarchive_failed, Toast.LENGTH_SHORT).show(); + DownloadHandler.onDownloadStartNoStream(mActivity, + url, null, null, null); } }); break; |