diff options
-rw-r--r-- | AndroidManifest.xml | 10 | ||||
-rw-r--r-- | res/layout/fragment_playback.xml | 37 | ||||
-rw-r--r-- | res/values/id.xml | 1 | ||||
-rw-r--r-- | res/values/integers.xml | 4 | ||||
-rw-r--r-- | src/com/android/car/media/BrowseFragment.java | 5 | ||||
-rw-r--r-- | src/com/android/car/media/PlaybackFragment.java | 13 |
6 files changed, 44 insertions, 26 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ec30449..1149059 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -16,6 +16,7 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="com.android.car.media"> <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"/> @@ -43,6 +44,7 @@ <!-- The Media center entry point that trampolines into MediaActivity or the radio app. --> <activity android:name=".MediaDispatcherActivity" + android:theme="@android:style/Theme.NoDisplay" android:launchMode="singleTask"> <meta-data android:name="distractionOptimized" android:value="true"/> <intent-filter> @@ -61,5 +63,13 @@ <action android:name="com.android.car.media.MEDIA_CONNECTION"/> </intent-filter> </service> + + <!-- Workaround for b/113294940 --> + <provider + android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer" + tools:replace="android:authorities" + android:authorities="${applicationId}.lifecycle" + android:exported="false" + android:multiprocess="true" /> </application> </manifest> diff --git a/res/layout/fragment_playback.xml b/res/layout/fragment_playback.xml index da935d3..511574e 100644 --- a/res/layout/fragment_playback.xml +++ b/res/layout/fragment_playback.xml @@ -111,27 +111,36 @@ app:layout_constraintTop_toBottomOf="@id/app_bar_guideline" app:layout_constraintBottom_toTopOf="@+id/control_bar_first_row_guideline"/> - <SeekBar + <!-- @id/seek_bar should be hidden when @id/control_bar_scrim is expanded, and shown when the + scrim is collapsed. Since its visibility is also controlled by MetadataController, it could + become visible again even if the scrim is still expanded. To solve that we add a wrapper around + it and hide/show the wrapper when the scrim is expanded/collapsed.--> + <FrameLayout style="@style/SeekBarStyle" - android:id="@+id/seek_bar" + android:id="@+id/seek_bar_container" android:layout_gravity="center" - android:clickable="false" - android:focusable="false" android:layout_marginStart="@dimen/playback_seekbar_margin_x" android:layout_marginEnd="@dimen/playback_seekbar_margin_x" - android:paddingEnd="@dimen/playback_seekbar_padding_x" - android:paddingStart="@dimen/playback_seekbar_padding_x" - android:progressDrawable="@drawable/seekbar_background" - android:thumb="@drawable/seekbar_thumb" - android:thumbOffset="@dimen/playback_seekbar_thumb_offset" - android:splitTrack="false" - android:progressTint="@color/progress_bar_highlight" - android:progressBackgroundTint="@color/progress_bar_background" - android:background="@null" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/metadata_container" - app:layout_constraintBottom_toTopOf="@+id/control_bar_first_row_guideline"/> + app:layout_constraintBottom_toTopOf="@+id/control_bar_first_row_guideline"> + <SeekBar + android:id="@+id/seek_bar" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clickable="false" + android:focusable="false" + android:paddingEnd="@dimen/playback_seekbar_padding_x" + android:paddingStart="@dimen/playback_seekbar_padding_x" + android:progressDrawable="@drawable/seekbar_background" + android:thumb="@drawable/seekbar_thumb" + android:thumbOffset="@dimen/playback_seekbar_thumb_offset" + android:splitTrack="false" + android:progressTint="@color/progress_bar_highlight" + android:progressBackgroundTint="@color/progress_bar_background" + android:background="@null"/> + </FrameLayout> <Space android:id="@+id/queue_list_top_constraint" diff --git a/res/values/id.xml b/res/values/id.xml index ae86f45..8f60cc7 100644 --- a/res/values/id.xml +++ b/res/values/id.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <item type="id" name="imageDownloadTask"/> + <item type="id" name="seek_bar_container"/> </resources> diff --git a/res/values/integers.xml b/res/values/integers.xml index cd87eea..79f53ab 100644 --- a/res/values/integers.xml +++ b/res/values/integers.xml @@ -41,13 +41,13 @@ <!-- Views to hide when opening the custom actions when the queue isn't visible. --> <integer-array name="playback_views_to_hide_when_showing_custom_actions"> - <item>@id/seek_bar</item> + <item>@id/seek_bar_container</item> </integer-array> <!-- Views to hide when the queue is visible (to show when the queue becomes invisible). --> <integer-array name="playback_views_to_hide_when_queue_is_visible"> <item>@id/metadata_container</item> - <item>@id/seek_bar</item> + <item>@id/seek_bar_container</item> </integer-array> <!-- Views to show when the queue is visible (to hide when the queue becomes invisible). --> diff --git a/src/com/android/car/media/BrowseFragment.java b/src/com/android/car/media/BrowseFragment.java index 488dab4..835e18b 100644 --- a/src/com/android/car/media/BrowseFragment.java +++ b/src/com/android/car/media/BrowseFragment.java @@ -51,6 +51,7 @@ import com.android.car.media.common.source.MediaSourceViewModel; import java.util.ArrayList; import java.util.List; import java.util.Stack; +import java.util.stream.Collectors; /** * A {@link Fragment} that implements the content forward browsing experience. @@ -274,6 +275,10 @@ public class BrowseFragment extends Fragment { } stopLoadingIndicator(); List<MediaItemMetadata> items = futureData.getData(); + if (items != null) { + items = items.stream().filter(item -> + (item.isPlayable() || item.isBrowsable())).collect(Collectors.toList()); + } mBrowseAdapter.submitItems(getCurrentMediaItem(), items); if (items == null) { mMessage.setText(R.string.unknown_error); diff --git a/src/com/android/car/media/PlaybackFragment.java b/src/com/android/car/media/PlaybackFragment.java index 75efde2..35f023d 100644 --- a/src/com/android/car/media/PlaybackFragment.java +++ b/src/com/android/car/media/PlaybackFragment.java @@ -71,6 +71,7 @@ public class PlaybackFragment extends Fragment { private PlaybackControlsActionBar mPlaybackControls; private QueueItemsAdapter mQueueAdapter; private RecyclerView mQueue; + private ViewGroup mSeekBarContainer; private SeekBar mSeekBar; private View mQueueButton; private ViewGroup mNavIconContainer; @@ -286,6 +287,7 @@ public class PlaybackFragment extends Fragment { View view = inflater.inflate(R.layout.fragment_playback, container, false); mAlbumBackground = view.findViewById(R.id.playback_background); mQueue = view.findViewById(R.id.queue_list); + mSeekBarContainer = view.findViewById(R.id.seek_bar_container); mSeekBar = view.findViewById(R.id.seek_bar); mQueueButton = view.findViewById(R.id.queue_button); mQueueButton.setOnClickListener(button -> toggleQueueVisibility()); @@ -346,7 +348,7 @@ public class PlaybackFragment extends Fragment { // Don't update the visibility of seekBar if show_linear_progress_bar is false. ViewUtils.Filter ignoreSeekBarFilter = - (viewToFilter) -> mShowLinearProgressBar || viewToFilter != mSeekBar; + (viewToFilter) -> mShowLinearProgressBar || viewToFilter != mSeekBarContainer; mViewsToHideForCustomActions = ViewUtils.getViewsById(view, res, R.array.playback_views_to_hide_when_showing_custom_actions, ignoreSeekBarFilter); @@ -394,18 +396,10 @@ public class PlaybackFragment extends Fragment { } if (expanding) { - ViewUtils.showViewAnimated(mControlBarScrim, millis); - if (mShowLinearProgressBar) { - ViewUtils.hideViewAnimated(mSeekBar, millis); - } if (mControlBarScrim != null) { ViewUtils.showViewAnimated(mControlBarScrim, millis); } } else { - ViewUtils.hideViewAnimated(mControlBarScrim, millis); - if (mShowLinearProgressBar) { - ViewUtils.showViewAnimated(mSeekBar, millis); - } if (mControlBarScrim != null) { ViewUtils.hideViewAnimated(mControlBarScrim, millis); } @@ -501,7 +495,6 @@ public class PlaybackFragment extends Fragment { mQueueButton.setActivated(mQueueIsVisible); mQueueButton.setSelected(mQueueIsVisible); if (mQueueIsVisible) { - ViewUtils.showViewsAnimated(mViewsToShowWhenQueueIsVisible, mFadeDuration); ViewUtils.hideViewsAnimated(mViewsToHideWhenQueueIsVisible, mFadeDuration); ViewUtils.setVisible(mViewsToShowImmediatelyWhenQueueIsVisible, true); |