From 5fc5d313ff8e8df82ad1d3dbb774f6408fd1a8ef Mon Sep 17 00:00:00 2001 From: Mikhail Kulesh Date: Sat, 18 Jan 2020 17:42:59 +0100 Subject: [PATCH] #121 Show track menu in a modal dialog: implemented in v1.9 --- .../com/mkulesh/onpc/MonitorFragment.java | 14 +++++--- .../java/com/mkulesh/onpc/iscp/State.java | 10 ++++-- .../main/res/layout/monitor_fragment_land.xml | 35 ++++++++++++------- .../main/res/layout/monitor_fragment_port.xml | 35 ++++++++++++------- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/com/mkulesh/onpc/MonitorFragment.java b/app/src/main/java/com/mkulesh/onpc/MonitorFragment.java index 15f1c9e1..f073cf93 100644 --- a/app/src/main/java/com/mkulesh/onpc/MonitorFragment.java +++ b/app/src/main/java/com/mkulesh/onpc/MonitorFragment.java @@ -335,7 +335,7 @@ protected void updateStandbyView(@Nullable final State state, @NonNull final Has TextView track = rootView.findViewById(R.id.tv_track); track.setText(""); - track.setCompoundDrawables(null, null, null, null); + updateInputSource(R.drawable.media_item_unknown, false); ((TextView) rootView.findViewById(R.id.tv_album)).setText(""); ((TextView) rootView.findViewById(R.id.tv_artist)).setText(""); @@ -420,11 +420,8 @@ protected void updateActiveView(@NonNull final State state, @NonNull final HashS // service icon and track { final TextView track = rootView.findViewById(R.id.tv_track); - @DrawableRes int icon = state.getServiceIcon(); - final Drawable bg = Utils.getDrawable(activity, icon); - Utils.setDrawableColorAttr(activity, bg, android.R.attr.textColorSecondary); - track.setCompoundDrawablesWithIntrinsicBounds(bg, null, null, null); track.setText(state.getTrackInfo(activity)); + updateInputSource(state.getServiceIcon(), true); } // cover @@ -534,6 +531,13 @@ private void updatePresetButtons() setButtonsEnabled(fmDabButtons, true); } + private void updateInputSource(@DrawableRes int imageId, final boolean visible) + { + AppCompatImageButton btn = rootView.findViewById(R.id.btn_input_selector); + btn.setImageResource(imageId); + btn.setVisibility(visible? View.VISIBLE : View.GONE); + setButtonEnabled(btn, false); + } /* * Playback control diff --git a/app/src/main/java/com/mkulesh/onpc/iscp/State.java b/app/src/main/java/com/mkulesh/onpc/iscp/State.java index 1ebf0541..c3848d33 100644 --- a/app/src/main/java/com/mkulesh/onpc/iscp/State.java +++ b/app/src/main/java/com/mkulesh/onpc/iscp/State.java @@ -241,8 +241,7 @@ private boolean isPopupMode() public boolean isMenuMode() { - return uiType == ListTitleInfoMsg.UIType.MENU || - uiType == ListTitleInfoMsg.UIType.MENU_LIST; + return uiType == ListTitleInfoMsg.UIType.MENU; } @NonNull @@ -972,6 +971,11 @@ private boolean process(XmlListInfoMsg msg) { trackInfoFromList(mediaItems); } + if (uiType == ListTitleInfoMsg.UIType.MENU_LIST) + { + Logging.info(this, "received track menu list with " + mediaItems.size() + " items"); + trackMenuReceived = true; + } return true; } catch (Exception e) @@ -1077,7 +1081,7 @@ else if (isMenuMode()) mediaItems.add(nsMsg); if (mediaItems.size() == numberOfItems) { - Logging.info(this, "received track menu with " + numberOfItems + " items"); + Logging.info(this, "received track menu with " + mediaItems.size() + " items"); trackMenuReceived = true; } } diff --git a/app/src/main/res/layout/monitor_fragment_land.xml b/app/src/main/res/layout/monitor_fragment_land.xml index 7a8ecf56..b181fb0f 100644 --- a/app/src/main/res/layout/monitor_fragment_land.xml +++ b/app/src/main/res/layout/monitor_fragment_land.xml @@ -45,26 +45,24 @@ android:orientation="horizontal" android:gravity="center_vertical"> + + - - + + diff --git a/app/src/main/res/layout/monitor_fragment_port.xml b/app/src/main/res/layout/monitor_fragment_port.xml index bb7ba28d..ebcb582c 100644 --- a/app/src/main/res/layout/monitor_fragment_port.xml +++ b/app/src/main/res/layout/monitor_fragment_port.xml @@ -57,26 +57,24 @@ android:orientation="horizontal" android:gravity="center_vertical"> + + - - + +