fix Runnables after protection check, cleanup
This commit is contained in:
parent
8858d3b5f9
commit
bba7adc9aa
16 changed files with 70 additions and 71 deletions
|
@ -47,7 +47,6 @@ import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionChec
|
|||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
||||
import info.nightscout.androidaps.utils.AndroidPermission
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.LocaleHelper
|
||||
|
@ -58,6 +57,8 @@ import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|||
import info.nightscout.androidaps.utils.resources.IconsProvider
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
@ -160,12 +161,9 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
||||
Runnable {
|
||||
OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() })
|
||||
},
|
||||
Runnable {
|
||||
OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() })
|
||||
})
|
||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }),
|
||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) })
|
||||
)
|
||||
}
|
||||
|
||||
private fun setWakeLock() {
|
||||
|
|
|
@ -279,7 +279,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
for (plugin in pluginStore.plugins) {
|
||||
pref?.let { pref-> pref.getKey()?.let { plugin.updatePreferenceSummary(pref) }}
|
||||
pref?.let { it.key?.let { plugin.updatePreferenceSummary(pref) }}
|
||||
}
|
||||
|
||||
val hmacPasswords = arrayOf(
|
||||
|
|
|
@ -212,7 +212,7 @@ class ObjectivesFragment : DaggerFragment() {
|
|||
bundle.putInt("currentTask", taskPosition)
|
||||
dialog.arguments = bundle
|
||||
ObjectivesExamDialog.objective = objective
|
||||
fragmentManager?.let { dialog.show(it, "ObjectivesFragment") }
|
||||
dialog.show(childFragmentManager, "ObjectivesFragment")
|
||||
}
|
||||
}
|
||||
// horizontal line
|
||||
|
|
|
@ -41,7 +41,7 @@ class PhoneCheckerPlugin @Inject constructor(
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
phoneRooted = RootBeer(context).isRootedWithoutBusyBoxCheck()
|
||||
phoneRooted = RootBeer(context).isRooted()
|
||||
devMode = isDevModeEnabled()
|
||||
}
|
||||
}
|
|
@ -25,14 +25,15 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
|||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.SingleClickButton
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.actions_fragment.*
|
||||
|
@ -68,19 +69,19 @@ class ActionsFragment : DaggerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
actions_profileswitch.setOnClickListener {
|
||||
fragmentManager?.let { ProfileSwitchDialog().show(it, "Actions") }
|
||||
ProfileSwitchDialog().show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_temptarget.setOnClickListener {
|
||||
fragmentManager?.let { TempTargetDialog().show(it, "Actions") }
|
||||
TempTargetDialog().show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_extendedbolus.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable {
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable {
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop),
|
||||
Runnable {
|
||||
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
|
||||
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
||||
}, null)
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
actions_extendedbolus_cancel.setOnClickListener {
|
||||
|
@ -101,7 +102,7 @@ class ActionsFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
actions_settempbasal.setOnClickListener {
|
||||
fragmentManager?.let { TempBasalDialog().show(it, "Actions") }
|
||||
TempBasalDialog().show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_canceltempbasal.setOnClickListener {
|
||||
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
||||
|
@ -122,25 +123,25 @@ class ActionsFragment : DaggerFragment() {
|
|||
}
|
||||
actions_fill.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { fragmentManager?.let { FillDialog().show(it, "FillDialog") } })
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { FillDialog().show(childFragmentManager, "FillDialog") }))
|
||||
}
|
||||
}
|
||||
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
||||
actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
||||
actions_bgcheck.setOnClickListener {
|
||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(it, "Actions") }
|
||||
CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_cgmsensorinsert.setOnClickListener {
|
||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(it, "Actions") }
|
||||
CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_pumpbatterychange.setOnClickListener {
|
||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(it, "Actions") }
|
||||
CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_note.setOnClickListener {
|
||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(it, "Actions") }
|
||||
CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(childFragmentManager, "Actions")
|
||||
}
|
||||
actions_exercise.setOnClickListener {
|
||||
fragmentManager?.let { CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(it, "Actions") }
|
||||
CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(childFragmentManager, "Actions")
|
||||
}
|
||||
|
||||
sp.putBoolean(R.string.key_objectiveuseactions, true)
|
||||
|
|
|
@ -72,7 +72,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
|||
args.putString("event", AutomationEvent(mainApp).toJSON())
|
||||
args.putInt("position", -1) // New event
|
||||
dialog.arguments = args
|
||||
fragmentManager?.let { dialog.show(it, "EditEventDialog") }
|
||||
dialog.show(childFragmentManager, "EditEventDialog")
|
||||
}
|
||||
|
||||
val callback: ItemTouchHelper.Callback = SimpleItemTouchHelperCallback(eventListAdapter)
|
||||
|
@ -182,7 +182,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
|||
args.putString("event", event.toJSON())
|
||||
args.putInt("position", position)
|
||||
dialog.arguments = args
|
||||
fragmentManager?.let { dialog.show(it, "EditEventDialog") }
|
||||
dialog.show(childFragmentManager, "EditEventDialog")
|
||||
}
|
||||
// Start a drag whenever the handle view it touched
|
||||
holder.iconSort.setOnTouchListener { v: View, motionEvent: MotionEvent ->
|
||||
|
|
|
@ -66,15 +66,15 @@ class EditEventDialog : DialogFragmentWithDate() {
|
|||
args.putString("trigger", event.trigger.toJSON())
|
||||
val dialog = EditTriggerDialog()
|
||||
dialog.arguments = args
|
||||
fragmentManager?.let { dialog.show(it, "EditTriggerDialog") }
|
||||
dialog.show(childFragmentManager, "EditTriggerDialog")
|
||||
}
|
||||
|
||||
// setup action list view
|
||||
fragmentManager?.let { actionListAdapter = ActionListAdapter() }
|
||||
actionListAdapter = ActionListAdapter()
|
||||
automation_actionListView.layoutManager = LinearLayoutManager(context)
|
||||
automation_actionListView.adapter = actionListAdapter
|
||||
|
||||
automation_addAction.setOnClickListener { fragmentManager?.let { ChooseActionDialog().show(it, "ChooseActionDialog") } }
|
||||
automation_addAction.setOnClickListener { ChooseActionDialog().show(childFragmentManager, "ChooseActionDialog") }
|
||||
|
||||
showPreconditions()
|
||||
|
||||
|
@ -187,9 +187,7 @@ class EditEventDialog : DialogFragmentWithDate() {
|
|||
args.putString("action", action.toJSON())
|
||||
val dialog = EditActionDialog()
|
||||
dialog.arguments = args
|
||||
fragmentManager?.let {
|
||||
dialog.show(it, "EditActionDialog")
|
||||
}
|
||||
dialog.show(childFragmentManager, "EditActionDialog")
|
||||
}
|
||||
}
|
||||
view.findViewById<ImageView>(R.id.automation_iconTrash).setOnClickListener {
|
||||
|
|
|
@ -125,9 +125,7 @@ class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
|||
R.id.careportal_openapsoffline -> newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline)
|
||||
R.id.careportal_temporarytarget -> newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget)
|
||||
}
|
||||
fragmentManager?.let {
|
||||
NewNSTreatmentDialog().show(it, "CareportalFragment")
|
||||
}
|
||||
NewNSTreatmentDialog().show(childFragmentManager, "CareportalFragment")
|
||||
}
|
||||
|
||||
private fun updateGUI() {
|
||||
|
|
|
@ -58,7 +58,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
|
|||
|
||||
init {
|
||||
itemView.isClickable = true
|
||||
itemView.setOnClickListener { v: View ->
|
||||
itemView.setOnClickListener {
|
||||
val prefFile = fileName.tag as PrefsFile
|
||||
val i = Intent()
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ import info.nightscout.androidaps.utils.extensions.toVisibility
|
|||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -293,22 +294,20 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
}
|
||||
|
||||
override fun onContextItemSelected(item: MenuItem): Boolean {
|
||||
val manager = fragmentManager
|
||||
return if (manager != null && overviewMenus.onContextItemSelected(item, manager)) true else super.onContextItemSelected(item)
|
||||
return if (overviewMenus.onContextItemSelected(item, childFragmentManager)) true else super.onContextItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val manager = fragmentManager ?: return
|
||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||
// https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction
|
||||
if (manager.isStateSaved) return
|
||||
if (childFragmentManager.isStateSaved) return
|
||||
activity?.let { activity ->
|
||||
when (v.id) {
|
||||
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { TreatmentDialog().show(manager, "Overview") })
|
||||
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { WizardDialog().show(manager, "Overview") })
|
||||
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { InsulinDialog().show(manager, "Overview") })
|
||||
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { onClickQuickWizard() })
|
||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { CarbsDialog().show(manager, "Overview") })
|
||||
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { TreatmentDialog().show(childFragmentManager, "Overview") }))
|
||||
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { WizardDialog().show(childFragmentManager, "Overview") }))
|
||||
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { InsulinDialog().show(childFragmentManager, "Overview") }))
|
||||
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { onClickQuickWizard() }))
|
||||
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { CarbsDialog().show(childFragmentManager, "Overview") }))
|
||||
|
||||
R.id.overview_cgmbutton -> {
|
||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
|
||||
|
@ -323,7 +322,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
R.id.overview_calibrationbutton -> {
|
||||
if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) {
|
||||
CalibrationDialog().show(manager, "CalibrationDialog")
|
||||
CalibrationDialog().show(childFragmentManager, "CalibrationDialog")
|
||||
} else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) {
|
||||
try {
|
||||
dexcomPlugin.findDexcomPackageName()?.let {
|
||||
|
|
|
@ -178,7 +178,7 @@ class LocalProfileFragment : DaggerFragment() {
|
|||
|
||||
localprofile_profileswitch.setOnClickListener {
|
||||
// TODO: select in dialog localProfilePlugin.currentProfileIndex
|
||||
fragmentManager?.let { ProfileSwitchDialog().show(it, "NewNSTreatmentDialog") }
|
||||
ProfileSwitchDialog().show(childFragmentManager, "NewNSTreatmentDialog")
|
||||
}
|
||||
|
||||
localprofile_reset.setOnClickListener {
|
||||
|
|
|
@ -71,21 +71,19 @@ class DanaRFragment : DaggerFragment() {
|
|||
|
||||
danar_history.setOnClickListener { startActivity(Intent(context, DanaRHistoryActivity::class.java)) }
|
||||
danar_viewprofile.setOnClickListener {
|
||||
fragmentManager?.let { fragmentManager ->
|
||||
val profile = danaRPump.createConvertedProfile()?.getDefaultProfile()
|
||||
?: return@let
|
||||
val profileName = danaRPump.createConvertedProfile()?.getDefaultProfileName()
|
||||
?: return@let
|
||||
val args = Bundle()
|
||||
args.putLong("time", DateUtil.now())
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.CUSTOM_PROFILE.ordinal)
|
||||
args.putString("customProfile", profile.data.toString())
|
||||
args.putString("customProfileUnits", profile.units)
|
||||
args.putString("customProfileName", profileName)
|
||||
val pvd = ProfileViewerDialog()
|
||||
pvd.arguments = args
|
||||
pvd.show(fragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
val profile = danaRPump.createConvertedProfile()?.getDefaultProfile()
|
||||
?: return@setOnClickListener
|
||||
val profileName = danaRPump.createConvertedProfile()?.getDefaultProfileName()
|
||||
?: return@setOnClickListener
|
||||
val args = Bundle()
|
||||
args.putLong("time", DateUtil.now())
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.CUSTOM_PROFILE.ordinal)
|
||||
args.putString("customProfile", profile.data.toString())
|
||||
args.putString("customProfileUnits", profile.units)
|
||||
args.putString("customProfileName", profileName)
|
||||
val pvd = ProfileViewerDialog()
|
||||
pvd.arguments = args
|
||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
danar_stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
||||
danar_user_options.setOnClickListener { startActivity(Intent(context, DanaRUserOptionsActivity::class.java)) }
|
||||
|
|
|
@ -176,7 +176,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
disposable += rxBus
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event ->
|
||||
.subscribe({
|
||||
setVisibilityOfPodDebugButton()
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
}
|
||||
|
|
|
@ -145,12 +145,10 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
init {
|
||||
calculation.setOnClickListener {
|
||||
val treatment = it.tag as Treatment
|
||||
fragmentManager?.let { fragmentManager ->
|
||||
if (treatment.getBoluscalc() != null) {
|
||||
val wizardDialog = WizardInfoDialog()
|
||||
wizardDialog.setData(treatment.getBoluscalc()!!)
|
||||
wizardDialog.show(fragmentManager, "WizardInfoDialog")
|
||||
}
|
||||
if (treatment.getBoluscalc() != null) {
|
||||
val wizardDialog = WizardInfoDialog()
|
||||
wizardDialog.setData(treatment.getBoluscalc()!!)
|
||||
wizardDialog.show(childFragmentManager, "WizardInfoDialog")
|
||||
}
|
||||
}
|
||||
calculation.paintFlags = calculation.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
|
|
|
@ -156,7 +156,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
|
||||
val pvd = ProfileViewerDialog()
|
||||
pvd.arguments = args
|
||||
fragmentManager?.let { pvd.show(it, "ProfileViewDialog") }
|
||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package info.nightscout.androidaps.utils.ui
|
||||
|
||||
import info.nightscout.androidaps.utils.extensions.runOnUiThread
|
||||
|
||||
class UIRunnable (val runnable: Runnable) : Runnable {
|
||||
override fun run() {
|
||||
runOnUiThread(runnable)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue