public Double getTimestamp() { return (Double) opt(KEY_TIMESTAMP); }
public int getVersionCode() { return optInt(KEY_VERSION_CODE); }
public String getVersionName() { return optString(KEY_VERSION_NAME, null); }
VersionHistoryEntry(Integer versionCode, String versionName, Double timestamp) throws JSONException { setVersionCode(versionCode); setVersionName(versionName); setTimestamp(timestamp); }
private void migrateVersionHistory() { // An existing static initializer will trigger the V1 to V2 migration of VersionHistory when VersionHistoryStore is loaded below. // Then migrate to V3, which is stored in the Conversation object. JSONArray versionHistoryOld = VersionHistoryStore.getBaseArray(); try { if (versionHistoryOld != null && versionHistoryOld.length() > 0) { VersionHistory versionHistory = conversation.getVersionHistory(); for (int i = 0; i < versionHistoryOld.length(); i++) { VersionHistoryEntry versionHistoryEntryOld = new VersionHistoryEntry((JSONObject) versionHistoryOld.get(i)); versionHistory.updateVersionHistory(versionHistoryEntryOld.getTimestamp(), versionHistoryEntryOld.getVersionCode(), versionHistoryEntryOld.getVersionName()); } } } catch (Exception e) { ApptentiveLog.w(CONVERSATION, e, "Error migrating VersionHistory entries V2 to V3."); logException(e); } }
public static synchronized void updateVersionHistory(Integer newVersionCode, String newVersionName, double date) { ensureLoaded(); try { boolean exists = false; for (VersionHistoryEntry entry : versionHistoryEntries) { if (entry.getVersionCode() == newVersionCode && entry.getVersionName().equals(newVersionName)) { exists = true; } } // Only modify the store if the version hasn't been seen. if (!exists) { VersionHistoryEntry entry = new VersionHistoryEntry(newVersionCode, newVersionName, date); ApptentiveLog.v(CONVERSATION, "Adding Version History entry: %s", entry); versionHistoryEntries.add(new VersionHistoryEntry(newVersionCode, newVersionName, date)); save(); } } catch (Exception e) { ApptentiveLog.w(CONVERSATION, e, "Error updating VersionHistoryStore."); logException(e); } }
case total: return new Apptentive.DateTime(entry.getTimestamp()); case version_code: if (entry.getVersionCode() == RuntimeUtils.getAppVersionCode(ApptentiveInternal.getInstance().getApplicationContext())) { return new Apptentive.DateTime(entry.getTimestamp()); Apptentive.Version entryVersionName = new Apptentive.Version(); Apptentive.Version currentVersionName = new Apptentive.Version(); entryVersionName.setVersion(entry.getVersionName()); currentVersionName.setVersion(RuntimeUtils.getAppVersionName(ApptentiveInternal.getInstance().getApplicationContext())); if (entryVersionName.equals(currentVersionName)) { return new Apptentive.DateTime(entry.getTimestamp());
/** * Returns true if the current version or build is not the first version or build that we have seen. Basically, it just * looks for two or more versions or builds. * * @param selector - The type of version entry we are looking for: version, or build. * @return True if there are records with more than one version or build, depending on the value of selector. */ public static synchronized boolean isUpdate(Selector selector) { ensureLoaded(); Set<String> uniques = new HashSet<String>(); for (VersionHistoryEntry entry : versionHistoryEntries) { switch (selector) { case version_name: uniques.add(entry.getVersionName()); break; case version_code: uniques.add(String.valueOf(entry.getVersionCode())); break; default: break; } } return uniques.size() > 1; }
public void setTimestamp(Double timestamp) throws JSONException { put(KEY_TIMESTAMP, timestamp); } }
private static void ensureLoaded() { if (versionHistoryEntries == null) { versionHistoryEntries = new ArrayList<VersionHistoryEntry>(); SharedPreferences prefs = ApptentiveInternal.getInstance().getGlobalSharedPrefs(); if (prefs != null) { try { String json = prefs.getString(Constants.PREF_KEY_VERSION_HISTORY_V2, "[]"); JSONArray baseArray = new JSONArray(json); for (int i = 0; i < baseArray.length(); i++) { VersionHistoryEntry entry = new VersionHistoryEntry(baseArray.getJSONObject(i)); versionHistoryEntries.add(entry); } } catch (Exception e) { ApptentiveLog.w(CONVERSATION, e, "Error loading VersionHistoryStore."); logException(e); } } } }
public void setVersionName(String versionName) throws JSONException { put(KEY_VERSION_NAME, versionName); }
public void setVersionCode(Integer versionCode) throws JSONException { put(KEY_VERSION_CODE, versionCode); }