Skip to content

Commit 144b892

Browse files
author
Chris Bellew
committed
Fixed layout of movie/show/music titles when titles are long strings. Animate between main fragment and player fragment.
1 parent dcefbe9 commit 144b892

File tree

9 files changed

+126
-80
lines changed

9 files changed

+126
-80
lines changed

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.support.design.widget.NavigationView;
2727
import android.support.v4.app.ActivityCompat;
2828
import android.support.v4.app.Fragment;
29+
import android.support.v4.app.FragmentTransaction;
2930
import android.support.v4.content.ContextCompat;
3031
import android.support.v4.view.GravityCompat;
3132
import android.support.v4.widget.DrawerLayout;
@@ -365,7 +366,7 @@ public void onPlayStarted(PlexMedia media, PlayerState state) {
365366

366367
if(layout != -1) {
367368
playerFragment.init(layout, client, media, false, plexSubscriptionListener);
368-
switchToFragment(playerFragment);
369+
switchToPlayerFragment();
369370
}
370371
sendWearPlaybackChange(state, media);
371372
}
@@ -376,7 +377,7 @@ public void onStateChanged(PlexMedia media, PlayerState state) {
376377
if(playerFragment != null && playerFragment.isVisible()) {
377378
if(state == PlayerState.STOPPED) {
378379
Logger.d("[MainActivity] onStopped");
379-
switchToFragment(getMainFragment());
380+
switchToMainFragment();
380381
} else {
381382
playerFragment.setState(state);
382383
}
@@ -399,7 +400,7 @@ public void onUnsubscribed() {
399400
Logger.d("[MainActivity] unsubscribed");
400401
setCastIconInactive();
401402
prefs.remove(Preferences.SUBSCRIBED_CLIENT);
402-
switchToFragment(getMainFragment());
403+
switchToMainFragment();
403404
if(VoiceControlForPlexApplication.getInstance().hasWear()) {
404405
new SendToDataLayerThread(WearConstants.DISCONNECTED, MainActivity.this).start();
405406
}
@@ -443,7 +444,7 @@ private void init() {
443444

444445
setupNavigationDrawer();
445446

446-
Logger.d("Intent action: %s", getIntent().getAction());
447+
Logger.d("[MainActivity] Intent action: %s", getIntent().getAction());
447448
if(getIntent().getAction() != null && getIntent().getAction().equals(ACTION_SHOW_NOW_PLAYING)) {
448449
handleShowNowPlayingIntent(getIntent());
449450
} else {
@@ -518,7 +519,7 @@ public void run() {
518519
Logger.d("Auto disconnecting player");
519520
if(playerFragment.isVisible()) {
520521
VoiceControlForPlexApplication.getInstance().cancelNotification();
521-
switchToFragment(mainFragment);
522+
switchToMainFragment();
522523
}
523524
}
524525
};
@@ -1066,13 +1067,27 @@ private void handleShowNowPlayingIntent(Intent intent) {
10661067
if(playerFragment.isVisible())
10671068
playerFragment.mediaChanged(media);
10681069
else
1069-
switchToFragment(playerFragment);
1070+
switchToPlayerFragment();
10701071
int seconds = intent.getBooleanExtra(com.atomjack.shared.Intent.EXTRA_STARTING_PLAYBACK, false) ? 10 : 3;
10711072
Logger.d("Setting auto disconnect for %d seconds", seconds);
10721073
handler.postDelayed(autoDisconnectPlayerTimer, seconds*1000);
10731074
}
10741075
}
10751076

1077+
private void switchToPlayerFragment() {
1078+
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
1079+
transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.slide_out_up);
1080+
transaction.replace(R.id.flContent, playerFragment);
1081+
transaction.commit();
1082+
}
1083+
1084+
private void switchToMainFragment() {
1085+
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
1086+
transaction.setCustomAnimations(R.anim.slide_in_down, R.anim.slide_out_down);
1087+
transaction.replace(R.id.flContent, getMainFragment());
1088+
transaction.commit();
1089+
}
1090+
10761091
private Runnable refreshServers = new Runnable() {
10771092
@Override
10781093
public void run() {
@@ -1345,8 +1360,8 @@ protected void setClient(PlexClient _client) {
13451360
Logger.d("[MainActivity] setClient");
13461361
client = _client;
13471362
prefs.put(Preferences.CLIENT, gsonWrite.toJson(_client));
1348-
if(mainFragment.isVisible())
1349-
mainFragment.setClient(_client);
1363+
if(getMainFragment().isVisible())
1364+
getMainFragment().setClient(_client);
13501365
}
13511366

13521367
private boolean isSubscribed() {
@@ -2243,7 +2258,7 @@ else if(connectionType == ConnectivityManager.TYPE_WIFI)
22432258
@Override
22442259
public void onLayoutNotFound() {
22452260
// This is passed by PlayerFragment in the case where it is not able to tell which layout (tv/movie/music) to use. We should switch back to the main fragment
2246-
switchToFragment(getMainFragment());
2261+
switchToMainFragment();
22472262
}
22482263

22492264
private MainFragment getMainFragment() {

mobile/src/main/java/com/atomjack/vcfp/fragments/PlayerFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ public void init(int layout, PlexClient client, PlexMedia media, boolean fromWea
159159

160160
public void mediaChanged(PlexMedia media) {
161161
nowPlayingMedia = media;
162+
showNowPlaying();
162163
setCurrentTimeDisplay(getOffset(nowPlayingMedia));
163164
seekBar.setMax(nowPlayingMedia.duration / 1000);
164165
seekBar.setProgress(Integer.parseInt(nowPlayingMedia.viewOffset) / 1000);
165166
durationDisplay.setText(VoiceControlForPlexApplication.secondsToTimecode(nowPlayingMedia.duration / 1000));
166-
showNowPlaying();
167167
}
168168

169169
@Override
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<translate xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="@android:integer/config_longAnimTime"
4+
android:fromYDelta="-100%p"
5+
android:toYDelta="0%p" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<translate xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="@android:integer/config_longAnimTime"
4+
android:fromYDelta="100%p"
5+
android:toYDelta="0%p" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<translate xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="@android:integer/config_longAnimTime"
4+
android:fromYDelta="0%p"
5+
android:toYDelta="100%p" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<translate xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="@android:integer/config_longAnimTime"
4+
android:fromYDelta="0%p"
5+
android:toYDelta="-100%p" />

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

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,43 @@
2424
/>
2525

2626
<TextView
27-
android:id="@+id/nowPlayingTitle"
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:layout_marginTop="16dp"
31-
android:textSize="24sp"
32-
android:textStyle="bold"
33-
style="@style/showShadow"
34-
android:text="Aliens"
35-
android:textColor="@color/white"/>
27+
android:id="@+id/nowPlayingTitle"
28+
android:layout_width="fill_parent"
29+
android:layout_height="wrap_content"
30+
android:layout_marginTop="16dp"
31+
android:textSize="24sp"
32+
android:textStyle="bold"
33+
style="@style/showShadow"
34+
android:text="Aliens"
35+
android:textColor="@color/white"
36+
android:gravity="center_horizontal"/>
3637

3738
<TextView
38-
android:id="@+id/nowPlayingGenre"
39-
android:layout_width="wrap_content"
40-
android:layout_height="wrap_content"
41-
style="@style/showShadow"
42-
android:text="Horror"
43-
android:textColor="@color/white"/>
39+
android:id="@+id/nowPlayingGenre"
40+
android:layout_width="fill_parent"
41+
android:layout_height="wrap_content"
42+
style="@style/showShadow"
43+
android:text="Horror"
44+
android:textColor="@color/white"
45+
android:gravity="center_horizontal"/>
4446

4547
<TextView
46-
android:id="@+id/nowPlayingYear"
47-
android:layout_width="wrap_content"
48-
android:layout_height="wrap_content"
49-
style="@style/showShadow"
50-
android:text="1986"
51-
android:textColor="@color/white"/>
48+
android:id="@+id/nowPlayingYear"
49+
android:layout_width="fill_parent"
50+
android:layout_height="wrap_content"
51+
style="@style/showShadow"
52+
android:text="1986"
53+
android:textColor="@color/white"
54+
android:gravity="center_horizontal"/>
5255

5356
<TextView
54-
android:id="@+id/nowPlayingDuration"
55-
android:layout_width="wrap_content"
56-
android:layout_height="wrap_content"
57-
style="@style/showShadow"
58-
android:text="2:30:00"
59-
android:textColor="@color/white"/>
57+
android:id="@+id/nowPlayingDuration"
58+
android:layout_width="fill_parent"
59+
android:layout_height="wrap_content"
60+
style="@style/showShadow"
61+
android:text="2:30:00"
62+
android:textColor="@color/white"
63+
android:gravity="center_horizontal"/>
6064

6165
<FrameLayout
6266
android:layout_width="match_parent"

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
<TextView
2929
android:id="@+id/nowPlayingArtist"
30-
android:layout_width="wrap_content"
30+
android:layout_width="fill_parent"
3131
android:layout_height="wrap_content"
3232
style="@style/showShadow"
3333
android:textSize="24sp"
@@ -36,31 +36,34 @@
3636
android:layout_alignParentStart="true"
3737
android:text="Bonobo"
3838
android:textColor="@color/white"
39-
android:layout_marginTop="16dp"/>
39+
android:layout_marginTop="16dp"
40+
android:gravity="center_horizontal"/>
4041

4142
<TextView
4243
android:id="@+id/nowPlayingTitle"
43-
android:layout_width="wrap_content"
44+
android:layout_width="fill_parent"
4445
android:layout_height="wrap_content"
4546
style="@style/showShadow"
4647
android:textSize="18sp"
4748
android:layout_below="@+id/nowPlayingArtist"
4849
android:layout_alignParentLeft="true"
4950
android:layout_alignParentStart="true"
5051
android:text="Animals"
51-
android:textColor="@color/white"/>
52+
android:textColor="@color/white"
53+
android:gravity="center_horizontal"/>
5254

5355
<TextView
5456
android:id="@+id/nowPlayingAlbum"
55-
android:layout_width="wrap_content"
57+
android:layout_width="fill_parent"
5658
android:layout_height="wrap_content"
5759
style="@style/showShadow"
5860
android:textSize="20sp"
5961
android:layout_below="@+id/nowPlayingTitle"
6062
android:layout_alignParentLeft="true"
6163
android:layout_alignParentStart="true"
6264
android:text="Black Sands"
63-
android:textColor="@color/white"/>
65+
android:textColor="@color/white"
66+
android:gravity="center_horizontal"/>
6467

6568
<FrameLayout
6669
android:layout_width="match_parent"

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

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,49 +26,53 @@
2626
android:text="@string/now_playing_on" />
2727

2828
<TextView
29-
android:id="@+id/nowPlayingShowTitle"
30-
android:layout_width="wrap_content"
31-
android:layout_height="wrap_content"
32-
android:layout_alignLeft="@+id/nowPlayingOnClient"
33-
android:layout_alignParentRight="true"
34-
android:layout_below="@+id/nowPlayingOnClient"
35-
android:layout_marginTop="16dp"
36-
style="@style/showShadow"
37-
android:textSize="24sp"
38-
android:textStyle="bold"
39-
android:text="Game of Thrones"
40-
android:textColor="@color/white"/>
29+
android:id="@+id/nowPlayingShowTitle"
30+
android:layout_width="fill_parent"
31+
android:layout_height="wrap_content"
32+
android:layout_alignLeft="@+id/nowPlayingOnClient"
33+
android:layout_alignParentRight="true"
34+
android:layout_below="@+id/nowPlayingOnClient"
35+
android:layout_marginTop="16dp"
36+
style="@style/showShadow"
37+
android:textSize="24sp"
38+
android:textStyle="bold"
39+
android:text="Game of Thrones"
40+
android:textColor="@color/white"
41+
android:gravity="center_horizontal"/>
4142

4243
<TextView
43-
android:id="@+id/nowPlayingEpisodeTitle"
44-
android:layout_width="wrap_content"
45-
android:layout_height="wrap_content"
46-
android:layout_alignLeft="@+id/nowPlayingShowTitle"
47-
android:layout_alignParentRight="true"
48-
android:layout_below="@+id/nowPlayingShowTitle"
49-
style="@style/showShadow"
50-
android:textSize="24sp"
51-
android:text="The Rains of Castamere"
52-
android:textColor="@color/white"/>
44+
android:id="@+id/nowPlayingEpisodeTitle"
45+
android:layout_width="fill_parent"
46+
android:layout_height="wrap_content"
47+
android:layout_alignLeft="@+id/nowPlayingShowTitle"
48+
android:layout_alignParentRight="true"
49+
android:layout_below="@+id/nowPlayingShowTitle"
50+
style="@style/showShadow"
51+
android:textSize="24sp"
52+
android:text="The Rains of Castamere"
53+
android:textColor="@color/white"
54+
android:gravity="center_horizontal"/>
5355

5456
<TextView
55-
android:id="@+id/nowPlayingYear"
56-
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:layout_alignLeft="@+id/nowPlayingEpisodeTitle"
59-
android:layout_alignParentRight="true"
60-
android:layout_below="@+id/nowPlayingEpisodeTitle"
61-
style="@style/showShadow"
62-
android:text="2013"
63-
android:textColor="@color/white"/>
57+
android:id="@+id/nowPlayingYear"
58+
android:layout_width="fill_parent"
59+
android:layout_height="wrap_content"
60+
android:layout_alignLeft="@+id/nowPlayingEpisodeTitle"
61+
android:layout_alignParentRight="true"
62+
android:layout_below="@+id/nowPlayingEpisodeTitle"
63+
style="@style/showShadow"
64+
android:text="2013"
65+
android:textColor="@color/white"
66+
android:gravity="center_horizontal"/>
6467

6568
<TextView
66-
android:id="@+id/nowPlayingDuration"
67-
android:layout_width="wrap_content"
68-
android:layout_height="wrap_content"
69-
style="@style/showShadow"
70-
android:text="52 min"
71-
android:textColor="@color/white"/>
69+
android:id="@+id/nowPlayingDuration"
70+
android:layout_width="fill_parent"
71+
android:layout_height="wrap_content"
72+
style="@style/showShadow"
73+
android:text="52 min"
74+
android:textColor="@color/white"
75+
android:gravity="center_horizontal"/>
7276

7377
<FrameLayout
7478
android:layout_width="match_parent"

0 commit comments

Comments
 (0)