/** * Returns true if the current versionCode is not the first version or build that we have seen. Basically, it just * looks for two or more versionCodes. * * @return True if this is not the first versionCode of the app we've seen. */ public boolean isUpdateForVersionCode() { Set<Integer> uniques = new HashSet<Integer>(); for (VersionHistoryItem item : versionHistoryItems) { uniques.add(item.getVersionCode()); } return uniques.size() > 1; }
public void updateVersionHistory(double timestamp, Integer newVersionCode, String newVersionName) { boolean exists = false; for (VersionHistoryItem item : versionHistoryItems) { if (item.getVersionCode() == newVersionCode && item.getVersionName().equals(newVersionName)) { exists = true; break; } } if (!exists) { VersionHistoryItem newVersionHistoryItem = new VersionHistoryItem(timestamp, newVersionCode, newVersionName); versionHistoryItems.add(newVersionHistoryItem); notifyDataChanged(); } }
/** * Returns the timestamp at the first install of the current versionCode of this app that Apptentive was aware of. */ public Apptentive.DateTime getTimeAtInstallForVersionCode(int versionCode) { for (VersionHistoryItem item : versionHistoryItems) { if (item.getVersionCode() == versionCode) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
@Test public void testVersionHistoryStoreGetLatestVersion() { VersionHistory versionHistory = new VersionHistory(); versionHistory.updateVersionHistory(1.472853954087E9d, 1, "3.3.0"); versionHistory.updateVersionHistory(1.472854098019E9d, 2, "3.3.1"); VersionHistoryItem latestEntry = versionHistory.getLastVersionSeen(); assertNotNull(latestEntry); assertEquals(1.472854098019E9d, latestEntry.getTimestamp(), .000001d); assertEquals(2, latestEntry.getVersionCode()); assertEquals("3.3.1", latestEntry.getVersionName()); }
appReleaseChanged = true; } else { previousVersionCode = lastVersionItemSeen.getVersionCode(); Apptentive.Version lastSeenVersionNameVersion = new Apptentive.Version();