Skip to content

Commit 8b45b05

Browse files
author
Chris Bellew
committed
Don't show What's New Dialog after doing first time setup. Wait until the app has updated again.
1 parent e71e2d4 commit 8b45b05

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ else if(musicPlayerFragment != null)
506506
doTutorial();
507507
}
508508
} else {
509+
WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
510+
whatsNewDialog.updateLastShown();
509511
fragment = new SetupFragment();
510512
switchToFragment(fragment);
511513
}
@@ -721,7 +723,8 @@ protected void onResume() {
721723
}
722724
}
723725

724-
// If we get unsubscribed from the notification, and the app isn't visible, the next time we show up the app will think it's still subscribed, so we have to set the UI to be unsubbed
726+
// If we get unsubscribed from the notification, and the app isn't visible, the next time we show up the app will think
727+
// it's still subscribed, so we have to set the UI to be unsubbed
725728
if(!isSubscribed() && !doingFirstTimeSetup) {
726729
switchToMainFragment();
727730
setCastIconInactive();

mobile/src/main/java/com/cubeactive/martin/inscription/ChangeLogDialog.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ protected void show(final int version) {
225225
if(customView != null) {
226226
builder.setView(customView);
227227
final AlertDialog dialog = builder.create();
228-
// customView.findViewWithTag()
229228
WebView whatsNewWebView = (WebView)customView.findViewById(mContext.getResources().getIdentifier("whatsNewWebView", "id", mContext.getPackageName()));
230229
whatsNewWebView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
231230
Button whatsNewCloseButton = (Button)customView.findViewById(mContext.getResources().getIdentifier("whatsNewCloseButton", "id", mContext.getPackageName()));

mobile/src/main/java/com/cubeactive/martin/inscription/WhatsNewDialog.java

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,53 @@
2222
import android.content.pm.PackageManager.NameNotFoundException;
2323
import android.preference.PreferenceManager;
2424

25-
2625
/**
2726
* Class to show a dialog with the latest changes for the current app version.
2827
*/
2928
public class WhatsNewDialog extends ChangeLogDialog {
30-
private static final String WHATS_NEW_LAST_SHOWN = "whats_new_last_shown";
29+
private static final String WHATS_NEW_LAST_SHOWN = "whats_new_last_shown";
3130

32-
public WhatsNewDialog(final Context context) {
33-
super(context);
34-
}
31+
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
3532

36-
//Get the current app version
37-
private int getAppVersionCode() {
38-
try {
39-
final PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
40-
return packageInfo.versionCode;
41-
} catch (NameNotFoundException ignored) {
42-
return 0;
43-
}
44-
}
33+
public WhatsNewDialog(final Context context) {
34+
super(context);
35+
}
4536

46-
public void forceShow() {
47-
//Show only the changes from this version (if available)
48-
show(getAppVersionCode());
37+
//Get the current app version
38+
private int getAppVersionCode() {
39+
try {
40+
final PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
41+
return packageInfo.versionCode;
42+
} catch (NameNotFoundException ignored) {
43+
return 0;
4944
}
45+
}
5046

51-
@Override
52-
public void show() {
53-
//ToDo check if version is shown
54-
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
55-
final int versionShown = prefs.getInt(WHATS_NEW_LAST_SHOWN, 0);
56-
if (versionShown != getAppVersionCode()) {
57-
//This version is new, show only the changes from this version (if available)
58-
show(getAppVersionCode());
47+
public void forceShow() {
48+
//Show only the changes from this version (if available)
49+
show(getAppVersionCode());
50+
}
5951

60-
//Update last shown version
61-
final SharedPreferences.Editor edit = prefs.edit();
62-
edit.putInt(WHATS_NEW_LAST_SHOWN, getAppVersionCode());
63-
edit.commit();
64-
}
65-
if(mOnDismissListener != null) {
66-
mOnDismissListener.onDismiss(null);
67-
}
52+
@Override
53+
public void show() {
54+
//ToDo check if version is shown
55+
final int versionShown = prefs.getInt(WHATS_NEW_LAST_SHOWN, 0);
56+
final int appVersionCode = getAppVersionCode();
57+
if (versionShown != appVersionCode) {
58+
//This version is new, show only the changes from this version (if available)
59+
show(appVersionCode);
60+
61+
//Update last shown version
62+
updateLastShown();
63+
} else if(mOnDismissListener != null) {
64+
mOnDismissListener.onDismiss(null);
6865
}
66+
}
67+
68+
public void updateLastShown() {
69+
final SharedPreferences.Editor edit = prefs.edit();
70+
edit.putInt(WHATS_NEW_LAST_SHOWN, getAppVersionCode());
71+
edit.commit();
72+
}
6973
}
74+

0 commit comments

Comments
 (0)