Skip to content

Commit c173695

Browse files
author
Chris Bellew
committed
Only show wear purchase popup after initial setup is complete. Only slide player fragment up when it's being shown from the main fragment.
1 parent edbd1e2 commit c173695

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ public class MainActivity extends AppCompatActivity
191191

192192
private boolean userIsInteracting;
193193

194+
// This will be set to true if wear support is purchased immediately upon launch before
195+
// initial setup has been done, to delay the wear purchase popup until after that has finished
196+
private boolean showWearPurchase = false;
197+
194198
// First time setup
195199
private boolean doingFirstTimeSetup = false;
196200
// The next two booleans will be set to true when their respective scans are finished. This will ensure
@@ -444,6 +448,11 @@ private void init() {
444448

445449
setupNavigationDrawer();
446450

451+
//
452+
if(showWearPurchase) {
453+
showWearPurchase = false;
454+
showWearPurchase();
455+
}
447456
Logger.d("[MainActivity] Intent action: %s", getIntent().getAction());
448457
if(getIntent().getAction() != null && getIntent().getAction().equals(ACTION_SHOW_NOW_PLAYING)) {
449458
handleShowNowPlayingIntent(getIntent());
@@ -840,7 +849,7 @@ public void onDrawerClosed(View drawerView) {
840849

841850

842851
};
843-
mDrawer.setDrawerListener(drawerToggle);
852+
mDrawer.addDrawerListener(drawerToggle);
844853
// Find our drawer view
845854
if(navigationViewMain == null)
846855
navigationViewMain = (NavigationView) findViewById(R.id.navigationViewMain);
@@ -1013,8 +1022,16 @@ protected void onNewIntent(Intent intent) {
10131022
if(VoiceControlForPlexApplication.getInstance().hasWear()) {
10141023
hidePurchaseWearMenuItem();
10151024
} else {
1016-
if (prefs.get(Preferences.HAS_SHOWN_WEAR_PURCHASE_POPUP, false) == false)
1017-
showWearPurchase();
1025+
if (prefs.get(Preferences.HAS_SHOWN_WEAR_PURCHASE_POPUP, false) == false) {
1026+
// If wear support has been purchased before initial setup has been done, the navigation drawer
1027+
// won't have been setup yet, so let's delay showing the popup until after that is done
1028+
// (since it's bad UI to show that popup so soon, and because upon successful purchase, the
1029+
// wear options navigation item isn't even showing yet
1030+
if(navigationViewMain == null)
1031+
showWearPurchase = true;
1032+
else
1033+
showWearPurchase();
1034+
}
10181035
}
10191036
} else if(intent.getAction() != null && intent.getAction().equals(com.atomjack.shared.Intent.SHOW_WEAR_PURCHASE_REQUIRED)) {
10201037
showWearPurchaseRequired();
@@ -1079,7 +1096,9 @@ private void handleShowNowPlayingIntent(Intent intent) {
10791096

10801097
private void switchToPlayerFragment() {
10811098
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
1082-
transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.slide_out_up);
1099+
if(getMainFragment().isVisible()) {
1100+
transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.slide_out_up);
1101+
}
10831102
transaction.replace(R.id.flContent, playerFragment);
10841103
transaction.commit();
10851104
}
@@ -2129,11 +2148,14 @@ public void onUserInteraction() {
21292148
}
21302149

21312150
public void hidePurchaseWearMenuItem() {
2132-
MenuItem wearItem = navigationViewMain.getMenu().findItem(R.id.menu_purchase_wear);
2133-
wearItem.setVisible(false);
2134-
MenuItem wearOptionsItem = navigationViewMain.getMenu().findItem(R.id.menu_wear_options);
2135-
wearOptionsItem.setVisible(true);
2136-
2151+
if(navigationViewMain != null) {
2152+
MenuItem wearItem = navigationViewMain.getMenu().findItem(R.id.menu_purchase_wear);
2153+
if (wearItem != null)
2154+
wearItem.setVisible(false);
2155+
MenuItem wearOptionsItem = navigationViewMain.getMenu().findItem(R.id.menu_wear_options);
2156+
if (wearOptionsItem != null)
2157+
wearOptionsItem.setVisible(true);
2158+
}
21372159
}
21382160

21392161
private boolean hasValidAutoVoice() {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ public void init(int layout, PlexClient client, PlexMedia media, boolean fromWea
159159

160160
public void mediaChanged(PlexMedia media) {
161161
nowPlayingMedia = media;
162-
showNowPlaying();
163-
setCurrentTimeDisplay(getOffset(nowPlayingMedia));
164-
seekBar.setMax(nowPlayingMedia.duration / 1000);
165-
seekBar.setProgress(Integer.parseInt(nowPlayingMedia.viewOffset) / 1000);
166-
durationDisplay.setText(VoiceControlForPlexApplication.secondsToTimecode(nowPlayingMedia.duration / 1000));
162+
if(mainView != null) { // Can't do anything with UI elements until mainView is defined and set
163+
showNowPlaying();
164+
setCurrentTimeDisplay(getOffset(nowPlayingMedia));
165+
seekBar.setMax(nowPlayingMedia.duration / 1000);
166+
seekBar.setProgress(Integer.parseInt(nowPlayingMedia.viewOffset) / 1000);
167+
durationDisplay.setText(VoiceControlForPlexApplication.secondsToTimecode(nowPlayingMedia.duration / 1000));
168+
}
167169
}
168170

169171
@Override

mobile/src/main/java/com/atomjack/vcfp/interfaces/ActivityListener.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,4 @@
33
// This interface is used for the PlayerFragment to pass messages on to the activity
44
public interface ActivityListener {
55
void onLayoutNotFound();
6-
// This will get passed to the activity with the key of the currently playing media, so the activity can set up the
7-
// fragment to display the media
8-
// void onFoundPlayingMedia(Timeline timeline);
9-
// Need this so that the activity can set the cast icon as active
10-
// void onSubscribed();
11-
// void onUnsubscribed();
12-
// void onStopped();
13-
// void onStopped();
146
}

0 commit comments

Comments
 (0)