Skip to content

Commit de86cec

Browse files
author
Chris Bellew
committed
Finish service if we didn't understand the query; Show some feedback when searching for stuff; Fixed some unchecked operations.
1 parent 3120dba commit de86cec

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Voice Control For Plex/src/main/java/com/atomjack/vcfp/PlexSearchService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ public int onStartCommand(Intent intent, int flags, int startId) {
108108
break;
109109
}
110110
}
111-
if(queryText == null)
111+
if(queryText == null) {
112112
feedback.e(getResources().getString(R.string.didnt_understand_that));
113+
return Service.START_NOT_STICKY;
114+
}
113115
} else {
114116
// Received spoken query from Google Search API
115117
Logger.d("Google Search API query");
@@ -186,7 +188,7 @@ private void startup() {
186188
Logger.d("Scan all was chosen");
187189

188190
// First, see if what needs to be done actually needs to know about the server (i.e. pause/stop/resume playback of offset).
189-
// If it does, execute the action and return as we don't need to do anything else. However, also check to see if the user
191+
// If it doesn't, execute the action and return as we don't need to do anything else. However, also check to see if the user
190192
// has specified a client (using " on <client name>") - if this is the case, we will need to find that client via server
191193
// discovery
192194
myRunnable actionToDo = handleVoiceSearch(true);
@@ -604,6 +606,7 @@ public void onFailure(Throwable error) {
604606

605607
private void doMovieSearch(final String queryTerm) {
606608
Logger.d("Doing movie search. %d servers", plexmediaServers.size());
609+
feedback.m(getString(R.string.searching_for), queryTerm);
607610
serversSearched = 0;
608611
for(final PlexServer server : plexmediaServers.values()) {
609612
server.movieSectionsSearched = 0;
@@ -787,6 +790,7 @@ private void showPlayingVideo(PlexVideo video) {
787790
}
788791

789792
private void doNextEpisodeSearch(final String queryTerm, final boolean fallback) {
793+
feedback.m(getString(R.string.searching_for), queryTerm);
790794
serversSearched = 0;
791795
for(final PlexServer server : plexmediaServers.values()) {
792796
server.showSectionsSearched = 0;
@@ -866,6 +870,7 @@ private void onFinishedNextEpisodeSearch(String queryTerm, boolean fallback) {
866870
}
867871

868872
private void doLatestEpisodeSearch(final String queryTerm) {
873+
feedback.m(getString(R.string.searching_for), queryTerm);
869874
Logger.d("doLatestEpisodeSearch: %s", queryTerm);
870875
serversSearched = 0;
871876
for(final PlexServer server : plexmediaServers.values()) {
@@ -968,6 +973,7 @@ public void onFailure(Throwable error) {
968973
}
969974

970975
private void doShowSearch(String episodeSpecified, final String showSpecified) {
976+
feedback.m(getString(R.string.searching_for_episode), showSpecified, episodeSpecified);
971977
serversSearched = 0;
972978
for(final PlexServer server : plexmediaServers.values()) {
973979
server.showSectionsSearched = 0;
@@ -1038,6 +1044,7 @@ private void playSpecificEpisode(String showSpecified) {
10381044
}
10391045

10401046
private void doShowSearch(final String queryTerm, final String season, final String episode) {
1047+
feedback.m(getString(R.string.searching_for_show_season_episode), queryTerm, season, episode);
10411048
Logger.d("doShowSearch: %s s%s e%s", queryTerm, season, episode);
10421049
serversSearched = 0;
10431050
for(final PlexServer server : plexmediaServers.values()) {
@@ -1160,6 +1167,7 @@ public void onFailure(Throwable error) {
11601167
}
11611168

11621169
private void searchForAlbum(final String artist, final String album) {
1170+
feedback.m(getString(R.string.searching_for_album), album, artist);
11631171
Logger.d("Searching for album %s by %s.", album, artist);
11641172
serversSearched = 0;
11651173
Logger.d("Servers: %d", plexmediaServers.size());
@@ -1231,6 +1239,7 @@ public void onFailure(Throwable error) {
12311239

12321240
private void searchForSong(final String artist, final String track) {
12331241
serversSearched = 0;
1242+
feedback.m(getString(R.string.searching_for_album), track, artist);
12341243
Logger.d("Servers: %d", plexmediaServers.size());
12351244
for(final PlexServer server : plexmediaServers.values()) {
12361245
server.musicSectionsSearched = 0;

Voice Control For Plex/src/main/java/com/atomjack/vcfp/model/Device.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.Arrays;
1010
import java.util.Date;
1111
import java.util.List;
12-
import java.util.Vector;
1312

1413
@Root(strict=false)
1514
public class Device {
@@ -29,7 +28,7 @@ public class Device {
2928
@ElementList(required=false, inline=true, entry="Connection")
3029
public List<Connection> connections = new ArrayList<Connection>();
3130

32-
public Vector<String> provides;
31+
public List<String> provides;
3332
public Date lastSeenDate;
3433
public boolean owned;
3534

@@ -43,8 +42,9 @@ public class Device {
4342
private int ownedInt;
4443

4544
@Commit
45+
@SuppressWarnings("unused")
4646
public void build() {
47-
provides = new Vector(Arrays.asList(providesStr.split(",")));
47+
provides = Arrays.asList(providesStr.split(","));
4848
lastSeenDate = new Date(lastSeenAt*1000);
4949
owned = ownedInt == 1;
5050
}

Voice Control For Plex/src/main/res/values/strings.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<string name="select_voice">Select Voice</string>
4545
<string name="cancel">Cancel</string>
4646
<string name="nothing_to_play">Sorry, I couldn\'t find anything to play.</string>
47-
<string name="http_status_code_error">Sorry, but I got an error, HTTP status code: %d</string>
47+
<string name="http_status_code_error">Sorry, but I got an error, HTTP status code: %s</string>
4848
<string name="got_error">Sorry, but I got an error: %s</string>
4949
<string name="client_not_found">Sorry, you didn\'t specify a client in the main settings, or I couldn\'t find it.</string>
5050
<string name="found_more_than_one_album">I found more than one matching album. Please specify artist.</string>
@@ -83,4 +83,8 @@
8383
<string name="logged_in">You are now logged in.</string>
8484
<string name="logged_out">You are now logged out.</string>
8585
<string name="sections">sections</string>
86+
<string name="searching_for">Searching for %s.</string>
87+
<string name="searching_for_episode">Searching for %1$s episode %2$s.</string>
88+
<string name="searching_for_show_season_episode">Searching for %1$s season %2$s episode %3$s.</string>
89+
<string name="searching_for_album">Searching for %1$s by %2$s.</string>
8690
</resources>

0 commit comments

Comments
 (0)