Add parameter to allow showing whats new in beta

This commit is contained in:
Bartosz Przybylski 2016-02-01 22:23:07 +01:00 committed by AndyScherzinger
parent 0e10c08442
commit deaf569c1c
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
3 changed files with 28 additions and 15 deletions

View file

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- Beta indicator -->
<bool name="is_beta">false</bool>
<!-- App name and other strings--> <!-- App name and other strings-->
<string name="app_name">Nextcloud</string> <string name="app_name">Nextcloud</string>
<string name="account_type">nextcloud</string> <!-- better if was a domain name; but changing it now would require migrate accounts when the app is updated --> <string name="account_type">nextcloud</string> <!-- better if was a domain name; but changing it now would require migrate accounts when the app is updated -->

View file

@ -40,11 +40,13 @@ public class FeatureList {
static final private FeatureItem featuresList[] = { static final private FeatureItem featuresList[] = {
new FeatureItem(R.drawable.what_new_instant_upload, R.string.welcome_feature_1_title, R.string.welcome_feature_1_text, "1.0.0", SHOW_ON_FIRST_RUN), // Basic features showed on first install
new FeatureItem(R.drawable.whats_new_files, R.string.welcome_feature_2_title, R.string.welcome_feature_2_text, "1.0.0", SHOW_ON_FIRST_RUN), new FeatureItem(R.drawable.what_new_instant_upload, R.string.welcome_feature_1_title, R.string.welcome_feature_1_text, "1.0.0", "0", SHOW_ON_FIRST_RUN),
new FeatureItem(R.drawable.whats_new_share, R.string.welcome_feature_3_title, R.string.welcome_feature_3_text, "1.0.0", SHOW_ON_FIRST_RUN), new FeatureItem(R.drawable.whats_new_files, R.string.welcome_feature_2_title, R.string.welcome_feature_2_text, "1.0.0", "0", SHOW_ON_FIRST_RUN),
new FeatureItem(R.drawable.whats_new_accounts, R.string.welcome_feature_4_title, R.string.welcome_feature_4_text, "1.0.0", SHOW_ON_FIRST_RUN), new FeatureItem(R.drawable.whats_new_share, R.string.welcome_feature_3_title, R.string.welcome_feature_3_text, "1.0.0", "0" ,SHOW_ON_FIRST_RUN),
new FeatureItem(R.drawable.whats_new_oc_files, R.string.welcome_feature_5_title, FeatureItem.DO_NOT_SHOW, "1.0.0", SHOW_ON_FIRST_RUN) new FeatureItem(R.drawable.whats_new_accounts, R.string.welcome_feature_4_title, R.string.welcome_feature_4_text, "1.0.0", "0", SHOW_ON_FIRST_RUN),
new FeatureItem(R.drawable.whats_new_oc_files, R.string.welcome_feature_5_title, FeatureItem.DO_NOT_SHOW, "1.0.0", "0", SHOW_ON_FIRST_RUN)
// Features introduced in certain point in time
}; };
@ -52,15 +54,16 @@ public class FeatureList {
return featuresList; return featuresList;
} }
static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun) { static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun, boolean isBeta) {
List<FeatureItem> features = new LinkedList<FeatureItem>(); List<FeatureItem> features = new LinkedList<FeatureItem>();
for (FeatureItem item : get()) { for (FeatureItem item : get()) {
final int itemVersionCode = isBeta ? item.getBetaVersionNumber() : item.getVersionNumber();
if (isFirstRun && item.shouldShowOnFirstRun()) { if (isFirstRun && item.shouldShowOnFirstRun()) {
features.add(item); features.add(item);
} else if (!isFirstRun && !item.shouldShowOnFirstRun() && } else if (!isFirstRun && !item.shouldShowOnFirstRun() &&
MainApp.getVersionCode() >= item.getVersionNumber() && MainApp.getVersionCode() >= itemVersionCode &&
lastSeenVersionCode < item.getVersionNumber()) { lastSeenVersionCode < itemVersionCode) {
features.add(item); features.add(item);
} }
} }
@ -73,17 +76,19 @@ public class FeatureList {
private int titleText; private int titleText;
private int contentText; private int contentText;
private int versionNumber; private int versionNumber;
private int betaVersion;
private boolean showOnInitialRun; private boolean showOnInitialRun;
public FeatureItem(int image, int titleText, int contentText, String version) { public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion) {
this(image, titleText, contentText, version, false); this(image, titleText, contentText, version, betaVersion, false);
} }
public FeatureItem(int image, int titleText, int contentText, String version, boolean showOnInitialRun) { public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion, boolean showOnInitialRun) {
this.image = image; this.image = image;
this.titleText = titleText; this.titleText = titleText;
this.contentText = contentText; this.contentText = contentText;
this.versionNumber = versionCodeFromString(version); this.versionNumber = versionCodeFromString(version);
this.betaVersion = Integer.parseInt(betaVersion);
this.showOnInitialRun = showOnInitialRun; this.showOnInitialRun = showOnInitialRun;
} }
@ -96,8 +101,8 @@ public class FeatureList {
public boolean shouldShowContentText() { return contentText != DO_NOT_SHOW; } public boolean shouldShowContentText() { return contentText != DO_NOT_SHOW; }
public int getContentText() { return contentText; } public int getContentText() { return contentText; }
public int getVersionNumber() { return versionNumber; } public int getVersionNumber() { return versionNumber; }
public int getBetaVersionNumber() { return betaVersion; }
public boolean shouldShowOnFirstRun() { return showOnInitialRun; } public boolean shouldShowOnFirstRun() { return showOnInitialRun; }
} }

View file

@ -69,7 +69,8 @@ public class WhatsNewActivity extends Activity {
mCurrentStep = 0; mCurrentStep = 0;
mProgress = (ProgressIndicator) findViewById(R.id.progressIndicator); mProgress = (ProgressIndicator) findViewById(R.id.progressIndicator);
final int listLength = FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun()).length; final boolean isBeta = getResources().getBoolean(R.bool.is_beta);
final int listLength = FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length;
mProgress.setNumberOfSteps(listLength); mProgress.setNumberOfSteps(listLength);
@ -112,7 +113,9 @@ public class WhatsNewActivity extends Activity {
private void fillContentPanelWithFeatureData() { private void fillContentPanelWithFeatureData() {
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
for (FeatureItem item : FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun())) { final boolean isBeta = getResources().getBoolean(R.bool.is_beta);
for (FeatureItem item : FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta)) {
LinearLayout newElement = (LinearLayout)inflater.inflate(R.layout.whats_new_element, null); LinearLayout newElement = (LinearLayout)inflater.inflate(R.layout.whats_new_element, null);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(getScreenWidth(), ViewGroup.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(getScreenWidth(), ViewGroup.LayoutParams.MATCH_PARENT);
@ -215,7 +218,9 @@ public class WhatsNewActivity extends Activity {
if (context instanceof WhatsNewActivity) if (context instanceof WhatsNewActivity)
return; return;
if (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun()).length > 0) final boolean isBeta = context.getResources().getBoolean(R.bool.is_beta);
if (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length > 0)
context.startActivity(new Intent(context, WhatsNewActivity.class)); context.startActivity(new Intent(context, WhatsNewActivity.class));
} }