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