code cleanup

This commit is contained in:
Milos Kozak 2022-03-30 20:54:06 +02:00
parent 0ec2a498c4
commit 0f67f74c96
18 changed files with 29 additions and 38 deletions

View file

@ -372,7 +372,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
if (sp.getString(pref.key, "").startsWith("hmac:")) {
pref.summary = "******"
} else {
if (pref.getKey().contains("pin")) {
if (pref.key.contains("pin")) {
pref.summary = rh.gs(R.string.pin_not_set)
}else {
pref.summary = rh.gs(R.string.password_not_set)

View file

@ -65,7 +65,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.getItemId()) {
when (item.itemId) {
android.R.id.home -> {
onBackPressed()
return true

View file

@ -51,7 +51,7 @@ class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector)
aapsLogger.error(LTag.APS, "Error parsing 'deliverAt' date: $date", e)
}
}
if (result.has("variable_sens")) variableSens = result.getDouble("variable_sens");
if (result.has("variable_sens")) variableSens = result.getDouble("variable_sens")
} catch (e: JSONException) {
aapsLogger.error(LTag.APS, "Error parsing determine-basal result JSON", e)
}

View file

@ -120,7 +120,7 @@ class SendToDataLayerThread extends AsyncTask<DataMap,Void,Void> {
}
state = 0;
} catch (Exception e) {
Log.e(TAG, logPrefix + "Got exception in sendToWear: " + e.toString());
Log.e(TAG, logPrefix + "Got exception in sendToWear: " + e);
} finally {
lastlock = 0;
lock.unlock();

View file

@ -574,17 +574,17 @@ class IobCobCalculatorPlugin @Inject constructor(
override fun getTempBasalIncludingConvertedExtended(timestamp: Long): TemporaryBasal? {
val tb = repository.getTemporaryBasalActiveAt(timestamp).blockingGet()
if (tb is ValueWrapper.Existing) return tb.value
return getConvertedExtended(timestamp);
return getConvertedExtended(timestamp)
}
override fun getTempBasalIncludingConvertedExtendedForRange(startTime: Long, endTime: Long, calculationStep: Long): Map<Long, TemporaryBasal?> {
val tempBasals = HashMap<Long, TemporaryBasal?>();
val tempBasals = HashMap<Long, TemporaryBasal?>()
val tbs = repository.getTemporaryBasalsDataActiveBetweenTimeAndTime(startTime, endTime).blockingGet()
for (t in startTime until endTime step calculationStep) {
val tb = tbs.firstOrNull { basal -> basal.timestamp <= t && (basal.timestamp + basal.duration) > t }
tempBasals[t] = tb ?: getConvertedExtended(t)
}
return tempBasals;
return tempBasals
}
override fun calculateAbsoluteIobFromBaseBasals(toTime: Long): IobTotal {

View file

@ -52,10 +52,6 @@ class VirtualPumpFragment : DaggerFragment() {
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
@Synchronized
override fun onResume() {
super.onResume()

View file

@ -109,25 +109,25 @@ public class ReadHistoryCommand extends BaseCommand {
if (!history.bolusHistory.isEmpty()) {
aapsLogger.debug(LTag.PUMP, "Read bolus history (" + history.bolusHistory.size() + "):");
for (Bolus bolus : history.bolusHistory) {
aapsLogger.debug(LTag.PUMP, new Date(bolus.timestamp) + ": " + bolus.toString());
aapsLogger.debug(LTag.PUMP, new Date(bolus.timestamp) + ": " + bolus);
}
}
if (!history.pumpAlertHistory.isEmpty()) {
aapsLogger.debug(LTag.PUMP, "Read error history (" + history.pumpAlertHistory.size() + "):");
for (PumpAlert pumpAlert : history.pumpAlertHistory) {
aapsLogger.debug(LTag.PUMP, new Date(pumpAlert.timestamp) + ": " + pumpAlert.toString());
aapsLogger.debug(LTag.PUMP, new Date(pumpAlert.timestamp) + ": " + pumpAlert);
}
}
if (!history.tddHistory.isEmpty()) {
aapsLogger.debug(LTag.PUMP, "Read TDD history (" + history.tddHistory.size() + "):");
for (Tdd tdd : history.tddHistory) {
aapsLogger.debug(LTag.PUMP, new Date(tdd.timestamp) + ": " + tdd.toString());
aapsLogger.debug(LTag.PUMP, new Date(tdd.timestamp) + ": " + tdd);
}
}
if (!history.tbrHistory.isEmpty()) {
aapsLogger.debug(LTag.PUMP, "Read TBR history (" + history.tbrHistory.size() + "):");
for (Tbr tbr : history.tbrHistory) {
aapsLogger.debug(LTag.PUMP, new Date(tbr.timestamp) + ": " + tbr.toString());
aapsLogger.debug(LTag.PUMP, new Date(tbr.timestamp) + ": " + tbr);
}
}

View file

@ -163,10 +163,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
double x = graphWidth * ratX;
// overdraw
boolean overdraw = false;
if (x > graphWidth) { // end right
overdraw = true;
}
boolean overdraw = x > graphWidth;
// end right
if (y < 0) { // end bottom
overdraw = true;
}

View file

@ -57,7 +57,7 @@ class MedtronicHistoryDataUTest : TestBase() {
val fileText = ClassLoader.getSystemResource("tbr_data.json").readText()
val listType: Type = object : TypeToken<MutableList<PumpHistoryEntry?>?>() {}.getType()
val listType: Type = object : TypeToken<MutableList<PumpHistoryEntry?>?>() {}.type
val yourClassList: MutableList<PumpHistoryEntry> = gson.fromJson(fileText, listType)
for (pumpHistoryEntry in yourClassList) {
@ -100,7 +100,7 @@ class MedtronicHistoryDataUTest : TestBase() {
val fileText = ClassLoader.getSystemResource("tbr_data_special.json").readText()
val listType: Type = object : TypeToken<MutableList<PumpHistoryEntry?>?>() {}.getType()
val listType: Type = object : TypeToken<MutableList<PumpHistoryEntry?>?>() {}.type
val yourClassList: MutableList<PumpHistoryEntry> = gson.fromJson(fileText, listType)
for (pumpHistoryEntry in yourClassList) {

View file

@ -34,7 +34,7 @@ class ErosHistoryTest {
@Test
fun testInsertionAndRetrieval() {
var history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L);
var history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L)
assert(history.isEmpty())
val type = PodHistoryEntryType.SET_BOLUS.code.toLong()
@ -42,7 +42,7 @@ class ErosHistoryTest {
erosHistory.create(entity)
erosHistory.create(ErosHistoryRecordEntity(3000L, PodHistoryEntryType.CANCEL_BOLUS.code.toLong()))
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L);
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L)
assert(history.size == 2)
assert(type.equals(history.first().podEntryTypeCode))

View file

@ -67,10 +67,7 @@ data class PumpDbEntryBolus(override var temporaryId: Long,
detailedBolusInfo: DetailedBolusInfo) : this(temporaryId, date, pumpType, serialNumber, null,
detailedBolusInfo.insulin,
detailedBolusInfo.carbs,
detailedBolusInfo.bolusType) {
}
detailedBolusInfo.bolusType)
}

View file

@ -7,5 +7,4 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data;
public enum RLMessageType {
PowerOn, // for powering on the pump (wakeup)
ReadSimpleData, // for checking if pump is readable (for Medtronic we can use GetModel)
;
}

View file

@ -7,5 +7,4 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs;
public enum RLMessageType {
PowerOn, // for powering on the pump (wakeup)
ReadSimpleData, // for checking if pump is readable (for Medtronic we can use GetModel)
;
}

View file

@ -22,7 +22,7 @@ import info.nightscout.androidaps.interaction.utils.WearUtil;
*/
public class RawDisplayData {
private WearUtil wearUtil;
private final WearUtil wearUtil;
public RawDisplayData(WearUtil wearUtil) {
this.wearUtil = wearUtil;

View file

@ -26,10 +26,10 @@ import info.nightscout.shared.logging.LTag;
@Singleton
public class Persistence {
private Context context;
private AAPSLogger aapsLogger;
private WearUtil wearUtil;
private SharedPreferences preferences;
private final Context context;
private final AAPSLogger aapsLogger;
private final WearUtil wearUtil;
private final SharedPreferences preferences;
private final String COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY =
"info.nightscout.androidaps.complications.COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY";

View file

@ -76,7 +76,7 @@ public class WearUtil {
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AAPS::" + name);
wl.acquire(millis);
if (debug_wakelocks)
aapsLogger.debug(LTag.WEAR, "getWakeLock: " + name + " " + wl.toString());
aapsLogger.debug(LTag.WEAR, "getWakeLock: " + name + " " + wl);
return wl;
}

View file

@ -3,6 +3,6 @@ package info.nightscout.androidaps.tile
class TempTargetTileService : TileBase() {
override val resourceVersion = "TempTargetTileService"
override val source = TempTargetSource;
override val source = TempTargetSource
}

View file

@ -18,7 +18,6 @@ import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.wearable.view.WatchViewStub;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowInsets;
@ -49,6 +48,8 @@ import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.data.RawDisplayData;
import info.nightscout.androidaps.interaction.utils.Persistence;
import info.nightscout.androidaps.interaction.utils.WearUtil;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.shared.logging.LTag;
import lecho.lib.hellocharts.view.LineChartView;
/**
@ -61,6 +62,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
@Inject WearUtil wearUtil;
@Inject Persistence persistence;
@Inject AAPSLogger aapsLogger;
public final static IntentFilter INTENT_FILTER;
@ -382,7 +384,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime) {
boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false);
if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) {
Log.i("hourlyVibratePref", "true --> " + newTime.toString());
aapsLogger.info(LTag.WEAR, "hourlyVibratePref", "true --> " + newTime);
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
long[] vibrationPattern = {0, 150, 125, 100};
vibrator.vibrate(vibrationPattern, -1);