From 91826228f401f0ce7523283f434318ba2727a86d Mon Sep 17 00:00:00 2001 From: Bartosz Przybylski Date: Sat, 13 Feb 2016 20:31:09 +0100 Subject: [PATCH] Show whats new only once on first run --- .../owncloud/android/features/FeatureList.java | 6 +++--- .../android/ui/activity/WhatsNewActivity.java | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/com/owncloud/android/features/FeatureList.java b/src/com/owncloud/android/features/FeatureList.java index 7f55addad2..4845a0fc83 100644 --- a/src/com/owncloud/android/features/FeatureList.java +++ b/src/com/owncloud/android/features/FeatureList.java @@ -48,7 +48,7 @@ public class FeatureList { 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) + 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 }; @@ -58,7 +58,7 @@ public class FeatureList { } static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun, boolean isBeta) { - List features = new LinkedList(); + List features = new LinkedList<>(); for (FeatureItem item : get()) { final int itemVersionCode = isBeta ? item.getBetaVersionNumber() : item.getVersionNumber(); @@ -154,7 +154,7 @@ public class FeatureList { } int result = Integer.parseInt(v[0])*(int)(10e6) + Integer.parseInt(v[1])*(int)(10e4) + - Integer.parseInt(v[2]); + Integer.parseInt(v[2])*100; return result; } diff --git a/src/com/owncloud/android/ui/activity/WhatsNewActivity.java b/src/com/owncloud/android/ui/activity/WhatsNewActivity.java index f8a9694f01..b6a465f0c2 100644 --- a/src/com/owncloud/android/ui/activity/WhatsNewActivity.java +++ b/src/com/owncloud/android/ui/activity/WhatsNewActivity.java @@ -42,6 +42,7 @@ import android.widget.TextView; import com.owncloud.android.MainApp; import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountAuthenticatorActivity; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.features.FeatureList; import com.owncloud.android.features.FeatureList.FeatureItem; @@ -150,12 +151,20 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa if (context instanceof WhatsNewActivity) return; - final boolean isBeta = context.getResources().getBoolean(R.bool.is_beta); - - if (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length > 0) + if (shouldShow(context)) context.startActivity(new Intent(context, WhatsNewActivity.class)); } + static private boolean shouldShow(Context context) { + final boolean isBeta = context.getResources().getBoolean(R.bool.is_beta); + return (isFirstRun() && context instanceof AccountAuthenticatorActivity) || + ( + !(isFirstRun() && (context instanceof FileDisplayActivity)) && + !(context instanceof PassCodeActivity) && + (FeatureList.getFiltered(getLastSeenVersionCode(), isFirstRun(), isBeta).length > 0) + ); + } + @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }