Bug 1269051 - (WIP) Use switchboard to disable screenshots in bookmarks. r=margaret
MozReview-Commit-ID: 6TVjjFgIGVz
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -339,12 +339,9 @@ public class AppConstants {
//#endif
public static final boolean MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE =
//#ifdef MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE
true;
//#else
false;
//#endif
-
- // (bug 1266820) Temporarily disabled since no one is working on it.
- public static final boolean SCREENSHOTS_IN_BOOKMARKS_ENABLED = false;
}
--- a/mobile/android/base/java/org/mozilla/gecko/ScreenshotDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ScreenshotDelegate.java
@@ -1,19 +1,22 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.util.Log;
+import com.keepsafe.switchboard.SwitchBoard;
+import org.mozilla.gecko.util.Experiments;
import java.lang.ref.WeakReference;
/**
* Delegate for observing screenshots being taken.
*/
public class ScreenshotDelegate extends BrowserAppDelegate implements ScreenshotObserver.OnScreenshotListener {
private static final String LOGTAG = "GeckoScreenshotDelegate";
@@ -28,31 +31,31 @@ public class ScreenshotDelegate extends
mScreenshotObserver.setListener(browserApp, this);
}
@Override
public void onScreenshotTaken(String screenshotPath, String title) {
// Treat screenshots as a sharing method.
Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.BUTTON, "screenshot");
- if (!AppConstants.SCREENSHOTS_IN_BOOKMARKS_ENABLED) {
+ final Activity activity = activityReference.get();
+ if (activity == null) {
+ return;
+ }
+
+ if (!SwitchBoard.isInExperiment(activity, Experiments.SCREENSHOT_IN_BOOKMARKS)) {
return;
}
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
if (selectedTab == null) {
Log.w(LOGTAG, "Selected tab is null: could not page info to store screenshot.");
return;
}
- final Activity activity = activityReference.get();
- if (activity == null) {
- return;
- }
-
GeckoProfile.get(activity).getDB().getUrlAnnotations().insertScreenshot(
activity.getContentResolver(), selectedTab.getURL(), screenshotPath);
SnackbarHelper.showSnackbar(activity,
activity.getResources().getString(R.string.screenshot_added_to_bookmarks), Snackbar.LENGTH_SHORT);
}
@Override
--- a/mobile/android/base/java/org/mozilla/gecko/util/Experiments.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/Experiments.java
@@ -40,16 +40,19 @@ public class Experiments {
public static final String ONBOARDING2_C = "onboarding2-c"; // 4 static + 1 clickable (Data saving) Feature slides
// Synchronizing the catalog of downloadable content from Kinto
public static final String DOWNLOAD_CONTENT_CATALOG_SYNC = "download-content-catalog-sync";
// Promotion for "Add to homescreen"
public static final String PROMOTE_ADD_TO_HOMESCREEN = "promote-add-to-homescreen";
+ // Show screenshots smart folder in bookmarks home panel.
+ public static final String SCREENSHOT_IN_BOOKMARKS = "screenshot-in-bookmarks";
+
public static final String PREF_ONBOARDING_VERSION = "onboarding_version";
private static volatile Boolean disabled = null;
/**
* Determines whether Switchboard is disabled by the MOZ_DISABLE_SWITCHBOARD
* environment variable. We need to read this value from the intent string
* extra because environment variables from our test harness aren't set