Show whats new only once on first run

This commit is contained in:
Bartosz Przybylski 2016-02-13 20:31:09 +01:00 committed by AndyScherzinger
parent 907a61b01e
commit 91826228f4
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 15 additions and 6 deletions

View file

@ -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<FeatureItem> features = new LinkedList<FeatureItem>();
List<FeatureItem> 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;
}

View file

@ -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) {
}