From 731a99925375e12a3eab3e4000be55e6fe1e7e96 Mon Sep 17 00:00:00 2001 From: Simon Dai Date: Thu, 30 May 2019 17:38:02 -0700 Subject: Replace single tab with text header Fixes: 131839088 Test: Manual Change-Id: If46c38be58e9d0e88d4c44b21839c5eadf8ade32 --- src/com/android/car/media/MediaActivity.java | 13 ++++++++++--- src/com/android/car/media/widgets/AppBarView.java | 9 +++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/com/android/car/media/MediaActivity.java b/src/com/android/car/media/MediaActivity.java index 93ee016..9fae491 100644 --- a/src/com/android/car/media/MediaActivity.java +++ b/src/com/android/car/media/MediaActivity.java @@ -375,7 +375,7 @@ public class MediaActivity extends FragmentActivity implements BrowseFragment.Ca if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Browsing: " + mediaSource.getName()); } - mAppBarView.setMediaAppName(mediaSource.getName()); + mAppBarView.setMediaAppTitle(mediaSource.getName()); mAppBarView.setTitle(null); updateTabs(null); mSearchFragment.resetSearchState(); @@ -386,7 +386,7 @@ public class MediaActivity extends FragmentActivity implements BrowseFragment.Ca // Always go through the trampoline activity to keep all the dispatching logic there. startActivity(new Intent(Car.CAR_INTENT_ACTION_MEDIA_TEMPLATE)); } else { - mAppBarView.setMediaAppName(""); + mAppBarView.setMediaAppTitle(null); mAppBarView.setTitle(null); updateTabs(null); updateSourcePreferences(null); @@ -437,7 +437,14 @@ public class MediaActivity extends FragmentActivity implements BrowseFragment.Ca .filter(MediaItemMetadata::isBrowsable) .collect(Collectors.toList()); - mAppBarView.setItems(browsableTopLevel); + if (browsableTopLevel.size() == 1) { + // If there is only a single tab, use it as a header instead + mAppBarView.setMediaAppTitle(browsableTopLevel.get(0).getTitle()); + mAppBarView.setTitle(null); + mAppBarView.setItems(null); + } else { + mAppBarView.setItems(browsableTopLevel); + } showTopItem(browsableTopLevel.isEmpty() ? null : browsableTopLevel.get(0)); } diff --git a/src/com/android/car/media/widgets/AppBarView.java b/src/com/android/car/media/widgets/AppBarView.java index 2bd4e07..6acb1c9 100644 --- a/src/com/android/car/media/widgets/AppBarView.java +++ b/src/com/android/car/media/widgets/AppBarView.java @@ -246,11 +246,12 @@ public class AppBarView extends ConstraintLayout { /** * Sets the name of the currently displayed media app. This is used as the default title for - * playback and the root browse menu + * playback and the root browse menu. If provided title is null, will use default media center + * title. */ - public void setMediaAppName(CharSequence appName) { - mMediaAppTitle = appName == null ? getResources().getString(R.string.media_app_title) - : appName.toString(); + public void setMediaAppTitle(CharSequence appTitle) { + mMediaAppTitle = appTitle == null ? getResources().getString(R.string.media_app_title) + : appTitle.toString(); } /** Sets whether the source has settings (not all screens show it). */ -- cgit v1.2.3