Merge pull request #92 from nightscout/adrian/reduce-warnings

Adrian/reduce warnings
This commit is contained in:
Milos Kozak 2020-11-30 08:32:41 +01:00 committed by GitHub
commit 853679e46c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 27 additions and 23 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="info.nightscout.androidaps">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
@ -71,6 +72,10 @@
<activity android:name=".activities.ProfileHelperActivity"
android:theme="@style/ProfileHelperAppTheme" />
<activity android:name=".activities.StatsActivity" />
<activity
android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
tools:replace="android:launchMode"
android:launchMode="standard" />
<!-- Receive new BG readings from other local apps -->
<receiver

View file

@ -136,12 +136,12 @@ class MainActivity : NoSplashAppCompatActivity() {
if (it.recreate) recreate()
else setupViews()
setWakeLock()
}) { fabricPrivacy::logException }
}, fabricPrivacy::logException )
)
disposable.add(rxBus
.toObservable(EventPreferenceChange::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ processPreferenceChange(it) }) { fabricPrivacy::logException }
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException )
)
if (!sp.getBoolean(R.string.key_setupwizard_processed, false) && !isRunningRealPumpTest()) {
val intent = Intent(this, SetupWizardActivity::class.java)

View file

@ -151,7 +151,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
(savedInstanceState ?: arguments)?.let { bundle ->
if (bundle.containsKey("id")) {
pluginId = bundle.getInt("id") ?: -1
pluginId = bundle.getInt("id")
}
if (bundle.containsKey("filter")) {
filter = bundle.getString("filter") ?: ""

View file

@ -168,7 +168,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
if (it.cause is EventCustomCalculationFinished) {
updateGUI("EventAutosensCalculationFinished", bgOnly = false)
}
}) { fabricPrivacy::logException }
}, fabricPrivacy::logException )
)
disposable.add(rxBus
.toObservable(EventAutosensBgLoaded::class.java)
@ -178,12 +178,12 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
if (it.cause is EventCustomCalculationFinished) {
updateGUI("EventAutosensCalculationFinished", bgOnly = true)
}
}) { fabricPrivacy::logException }
}, fabricPrivacy::logException )
)
disposable.add(rxBus
.toObservable(EventIobCalculationProgress::class.java)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ overview_iobcalculationprogess?.text = it.progress }) { fabricPrivacy::logException }
.subscribe({ overview_iobcalculationprogess?.text = it.progress }, fabricPrivacy::logException )
)
disposable.add(rxBus
.toObservable(EventRefreshOverview::class.java)
@ -193,7 +193,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
prepareGraphs()
updateGUI("EventRefreshOverview", bgOnly = false)
}
}) { fabricPrivacy::logException }
}, fabricPrivacy::logException )
)
if (start == 0L) {
// set start of current day

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.plugins.general.maintenance
import android.Manifest
import androidx.appcompat.app.AppCompatActivity
import android.bluetooth.BluetoothAdapter
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.provider.Settings
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
@ -21,6 +21,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
import info.nightscout.androidaps.utils.AndroidPermission
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
@ -43,12 +44,6 @@ import javax.inject.Singleton
* Created by mike on 03.07.2016.
*/
private const val REQUEST_EXTERNAL_STORAGE = 1
private val PERMISSIONS_STORAGE = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
@Singleton
class ImportExportPrefs @Inject constructor(
private var log: AAPSLogger,
@ -57,6 +52,7 @@ class ImportExportPrefs @Inject constructor(
private val buildHelper: BuildHelper,
private val rxBus: RxBusWrapper,
private val passwordCheck: PasswordCheck,
private val androidPermission: AndroidPermission,
private val classicPrefsFormat: ClassicPrefsFormat,
private val encryptedPrefsFormat: EncryptedPrefsFormat,
private val prefFileList: PrefFileListProvider
@ -73,12 +69,15 @@ class ImportExportPrefs @Inject constructor(
}
fun verifyStoragePermissions(fragment: Fragment, onGranted: Runnable) {
fragment.context?.let {
val permission = ContextCompat.checkSelfPermission(it,
fragment.context?.let { ctx ->
val permission = ContextCompat.checkSelfPermission(ctx,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
fragment.requestPermissions(PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE)
fragment.activity?.let {
androidPermission.askForPermission(it, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE), AndroidPermission.CASE_STORAGE)
}
} else {
onGranted.run()
}

View file

@ -43,8 +43,8 @@ class OpenHumansAPI(
.toSingle()
.map { response ->
response.use { _ ->
val body = response.body
val jsonObject = body?.let { JSONObject(it.string()) }
val responseBody = response.body
val jsonObject = responseBody?.let { JSONObject(it.string()) }
if (!response.isSuccessful) throw OHHttpException(response.code, response.message, jsonObject?.getString("error"))
if (jsonObject == null) throw OHHttpException(response.code, response.message, "No body")
if (!jsonObject.has("expires_in")) throw OHMissingFieldException("expires_in")

View file

@ -564,7 +564,7 @@ class OpenHumansUploader @Inject constructor(
creationDate = uploadDate.time
),
content = bytes,
highestQueueId = items.map { it.id }.max()
highestQueueId = items.map { it.id }.maxOrNull()
))
}

View file

@ -44,7 +44,7 @@ class DummyService : DaggerService() {
.subscribe({
aapsLogger.debug(LTag.CORE, "EventAppExit received")
stopSelf()
}) { fabricPrivacy::logException }
}, fabricPrivacy::logException )
)
}

View file

@ -46,7 +46,7 @@ class AndroidPermission @Inject constructor(
private var permission_battery_optimization_failed = false
@SuppressLint("BatteryLife")
private fun askForPermission(activity: FragmentActivity, permission: Array<String>, requestCode: Int) {
fun askForPermission(activity: FragmentActivity, permission: Array<String>, requestCode: Int) {
var test = false
var testBattery = false
for (s in permission) {

View file

@ -209,7 +209,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
}
private fun displayNotConfiguredDialog() {
context?.let {
context.let {
UIRunnable(Runnable {
OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning),
resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null)