summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-06-29 02:24:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-06-29 02:24:44 +0000
commit7d0df8c1410d3c63f52c23c6001110981c3894ea (patch)
treebfbec5025c87d6e25b4221fa710930fb50b638a4
parentd0a0e7dd30e46c9cded4ae52fc6e7d684c43d3a1 (diff)
parent731a99925375e12a3eab3e4000be55e6fe1e7e96 (diff)
downloadMedia-7d0df8c1410d3c63f52c23c6001110981c3894ea.tar.gz
Merge "Replace single tab with text header" into pi-car-dev
-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 f438a57b..2cb96d7d 100644
--- a/src/com/android/car/media/MediaActivity.java
+++ b/src/com/android/car/media/MediaActivity.java
@@ -385,7 +385,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();
@@ -396,7 +396,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);
@@ -447,7 +447,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 2bd4e071..6acb1c91 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). */