public static int getStringToInt(final String pref, final int defaultValue) { try { return Integer.parseInt(getString(pref, Integer.toString(defaultValue))); } catch (Exception e) { return defaultValue; } }
public static int getStringToInt(final String pref, final int defaultValue) { try { return Integer.parseInt(getString(pref, Integer.toString(defaultValue))); } catch (Exception e) { return defaultValue; } }
static boolean checkPin(String pin) { String pinPref = Pref.getString("pendiq_pin", "0000"); if (pinPref.equals("0")) pinPref = "0000"; // annoying preference issue return pin != null && pin.equals(pinPref); } }
public static boolean backupAvailable() { final String backup_file = Pref.getString("last-saved-database-zip", ""); if (backup_file.length() > 0) { if (new File(backup_file).exists()) { return true; } } return false; }
public static synchronized CalibrationAbstract getCalibrationPluginFromPreferences() { if (current_plugin_cache == null) { current_plugin_cache = getCalibrationPluginByName(Pref.getString("current_calibration_plugin", "None")); } return current_plugin_cache; }
@Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); startActivity(new Intent(context, ImportDatabaseActivity.class).putExtra("importit", Pref.getString("last-saved-database-zip", "")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } });
@Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); startActivity(new Intent(context, ImportDatabaseActivity.class).putExtra("importit", Pref.getString("last-saved-database-zip", "")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } });
public static double getStringToDouble(final String pref, final double defaultValue) { try { return JoH.tolerantParseDouble(getString(pref, Double.toString(defaultValue)), defaultValue); } catch (Exception e) { return defaultValue; } }
public static String unitized_string_static_no_interpretation_short(double value) { final boolean domgdl = Pref.getString("units", "mgdl").equals("mgdl"); final DecimalFormat df = new DecimalFormat("#"); if (domgdl) { df.setMaximumFractionDigits(0); } else { df.setMaximumFractionDigits(1); } return df.format(unitized(value, domgdl)) + " " + (domgdl ? "mgdl" : "mmol"); }
public static int getNoiseBlockLevel() { int value = 200; try { value = Integer.parseInt(Pref.getString("noise_block_level", "200")); } catch (NumberFormatException e) { UserError.Log.e(TAG, "Cannot process noise block level: " + e); } return value; }
public synchronized void desertSyncSettings(View view) { prefsMap.clear(); prefsMap.put("desert_sync_enabled", Boolean.toString(true)); prefsMap.put("desert_sync_master_ip", RouteTools.getBestInterfaceAddress()); prefsMap.put("dex_collection_method", "Follower"); prefsMap.put("custom_sync_key", Pref.getString("custom_sync_key", "")); prefsMap.put("use_custom_sync_key", Boolean.toString(Pref.getBoolean("use_custom_sync_key", false))); prefsMap.put("desert_use_https", Boolean.toString(Pref.getBooleanDefaultFalse("desert_use_https"))); prefsMap.put("xdrip_webservice_secret", Pref.getString("xdrip_webservice_secret", "")); showQRCode(); }
public static String getAuthRequestHeader() { final String username = Pref.getString("tidepool_username", null); final String password = Pref.getString("tidepool_password", null); if (emptyString(username) || emptyString(password)) return null; return Credentials.basic(username.trim(), password); } }
public static List<EmergencyContact> load() { final String json = Pref.getString(PREF_NAME, ""); final Type queueType = new TypeToken<ArrayList<EmergencyContact>>() { }.getType(); List<EmergencyContact> result = JoH.defaultGsonInstance().fromJson(json, queueType); if (result == null) { result = new ArrayList<>(); } return result; }
public static ITrendArrow create(ImageView imageView) { final String arrow_type = Pref.getString(PREF_TREND_ARROW_TYPE, ""); // yucky workaround for broken LG lack of gradient fill. if (Build.VERSION.SDK_INT == 23 && Build.MANUFACTURER.startsWith("LG")) { if (arrow_type.equals("JamTrendArrowImpl")) { JoH.static_toast_long("LG Phones have problems with some arrows, choose another"); return create("JamTrendArrow2Impl", imageView); } } return create(arrow_type, imageView); }
public static void validateTargetRange() { final double default_target_glucose = tolerantParseDouble(Pref.getString("plus_target_range", Double.toString(5.5 / scale_factor))); if (default_target_glucose > tolerantParseDouble(Pref.getString("highValue", Double.toString(5.5 / scale_factor)))) { Pref.setString("plus_target_range", JoH.qs(default_target_glucose * Constants.MGDL_TO_MMOLL, 1)); UserError.Log.i(TAG, "Converted initial value of target glucose to mmol"); } }
public static Bitmap getLockScreenBitmap(final String text, final String arrow, final boolean strike_through) { final boolean tiled = isLockScreenBitmapTiled(); final double x_ratio = JoH.tolerantParseDouble(Pref.getString("numberwall_x_param", ""), 50d) / 100d; double y_ratio = JoH.tolerantParseDouble(Pref.getString("numberwall_y_param", ""), 50d) / 100d; double spacer_ratio = JoH.tolerantParseDouble(Pref.getString("numberwall_s_param", ""), 10d) / 100d; if (!tiled) { y_ratio = 0.30d; // standardized defaults somewhere for this would be nice; and roll in to final declaration above spacer_ratio = 0d; } return getBitmap(text, getCol(ColorCache.X.color_number_wall), arrow, (int) (getScreenDpi() * x_ratio), (int) (getScreenDpi() * x_ratio * y_ratio), (int) (getScreenDpi() * x_ratio * spacer_ratio), strike_through, !tiled, true); }
private static void correctWebServiceSettings() { Pref.setBoolean("xdrip_webservice", true); Pref.setBoolean("xdrip_webservice_open", true); if (Pref.getString(PREF_WEBSERVICE_SECRET, "").length() == 0) { Pref.setString(PREF_WEBSERVICE_SECRET, CipherUtils.getRandomHexKey()); } Inevitable.task("web service changed", 2000, XdripWebService::settingsChanged); }
public static void resetTransmitterBatteryStatus() { final String transmitterId = Pref.getString("dex_txid", "NULL"); PersistentStore.setString(G5_BATTERY_MARKER + transmitterId, ""); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, 0); PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, 0); PersistentStore.commit(); }
private static void uploadToShare(BgReading bgReading, boolean is_follower) { if ((!is_follower) && (Pref.getBooleanDefaultFalse("share_upload"))) { if (JoH.ratelimit("sending-to-share-upload", 10)) { UserError.Log.d("ShareRest", "About to call ShareRest!!"); String receiverSn = Pref.getString("share_key", "SM00000000").toUpperCase(); BgUploader bgUploader = new BgUploader(xdrip.getAppContext()); bgUploader.upload(new ShareUploadPayload(receiverSn, bgReading)); } } } }