Skip to content

Commit

Permalink
mkulesh#121 Show track menu in a modal dialog: implemented in v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mkulesh committed Jan 18, 2020
1 parent c06d44b commit 5fc5d31
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 32 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/com/mkulesh/onpc/MonitorFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/mkulesh/onpc/iscp/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}
Expand Down
35 changes: 23 additions & 12 deletions app/src/main/res/layout/monitor_fragment_land.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,24 @@
android:orientation="horizontal"
android:gravity="center_vertical">

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_input_selector"
android:src="@drawable/media_item_unknown" />

<TextView
android:id="@+id/tv_track"
style="@style/SecondaryTextViewStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="2"
android:gravity="left" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_track_menu"
android:src="@drawable/cmd_track_menu"
android:contentDescription="@string/cmd_track_menu"
android:visibility="invisible"
android:tag="MENU" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -95,8 +93,21 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="2"
android:gravity="right" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_track_menu"
android:src="@drawable/cmd_track_menu"
android:contentDescription="@string/cmd_track_menu"
android:visibility="invisible"
android:tag="MENU" />

</LinearLayout>


Expand Down
35 changes: 23 additions & 12 deletions app/src/main/res/layout/monitor_fragment_port.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,24 @@
android:orientation="horizontal"
android:gravity="center_vertical">

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_input_selector"
android:src="@drawable/media_item_unknown" />

<TextView
android:id="@+id/tv_track"
style="@style/SecondaryTextViewStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="2"
android:gravity="left" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_track_menu"
android:src="@drawable/cmd_track_menu"
android:contentDescription="@string/cmd_track_menu"
android:visibility="invisible"
android:tag="MENU" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -107,8 +105,21 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="2"
android:gravity="right" />

<androidx.appcompat.widget.AppCompatImageButton
style="@style/ImageButtonSecondaryStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/button_margin_horizontal"
android:paddingRight="@dimen/button_margin_horizontal"
android:id="@+id/btn_track_menu"
android:src="@drawable/cmd_track_menu"
android:contentDescription="@string/cmd_track_menu"
android:visibility="invisible"
android:tag="MENU" />

</LinearLayout>

<LinearLayout
Expand Down

0 comments on commit 5fc5d31

Please sign in to comment.