From deaf569c1cd1821ff79d0d03d4d83609af9e0689 Mon Sep 17 00:00:00 2001 From: Bartosz Przybylski Date: Mon, 1 Feb 2016 22:23:07 +0100 Subject: [PATCH] Add parameter to allow showing whats new in beta --- res/values/setup.xml | 3 ++ .../android/features/FeatureList.java | 29 +++++++++++-------- .../android/ui/activity/WhatsNewActivity.java | 11 +++++-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/res/values/setup.xml b/res/values/setup.xml index 5947e62bed..8702106632 100644 --- a/res/values/setup.xml +++ b/res/values/setup.xml @@ -1,5 +1,8 @@ + + false + Nextcloud nextcloud diff --git a/src/com/owncloud/android/features/FeatureList.java b/src/com/owncloud/android/features/FeatureList.java index c3982647ee..b11bccabaa 100644 --- a/src/com/owncloud/android/features/FeatureList.java +++ b/src/com/owncloud/android/features/FeatureList.java @@ -40,11 +40,13 @@ public class FeatureList { 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), - 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.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_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_oc_files, R.string.welcome_feature_5_title, FeatureItem.DO_NOT_SHOW, "1.0.0", SHOW_ON_FIRST_RUN) + // Basic features showed on first install + 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_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_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_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; } - static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun) { + static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun, boolean isBeta) { List features = new LinkedList(); for (FeatureItem item : get()) { + final int itemVersionCode = isBeta ? item.getBetaVersionNumber() : item.getVersionNumber(); if (isFirstRun && item.shouldShowOnFirstRun()) { features.add(item); } else if (!isFirstRun && !item.shouldShowOnFirstRun() && - MainApp.getVersionCode() >= item.getVersionNumber() && - lastSeenVersionCode < item.getVersionNumber()) { + MainApp.getVersionCode() >= itemVersionCode && + lastSeenVersionCode < itemVersionCode) { features.add(item); } } @@ -73,17 +76,19 @@ public class FeatureList { private int titleText; private int contentText; private int versionNumber; + private int betaVersion; private boolean showOnInitialRun; - public FeatureItem(int image, int titleText, int contentText, String version) { - this(image, titleText, contentText, version, false); + public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion) { + 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.titleText = titleText; this.contentText = contentText; this.versionNumber = versionCodeFromString(version); + this.betaVersion = Integer.parseInt(betaVersion); this.showOnInitialRun = showOnInitialRun; } @@ -96,8 +101,8 @@ public class FeatureList { public boolean shouldShowContentText() { return contentText != DO_NOT_SHOW; } public int getContentText() { return contentText; } - public int getVersionNumber() { return versionNumber; } + public int getBetaVersionNumber() { return betaVersion; } public boolean shouldShowOnFirstRun() { return showOnInitialRun; } } diff --git a/src/com/owncloud/android/ui/activity/WhatsNewActivity.java b/src/com/owncloud/android/ui/activity/WhatsNewActivity.java index 857d6335c9..598ec3a695 100644 --- a/src/com/owncloud/android/ui/activity/WhatsNewActivity.java +++ b/src/com/owncloud/android/ui/activity/WhatsNewActivity.java @@ -69,7 +69,8 @@ public class WhatsNewActivity extends Activity { mCurrentStep = 0; 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); @@ -112,7 +113,9 @@ public class WhatsNewActivity extends Activity { private void fillContentPanelWithFeatureData() { 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.LayoutParams params = new LinearLayout.LayoutParams(getScreenWidth(), ViewGroup.LayoutParams.MATCH_PARENT); @@ -215,7 +218,9 @@ public class WhatsNewActivity extends Activity { if (context instanceof WhatsNewActivity) 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)); }