Skip to content

Commit

Permalink
Bug 1357356 - Open aurora transition page once user upgrade from auro…
Browse files Browse the repository at this point in the history
…ra to nightly, r=sebastian

MozReview-Commit-ID: HEV06stuwm5
  • Loading branch information
mxlius committed Apr 20, 2017
1 parent 0f10247 commit 52ca217
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -1111,6 +1112,8 @@ public void onBackPressed() {
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
Expand Down
70 changes: 70 additions & 0 deletions mobile/android/base/java/org/mozilla/gecko/dawn/DawnHelper.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
1 change: 1 addition & 0 deletions mobile/android/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'customtabs/GeckoCustomTabsService.java',
'customtabs/IntentUtil.java',
'DataReportingNotification.java',
'dawn/DawnHelper.java',
'db/AbstractPerProfileDatabaseProvider.java',
'db/AbstractTransactionalProvider.java',
'db/BaseTable.java',
Expand Down
1 change: 1 addition & 0 deletions mobile/android/base/strings.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@
<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>

Expand Down

0 comments on commit 52ca217

Please sign in to comment.