|
38 | 38 | */ |
39 | 39 | public class FeatureList { |
40 | 40 |
|
41 | | - static final private boolean SHOW_ON_FIRST_RUN = true; |
42 | | - static final private boolean SHOW_ON_UPGRADE = false; |
| 41 | + static final private boolean SHOW_ON_FIRST_RUN = true; |
| 42 | + static final private boolean SHOW_ON_UPGRADE = false; |
43 | 43 |
|
44 | 44 |
|
45 | | - static final private FeatureItem featuresList[] = { |
| 45 | + static final private FeatureItem featuresList[] = { |
46 | 46 | // Basic features showed on first install |
47 | | - 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), |
48 | | - 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), |
49 | | - 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), |
50 | | - 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), |
51 | | - 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), |
| 47 | + 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), |
| 48 | + 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), |
| 49 | + 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), |
| 50 | + 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), |
| 51 | + 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), |
52 | 52 | // Features introduced in certain point in time |
53 | 53 | }; |
54 | 54 |
|
55 | 55 |
|
56 | | - static public FeatureItem[] get() { |
57 | | - return featuresList; |
58 | | - } |
| 56 | + static public FeatureItem[] get() { |
| 57 | + return featuresList; |
| 58 | + } |
59 | 59 |
|
60 | | - static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun, boolean isBeta) { |
61 | | - List<FeatureItem> features = new LinkedList<>(); |
| 60 | + static public FeatureItem[] getFiltered(final int lastSeenVersionCode, final boolean isFirstRun, boolean isBeta) { |
| 61 | + List<FeatureItem> features = new LinkedList<>(); |
62 | 62 |
|
63 | | - for (FeatureItem item : get()) { |
| 63 | + for (FeatureItem item : get()) { |
64 | 64 | final int itemVersionCode = isBeta ? item.getBetaVersionNumber() : item.getVersionNumber(); |
65 | | - if (isFirstRun && item.shouldShowOnFirstRun()) { |
66 | | - features.add(item); |
67 | | - } else if (!isFirstRun && !item.shouldShowOnFirstRun() && |
68 | | - MainApp.getVersionCode() >= itemVersionCode && |
69 | | - lastSeenVersionCode < itemVersionCode) { |
70 | | - features.add(item); |
71 | | - } |
72 | | - } |
73 | | - return features.toArray(new FeatureItem[features.size()]); |
74 | | - } |
75 | | - |
76 | | - static public class FeatureItem implements Parcelable { |
77 | | - public static final int DO_NOT_SHOW = -1; |
78 | | - private int image; |
79 | | - private int titleText; |
80 | | - private int contentText; |
81 | | - private int versionNumber; |
| 65 | + if (isFirstRun && item.shouldShowOnFirstRun()) { |
| 66 | + features.add(item); |
| 67 | + } else if (!isFirstRun && !item.shouldShowOnFirstRun() && |
| 68 | + MainApp.getVersionCode() >= itemVersionCode && |
| 69 | + lastSeenVersionCode < itemVersionCode) { |
| 70 | + features.add(item); |
| 71 | + } |
| 72 | + } |
| 73 | + return features.toArray(new FeatureItem[features.size()]); |
| 74 | + } |
| 75 | + |
| 76 | + static public class FeatureItem implements Parcelable { |
| 77 | + public static final int DO_NOT_SHOW = -1; |
| 78 | + private int image; |
| 79 | + private int titleText; |
| 80 | + private int contentText; |
| 81 | + private int versionNumber; |
82 | 82 | private int betaVersion; |
83 | | - private boolean showOnInitialRun; |
| 83 | + private boolean showOnInitialRun; |
84 | 84 |
|
85 | | - public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion) { |
86 | | - this(image, titleText, contentText, version, betaVersion, false); |
87 | | - } |
| 85 | + public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion) { |
| 86 | + this(image, titleText, contentText, version, betaVersion, false); |
| 87 | + } |
88 | 88 |
|
89 | | - public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion, boolean showOnInitialRun) { |
90 | | - this.image = image; |
91 | | - this.titleText = titleText; |
92 | | - this.contentText = contentText; |
93 | | - this.versionNumber = versionCodeFromString(version); |
| 89 | + public FeatureItem(int image, int titleText, int contentText, String version, String betaVersion, boolean showOnInitialRun) { |
| 90 | + this.image = image; |
| 91 | + this.titleText = titleText; |
| 92 | + this.contentText = contentText; |
| 93 | + this.versionNumber = versionCodeFromString(version); |
94 | 94 | this.betaVersion = Integer.parseInt(betaVersion); |
95 | | - this.showOnInitialRun = showOnInitialRun; |
96 | | - } |
| 95 | + this.showOnInitialRun = showOnInitialRun; |
| 96 | + } |
97 | 97 |
|
98 | | - public boolean shouldShowImage() { return image != DO_NOT_SHOW; } |
99 | | - public int getImage() { return image; } |
| 98 | + public boolean shouldShowImage() { return image != DO_NOT_SHOW; } |
| 99 | + public int getImage() { return image; } |
100 | 100 |
|
101 | | - public boolean shouldShowTitleText() { return titleText != DO_NOT_SHOW; } |
102 | | - public int getTitleText() { return titleText; } |
| 101 | + public boolean shouldShowTitleText() { return titleText != DO_NOT_SHOW; } |
| 102 | + public int getTitleText() { return titleText; } |
103 | 103 |
|
104 | | - public boolean shouldShowContentText() { return contentText != DO_NOT_SHOW; } |
105 | | - public int getContentText() { return contentText; } |
| 104 | + public boolean shouldShowContentText() { return contentText != DO_NOT_SHOW; } |
| 105 | + public int getContentText() { return contentText; } |
106 | 106 |
|
107 | | - public int getVersionNumber() { return versionNumber; } |
| 107 | + public int getVersionNumber() { return versionNumber; } |
108 | 108 | public int getBetaVersionNumber() { return betaVersion; } |
109 | | - public boolean shouldShowOnFirstRun() { return showOnInitialRun; } |
| 109 | + public boolean shouldShowOnFirstRun() { return showOnInitialRun; } |
110 | 110 |
|
111 | 111 | @Override |
112 | 112 | public int describeContents() { |
@@ -146,16 +146,16 @@ public Object[] newArray(int size) { |
146 | 146 | }; |
147 | 147 | } |
148 | 148 |
|
149 | | - static int versionCodeFromString(String version) { |
150 | | - String v[] = version.split(Pattern.quote(".")); |
151 | | - if (v.length != 3) { |
152 | | - Log_OC.wtf("FeatureList", "Version string is incorrect " + version); |
153 | | - return 0; |
154 | | - } |
155 | | - int result = Integer.parseInt(v[0])*(int)(10e6) + |
156 | | - Integer.parseInt(v[1])*(int)(10e4) + |
157 | | - Integer.parseInt(v[2])*100; |
158 | | - |
159 | | - return result; |
160 | | - } |
| 149 | + static int versionCodeFromString(String version) { |
| 150 | + String v[] = version.split(Pattern.quote(".")); |
| 151 | + if (v.length != 3) { |
| 152 | + Log_OC.wtf("FeatureList", "Version string is incorrect " + version); |
| 153 | + return 0; |
| 154 | + } |
| 155 | + int result = Integer.parseInt(v[0])*(int)(10e6) + |
| 156 | + Integer.parseInt(v[1])*(int)(10e4) + |
| 157 | + Integer.parseInt(v[2])*100; |
| 158 | + |
| 159 | + return result; |
| 160 | + } |
161 | 161 | } |
0 commit comments