Skip to content

Commit 2547e55

Browse files
author
Chris Bellew
committed
Big update to allow scanning of all available servers, specify client while speaking query, redo settings screen, add now playing screen.
1 parent b8ffa8c commit 2547e55

18 files changed

+492
-665
lines changed

AndroidManifest.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.atomjack.vcfpht"
44
android:versionCode="2"
5-
android:versionName="1.1" >
5+
android:versionName="1.2" >
66

77
<uses-permission android:name="com.mohammadag.googlesearchapi.permission.ACCESS_GGOGLE_SEARCH_API" />
88
<uses-permission android:name="android.permission.INTERNET" />
99
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
10-
10+
1111
<uses-sdk
1212
android:minSdkVersion="16"
1313
android:targetSdkVersion="19" />
@@ -26,18 +26,29 @@
2626
<category android:name="android.intent.category.LAUNCHER" />
2727
</intent-filter>
2828
</activity>
29-
29+
<activity
30+
android:name="com.atomjack.vcfpht.PlayMediaActivity"
31+
android:configChanges="orientation|screenSize"
32+
android:label="@string/app_name" >
33+
<intent-filter>
34+
<action android:name="android.intent.action.MAIN" />
35+
36+
<category android:name="android.intent.category.LAUNCHER" />
37+
</intent-filter>
38+
</activity>
39+
3040
<service
3141
android:name="com.atomjack.vcfpht.GDMService"
3242
android:exported="false" />
33-
43+
3444
<receiver
3545
android:name="com.atomjack.vcfpht.GoogleSearchReceiver"
3646
android:exported="true" >
3747
<intent-filter>
3848
<action android:name="com.mohammadag.googlesearchapi.NEW_SEARCH" />
3949
</intent-filter>
4050
</receiver>
51+
4152
</application>
4253

4354
</manifest>

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Running the application for the first time will immediately start scanning for P
1111

1212
## Usage
1313

14-
Below are examples of what to say to Google Now to trigger playback. Sentence fragments in bold are required **AS IS**, while fragments in italics depend on the show, season and episode you wish to watch.
14+
Below are examples of what to say to Google Now to trigger playback. Sentence fragments in bold are required **AS IS**, while fragments in italics depend on the show, season and episode you wish to watch. If "Resume if in progress" is not checked, you can resume playback by speaking "Resume watching" instead of "Watch" (e.g. "Resume watching Inception")
1515

1616
### For movies:
1717
"**Watch** *Aliens*"
@@ -24,9 +24,11 @@ Below are examples of what to say to Google Now to trigger playback. Sentence fr
2424

2525
"**Watch** *Homeland* **Season** *1* **Episode** *1*"
2626

27-
"**Watch** *Orange Is The New Black* **Season** *1* **Episode** *5*"
27+
"**Watch** *Breaking Bad* **Season** *5* **Episode** *8*"
2828

2929
"**Watch episode** *Once More With Feeling* **of** *Buffy The Vampire Slayer*"
3030

31+
"**Watch** *Game of Thrones* **episode** *The Rains of Castamere*"
32+
3133
"**Watch the latest episode of** *The Walking Dead*" - uses Plex's "on deck"
3234

res/layout/main_setting_item_row.xml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5+
android:descendantFocusability="blocksDescendants"
56
android:orientation="vertical" >
67

78
<!--
@@ -27,20 +28,35 @@
2728
android:id="@+id/mainSettingItem1"
2829
android:layout_width="wrap_content"
2930
android:layout_height="wrap_content"
30-
android:layout_marginBottom="20dp"
3131
android:layout_alignParentLeft="true"
3232
android:layout_alignParentTop="true"
33-
android:textSize="20sp"
34-
android:text="item1" />
33+
android:layout_marginBottom="5dp"
34+
android:layout_toLeftOf="@+id/settingRowHelpButton"
35+
android:text=""
36+
android:textSize="20sp" />
3537

3638
<TextView
3739
android:id="@+id/mainSettingItem2"
3840
android:layout_width="wrap_content"
3941
android:layout_height="wrap_content"
40-
android:layout_marginBottom="20dp"
42+
android:layout_alignParentLeft="true"
43+
android:layout_alignRight="@+id/mainSettingItem1"
44+
android:layout_below="@+id/mainSettingItem1"
45+
android:textSize="20sp" />
46+
47+
<ImageButton
48+
android:id="@+id/settingRowHelpButton"
49+
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content"
51+
android:layout_alignBottom="@+id/mainSettingItem2"
4152
android:layout_alignParentRight="true"
4253
android:layout_alignParentTop="true"
43-
android:textSize="20sp"
44-
android:text="item2" />
54+
android:paddingRight="10dp"
55+
android:paddingLeft="10dp"
56+
android:layout_marginRight="10dp"
57+
android:onClick="settingRowHelpButtonClicked"
58+
android:background="?android:selectableItemBackground"
59+
android:contentDescription="@string/help_button_desc"
60+
android:src="@drawable/help_icon" />
4561

4662
</RelativeLayout>

res/layout/main_with_server.xml

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

res/values/strings.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@
88
<string name="stream_video_from_server">Stream video from the server</string>
99
<string name="to_the_client">to the Client</string>
1010
<string name="resume_if_in_progress">Resume if in progress</string>
11-
<string name="help_text1">Here are some examples to trigger playback:</string>
12-
<string name="help_text2">&quot;Watch V For Vendetta&quot;</string>
13-
<string name="help_text3">Watch Season 1 Episode 1 of Homeland</string>
14-
<string name="help_text4">Watch Orange Is The New Black Season 1 Episode 5</string>
15-
<string name="help_text5">Watch episode Once More With Feeling of Buffy The Vampire Slayer</string>
16-
<string name="help_text6">Watch the latest episode of The Walking Dead</string>
1711
<string name="search">Search</string>
1812
<string name="menu_about">About</string>
1913
<string name="about_text">Voice Control for Plex Home Theater\n© 2013 Chris Bellew\nLicensed under GPLv3\n\nPlex Home Theater is copyright Plex, Inc.</string>
2014
<string name="menu_donate">Donate</string>
2115
<string name="feedback_voice">Voice</string>
2216
<string name="feedback_toast">Toast</string>
17+
<string name="now_playing_on">Now Playing On</string>
18+
<string name="voice">Voice</string>
19+
<string name="toast">Toast</string>
20+
<string name="scan_all">Scan All</string>
21+
<string name="not_set">Not Set</string>
22+
<string name="feedback">Feedback</string>
23+
<string name="help_server">Select a Plex Media Server to stream from. If you have more than one media server, select &quot;Scan All&quot; to search all available servers for media. If you only have one, you should select it here as scanning all servers each time will take longer to trigger playback.</string>
24+
<string name="help_client">Select the default client to stream media to. You can easily stream to a different client by ending your search query with \&quot;on &lt;client name&gt;\&quot;, where &lt;client name&gt; is the name of the PHT Client.</string>
25+
<string name="help_feedback">Select which type of feedback I should give you.</string>
26+
<string name="help_button_desc">Help Button</string>
27+
<string name="help_usage">Here are some examples to trigger playback:\n\nWatch V For Vendetta\nWatch Season 1 Episode 1 of Homeland\nWatch Breaking Bad Season 5 Episode 8\nWatch episode Once More With Feeling of Buffy The Vampire Slayer\nWatch the latest episode of The Walking Dead\n\nIf you don\'t have \&quot;Resume if in progress\&quot; checked, you can selectively resume by saying \&quot;Resume watching\&quot; instead of \&quot;Watch\&quot;\n\nYou can also specify a client by adding \&quot;on &lt;client name&gt;\&quot; to your spoken query.</string>
28+
<string name="help_usage_button">Usage Examples</string>
2329

2430
</resources>

res/values/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
<style name="AppTheme" parent="AppBaseTheme">
1717
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
1818
</style>
19+
<style name="Line">
20+
<item name="android:layout_width">fill_parent</item>
21+
<item name="android:layout_height">1dp</item>
22+
<item name="android:background">#bfbfbf</item>
23+
</style>
1924

2025
</resources>

src/com/atomjack/vcfpht/GDMService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public GDMService() {
2525
protected void onHandleIntent(Intent intent) {
2626
try
2727
{
28+
String origin = intent.getStringExtra("ORIGIN") == null ? "" : intent.getStringExtra("ORIGIN");
29+
String queryText = intent.getStringExtra("queryText");
2830
DatagramSocket socket = new DatagramSocket(32414);
2931
socket.setBroadcast(true);
3032
String data = "M-SEARCH * HTTP/1.0";
@@ -49,6 +51,7 @@ protected void onHandleIntent(Intent intent) {
4951
Intent packetBroadcast = new Intent(GDMService.MSG_RECEIVED);
5052
packetBroadcast.putExtra("data", packetData);
5153
packetBroadcast.putExtra("ipaddress", packet.getAddress().toString());
54+
packetBroadcast.putExtra("ORIGIN", origin);
5255
LocalBroadcastManager.getInstance(this).sendBroadcast(packetBroadcast);
5356
}
5457
}
@@ -58,6 +61,10 @@ protected void onHandleIntent(Intent intent) {
5861
socket.close();
5962
listening = false;
6063
Intent socketBroadcast = new Intent(GDMService.SOCKET_CLOSED);
64+
socketBroadcast.putExtra("ORIGIN", origin);
65+
if(queryText != null) {
66+
socketBroadcast.putExtra("queryText", queryText);
67+
}
6168
LocalBroadcastManager.getInstance(this).sendBroadcast(socketBroadcast);
6269
}
6370

src/com/atomjack/vcfpht/GoogleSearchPlexControlApplication.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ public static ConcurrentHashMap<String, PlexServer> getPlexMediaServers() {
2323
private static Serializer serial = new Persister();
2424

2525
public static void addPlexServer(final PlexServer server) {
26+
Log.v(MainActivity.TAG, "ADDING PLEX SERVER: " + server);
27+
if(server.getName().equals("") || server.getIPAddress().equals("")) {
28+
return;
29+
}
2630
if (!plexmediaServers.containsKey(server.getName())) {
2731
try {
2832
String url = "http://" + server.getIPAddress() + ":" + server.getPort() + "/library/sections/";
29-
AsyncHttpClient client = new AsyncHttpClient();
30-
client.get(url, new AsyncHttpResponseHandler() {
33+
AsyncHttpClient httpClient = new AsyncHttpClient();
34+
httpClient.get(url, new AsyncHttpResponseHandler() {
3135
@Override
3236
public void onSuccess(String response) {
3337
Log.v(MainActivity.TAG, "HTTP REQUEST: " + response);
@@ -40,7 +44,6 @@ public void onSuccess(String response) {
4044
e.printStackTrace();
4145
}
4246
for(int i=0;i<mc.directories.size();i++) {
43-
Log.v(MainActivity.TAG, "Directory type: " + mc.directories.get(i).getType());
4447
if(mc.directories.get(i).getType().equals("movie")) {
4548
server.addMovieSection(mc.directories.get(i).getKey());
4649
}
@@ -53,8 +56,9 @@ public void onSuccess(String response) {
5356
Log.v(MainActivity.TAG, "Directories: " + mc.directories.size());
5457
else
5558
Log.v(MainActivity.TAG, "No directories found!");
56-
plexmediaServers.putIfAbsent(server.getName(), server);
57-
// getClients(mc);
59+
if(!server.getName().equals("") && !server.getIPAddress().equals("")) {
60+
plexmediaServers.putIfAbsent(server.getName(), server);
61+
}
5862
}
5963
});
6064

0 commit comments

Comments
 (0)