Skip to content

Commit f057f76

Browse files
author
Chris Bellew
committed
Subscribe to a player and exit Now Playing screen when the player has exited; Added pin login; Refactored a lot of code.
1 parent 14b1ee8 commit f057f76

26 files changed

+819
-266
lines changed

Voice Control For Plex/src/main/AndroidManifest.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.atomjack.vcfp"
4-
android:versionCode="14"
5-
android:versionName="1.8" >
4+
android:versionCode="15"
5+
android:versionName="1.8.1b" >
66

77
<uses-permission android:name="com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API" />
88
<uses-permission android:name="android.permission.INTERNET" />
@@ -23,7 +23,7 @@
2323
android:label="@string/app_name"
2424
android:theme="@style/AppTheme">
2525
<activity
26-
android:name=".MainActivity"
26+
android:name=".activities.MainActivity"
2727
android:label="@string/app_name" >
2828
<intent-filter>
2929
<action android:name="android.intent.action.MAIN" />
@@ -43,21 +43,21 @@
4343
</intent-filter>
4444
</activity>
4545
<activity
46-
android:name=".NowPlayingActivity"
46+
android:name=".activities.NowPlayingActivity"
4747
android:configChanges="orientation|screenSize"
4848
android:label="@string/app_name" >
4949
<intent-filter>
5050
<action android:name="android.intent.action.SEND" />
5151
</intent-filter>
5252
</activity>
53-
<activity android:name=".ShortcutProviderActivity"
53+
<activity android:name=".activities.ShortcutProviderActivity"
5454
android:theme="@style/Theme.Transparent">
5555
<intent-filter>
5656
<action android:name="android.intent.action.CREATE_SHORTCUT" />
5757
<category android:name="android.intent.category.DEFAULT" />
5858
</intent-filter>
5959
</activity>
60-
<activity android:name=".ShortcutActivity"
60+
<activity android:name=".activities.ShortcutActivity"
6161
android:theme="@android:style/Theme.NoDisplay"
6262
android:launchMode="singleInstance">
6363
<intent-filter>

Voice Control For Plex/src/main/assets/VoiceControlForPlex.prj.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ All recognized commands without filter
105105
<pids>50,51</pids>
106106
<tids>49,46,48</tids>
107107
<Img sr="icon" ve="2">
108-
<cls>com.atomjack.vcfp.MainActivity</cls>
108+
<cls>com.atomjack.vcfp.activities.MainActivity</cls>
109109
<pkg>com.atomjack.vcfp</pkg>
110110
</Img>
111111
</Project>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.speech.tts.TextToSpeech;
66
import android.widget.Toast;
77

8+
import com.atomjack.vcfp.activities.MainActivity;
9+
810
public class Feedback implements TextToSpeech.OnInitListener {
911
private SharedPreferences mPrefs;
1012
private TextToSpeech feedbackTts = null;
@@ -22,9 +24,9 @@ public Feedback(SharedPreferences prefs, Context ctx) {
2224
public void onInit(int i) {
2325
Logger.d("Feedback onInit");
2426
if(errorsTts != null)
25-
errorsTts.setLanguage(VoiceControlForPlexApplication.getVoiceLocale(mPrefs.getString(VoiceControlForPlexApplication.Pref.ERRORS_VOICE, "Locale.US")));
27+
errorsTts.setLanguage(VoiceControlForPlexApplication.getVoiceLocale(mPrefs.getString(Preferences.ERRORS_VOICE, "Locale.US")));
2628
if(feedbackTts != null)
27-
feedbackTts.setLanguage(VoiceControlForPlexApplication.getVoiceLocale(mPrefs.getString(VoiceControlForPlexApplication.Pref.FEEDBACK_VOICE, "Locale.US")));
29+
feedbackTts.setLanguage(VoiceControlForPlexApplication.getVoiceLocale(mPrefs.getString(Preferences.FEEDBACK_VOICE, "Locale.US")));
2830

2931
if(errorsQueue != null) {
3032
feedback(errorsQueue, true);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.atomjack.vcfp;
2+
3+
import java.util.concurrent.Future;
4+
5+
public abstract class FutureRunnable implements Runnable {
6+
7+
private Future<?> future;
8+
9+
/* Getter and Setter for future */
10+
public Future getFuture() {
11+
return future;
12+
}
13+
14+
public void setFuture(Future _future) {
15+
future = _future;
16+
}
17+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.widget.AdapterView;
1111
import android.widget.ListView;
1212

13+
import com.atomjack.vcfp.adapters.PlexListAdapter;
1314
import com.atomjack.vcfp.model.MediaContainer;
1415
import com.atomjack.vcfp.model.PlexClient;
1516
import com.atomjack.vcfp.model.PlexServer;
@@ -156,7 +157,7 @@ public void onClick(DialogInterface dialog, int id) {
156157
} else {
157158
Logger.d("Clients: " + clients.size());
158159
SharedPreferences.Editor mPrefsEditor = mPrefs.edit();
159-
mPrefsEditor.putString(VoiceControlForPlexApplication.Pref.SAVED_CLIENTS, gson.toJson(clients));
160+
mPrefsEditor.putString(Preferences.SAVED_CLIENTS, gson.toJson(clients));
160161
mPrefsEditor.commit();
161162
showPlexClients(clients);
162163
}

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

Lines changed: 0 additions & 68 deletions
This file was deleted.

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

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.atomjack.vcfp;
2+
3+
public class PlexHeaders {
4+
public static final String XPlexClientPlatform = "X-Plex-Client-Platform";
5+
public static final String XPlexClientIdentifier = "X-Plex-Client-Identifier";
6+
public static final String XPlexTargetClientIdentifier = "X-Plex-Target-Client-Identifier";
7+
public static final String XPlexToken = "X-Plex-Token";
8+
public static final String XPlexDeviceName = "X-Plex-Device-Name";
9+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import android.speech.RecognizerIntent;
1010
import android.support.v4.content.LocalBroadcastManager;
1111

12+
import com.atomjack.vcfp.activities.MainActivity;
13+
import com.atomjack.vcfp.activities.NowPlayingActivity;
1214
import com.atomjack.vcfp.model.MediaContainer;
1315
import com.atomjack.vcfp.model.PlexClient;
1416
import com.atomjack.vcfp.model.PlexDirectory;
@@ -745,7 +747,7 @@ private void playVideo(final PlexVideo video, String transientToken) {
745747
if(transientToken != null)
746748
qs.add("token", transientToken);
747749
if(video.server.accessToken != null)
748-
qs.add(MainActivity.PlexHeaders.XPlexToken, video.server.accessToken);
750+
qs.add(PlexHeaders.XPlexToken, video.server.accessToken);
749751

750752
String url = String.format("http://%s:%s/player/playback/playMedia?%s", client.host, client.port, qs);
751753
PlexHttpClient.get(url, new PlexHttpResponseHandler()
@@ -1345,7 +1347,7 @@ private void playTrack(final PlexTrack track, final PlexDirectory album) {
13451347
qs.add("containerKey", album.key);
13461348
if(mPrefs.getBoolean("resume", false) || resumePlayback)
13471349
qs.add("viewOffset", track.viewOffset);
1348-
qs.add(MainActivity.PlexHeaders.XPlexTargetClientIdentifier, client.machineIdentifier);
1350+
qs.add(PlexHeaders.XPlexTargetClientIdentifier, client.machineIdentifier);
13491351
String url = String.format("http://%s:%s/player/playback/playMedia?%s", client.host, client.port, qs);
13501352

13511353
PlexHttpClient.get(url, new PlexHttpResponseHandler()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.atomjack.vcfp;
2+
3+
public class Preferences {
4+
public final static String FEEDBACK_VOICE = "pref.feedback.voice";
5+
public final static String ERRORS_VOICE = "pref.errors.voice";
6+
public final static String SAVED_SERVERS = "pref.saved_servers";
7+
public final static String SAVED_CLIENTS = "pref.saved_clients";
8+
public final static String UUID = "pref.uuid";
9+
public final static String AUTHENTICATION_TOKEN = "pref.authentication_token";
10+
}

0 commit comments

Comments
 (0)