diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/base/BaseAppActivity.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/base/BaseAppActivity.kt index 0294cd30b1..2e979fe634 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/base/BaseAppActivity.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/base/BaseAppActivity.kt @@ -10,9 +10,13 @@ import com.google.android.gms.cast.framework.CastStateListener import org.edx.mobile.R import org.edx.mobile.googlecast.GoogleCastDelegate import org.edx.mobile.logger.Logger +import org.edx.mobile.util.Config +import javax.inject.Inject abstract class BaseAppActivity : AppCompatActivity(), CastStateListener { + @Inject + lateinit var config: Config private var googleCastDelegate: GoogleCastDelegate? = null private var mediaRouteMenuItem: MenuItem? = null private val logger = Logger( @@ -22,11 +26,13 @@ abstract class BaseAppActivity : AppCompatActivity(), CastStateListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - googleCastDelegate = GoogleCastDelegate.getInstance( - MainApplication.getEnvironment(this) - .analyticsRegistry - ) - googleCastDelegate?.addCastStateListener(this) + if (config.isChromeCastEnabled) { + googleCastDelegate = GoogleCastDelegate.getInstance( + MainApplication.getEnvironment(this) + .analyticsRegistry + ) + googleCastDelegate?.addCastStateListener(this) + } } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -83,7 +89,7 @@ abstract class BaseAppActivity : AppCompatActivity(), CastStateListener { * as part of the Jira story: https://openedx.atlassian.net/browse/LEARNER-7722 */ try { - if (isInForeground) { + if (config.isChromeCastEnabled && isInForeground) { if (mediaRouteMenuItem != null) { googleCastDelegate?.showIntroductoryOverlay(this, mediaRouteMenuItem) } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/player/PlayerFragment.java b/OpenEdXMobile/src/main/java/org/edx/mobile/player/PlayerFragment.java index c9bea32fce..0ea8d5bb58 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/player/PlayerFragment.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/player/PlayerFragment.java @@ -182,7 +182,9 @@ public void setPlayWhenReady(boolean playWhenReady) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - googleCastDelegate = GoogleCastDelegate.getInstance(environment.getAnalyticsRegistry()); + if (environment.getConfig().isChromeCastEnabled()) { + googleCastDelegate = GoogleCastDelegate.getInstance(environment.getAnalyticsRegistry()); + } } @Override @@ -547,7 +549,7 @@ public synchronized void playOrPrepare(DownloadEntry video, TranscriptModel trMo final long seekTo = videoEntry.getLastPlayedOffset(); logger.debug("playing [seek=" + seekTo + "]: " + path); - if (googleCastDelegate.isConnected()) { + if (googleCastDelegate != null && googleCastDelegate.isConnected()) { playVideoOnRemoteDevice(lastSavedPosition, true); player.setUri(path, seekTo); } else if (prepareOnly) diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java b/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java index 83484bf70f..57e4ffe760 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java @@ -82,6 +82,7 @@ public class Config { private static final String COURSE_VIDEOS_ENABLED = "COURSE_VIDEOS_ENABLED"; private static final String DOWNLOAD_TO_SD_CARD_ENABLED = "DOWNLOAD_TO_SD_CARD_ENABLED"; private static final String ANNOUNCEMENTS_ENABLED = "ANNOUNCEMENTS_ENABLED"; + private static final String CHROMECAST_ENABLED = "CHROMECAST_ENABLED"; public static class DiscoveryConfig { @SerializedName("TYPE") @@ -629,6 +630,11 @@ public boolean isAnnouncementEnabled() { return getBoolean(ANNOUNCEMENTS_ENABLED, true); } + // locally defined flag to disable the chromecast + public boolean isChromeCastEnabled() { + return getBoolean(CHROMECAST_ENABLED, false); + } + public boolean isDownloadToSDCardEnabled() { return getBoolean(DOWNLOAD_TO_SD_CARD_ENABLED, false); } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/app_nav/CourseUnitNavigationActivity.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/app_nav/CourseUnitNavigationActivity.kt index a77a32144b..f8e9348989 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/app_nav/CourseUnitNavigationActivity.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/app_nav/CourseUnitNavigationActivity.kt @@ -653,7 +653,7 @@ class CourseUnitNavigationActivity : BaseFragmentActivity(), CourseUnitFragment. override fun showGoogleCastButton(): Boolean { val component = getCurrentComponent() - return if (component is VideoBlockModel) { + return if (config.isChromeCastEnabled && component is VideoBlockModel) { // Showing casting button only for native video block // Currently casting for youtube video isn't available VideoUtil.isCourseUnitVideo(environment, component)