Resolve warnings
This commit is contained in:
parent
2034774b39
commit
d18c05205c
41 changed files with 90 additions and 114 deletions
|
@ -95,7 +95,6 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Iconify.with(FontAwesomeModule())
|
||||
|
@ -361,7 +360,6 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
// Correct place for calling setUserStats() would be probably MainApp
|
||||
// but we need to have it called at least once a day. Thus this location
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun setUserStats() {
|
||||
if (!fabricPrivacy.fabricEnabled()) return
|
||||
val closedLoopEnabled = if (constraintChecker.isClosedLoopAllowed().value()) "CLOSED_LOOP_ENABLED" else "CLOSED_LOOP_DISABLED"
|
||||
|
|
|
@ -151,7 +151,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
val dm = DisplayMetrics()
|
||||
windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||
display?.getRealMetrics(dm)
|
||||
else
|
||||
@Suppress("DEPRECATION") windowManager.defaultDisplay.getMetrics(dm)
|
||||
|
||||
|
||||
axisWidth = if (dm.densityDpi <= 120) 3 else if (dm.densityDpi <= 160) 10 else if (dm.densityDpi <= 320) 35 else if (dm.densityDpi <= 420) 50 else if (dm.densityDpi <= 560) 70 else 80
|
||||
binding.bgGraph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
|
||||
|
|
|
@ -7,10 +7,8 @@ import javax.inject.Inject
|
|||
class RequestDexcomPermissionActivity : DialogAppCompatActivity() {
|
||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private val requestCode = "AndroidAPS <3".map { it.code }.sum()
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestPermissions(arrayOf(DexcomPlugin.PERMISSION), requestCode)
|
||||
|
|
|
@ -190,7 +190,6 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
|||
|
||||
override fun getItemCount(): Int = tempBasalList.size
|
||||
|
||||
@Deprecated("remove remove functionality after finish")
|
||||
inner class TempBasalsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
val binding = TreatmentsTempbasalsItemBinding.bind(itemView)
|
||||
|
|
|
@ -58,7 +58,6 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
@ -91,7 +90,6 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun updateGUI() {
|
||||
if (_binding == null) return
|
||||
openAPSAMAPlugin.lastAPSResult?.let { lastAPSResult ->
|
||||
|
|
|
@ -59,7 +59,6 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += rxBus
|
||||
|
@ -91,7 +90,6 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun updateGUI() {
|
||||
if (_binding == null) return
|
||||
openAPSSMBPlugin.lastAPSResult?.let { lastAPSResult ->
|
||||
|
|
|
@ -100,7 +100,6 @@ class ObjectivesPlugin @Inject constructor(
|
|||
sp.putBoolean(R.string.key_objectiveusescale, false)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun completeObjectives(activity: FragmentActivity, request: String) {
|
||||
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
|
||||
var url = sp.getString(R.string.key_nsclientinternal_url, "").lowercase(Locale.getDefault())
|
||||
|
|
|
@ -29,7 +29,6 @@ class Objective3 @Inject constructor(injector: HasAndroidInjector) : Objective(i
|
|||
override fun specialActionEnabled(): Boolean =
|
||||
nsClientPlugin.nsClientService?.isConnected == true && nsClientPlugin.nsClientService?.hasWriteAuth == true
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun specialAction(activity: FragmentActivity, input: String) {
|
||||
objectivesPlugin.completeObjectives(activity, input)
|
||||
}
|
||||
|
|
|
@ -152,7 +152,6 @@ class SignatureVerifierPlugin @Inject constructor(
|
|||
return sb.toString()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun singleCharUnMap(shortHash: String): String {
|
||||
val array = ByteArray(shortHash.length)
|
||||
val sb = StringBuilder()
|
||||
|
|
|
@ -115,7 +115,10 @@ class ActionsFragment : DaggerFragment() {
|
|||
savedInstanceState: Bundle?): View? {
|
||||
//check screen width
|
||||
dm = DisplayMetrics()
|
||||
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||
activity?.display?.getRealMetrics(dm)
|
||||
else
|
||||
@Suppress("DEPRECATION") activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
|
||||
val screenWidth = dm.widthPixels
|
||||
val screenHeight = dm.heightPixels
|
||||
|
|
|
@ -67,7 +67,6 @@ class FoodFragment : DaggerFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
@ -129,7 +128,6 @@ class FoodFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(rxBus
|
||||
|
@ -141,7 +139,6 @@ class FoodFragment : DaggerFragment() {
|
|||
swapAdapter()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun swapAdapter() {
|
||||
disposable += repository
|
||||
.getFoodData()
|
||||
|
@ -202,7 +199,6 @@ class FoodFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun filterData() {
|
||||
val textFilter = binding.filter.text.toString()
|
||||
val categoryFilter = binding.category.selectedItem?.toString()
|
||||
|
|
|
@ -73,7 +73,7 @@ class MaintenancePlugin @Inject constructor(
|
|||
val files = logDir.listFiles { _: File?, name: String ->
|
||||
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))
|
||||
}
|
||||
if (files.isEmpty()) return
|
||||
if (files == null || files.isEmpty()) return
|
||||
Arrays.sort(files) { f1: File, f2: File -> f2.name.compareTo(f1.name) }
|
||||
var delFiles = listOf(*files)
|
||||
val amount = sp.getInt(R.string.key_logshipper_amount, keep)
|
||||
|
@ -109,7 +109,7 @@ class MaintenancePlugin @Inject constructor(
|
|||
(name.startsWith("AndroidAPS")
|
||||
&& (name.endsWith(".log")
|
||||
|| name.endsWith(".zip") && !name.endsWith(loggerUtils.suffix)))
|
||||
}
|
||||
} ?: emptyArray()
|
||||
Arrays.sort(files) { f1: File, f2: File -> f2.name.compareTo(f1.name) }
|
||||
val result = listOf(*files)
|
||||
var toIndex = amount
|
||||
|
|
|
@ -112,7 +112,6 @@ class NSClientService : DaggerService() {
|
|||
var latestDateInReceivedData: Long = 0
|
||||
|
||||
@SuppressLint("WakelockTimeout")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
wakeLock = (getSystemService(Context.POWER_SERVICE) as PowerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService")
|
||||
|
@ -236,7 +235,6 @@ class NSClientService : DaggerService() {
|
|||
return START_STICKY
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun initialize() {
|
||||
dataCounter = 0
|
||||
readPreferences()
|
||||
|
@ -651,7 +649,6 @@ class NSClientService : DaggerService() {
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun restart() {
|
||||
destroy()
|
||||
initialize()
|
||||
|
|
|
@ -138,7 +138,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
_binding = it
|
||||
//check screen width
|
||||
dm = DisplayMetrics()
|
||||
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||
activity?.display?.getRealMetrics(dm)
|
||||
else
|
||||
@Suppress("DEPRECATION") activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
|
@ -64,12 +64,12 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
|||
val manager = fragmentManager
|
||||
val editQuickWizardDialog = EditQuickWizardDialog()
|
||||
val bundle = Bundle()
|
||||
bundle.putInt("position", adapterPosition)
|
||||
bundle.putInt("position", bindingAdapterPosition)
|
||||
editQuickWizardDialog.arguments = bundle
|
||||
editQuickWizardDialog.show(manager, "EditQuickWizardDialog")
|
||||
}
|
||||
removeButton.setOnClickListener {
|
||||
quickWizard.remove(adapterPosition)
|
||||
quickWizard.remove(bindingAdapterPosition)
|
||||
rxBus.send(EventQuickWizardChange())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun doWork(): Result {
|
||||
val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1))
|
||||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
|
@ -224,7 +223,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
return false
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun processSms(receivedSms: Sms) {
|
||||
if (!isEnabled(PluginType.GENERAL)) {
|
||||
aapsLogger.debug(LTag.SMS, "Ignoring SMS. Plugin disabled.")
|
||||
|
@ -341,7 +339,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processLOOP(divided: Array<String>, receivedSms: Sms) {
|
||||
when (divided[1].uppercase(Locale.getDefault())) {
|
||||
"DISABLE", "STOP" -> {
|
||||
|
@ -470,7 +467,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processNSCLIENT(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "RESTART") {
|
||||
rxBus.send(EventNSClientRestart())
|
||||
|
@ -480,7 +476,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processHELP(divided: Array<String>, receivedSms: Sms) {
|
||||
when {
|
||||
divided.size == 1 -> {
|
||||
|
@ -567,7 +562,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processPROFILE(divided: Array<String>, receivedSms: Sms) { // load profiles
|
||||
val anInterface = activePlugin.activeProfileSource
|
||||
val store = anInterface.profile
|
||||
|
@ -621,7 +615,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
receivedSms.processed = true
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processBASAL(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
|
@ -738,7 +731,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processEXTENDED(divided: Array<String>, receivedSms: Sms) {
|
||||
if (divided[1].uppercase(Locale.getDefault()) == "CANCEL" || divided[1].uppercase(Locale.getDefault()) == "STOP") {
|
||||
val passCode = generatePassCode()
|
||||
|
@ -905,7 +897,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
return retVal
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processCARBS(divided: Array<String>, receivedSms: Sms) {
|
||||
var grams = SafeParse.stringToInt(divided[1])
|
||||
var time = dateUtil.now()
|
||||
|
@ -949,7 +940,6 @@ class SmsCommunicatorPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun processTARGET(divided: Array<String>, receivedSms: Sms) {
|
||||
val isMeal = divided[1].equals("MEAL", ignoreCase = true)
|
||||
val isActivity = divided[1].equals("ACTIVITY", ignoreCase = true)
|
||||
|
|
|
@ -357,16 +357,18 @@ class LocalProfilePlugin @Inject constructor(
|
|||
try {
|
||||
for (i in 0 until numOfProfiles) {
|
||||
profiles[i].run {
|
||||
val profile = JSONObject()
|
||||
profile.put("dia", dia)
|
||||
profile.put("carbratio", ic)
|
||||
profile.put("sens", isf)
|
||||
profile.put("basal", basal)
|
||||
profile.put("target_low", targetLow)
|
||||
profile.put("target_high", targetHigh)
|
||||
profile.put("units", if (mgdl) Constants.MGDL else Constants.MMOL)
|
||||
profile.put("timezone", TimeZone.getDefault().id)
|
||||
store.put(name, profile)
|
||||
name?.let { name ->
|
||||
val profile = JSONObject()
|
||||
profile.put("dia", dia)
|
||||
profile.put("carbratio", ic)
|
||||
profile.put("sens", isf)
|
||||
profile.put("basal", basal)
|
||||
profile.put("target_low", targetLow)
|
||||
profile.put("target_high", targetHigh)
|
||||
profile.put("units", if (mgdl) Constants.MGDL else Constants.MMOL)
|
||||
profile.put("timezone", TimeZone.getDefault().id)
|
||||
store.put(name, profile)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (numOfProfiles > 0) json.put("defaultProfile", currentProfile()?.name)
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.virtual
|
|||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -10,6 +11,7 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.databinding.VirtualpumpFragmentBinding
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange
|
||||
import info.nightscout.androidaps.extensions.toStringFull
|
||||
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
|
@ -17,7 +19,6 @@ import info.nightscout.androidaps.plugins.pump.virtual.events.EventVirtualPumpUp
|
|||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.extensions.toStringFull
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -37,15 +38,8 @@ class VirtualPumpFragment : DaggerFragment() {
|
|||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
private val loopHandler = Handler()
|
||||
private lateinit var refreshLoop: Runnable
|
||||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
activity?.runOnUiThread { updateGui() }
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
}
|
||||
}
|
||||
private lateinit var handler: Handler
|
||||
|
||||
private var _binding: VirtualpumpFragmentBinding? = null
|
||||
|
||||
|
@ -58,7 +52,11 @@ class VirtualPumpFragment : DaggerFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
}
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += rxBus
|
||||
|
@ -73,7 +71,11 @@ class VirtualPumpFragment : DaggerFragment() {
|
|||
.toObservable(EventExtendedBolusChange::class.java)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
refreshLoop = Runnable {
|
||||
activity?.runOnUiThread { updateGui() }
|
||||
handler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
}
|
||||
handler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
updateGui()
|
||||
}
|
||||
|
||||
|
@ -81,7 +83,7 @@ class VirtualPumpFragment : DaggerFragment() {
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
loopHandler.removeCallbacks(refreshLoop)
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
|
|
@ -17,7 +17,6 @@ class JSONFormatter @Inject constructor(
|
|||
private val aapsLogger: AAPSLogger
|
||||
) {
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun format(jsonString: String?): Spanned {
|
||||
jsonString ?: return fromHtml("")
|
||||
val visitor = JsonVisitor(1, '\t')
|
||||
|
|
|
@ -15,6 +15,6 @@ object PercentageSplitter {
|
|||
*/
|
||||
fun pureName(name: String): String {
|
||||
val percentageMatch = splitPattern.matcher(name)
|
||||
return if (percentageMatch.find()) percentageMatch.group(1).trim { it <= ' ' } else name
|
||||
return if (percentageMatch.find()) (percentageMatch.group(1) as String).trim { it <= ' ' } else name
|
||||
}
|
||||
}
|
|
@ -164,6 +164,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:visibility="gone"
|
||||
android:text="@string/remove_button"
|
||||
android:textAlignment="viewEnd"
|
||||
android:textColor="@android:color/holo_orange_light" />
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.junit.Assert
|
|||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class SignatureVerifierPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -58,7 +58,6 @@ import java.util.*
|
|||
SmsManager::class, CommandQueue::class, LocalProfilePlugin::class, DateUtil::class,
|
||||
OneTimePassword::class, UserEntryLogger::class, LoopPlugin::class,
|
||||
AppRepository::class, DateUtil::class, AutosensDataStore::class)
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
|
|
|
@ -41,12 +41,12 @@ class SimpleItemTouchHelperCallback(private val mAdapter: ItemTouchHelperAdapter
|
|||
return false
|
||||
}
|
||||
// Notify the adapter of the move
|
||||
mAdapter.onItemMove(source.adapterPosition, target.adapterPosition)
|
||||
mAdapter.onItemMove(source.absoluteAdapterPosition, target.absoluteAdapterPosition)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, i: Int) { // Notify the adapter of the dismissal
|
||||
mAdapter.onItemDismiss(viewHolder.adapterPosition)
|
||||
mAdapter.onItemDismiss(viewHolder.absoluteAdapterPosition)
|
||||
}
|
||||
|
||||
override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
|
||||
|
|
|
@ -15,7 +15,7 @@ private fun getShiftedTimeSecs(originalSeconds: Int, timeShiftHours: Int): Int {
|
|||
|
||||
fun List<Block>.shiftBlock(multiplier: Double, timeShiftHours: Int): List<Block> {
|
||||
val newList = arrayListOf<Block>()
|
||||
for (hour in 0..23) newList.add(Block(1000 * 60 * 60, blockValueBySeconds(hour * 3600, multiplier, timeShiftHours)))
|
||||
for (hour in 0..23) newList.add(Block(1000L * 60 * 60, blockValueBySeconds(hour * 3600, multiplier, timeShiftHours)))
|
||||
for (i in newList.indices.reversed()) {
|
||||
if (i > 0)
|
||||
if (newList[i].amount == newList[i - 1].amount) {
|
||||
|
@ -29,7 +29,7 @@ fun List<Block>.shiftBlock(multiplier: Double, timeShiftHours: Int): List<Block>
|
|||
fun List<TargetBlock>.shiftTargetBlock(timeShiftHours: Int): List<TargetBlock> {
|
||||
val newList = arrayListOf<TargetBlock>()
|
||||
for (hour in 0..23)
|
||||
newList.add(TargetBlock(1000 * 60 * 60, lowTargetBlockValueBySeconds(hour * 3600, timeShiftHours), highTargetBlockValueBySeconds(hour * 3600, timeShiftHours)))
|
||||
newList.add(TargetBlock(1000L * 60 * 60, lowTargetBlockValueBySeconds(hour * 3600, timeShiftHours), highTargetBlockValueBySeconds(hour * 3600, timeShiftHours)))
|
||||
for (i in newList.indices.reversed()) {
|
||||
if (i > 0)
|
||||
if (newList[i].lowTarget == newList[i - 1].lowTarget && newList[i].highTarget == newList[i - 1].highTarget) {
|
||||
|
|
|
@ -18,7 +18,6 @@ fun ByteArray.toHex() : String{
|
|||
return result.toString()
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun String.hexStringToByteArray(): ByteArray {
|
||||
|
||||
val result = ByteArray(length / 2)
|
||||
|
@ -29,7 +28,7 @@ fun String.hexStringToByteArray(): ByteArray {
|
|||
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1])
|
||||
|
||||
val octet = firstIndex.shl(4).or(secondIndex)
|
||||
result.set(i.shr(1), octet.toByte())
|
||||
result[i.shr(1)] = octet.toByte()
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
@ -26,8 +26,7 @@ class PrefFileListProvider @Inject constructor(
|
|||
private val classicPrefsFormat: ClassicPrefsFormat,
|
||||
private val encryptedPrefsFormat: EncryptedPrefsFormat,
|
||||
private val storage: Storage,
|
||||
private val versionCheckerUtils: VersionCheckerUtils,
|
||||
context: Context
|
||||
private val versionCheckerUtils: VersionCheckerUtils
|
||||
) {
|
||||
|
||||
private val path = File(Environment.getExternalStorageDirectory().toString())
|
||||
|
|
|
@ -105,7 +105,6 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun loadPreferences(file: File, masterPassword: String?): Prefs {
|
||||
|
||||
val entries: MutableMap<String, String> = mutableMapOf()
|
||||
|
@ -214,7 +213,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
} catch (e: IOException) {
|
||||
throw PrefIOError(file.absolutePath)
|
||||
} catch (e: JSONException) {
|
||||
throw PrefFormatError("Mallformed preferences JSON file: $e")
|
||||
throw PrefFormatError("Malformed preferences JSON file: $e")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ class PinStrengthValidator(val _customErrorMessage: String?) : Validator(_custom
|
|||
|
||||
val regex = "[0-9]{3,6}".toRegex()
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun isValid(editText: EditText): Boolean {
|
||||
return try {
|
||||
val value = editText.text.toString()
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.File
|
|||
@PowerMockIgnore("javax.crypto.*")
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(File::class)
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
class EncryptedPrefsFormatTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -33,7 +33,7 @@ import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInf
|
|||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.T.Companion.mins
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
@ -141,7 +141,6 @@ class DanaRSPlugin @Inject constructor(
|
|||
commandQueue.readStatus("DeviceChanged", null)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun connect(reason: String) {
|
||||
aapsLogger.debug(LTag.PUMP, "RS connect from: $reason")
|
||||
if (danaRSService != null && mDeviceAddress != "" && mDeviceName != "") {
|
||||
|
@ -371,7 +370,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), mins(durationInMinutes.toLong()).msecs(), percentRate.toDouble(), false, tbrType, 0L, 0L))
|
||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), percentRate.toDouble(), false, tbrType, 0L, 0L))
|
||||
// Convert duration from minutes to hours
|
||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal $percentRate% for $durationInMinutes minutes (doLowTemp || doHighTemp)")
|
||||
result = if (percentRate == 0 && durationInMinutes > 30) {
|
||||
|
@ -418,7 +417,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set")
|
||||
return result
|
||||
}
|
||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), mins(durationInMinutes.toLong()).msecs(), percent.toDouble(), false, tbrType, 0L, 0L))
|
||||
temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes.toLong()).msecs(), percent.toDouble(), false, tbrType, 0L, 0L))
|
||||
val connectionOK: Boolean = if (durationInMinutes == 15 || durationInMinutes == 30) {
|
||||
danaRSService?.tempBasalShortDuration(percentAfterConstraint, durationInMinutes)
|
||||
?: false
|
||||
|
|
|
@ -33,7 +33,6 @@ class EnterPinActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
private lateinit var binding: DanarsEnterPinActivityBinding
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DanarsEnterPinActivityBinding.inflate(layoutInflater)
|
||||
|
|
|
@ -60,7 +60,6 @@ abstract class DanaRSPacketHistory(
|
|||
return request
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
override fun handleMessage(data: ByteArray) {
|
||||
val error: Int
|
||||
totalCount = 0
|
||||
|
|
|
@ -90,7 +90,6 @@ class BLEComm @Inject internal constructor(
|
|||
private var uartWrite: BluetoothGattCharacteristic? = null
|
||||
|
||||
@Synchronized
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun connect(from: String, address: String?): Boolean {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.")
|
||||
if (bluetoothManager == null) {
|
||||
|
@ -227,7 +226,6 @@ class BLEComm @Inject internal constructor(
|
|||
bluetoothGatt = null
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private val mGattCallback: BluetoothGattCallback = object : BluetoothGattCallback() {
|
||||
override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
|
||||
onConnectionStateChangeSynchronized(gatt, newState) // call it synchronized
|
||||
|
@ -384,7 +382,6 @@ class BLEComm @Inject internal constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
private fun readDataParsing(receivedData: ByteArray) {
|
||||
//aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< readDataParsing " + DanaRS_Packet.toHexString(receivedData))
|
||||
var packetIsValid = false
|
||||
|
@ -518,7 +515,6 @@ class BLEComm @Inject internal constructor(
|
|||
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
// 1st packet response
|
||||
private fun processConnectResponse(decryptedBuffer: ByteArray) {
|
||||
// response OK v1
|
||||
|
|
|
@ -97,7 +97,6 @@ class DanaRSService : DaggerService() {
|
|||
val isConnecting: Boolean
|
||||
get() = bleComm.isConnecting
|
||||
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun connect(from: String, address: String): Boolean {
|
||||
return bleComm.connect(from, address)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() {
|
|||
}
|
||||
|
||||
@Test
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
fun runTest() {
|
||||
val packet = DanaRSPacketHistoryAlarm(packetInjector, 0)
|
||||
|
||||
|
|
|
@ -851,6 +851,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
//aapsLogger.debug(LTag.PUMP, "HST: Target Date: " + targetDate);
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val responseTask2 = rileyLinkMedtronicService.medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
|
||||
arrayListOf(/*lastPumpHistoryEntry*/ null, targetDate) as? ArrayList<Any>?)
|
||||
if (debugHistory) aapsLogger.debug(LTag.PUMP, "HST: After task")
|
||||
|
|
|
@ -143,7 +143,7 @@ class MedtronicUIPostprocessor @Inject constructor(
|
|||
}
|
||||
|
||||
private fun postProcessSettings(uiTask: MedtronicUITask) {
|
||||
val settings = uiTask.result as? Map<String, PumpSettingDTO> ?: return
|
||||
@Suppress("UNCHECKED_CAST") val settings = uiTask.result as? Map<String, PumpSettingDTO> ?: return
|
||||
|
||||
medtronicUtil.settings = settings
|
||||
var checkValue: PumpSettingDTO
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.plugin.general.openhumans.dagger.BaseUrl
|
|||
import info.nightscout.androidaps.plugin.general.openhumans.dagger.ClientId
|
||||
import info.nightscout.androidaps.plugin.general.openhumans.dagger.ClientSecret
|
||||
import info.nightscout.androidaps.plugin.general.openhumans.dagger.RedirectUrl
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import okhttp3.*
|
||||
import okio.BufferedSink
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.NotificationManager
|
|||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.WindowManager
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
@ -225,16 +224,20 @@ class OpenHumansUploader @Inject internal constructor(
|
|||
tags.add("ApplicationInfo")
|
||||
|
||||
val deviceInfo = JSONObject()
|
||||
deviceInfo.put("brand", Build.BRAND)
|
||||
deviceInfo.put("device", Build.DEVICE)
|
||||
deviceInfo.put("manufacturer", Build.MANUFACTURER)
|
||||
deviceInfo.put("model", Build.MODEL)
|
||||
deviceInfo.put("product", Build.PRODUCT)
|
||||
deviceInfo.put("brand", android.os.Build.BRAND)
|
||||
deviceInfo.put("device", android.os.Build.DEVICE)
|
||||
deviceInfo.put("manufacturer", android.os.Build.MANUFACTURER)
|
||||
deviceInfo.put("model", android.os.Build.MODEL)
|
||||
deviceInfo.put("product", android.os.Build.PRODUCT)
|
||||
zos.writeFile("DeviceInfo.json", deviceInfo.toString().toByteArray())
|
||||
tags.add("DeviceInfo")
|
||||
|
||||
val displayMetrics = DisplayMetrics()
|
||||
(context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(displayMetrics)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||
context.display?.getRealMetrics(displayMetrics)
|
||||
else
|
||||
@Suppress("DEPRECATION") (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(displayMetrics)
|
||||
|
||||
val displayInfo = JSONObject()
|
||||
displayInfo.put("height", displayMetrics.heightPixels)
|
||||
displayInfo.put("width", displayMetrics.widthPixels)
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.sync
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission
|
||||
import com.thoughtworks.xstream.XStream
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.interfaces.PumpSync
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
@ -23,17 +21,20 @@ class PumpSyncStorage @Inject constructor(
|
|||
val aapsLogger: AAPSLogger
|
||||
) {
|
||||
|
||||
val pumpSyncStorageKey: String = "pump_sync_storage_xstream_v2"
|
||||
companion object {
|
||||
|
||||
const val pumpSyncStorageKey: String = "pump_sync_storage_xstream_v2"
|
||||
const val TBR: String = "TBR"
|
||||
const val BOLUS: String = "BOLUS"
|
||||
}
|
||||
|
||||
var pumpSyncStorage: MutableMap<String, MutableList<PumpDbEntry>> = mutableMapOf()
|
||||
var TBR: String = "TBR"
|
||||
var BOLUS: String = "BOLUS"
|
||||
var storageInitialized: Boolean = false
|
||||
var gson: Gson = GsonBuilder().create()
|
||||
var xstream: XStream = XStream()
|
||||
private var storageInitialized: Boolean = false
|
||||
private var xstream: XStream = XStream()
|
||||
|
||||
init {
|
||||
initStorage()
|
||||
cleanOldStorage();
|
||||
cleanOldStorage()
|
||||
}
|
||||
|
||||
fun initStorage() {
|
||||
|
@ -43,10 +44,11 @@ class PumpSyncStorage @Inject constructor(
|
|||
var loaded = false
|
||||
|
||||
if (sp.contains(pumpSyncStorageKey)) {
|
||||
val jsonData: String = sp.getString(pumpSyncStorageKey, "");
|
||||
val jsonData: String = sp.getString(pumpSyncStorageKey, "")
|
||||
|
||||
if (jsonData.isNotBlank()) {
|
||||
xstream.addPermission(AnyTypePermission.ANY)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
pumpSyncStorage = xstream.fromXML(jsonData, MutableMap::class.java) as MutableMap<String, MutableList<PumpDbEntry>>
|
||||
|
||||
aapsLogger.debug(LTag.PUMP, String.format("Loading Pump Sync Storage: boluses=%d, tbrs=%d.", pumpSyncStorage[BOLUS]!!.size, pumpSyncStorage[TBR]!!.size))
|
||||
|
@ -69,7 +71,7 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun cleanOldStorage(): Unit {
|
||||
private fun cleanOldStorage() {
|
||||
val oldSpKeys = setOf("pump_sync_storage", "pump_sync_storage_xstream")
|
||||
|
||||
for (oldSpKey in oldSpKeys) {
|
||||
|
@ -78,16 +80,16 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun isStorageEmpty(): Boolean {
|
||||
private fun isStorageEmpty(): Boolean {
|
||||
return pumpSyncStorage[BOLUS]!!.isEmpty() && pumpSyncStorage[TBR]!!.isEmpty()
|
||||
}
|
||||
|
||||
fun getBoluses(): MutableList<PumpDbEntry> {
|
||||
return pumpSyncStorage[BOLUS]!!;
|
||||
return pumpSyncStorage[BOLUS]!!
|
||||
}
|
||||
|
||||
fun getTBRs(): MutableList<PumpDbEntry> {
|
||||
return pumpSyncStorage[TBR]!!;
|
||||
return pumpSyncStorage[TBR]!!
|
||||
}
|
||||
|
||||
fun addBolusWithTempId(detailedBolusInfo: DetailedBolusInfo, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
|
||||
|
@ -135,11 +137,11 @@ class PumpSyncStorage @Inject constructor(
|
|||
}
|
||||
|
||||
fun addTemporaryBasalRateWithTempId(temporaryBasal: PumpDbEntryTBR, writeToInternalHistory: Boolean, creator: PumpSyncEntriesCreator): Boolean {
|
||||
val timenow: Long = System.currentTimeMillis()
|
||||
val temporaryId = creator.generateTempId(timenow)
|
||||
val timeNow: Long = System.currentTimeMillis()
|
||||
val temporaryId = creator.generateTempId(timeNow)
|
||||
|
||||
val response = pumpSync.addTemporaryBasalWithTempId(
|
||||
timenow,
|
||||
timeNow,
|
||||
temporaryBasal.rate,
|
||||
(temporaryBasal.durationInSeconds * 1000L),
|
||||
temporaryBasal.isAbsolute,
|
||||
|
@ -151,12 +153,12 @@ class PumpSyncStorage @Inject constructor(
|
|||
if (response && writeToInternalHistory) {
|
||||
val innerList: MutableList<PumpDbEntry> = pumpSyncStorage[TBR]!!
|
||||
|
||||
innerList.add(PumpDbEntry(temporaryId, timenow, creator.model(), creator.serialNumber(), null, temporaryBasal))
|
||||
innerList.add(PumpDbEntry(temporaryId, timeNow, creator.model(), creator.serialNumber(), null, temporaryBasal))
|
||||
pumpSyncStorage[BOLUS] = innerList
|
||||
saveStorage()
|
||||
}
|
||||
|
||||
return response;
|
||||
return response
|
||||
}
|
||||
|
||||
fun removeBolusWithTemporaryId(temporaryId: Long) {
|
||||
|
|
Loading…
Reference in a new issue