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

chore: Update ChromeCast for AppNav #1839

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions OpenEdXMobile/res/layout/course_dashboard_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@
android:textAppearance="@style/CourseDashboardCollapsedToolbarTitle"
tools:text="The Science of Happiness " />

<androidx.mediarouter.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:mediaRouteTypes="user"
android:visibility="gone"
app:mediaRouteButtonTint="@color/neutralWhiteT" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/collapsed_toolbar_dismiss"
android:layout_width="@dimen/widget_margin_double"
Expand Down
6 changes: 6 additions & 0 deletions OpenEdXMobile/res/layout/player_controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
android:textStyle="bold"
tools:text="02:05" />

<androidx.mediarouter.app.MediaRouteButton
android:id="@+id/media_route_button"
style="@style/video_player_bottom_control"
android:mediaRouteTypes="user"
app:mediaRouteButtonTint="@color/white" />

<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/settings"
style="@style/video_player_bottom_control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

import androidx.appcompat.widget.AppCompatImageButton;
import androidx.core.content.ContextCompat;
import androidx.mediarouter.app.MediaRouteButton;

import com.google.android.gms.cast.framework.CastButtonFactory;

import org.edx.mobile.R;
import org.edx.mobile.logger.Logger;
Expand Down Expand Up @@ -108,6 +111,7 @@ public class PlayerController extends FrameLayout {
private AppCompatImageButton mForwardButton;
private AppCompatImageButton mFullscreenButton;
private AppCompatImageButton mSettingsButton;
private MediaRouteButton mMediaRouteButton;
private Handler mHandler = new MessageHandler(this);
private String mTitle;
private TextView mTitleTextView;
Expand Down Expand Up @@ -243,6 +247,10 @@ private void initControllerView(View v) {
mSettingsButton.setOnClickListener(mSettingsListener);
}

mMediaRouteButton = v.findViewById(R.id.media_route_button);
mMediaRouteButton.setVisibility(VISIBLE);
CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), mMediaRouteButton);

mEndTime = (TextView) v.findViewById(R.id.time);
mCurrentTime = (TextView) v.findViewById(R.id.time_current);
mFormatBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public boolean isAnnouncementEnabled() {

// locally defined flag to disable the chromecast
public boolean isChromeCastEnabled() {
return getBoolean(CHROMECAST_ENABLED, false);
return getBoolean(CHROMECAST_ENABLED, true);
}

public boolean isDownloadToSDCardEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.fragment.app.viewModels
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
import com.android.billingclient.api.ProductDetails
import com.facebook.shimmer.ShimmerFrameLayout
import com.google.android.gms.cast.framework.CastButtonFactory
import com.google.android.gms.cast.framework.CastState
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.google.android.material.tabs.TabLayoutMediator
Expand All @@ -37,6 +39,7 @@ import org.edx.mobile.extenstion.serializable
import org.edx.mobile.extenstion.serializableOrThrow
import org.edx.mobile.extenstion.setTitleStateListener
import org.edx.mobile.extenstion.setVisibility
import org.edx.mobile.googlecast.GoogleCastDelegate
import org.edx.mobile.http.HttpStatus
import org.edx.mobile.http.HttpStatusException
import org.edx.mobile.http.notifications.SnackbarErrorNotification
Expand Down Expand Up @@ -109,6 +112,7 @@ class CourseTabsDashboardFragment : BaseFragment() {

private lateinit var binding: FragmentCourseTabsDashboardBinding
private lateinit var courseData: EnrolledCoursesResponse
private lateinit var googleCastDelegate: GoogleCastDelegate

private val iapViewModel: InAppPurchasesViewModel by viewModels()
private val courseDateViewModel: CourseDateViewModel by viewModels()
Expand Down Expand Up @@ -171,6 +175,7 @@ class CourseTabsDashboardFragment : BaseFragment() {
courseData =
arguments?.serializableOrThrow(Router.EXTRA_COURSE_DATA) as EnrolledCoursesResponse
courseTabItems = getCourseTabItems()
googleCastDelegate = GoogleCastDelegate.getInstance(analyticsRegistry)
HamzaIsrar12 marked this conversation as resolved.
Show resolved Hide resolved

setHasOptionsMenu(courseData.course.coursewareAccess.hasAccess())

Expand Down Expand Up @@ -529,6 +534,15 @@ class CourseTabsDashboardFragment : BaseFragment() {
courseTitle.text = courseData.course.name
tabs.setVisibility(hasAccess)

if (environment.config.isChromeCastEnabled) {
mediaRouteButton.setVisibility(googleCastDelegate.isConnected)
CastButtonFactory.setUpMediaRouteButton(requireContext(), mediaRouteButton)

googleCastDelegate.addCastStateListener { state ->
mediaRouteButton.setVisibility(state == CastState.CONNECTED)
}
}

val expiryDate = CourseCardUtils.getFormattedDate(requireContext(), courseData)
if (!expiryDate.isNullOrEmpty()) {
courseExpiryDate.apply {
Expand Down
Loading