private static void setLastVersion(String version) { Options.setString(Options.OPTION_LAST_VERSION, version); if (hasNewVersion()) { Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, 0); } Options.safeSave(); }
public static void checkUpdates() { if (Options.getBoolean(Options.OPTION_CHECK_UPDATES) && !hasNewVersion()) { final int today = (int) (System.currentTimeMillis() / (24L * 60 * 60 * 1000)); final int nextCheck = Options.getInt(Options.OPTION_UPDATE_CHECK_TIME); if (nextCheck <= today) { new GetVersion(TYPE_DATE).get(); final int nextDay = today + CHECK_UPDATES_INTERVAL; Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, nextDay); Options.safeSave(); } } }
public static boolean showUpdates() { if (Options.getBoolean(Options.OPTION_CHECK_UPDATES) && hasNewVersion()) { final int today = (int) (System.currentTimeMillis() / (24L * 60 * 60 * 1000)); final int nextCheck = Options.getInt(Options.OPTION_UPDATE_CHECK_TIME); if (nextCheck <= today) { final int nextDay = today + SHOW_NEW_VERSION_INTERVAL; Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, nextDay); Options.safeSave(); return true; } } return false; }
public void addChatMenuItems(MenuModel model) { if (isOnline() && !(this instanceof XmppServiceContact)) { if (Options.getBoolean(Options.OPTION_ALARM)) { model.addItem("wake", USER_MENU_WAKE); } } }
// Generates int of money amount spent on connection protected int generateCostSum(int in, int out, boolean thisSession) { int cost = 0; int costOf1M = Options.getInt(Options.OPTION_COST_OF_1M) * 100; int costPacketLength = Math.max(Options.getInt(Options.OPTION_COST_PACKET_LENGTH), 1); long packets = 0; if (0 != in) { packets += (in + costPacketLength - 1) / costPacketLength; } if (0 != out) { packets += (out + costPacketLength - 1) / costPacketLength; } cost += (int) (packets * costPacketLength * costOf1M / (1024 * 1024)); if (!usedToday() && (0 != sessionInTraffic) && (0 == costPerDaySum)) { costPerDaySum = costPerDaySum + Options.getInt(Options.OPTION_COST_PER_DAY); lastTimeUsed.setTime(new Date().getTime()); } return cost + costPerDaySum; }
private static boolean hasNewVersion() { final String lastSVersion = Options.getString(Options.OPTION_LAST_VERSION); if (0 == lastSVersion.length()) { return false; } final int[] curVersion = getVersionDate("###DATE###"); final int[] lastVersion = getVersionDate(lastSVersion); if (curVersion[2] < lastVersion[2]) return true; if (curVersion[2] > lastVersion[2]) return false; if (curVersion[1] < lastVersion[1]) return true; if (curVersion[1] > lastVersion[1]) return false; if (curVersion[0] < lastVersion[0]) return true; return false; }
// Returns String value of cost value public static String costToString(int value) { String costString = ""; try { if (value != 0) { costString = Integer.toString(value / 100000); String afterDot = Integer.toString(value % 100000); while (afterDot.length() != 5) { afterDot = "0" + afterDot; } costString = costString + "." + afterDot.substring(0, 2); } else { costString = "0.00"; } } catch (Exception e) { costString = "0.00"; } return costString + Options.getString(Options.OPTION_CURRENCY); }