summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Dai <sdai@google.com>2019-05-30 17:38:02 -0700
committerSimon Dai <sdai@google.com>2019-06-27 16:23:17 -0700
commit731a99925375e12a3eab3e4000be55e6fe1e7e96 (patch)
tree2f327af47fa530ac6856174a6dc8b117707bb78c /src
parentd88227f823e859011ca158c1782150951592236c (diff)
downloadMedia-731a99925375e12a3eab3e4000be55e6fe1e7e96.tar.gz
Replace single tab with text header
Fixes: 131839088 Test: Manual Change-Id: If46c38be58e9d0e88d4c44b21839c5eadf8ade32
Diffstat (limited to 'src')
-rw-r--r--src/com/android/car/media/MediaActivity.java13
-rw-r--r--src/com/android/car/media/widgets/AppBarView.java9
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). */