Skip to content

Commit 65aa771

Browse files
author
Chris Bellew
committed
Display season and episode on Now Playing screens.
Fixed display of media info on Wear. Changed back/forward buttons on Now Playing screens, and adjusted element layout a bit. [Wear] Fixed voice input when triggered from action button.
1 parent 3b6d762 commit 65aa771

File tree

11 files changed

+55
-27
lines changed

11 files changed

+55
-27
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,21 @@ public void run() {
7878
}, 3000);
7979

8080

81-
Logger.d("mClient: %s", mClient);
82-
Logger.d("nowPlayingMedia: %s", nowPlayingMedia);
83-
showNowPlaying();
84-
seekBar = (SeekBar) findViewById(R.id.seekBar);
85-
seekBar.setOnSeekBarChangeListener(NowPlayingActivity.this);
86-
seekBar.setMax(nowPlayingMedia.duration);
87-
seekBar.setProgress(Integer.parseInt(nowPlayingMedia.viewOffset));
88-
89-
setCurrentTimeDisplay(getOffset(nowPlayingMedia));
90-
durationDisplay.setText(VoiceControlForPlexApplication.secondsToTimecode(nowPlayingMedia.duration / 1000));
81+
if(nowPlayingMedia == null) {
82+
VoiceControlForPlexApplication.getInstance().cancelNotification();
83+
finish();
84+
} else {
85+
Logger.d("mClient: %s", mClient);
86+
Logger.d("nowPlayingMedia: %s", nowPlayingMedia);
87+
showNowPlaying();
88+
seekBar = (SeekBar) findViewById(R.id.seekBar);
89+
seekBar.setOnSeekBarChangeListener(NowPlayingActivity.this);
90+
seekBar.setMax(nowPlayingMedia.duration);
91+
seekBar.setProgress(Integer.parseInt(nowPlayingMedia.viewOffset));
92+
93+
setCurrentTimeDisplay(getOffset(nowPlayingMedia));
94+
durationDisplay.setText(VoiceControlForPlexApplication.secondsToTimecode(nowPlayingMedia.duration / 1000));
95+
}
9196
}
9297

9398

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void showNowPlaying(boolean setView) {
111111
TextView showTitle = (TextView)findViewById(R.id.nowPlayingShowTitle);
112112
showTitle.setText(video.grandparentTitle);
113113
TextView episodeTitle = (TextView)findViewById(R.id.nowPlayingEpisodeTitle);
114-
episodeTitle.setText(video.title);
114+
episodeTitle.setText(String.format("%s (s%02de%02d)", video.title, Integer.parseInt(video.parentIndex), Integer.parseInt(video.index)));
115115
TextView year = (TextView)findViewById(R.id.nowPlayingYear);
116116
year.setText(video.year);
117117
TextView duration = (TextView)findViewById(R.id.nowPlayingDuration);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ public void sendWearPlaybackChange() {
911911
msg = WearConstants.MEDIA_STOPPED;
912912
} else if (mCurrentState == PlayerState.PAUSED) {
913913
msg = WearConstants.MEDIA_PAUSED;
914+
VoiceControlForPlexApplication.SetWearMediaTitles(data, nowPlayingMedia);
914915
}
915916
if (msg != null) {
916917
if (msg.equals(WearConstants.MEDIA_PLAYING)) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
public class PlexVideo extends PlexMedia {
1818
@Attribute(required=false)
1919
public String index;
20+
@Attribute(required=false)
21+
public String parentIndex;
2022

2123

2224
@Attribute(required=false)
@@ -103,6 +105,7 @@ public String getDuration() {
103105
public void writeToParcel(Parcel out, int flags) {
104106
super.writeToParcel(out, flags);
105107
out.writeString(index);
108+
out.writeString(parentIndex);
106109
out.writeString(type);
107110
out.writeString(year);
108111
out.writeString(summary);
@@ -114,6 +117,7 @@ public void writeToParcel(Parcel out, int flags) {
114117
public PlexVideo(Parcel in) {
115118
super(in);
116119
index = in.readString();
120+
parentIndex = in.readString();
117121
type = in.readString();
118122
year = in.readString();
119123
summary = in.readString();

mobile/src/main/java/com/atomjack/vcfp/services/WearListenerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void onMessageReceived(MessageEvent messageEvent) {
147147

148148
if(listener != null && listener.getNowPlayingMedia() != null) {
149149
Logger.d("now playing: %s", listener.getNowPlayingMedia().title);
150-
dataMap.putString(WearConstants.MEDIA_TITLE, listener.getNowPlayingMedia().title);
150+
VoiceControlForPlexApplication.SetWearMediaTitles(dataMap, listener.getNowPlayingMedia());
151151
dataMap.putString(WearConstants.MEDIA_TYPE, listener.getNowPlayingMedia().getType());
152152
final PlexMedia media = plexSubscription.getListener().getNowPlayingMedia();
153153
VoiceControlForPlexApplication.getWearMediaImage(media, new BitmapHandler() {

mobile/src/main/res/layout/now_playing_movie.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888

8989
<LinearLayout
9090
android:layout_width="fill_parent"
91-
android:layout_height="110dp"
91+
android:layout_height="120dp"
9292
android:orientation="vertical"
9393
android:layout_alignParentBottom="true"
9494
android:layout_centerHorizontal="true"
@@ -97,7 +97,7 @@
9797
android:layout_width="fill_parent"
9898
android:layout_height="wrap_content"
9999
android:id="@+id/seekBar"
100-
android:layout_alignParentBottom="true"/>
100+
android:paddingBottom="10dp"/>
101101
<include layout="@layout/playback" />
102102
</LinearLayout>
103103

mobile/src/main/res/layout/now_playing_music.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
<LinearLayout
6969
android:layout_width="fill_parent"
70-
android:layout_height="110dp"
70+
android:layout_height="120dp"
7171
android:orientation="vertical"
7272
android:layout_alignParentBottom="true"
7373
android:layout_centerHorizontal="true"
@@ -76,7 +76,7 @@
7676
android:layout_width="fill_parent"
7777
android:layout_height="wrap_content"
7878
android:id="@+id/seekBar"
79-
android:layout_alignParentBottom="true"/>
79+
android:paddingBottom="10dp"/>
8080
<include layout="@layout/playback_music" />
8181
</LinearLayout>
8282

mobile/src/main/res/layout/now_playing_show.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
<LinearLayout
9191
android:layout_width="fill_parent"
92-
android:layout_height="110dp"
92+
android:layout_height="120dp"
9393
android:orientation="vertical"
9494
android:layout_alignParentBottom="true"
9595
android:layout_centerHorizontal="true"
@@ -98,7 +98,7 @@
9898
android:layout_width="fill_parent"
9999
android:layout_height="wrap_content"
100100
android:id="@+id/seekBar"
101-
android:layout_alignParentBottom="true"/>
101+
android:paddingBottom="10dp"/>
102102
<include layout="@layout/playback" />
103103
</LinearLayout>
104104

mobile/src/main/res/layout/playback.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
android:maxLines="1"
1515
android:layout_weight="1"
1616
android:paddingLeft="15sp"
17-
android:layout_marginTop="10dp"/>
17+
android:layout_marginTop="18dp"/>
1818
<ImageButton
1919
android:layout_width="0dp"
2020
android:layout_height="wrap_content"
2121
android:background="@android:color/transparent"
2222
android:onClick="doRewind"
23-
android:id="@+id/rewindButton" android:src="@drawable/button_rewind"
23+
android:id="@+id/rewindButton" android:src="@drawable/notif_back15"
2424
android:layout_weight="1"
25-
android:layout_marginTop="10dp"/>
25+
android:layout_marginTop="13dp"/>
2626
<ImageButton
2727
android:layout_width="0dp"
2828
android:layout_height="wrap_content"
@@ -44,9 +44,9 @@
4444
android:layout_height="wrap_content"
4545
android:background="@android:color/transparent"
4646
android:onClick="doForward"
47-
android:id="@+id/forwardButton" android:src="@drawable/button_forward"
47+
android:id="@+id/forwardButton" android:src="@drawable/notif_ff30"
4848
android:layout_weight="1"
49-
android:layout_marginTop="10dp"/>
49+
android:layout_marginTop="13dp"/>
5050
<ImageButton
5151
android:layout_width="0dp"
5252
android:layout_height="wrap_content"
@@ -62,5 +62,5 @@
6262
android:id="@+id/durationView"
6363
android:maxLines="1"
6464
android:layout_weight="1"
65-
android:layout_marginTop="10dp"/>
65+
android:layout_marginTop="18dp"/>
6666
</LinearLayout>

wear/src/main/java/com/atomjack/wear/MainActivity.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Activity;
44
import android.app.NotificationManager;
5+
import android.app.RemoteInput;
56
import android.content.Intent;
67
import android.net.Uri;
78
import android.os.Bundle;
@@ -25,6 +26,8 @@
2526
import com.google.gson.JsonSerializer;
2627

2728
import java.lang.reflect.Type;
29+
import java.util.ArrayList;
30+
import java.util.Arrays;
2831
import java.util.HashMap;
2932
import java.util.List;
3033

@@ -34,6 +37,8 @@ public class MainActivity extends Activity implements
3437
public static final String SHOW_WEAR_UNAUTHORIZED = "com.atomjack.vcfp.intent.show_wear_unauthorized";
3538
public static final String FINISH = "com.atomjack.vcfp.intent.finish";
3639
public static final String START_SPEECH_RECOGNITION = "com.atomjack.vcfp.intent.start_speech_recognition";
40+
public static final String RECEIVE_VOICE_INPUT = "com.atomjack.vcfp.intent.receive_voice_input";
41+
3742
private static final int SPEECH_RECOGNIZER_REQUEST_CODE = 0;
3843

3944
GoogleApiClient googleApiClient;
@@ -42,7 +47,7 @@ public class MainActivity extends Activity implements
4247
@Override
4348
protected void onCreate(Bundle savedInstanceState) {
4449
super.onCreate(savedInstanceState);
45-
Logger.d("[MainActivity] onCreate: %s", savedInstanceState);
50+
Logger.d("[MainActivity] onCreate: %s", getIntent().getAction());
4651

4752
setMainView();
4853

@@ -61,10 +66,24 @@ protected void onCreate(Bundle savedInstanceState) {
6166
} else if(action.equals(WearConstants.SET_INFO)) {
6267
Logger.d("[MainActivity] setting info to %s", getIntent().getStringExtra(WearConstants.INFORMATION));
6368
setInformationView(getIntent().getStringExtra(WearConstants.INFORMATION));
69+
} else if(action.equals(RECEIVE_VOICE_INPUT)) {
70+
String query = getMessageText(getIntent());
71+
DataMap dataMap = new DataMap();
72+
dataMap.putStringArrayList(WearConstants.SPEECH_QUERY, new ArrayList<>(Arrays.asList(query)));
73+
new SendToDataLayerThread(WearConstants.SPEECH_QUERY, dataMap, this).start();
74+
finish();
6475
}
6576
}
6677
}
6778

79+
private String getMessageText(Intent intent) {
80+
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
81+
if (remoteInput != null) {
82+
CharSequence charSequence = remoteInput.getCharSequence(WearConstants.SPEECH_QUERY);
83+
return new StringBuilder(charSequence.length()).append(charSequence).toString();
84+
}
85+
return null;
86+
}
6887
@Override
6988
protected void onPause() {
7089
super.onPause();

0 commit comments

Comments
 (0)