Bug 1243558 - Insert metadata into db when the user takes a screenshot. r=sebastian
MozReview-Commit-ID: Cx1I1Ie22kU
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -750,19 +750,30 @@ public class BrowserApp extends GeckoApp
public void onEnabledChanged(boolean enabled) {
setDynamicToolbarEnabled(enabled);
}
});
// Watch for screenshots while browser is in foreground.
mScreenshotObserver.setListener(getContext(), new ScreenshotObserver.OnScreenshotListener() {
@Override
- public void onScreenshotTaken(String data, String title) {
+ public void onScreenshotTaken(final String screenshotPath, final String title) {
// Treat screenshots as a sharing method.
Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.BUTTON, "screenshot");
+
+ final Tab selectedTab = Tabs.getInstance().getSelectedTab();
+ if (selectedTab == null) {
+ Log.w(LOGTAG, "Selected tab is null: could not page info to store screenshot.");
+ return;
+ }
+
+ getProfile().getDB().getUrlAnnotations().insertScreenshot(
+ getContentResolver(), selectedTab.getURL(), screenshotPath);
+ SnackbarHelper.showSnackbar(BrowserApp.this,
+ getResources().getString(R.string.screenshot_added_to_bookmarks), Snackbar.LENGTH_SHORT);
}
});
// Set the maximum bits-per-pixel the favicon system cares about.
IconDirectoryEntry.setMaxBPP(GeckoAppShell.getScreenDepth());
// The update service is enabled for RELEASE_BUILD, which includes the release and beta channels.
// However, no updates are served. Therefore, we don't trust the update service directly, and
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -63,16 +63,17 @@
<!ENTITY bookmark_added "Bookmark added">
<!-- Localization note (bookmark_already_added) : This string is
used as a label in a toast. It is the verb "to bookmark", not
the noun "a bookmark". -->
<!ENTITY bookmark_already_added "Already bookmarked">
<!ENTITY bookmark_removed "Bookmark removed">
<!ENTITY bookmark_updated "Bookmark updated">
<!ENTITY bookmark_options "Options">
+<!ENTITY screenshot_added_to_bookmarks "Screenshot added to bookmarks">
<!ENTITY history_today_section "Today">
<!ENTITY history_yesterday_section "Yesterday">
<!ENTITY history_week_section3 "Last 7 days">
<!ENTITY history_this_month_section "This month">
<!ENTITY history_older_section3 "Older than 6 months">
<!ENTITY go "Go">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -97,16 +97,17 @@
<string name="quit">&quit;</string>
<string name="bookmark">&bookmark;</string>
<string name="bookmark_remove">&bookmark_remove;</string>
<string name="bookmark_added">&bookmark_added;</string>
<string name="bookmark_already_added">&bookmark_already_added;</string>
<string name="bookmark_removed">&bookmark_removed;</string>
<string name="bookmark_updated">&bookmark_updated;</string>
<string name="bookmark_options">&bookmark_options;</string>
+ <string name="screenshot_added_to_bookmarks">&screenshot_added_to_bookmarks;</string>
<string name="history_today_section">&history_today_section;</string>
<string name="history_yesterday_section">&history_yesterday_section;</string>
<string name="history_week_section">&history_week_section3;</string>
<string name="history_this_month_section">&history_this_month_section;</string>
<string name="history_older_section">&history_older_section3;</string>
<string name="share">&share;</string>