public static int getCol(final X color) { if (!the_cache.containsKey(color)) { try { the_cache.put(color, Pref.getInt(color.internalName, 0xABCDEF)); } catch (ClassCastException e) { UserError.Log.wtf(TAG, "Cannot set initial value - preference type likely wrong for: " + color.internalName + " " + e); the_cache.put(color, Color.GRAY); } if (debug) UserError.Log.d(TAG, "Setting cache for color: " + color.internalName + " / " + Pref.getInt(color.internalName, 1234)); } return the_cache.get(color); }
public static void setG6bareBones() { Pref.setBoolean("using_g6", true); // TODO add initiate bonding true in case gets disabled?? final int battery_warning_level = Pref.getStringToInt("g5-battery-warning-level", G5_LOW_BATTERY_WARNING_DEFAULT); if (battery_warning_level == G5_LOW_BATTERY_WARNING_DEFAULT) { Pref.setString("g5-battery-warning-level", "" + G6_LOW_BATTERY_WARNING_DEFAULT); } }
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(); }
private boolean inTimeFrame() { int startMinutes = Pref.getInt("missed_readings_start", 0); int endMinutes = Pref.getInt("missed_readings_end", 0); boolean allDay = Pref.getBoolean("missed_readings_all_day", true); return AlertType.s_in_time_frame(allDay, startMinutes, endMinutes); }
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); }
private synchronized void markDeviceAsSuccessful(BluetoothGatt gatt) { if (!Pref.getStringDefaultBlank("selected_bluetooth_meter_address").equals(mLastConnectedDeviceAddress)) { Pref.setString("selected_bluetooth_meter_address", mLastConnectedDeviceAddress); Pref.setString("selected_bluetooth_meter_info", mLastManufacturer + " " + mLastConnectedDeviceAddress); Pref.setBoolean("bluetooth_meter_enabled", true); // auto-enable the setting JoH.static_toast_long("Success with: " + mLastConnectedDeviceAddress + " Enabling auto-start"); if (gatt != null) sendDeviceUpdate(gatt.getDevice(), true); // force update } }
@Test public void test_PrefTest() { // test getStringToInt assertThat("empty defaults", Pref.getStringToInt("text-integer", 300), is(300)); Pref.setString("text-integer", "123"); assertThat("set correctly", Pref.getStringToInt("text-integer", 300), is(123)); Pref.setString("text-integer", "ouch"); assertThat("bad string defaults", Pref.getStringToInt("text-integer", 300), is(300)); Pref.setString("text-integer", ""); assertThat("empty string defaults", Pref.getStringToInt("text-integer", 300), is(300)); }
public static void setG6Defaults() { Pref.setBoolean("use_ob1_g5_collector_service", true); Pref.setBoolean("ob1_g5_use_transmitter_alg", true); Pref.setBoolean("ob1_g5_fallback_to_xdrip", false); Pref.setBoolean("display_glucose_from_plugin", false); setG6bareBones(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_toggle_historystats) { Pref.setBoolean("show_history_stats", !Pref.getBoolean("show_history_stats", true)); invalidateOptionsMenu(); setupCharts(); return true; } return super.onOptionsItemSelected(item); }
static public long getOtherAlertReraiseSec(Context context, String alertName) { boolean enableAlertsReraise = Pref.getBoolean(alertName + "_enable_alerts_reraise", false); if (enableAlertsReraise) { return Pref.getStringToInt(alertName + "_reraise_sec", 60); } else { return 60 * getOtherAlertSnoozeMinutes(PreferenceManager.getDefaultSharedPreferences(context), alertName); } }
public static long getLong(final String pref, final long def) { initializePrefs(); if (prefs != null) { return prefs.getLong(pref, def); } return def; }
public void onClick(DialogInterface dialog, int whichButton) { final String text = edt.getText().toString().trim(); Pref.setString(setting, text); if (postRun != null) postRun.run(); } });
static public long getOtherAlertSnoozeMinutes(SharedPreferences prefs, String alertName) { int defaultSnooze = Pref.getStringToInt("other_alerts_snooze", 20); return Pref.getStringToInt(alertName + "_snooze", defaultSnooze); }
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); } }
private static boolean addChannelGroup() { // If notifications are grouped, the BG number icon doesn't update if (Pref.getBooleanDefaultFalse("use_number_icon")) { return false; } return Pref.getBooleanDefaultFalse("notification_channels_grouping"); }
private static void sendToWear() { if ((Pref.getBooleanDefaultFalse("wear_sync")) && !Home.get_forced_wear()) {//KS not necessary since MongoSendTask sends UploaderQueue.newEntry BG to WatchUpdaterService.sendWearUpload JoH.startService(WatchUpdaterService.class); // I don't think this wakelock is really needed anymore if (Pref.getBoolean("excessive_wakelocks", false)) { JoH.getWakeLock("wear-quickFix3", 15000); // dangling wakelock } } }
public static void startIfEnabled() { if (Pref.getBoolean("bluetooth_meter_enabled", false)) { final String meter_address = Pref.getStringDefaultBlank("selected_bluetooth_meter_address"); if (meter_address.length() > 5) { if (JoH.pratelimit("bluetooth-glucose-immortality", 10)) { UserError.Log.d(TAG, "Starting Service"); start_service(meter_address); } else { UserError.Log.e(TAG, "Not starting due to rate limit"); } } } }
public static boolean isLimitter() { return Pref.getStringDefaultBlank("dex_collection_method").equals("LimiTTer"); }