Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1341 from edx/farhan/LEARNER-7430
Browse files Browse the repository at this point in the history
Put "Upgrade to Verified" feature behind Firebase Remote Config
  • Loading branch information
Muhammad Farhan Khan committed Oct 18, 2019
2 parents 82f0884 + b13f7cb commit 514331d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 10 additions & 0 deletions OpenEdXMobile/src/main/java/org/edx/mobile/util/AppConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public enum AppConstants {
public static final String VIDEO_FORMAT_MP4 = ".mp4";
public static final String APP_URI_SCHEME = "org.edx.mobile.innerlinks://";

/**
* This class defines all the Firebase constants related to the app.
*/
public static final class FirebaseConstants {
/**
* Feature flag for course upgrade.
*/
public static final String REV_934_ENABLED = "REV_934_Enabled";
}

/**
* This class defines the names of various directories which are used for
* storing application data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.edx.mobile.services.EdxCookieManager;
import org.edx.mobile.services.LastAccessManager;
import org.edx.mobile.services.VideoDownloadHelper;
import org.edx.mobile.util.AppConstants;
import org.edx.mobile.util.NetworkUtil;
import org.edx.mobile.util.PermissionsUtil;
import org.edx.mobile.util.UiUtil;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void onRefresh() {
fetchCourseComponent();
// Track CourseOutline for A/A test
trackAATestCourseOutline();
fetchCourseUpgradeStatus();
getCourseUpgradeFirebaseConfig();
return view;
}

Expand Down Expand Up @@ -567,8 +568,24 @@ private void loadData(@NonNull CourseComponent courseComponent) {
fetchLastAccessed();
}

private void getCourseUpgradeFirebaseConfig() {
if (!isOnCourseOutline || isVideoMode || getCourseUpgradeStatus != null) {
return;
}
if (environment.getConfig().getFirebaseConfig().isEnabled()) {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.fetchAndActivate().addOnCompleteListener(task -> {
final boolean courseUpgradeEnabled = firebaseRemoteConfig
.getBoolean(AppConstants.FirebaseConstants.REV_934_ENABLED);
if (courseUpgradeEnabled) {
fetchCourseUpgradeStatus();
}
});
}
}

private void fetchCourseUpgradeStatus() {
if (isOnCourseOutline && !isVideoMode && getCourseUpgradeStatus == null) {
if (getCourseUpgradeStatus == null) {
getCourseUpgradeStatus = courseApi.getCourseUpgradeStatus(courseData.getCourse().getId());
getCourseUpgradeStatus.enqueue(new Callback<CourseUpgradeResponse>() {
@Override
Expand Down Expand Up @@ -635,7 +652,7 @@ private void setUpBulkDownloadHeader(CourseComponent courseComponent) {
public void onRevisit() {
super.onRevisit();
fetchLastAccessed();
fetchCourseUpgradeStatus();
getCourseUpgradeFirebaseConfig();
if (adapter != null) {
adapter.notifyDataSetChanged();
}
Expand Down

0 comments on commit 514331d

Please sign in to comment.