Bug 1243558 - Insert metadata into db when the user takes a screenshot. r=sebastian draft
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 26 Feb 2016 17:34:50 -0800
changeset 335634 7521f7d902e9a70adfb49d0b4dfa2be4917c9287
parent 335633 cb04a2892490fd23b48f8b14d3b4c662e2e7e8a7
child 335635 393684f11e2d69f98f49eff9859e1ab21738979f
push id11839
push usermichael.l.comella@gmail.com
push dateTue, 01 Mar 2016 01:32:00 +0000
reviewerssebastian
bugs1243558
milestone47.0a1
Bug 1243558 - Insert metadata into db when the user takes a screenshot. r=sebastian MozReview-Commit-ID: Cx1I1Ie22kU
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- 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>