Bug 1357356 - Open aurora transition page once user upgrade from aurora to nightly, r=sebastian
MozReview-Commit-ID: HEV06stuwm5
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -19,16 +19,17 @@ import org.mozilla.gecko.annotation.Robo
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.DynamicToolbar.VisibilityTransition;
import org.mozilla.gecko.Tabs.TabEvents;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.bookmarks.BookmarkEditFragment;
import org.mozilla.gecko.bookmarks.BookmarkUtils;
import org.mozilla.gecko.bookmarks.EditBookmarkTask;
import org.mozilla.gecko.cleanup.FileCleanupController;
+import org.mozilla.gecko.dawn.DawnHelper;
import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.SuggestedSites;
import org.mozilla.gecko.delegates.BrowserAppDelegate;
import org.mozilla.gecko.delegates.OfflineTabStatusDelegate;
import org.mozilla.gecko.delegates.ScreenshotDelegate;
import org.mozilla.gecko.distribution.Distribution;
import org.mozilla.gecko.distribution.DistributionStoreCallback;
@@ -1085,16 +1086,18 @@ public class BrowserApp extends GeckoApp
super.onBackPressed();
}
@Override
public void onAttachedToWindow() {
// We can't show the first run experience until Gecko has finished initialization (bug 1077583).
checkFirstrun(this, new SafeIntent(getIntent()));
+
+ DawnHelper.conditionallyNotifyDawn(this);
}
@Override
protected void processTabQueue() {
if (TabQueueHelper.TAB_QUEUE_ENABLED && mInitialized) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/dawn/DawnHelper.java
@@ -0,0 +1,70 @@
+/* -*- 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.dawn;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.annotation.NonNull;
+
+import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.GeckoSharedPrefs;
+import org.mozilla.gecko.Locales;
+import org.mozilla.gecko.R;
+import org.mozilla.gecko.Tabs;
+
+import java.util.Locale;
+
+/**
+ * This helper class is specific for the termination of aurora release train, a.k.a. Project Dawn.
+ * ( https://hacks.mozilla.org/2017/04/simplifying-firefox-release-channels/ )
+ * We want to keep current aurora user transit to use nightly codebase with aurora package name on
+ * Google play. The purpose is similar to org.mozilla.gecko.notifications.WhatsNewReceiver and org.mozilla.gecko.BrowserApp#conditionallyNotifyEOL.
+ * TODO: Make this more generic and able to on/off from Switchboard.
+ */
+public class DawnHelper {
+
+ private static final String ANDROID_PACKAGE_NAME = AppConstants.ANDROID_PACKAGE_NAME;
+ private static final String ANDROID_PACKAGE_NAME_NIGHTLY_NEW = "org.mozilla.fennec_aurora";
+
+ private static final String KEY_PERF_BOOLEAN_NOTIFY_DAWN_ENABLED = "key-pref-boolean-notify-dawn-enabled";
+ private static final String TARGET_APP_VERSION = "55";
+
+
+ private static boolean isAuroraNightly() {
+ return ANDROID_PACKAGE_NAME.equals(ANDROID_PACKAGE_NAME_NIGHTLY_NEW);
+ }
+
+ private static boolean isTransitionRelease() {
+ return AppConstants.MOZ_APP_VERSION.startsWith(TARGET_APP_VERSION);
+ }
+
+ public static boolean conditionallyNotifyDawn(@NonNull Context context) {
+ if (!isAuroraNightly()) {
+ return false;
+ }
+
+ if (!isTransitionRelease()) {
+ return false;
+ }
+
+ final SharedPreferences prefs = GeckoSharedPrefs.forProfile(context);
+ if (!prefs.getBoolean(KEY_PERF_BOOLEAN_NOTIFY_DAWN_ENABLED, true)) {
+ return false;
+ } else {
+ prefs.edit().putBoolean(KEY_PERF_BOOLEAN_NOTIFY_DAWN_ENABLED, false).apply();
+ }
+
+ final String link = context.getString(R.string.aurora_transition_notification_url,
+ AppConstants.MOZ_APP_VERSION,
+ AppConstants.OS_TARGET,
+ Locales.getLanguageTag(Locale.getDefault()));
+
+ Tabs.getInstance().loadUrl(link, Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED);
+
+ return true;
+ }
+
+}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -518,16 +518,17 @@ gbjar.sources += ['java/org/mozilla/geck
'cleanup/FileCleanupController.java',
'cleanup/FileCleanupService.java',
'CustomEditText.java',
'customtabs/ActionBarPresenter.java',
'customtabs/CustomTabsActivity.java',
'customtabs/GeckoCustomTabsService.java',
'customtabs/IntentUtil.java',
'DataReportingNotification.java',
+ 'dawn/DawnHelper.java',
'db/AbstractPerProfileDatabaseProvider.java',
'db/AbstractTransactionalProvider.java',
'db/BaseTable.java',
'db/BrowserDatabaseHelper.java',
'db/BrowserDB.java',
'db/BrowserProvider.java',
'db/DBUtils.java',
'db/FormHistoryProvider.java',
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -614,16 +614,17 @@
<string name="eol_notification_summary">&eol_notification_summary;</string>
<!-- https://support.mozilla.org/1/mobile/%VERSION%/%OS%/%LOCALE%/honeycomb -->
<string name="eol_notification_url">https://support.mozilla.org/1/mobile/&formatS1;/&formatS2;/&formatS3;/unsupported-version</string>
<string name="whatsnew_notification_title">&whatsnew_notification_title;</string>
<string name="whatsnew_notification_summary">&whatsnew_notification_summary;</string>
<!-- https://support.mozilla.org/1/mobile/%VERSION%/%OS%/%LOCALE%/new-android -->
<string name="whatsnew_notification_url">https://support.mozilla.org/1/mobile/&formatS1;/&formatS2;/&formatS3;/new-android</string>
+ <string name="aurora_transition_notification_url">https://support.mozilla.org/1/mobile/&formatS1;/&formatS2;/&formatS3;/aurora-transition</string>
<string name="promotion_add_to_homescreen">&promotion_add_to_homescreen;</string>
<string name="helper_first_offline_bookmark_title">&helper_first_offline_bookmark_title;</string>
<string name="helper_first_offline_bookmark_message">&helper_first_offline_bookmark_message;</string>
<string name="helper_first_offline_bookmark_button">&helper_first_offline_bookmark_button;</string>
<string name="helper_triple_readerview_open_title">&helper_triple_readerview_open_title;</string>