Skip to content

Commit ff117cc

Browse files
author
Chris Bellew
committed
Don't show audio/subtitle stream selection row if there are no audio/subtitle streams for the playing media. Hide audio/subs button if no audio AND no subtitle streams. Show "Unknown" for title/language of a stream when both title and language are null.
1 parent 36c36d8 commit ff117cc

File tree

5 files changed

+55
-36
lines changed

5 files changed

+55
-36
lines changed

mobile/src/main/java/com/atomjack/vcfp/PlexSubscription.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public void unsubscribe(final boolean notify, final Runnable onFinish) {
361361
// if(listener == null)
362362
// return;
363363

364-
PlexHttpClient.unsubscribe(mClient, commandId, VoiceControlForPlexApplication.getInstance().prefs.getUUID(), listener.getString(R.string.app_name), new PlexHttpResponseHandler() {
364+
PlexHttpClient.unsubscribe(mClient, commandId, VoiceControlForPlexApplication.getInstance().prefs.getUUID(), VoiceControlForPlexApplication.getInstance().getString(R.string.app_name), new PlexHttpResponseHandler() {
365365
@Override
366366
public void onSuccess(PlexResponse response) {
367367
Logger.d("Unsubscribed");

mobile/src/main/java/com/atomjack/vcfp/activities/PlayerActivity.java

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -96,44 +96,54 @@ public void doMediaOptions(View v) {
9696
LayoutInflater inflater = getLayoutInflater();
9797
View layout = inflater.inflate(R.layout.media_options_dialog, null);
9898

99-
Spinner subtitlesSpinner = (Spinner)layout.findViewById(R.id.subtitlesSpinner);
100-
StreamAdapter subtitlesStreamAdapter = new StreamAdapter(this, android.R.layout.simple_spinner_dropdown_item, subtitleStreams);
101-
subtitlesSpinner.setAdapter(subtitlesStreamAdapter);
102-
subtitlesSpinner.setSelection(subtitleStreams.indexOf(nowPlayingMedia.getActiveStream(Stream.SUBTITLE)), false);
103-
104-
subtitlesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
105-
@Override
106-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
107-
Stream stream = subtitleStreams.get(position);
108-
if(!stream.isActive()) {
109-
mClient.setStream(stream);
110-
nowPlayingMedia.setActiveStream(stream);
99+
if(subtitleStreams.size() > 0) {
100+
Spinner subtitlesSpinner = (Spinner) layout.findViewById(R.id.subtitlesSpinner);
101+
StreamAdapter subtitlesStreamAdapter = new StreamAdapter(this, android.R.layout.simple_spinner_dropdown_item, subtitleStreams);
102+
subtitlesSpinner.setAdapter(subtitlesStreamAdapter);
103+
subtitlesSpinner.setSelection(subtitleStreams.indexOf(nowPlayingMedia.getActiveStream(Stream.SUBTITLE)), false);
104+
105+
subtitlesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
106+
@Override
107+
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
108+
Stream stream = subtitleStreams.get(position);
109+
if (!stream.isActive()) {
110+
mClient.setStream(stream);
111+
nowPlayingMedia.setActiveStream(stream);
112+
}
111113
}
112-
}
113114

114-
@Override
115-
public void onNothingSelected(AdapterView<?> parent) {
116-
}
117-
});
118-
Spinner audioSpinner = (Spinner)layout.findViewById(R.id.audioSpinner);
119-
StreamAdapter audioStreamAdapter = new StreamAdapter(this, android.R.layout.simple_spinner_dropdown_item, audioStreams);
120-
audioSpinner.setAdapter(audioStreamAdapter);
121-
audioSpinner.setSelection(audioStreams.indexOf(nowPlayingMedia.getActiveStream(Stream.AUDIO)), false);
115+
@Override
116+
public void onNothingSelected(AdapterView<?> parent) {
117+
}
118+
});
119+
} else {
120+
layout.findViewById(R.id.subtitlesRow).setVisibility(View.GONE);
121+
}
122122

123-
audioSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
124-
@Override
125-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
126-
Stream stream = audioStreams.get(position);
127-
if(!stream.isActive()) {
128-
mClient.setStream(stream);
129-
nowPlayingMedia.setActiveStream(stream);
123+
if(audioStreams.size() > 0) {
124+
Spinner audioSpinner = (Spinner) layout.findViewById(R.id.audioSpinner);
125+
StreamAdapter audioStreamAdapter = new StreamAdapter(this, android.R.layout.simple_spinner_dropdown_item, audioStreams);
126+
audioSpinner.setAdapter(audioStreamAdapter);
127+
audioSpinner.setSelection(audioStreams.indexOf(nowPlayingMedia.getActiveStream(Stream.AUDIO)), false);
128+
129+
audioSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
130+
@Override
131+
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
132+
Stream stream = audioStreams.get(position);
133+
if (!stream.isActive()) {
134+
mClient.setStream(stream);
135+
nowPlayingMedia.setActiveStream(stream);
136+
}
130137
}
131-
}
132138

133-
@Override
134-
public void onNothingSelected(AdapterView<?> parent) {
135-
}
136-
});
139+
@Override
140+
public void onNothingSelected(AdapterView<?> parent) {
141+
}
142+
});
143+
} else {
144+
// For some reason, no audio streams found, so hide the row
145+
layout.findViewById(R.id.audioRow).setVisibility(View.GONE);
146+
}
137147

138148
builder.setView(layout);
139149
builder.setTitle(getResources().getString(R.string.stream_selection));
@@ -256,6 +266,10 @@ public void showNowPlaying(boolean setView) {
256266
TextView nowPlayingOnClient = (TextView)findViewById(R.id.nowPlayingOnClient);
257267
nowPlayingOnClient.setText(getResources().getString(R.string.now_playing_on) + " " + mClient.name);
258268

269+
if(findViewById(R.id.mediaOptionsButton) != null && nowPlayingMedia.getStreams(Stream.SUBTITLE).size() == 0 && nowPlayingMedia.getStreams(Stream.AUDIO).size() == 0) {
270+
findViewById(R.id.mediaOptionsButton).setVisibility(View.GONE);
271+
}
272+
259273
Logger.d("[PlayerActivity] Setting thumb in showNowPlaying");
260274
setThumb();
261275
attachUIElements();

mobile/src/main/java/com/atomjack/vcfp/model/Stream.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public void setActive(boolean active) {
3535
}
3636

3737
public String getTitle() {
38-
return title != null ? title : language;
38+
if(title != null)
39+
return title;
40+
if(language != null)
41+
return language;
42+
return VoiceControlForPlexApplication.getInstance().getString(R.string.unknown);
3943
}
4044

4145
public static final int UNKNOWN = 0;

mobile/src/main/java/com/atomjack/vcfp/net/PlexHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public void onFailure(Throwable t) {
428428
}
429429

430430
public static void get(String baseHostname, String path, final PlexHttpResponseHandler responseHandler) {
431-
PlexHttpService service = getService(baseHostname, true);
431+
PlexHttpService service = getService(baseHostname);
432432
Call<PlexResponse> call = service.getPlexResponse(VoiceControlForPlexApplication.getInstance().prefs.getUUID(),
433433
path.replaceFirst("^/", ""));
434434
call.enqueue(new Callback<PlexResponse>() {

mobile/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,5 @@
157157
<string name="unauthorized_local_server_found_logged_out">I found one or more local servers but was denied access. Log in to Plex (via the Menu button) to attempt to access this server.</string>
158158
<string name="unauthorized_local_server_found_logged_in">I found one or more local servers but was denied access. Since you are already logged in to Plex, either log out and back in (in case your access token has changed), or verify your access to this server/servers.</string>
159159
<string name="stream_selection">Stream Selection</string>
160+
<string name="unknown">Unknown</string>
160161
</resources>

0 commit comments

Comments
 (0)