activity -> FragmentActivity
This commit is contained in:
parent
bbdc6289b8
commit
154d2af774
|
@ -4,18 +4,9 @@
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
<value>
|
<value>
|
||||||
<package name="java.util" alias="false" withSubpackages="false" />
|
<package name="java.util" withSubpackages="false" static="false" />
|
||||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
|
||||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
<package name="io.ktor" withSubpackages="true" static="false" />
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
|
||||||
<value>
|
|
||||||
<package name="" alias="false" withSubpackages="true" />
|
|
||||||
<package name="java" alias="false" withSubpackages="true" />
|
|
||||||
<package name="javax" alias="false" withSubpackages="true" />
|
|
||||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
|
||||||
<package name="" alias="true" withSubpackages="true" />
|
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.objectives
|
package info.nightscout.androidaps.plugins.constraints.objectives
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.google.common.base.Charsets
|
import com.google.common.base.Charsets
|
||||||
import com.google.common.hash.Hashing
|
import com.google.common.hash.Hashing
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
@ -116,7 +117,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
sp.putBoolean(R.string.key_objectiveusescale, false)
|
sp.putBoolean(R.string.key_objectiveusescale, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun completeObjectives(activity: Activity, 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, "").toLowerCase(Locale.getDefault())
|
var url = sp.getString(R.string.key_nsclientinternal_url, "").toLowerCase(Locale.getDefault())
|
||||||
if (!url.endsWith("/")) url = "$url/"
|
if (!url.endsWith("/")) url = "$url/"
|
||||||
|
@ -145,7 +146,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun allPriorAccomplished(position: Int) : Boolean {
|
fun allPriorAccomplished(position: Int): Boolean {
|
||||||
var accomplished = true
|
var accomplished = true
|
||||||
for (i in 0 until position) {
|
for (i in 0 until position) {
|
||||||
accomplished = accomplished && objectives[i].isAccomplished
|
accomplished = accomplished && objectives[i].isAccomplished
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.CheckBox;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -110,7 +111,7 @@ public abstract class Objective {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void specialAction(Activity activity, String input) {
|
public void specialAction(FragmentActivity activity, String input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class Task {
|
public abstract class Task {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
|
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
|
||||||
|
|
||||||
import android.app.Activity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class Objective3 extends Objective {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void specialAction(Activity activity, String input) {
|
public void specialAction(FragmentActivity activity, String input) {
|
||||||
objectivesPlugin.completeObjectives(activity, input);
|
objectivesPlugin.completeObjectives(activity, input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,17 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
private SP sp;
|
private final SP sp;
|
||||||
private RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private OpenAPSAMAPlugin openAPSAMAPlugin;
|
private final OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||||
private OpenAPSSMBPlugin openAPSSMBPlugin;
|
private final OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||||
private SensitivityOref1Plugin sensitivityOref1Plugin;
|
private final SensitivityOref1Plugin sensitivityOref1Plugin;
|
||||||
private ActivePluginProvider activePlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
private HardLimits hardLimits;
|
private final HardLimits hardLimits;
|
||||||
private BuildHelper buildHelper;
|
private final BuildHelper buildHelper;
|
||||||
private TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private Config config;
|
private final Config config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SafetyPlugin(
|
public SafetyPlugin(
|
||||||
|
|
|
@ -122,7 +122,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
private fun prefsEncryptionIsDisabled() =
|
private fun prefsEncryptionIsDisabled() =
|
||||||
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
||||||
|
|
||||||
private fun askForMasterPass(activity: Activity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||||
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { password ->
|
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { password ->
|
||||||
then(password)
|
then(password)
|
||||||
}, {
|
}, {
|
||||||
|
@ -130,7 +130,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askForEncryptionPass(activity: Activity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?,
|
private fun askForEncryptionPass(activity: FragmentActivity, @StringRes canceledMsg: Int, @StringRes passwordName: Int, @StringRes passwordExplanation: Int?,
|
||||||
@StringRes passwordWarning: Int?, then: ((password: String) -> Unit)) {
|
@StringRes passwordWarning: Int?, then: ((password: String) -> Unit)) {
|
||||||
passwordCheck.queryAnyPassword(activity, passwordName, R.string.key_master_password, passwordExplanation, passwordWarning, { password ->
|
passwordCheck.queryAnyPassword(activity, passwordName, R.string.key_master_password, passwordExplanation, passwordWarning, { password ->
|
||||||
then(password)
|
then(password)
|
||||||
|
@ -139,7 +139,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askForMasterPassIfNeeded(activity: Activity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
private fun askForMasterPassIfNeeded(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||||
if (prefsEncryptionIsDisabled()) {
|
if (prefsEncryptionIsDisabled()) {
|
||||||
then("")
|
then("")
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,7 +147,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assureMasterPasswordSet(activity: Activity, @StringRes wrongPwdTitle: Int): Boolean {
|
private fun assureMasterPasswordSet(activity: FragmentActivity, @StringRes wrongPwdTitle: Int): Boolean {
|
||||||
if (!sp.contains(R.string.key_master_password) || (sp.getString(R.string.key_master_password, "") == "")) {
|
if (!sp.contains(R.string.key_master_password) || (sp.getString(R.string.key_master_password, "") == "")) {
|
||||||
WarningDialog.showWarning(activity,
|
WarningDialog.showWarning(activity,
|
||||||
resourceHelper.gs(wrongPwdTitle),
|
resourceHelper.gs(wrongPwdTitle),
|
||||||
|
@ -163,7 +163,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askToConfirmExport(activity: Activity, fileToExport: File, then: ((password: String) -> Unit)) {
|
private fun askToConfirmExport(activity: FragmentActivity, fileToExport: File, then: ((password: String) -> Unit)) {
|
||||||
if (!prefsEncryptionIsDisabled() && !assureMasterPasswordSet(activity, R.string.nav_export)) return
|
if (!prefsEncryptionIsDisabled() && !assureMasterPasswordSet(activity, R.string.nav_export)) return
|
||||||
|
|
||||||
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_export),
|
TwoMessagesAlertDialog.showAlert(activity, resourceHelper.gs(R.string.nav_export),
|
||||||
|
@ -173,7 +173,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}, null, R.drawable.ic_header_export)
|
}, null, R.drawable.ic_header_export)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askToConfirmImport(activity: Activity, fileToImport: PrefsFile, then: ((password: String) -> Unit)) {
|
private fun askToConfirmImport(activity: FragmentActivity, fileToImport: PrefsFile, then: ((password: String) -> Unit)) {
|
||||||
|
|
||||||
if (fileToImport.handler == PrefsFormatsHandler.ENCRYPTED) {
|
if (fileToImport.handler == PrefsFormatsHandler.ENCRYPTED) {
|
||||||
if (!assureMasterPasswordSet(activity, R.string.nav_import)) return
|
if (!assureMasterPasswordSet(activity, R.string.nav_import)) return
|
||||||
|
@ -190,7 +190,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun promptForDecryptionPasswordIfNeeded(activity: Activity, prefs: Prefs, importOk: Boolean,
|
private fun promptForDecryptionPasswordIfNeeded(activity: FragmentActivity, prefs: Prefs, importOk: Boolean,
|
||||||
format: PrefsFormat, importFile: PrefsFile, then: ((prefs: Prefs, importOk: Boolean) -> Unit)) {
|
format: PrefsFormat, importFile: PrefsFile, then: ((prefs: Prefs, importOk: Boolean) -> Unit)) {
|
||||||
|
|
||||||
// current master password was not the one used for decryption, so we prompt for old password...
|
// current master password was not the one used for decryption, so we prompt for old password...
|
||||||
|
@ -212,7 +212,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportSharedPreferences(activity: Activity) {
|
private fun exportSharedPreferences(activity: FragmentActivity) {
|
||||||
|
|
||||||
prefFileList.ensureExportDirExists()
|
prefFileList.ensureExportDirExists()
|
||||||
val legacyFile = prefFileList.legacyFile()
|
val legacyFile = prefFileList.legacyFile()
|
||||||
|
@ -277,12 +277,12 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun importSharedPreferences(activity: Activity, importFile: PrefsFile) {
|
private fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
|
||||||
|
|
||||||
askToConfirmImport(activity, importFile) { password ->
|
askToConfirmImport(activity, importFile) { password ->
|
||||||
|
|
||||||
val format: PrefsFormat = when (importFile.handler) {
|
val format: PrefsFormat = when (importFile.handler) {
|
||||||
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat
|
PrefsFormatsHandler.CLASSIC -> classicPrefsFormat
|
||||||
PrefsFormatsHandler.ENCRYPTED -> encryptedPrefsFormat
|
PrefsFormatsHandler.ENCRYPTED -> encryptedPrefsFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance
|
package info.nightscout.androidaps.plugins.general.maintenance
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.*
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
import kotlinx.android.parcel.RawValue
|
import kotlinx.android.parcel.RawValue
|
||||||
|
@ -53,8 +51,8 @@ class PrefsFileContract : ActivityResultContract<Void, PrefsFile>() {
|
||||||
|
|
||||||
override fun parseResult(resultCode: Int, intent: Intent?): PrefsFile? {
|
override fun parseResult(resultCode: Int, intent: Intent?): PrefsFile? {
|
||||||
return when (resultCode) {
|
return when (resultCode) {
|
||||||
Activity.RESULT_OK -> intent?.getParcelableExtra(OUTPUT_PARAM)
|
FragmentActivity.RESULT_OK -> intent?.getParcelableExtra(OUTPUT_PARAM)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.maintenance.activities
|
package info.nightscout.androidaps.plugins.general.maintenance.activities
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -9,6 +8,7 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerAppCompatActivity
|
import dagger.android.support.DaggerAppCompatActivity
|
||||||
|
@ -63,7 +63,7 @@ class PrefImportListActivity : DaggerAppCompatActivity() {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
|
|
||||||
i.putExtra(PrefsFileContract.OUTPUT_PARAM, prefFile)
|
i.putExtra(PrefsFileContract.OUTPUT_PARAM, prefFile)
|
||||||
setResult(Activity.RESULT_OK, i)
|
setResult(FragmentActivity.RESULT_OK, i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.openhumans
|
package info.nightscout.androidaps.plugins.general.openhumans
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -11,6 +10,7 @@ import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.browser.customtabs.CustomTabsIntent
|
import androidx.browser.customtabs.CustomTabsIntent
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
|
@ -128,7 +128,7 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.close) { _, _ ->
|
.setPositiveButton(R.string.close) { _, _ ->
|
||||||
requireActivity().run {
|
requireActivity().run {
|
||||||
setResult(Activity.RESULT_OK)
|
setResult(FragmentActivity.RESULT_OK)
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.profile.local
|
package info.nightscout.androidaps.plugins.profile.local
|
||||||
|
|
||||||
import android.app.Activity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
@ -93,7 +93,7 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun storeSettings(activity: Activity? = null) {
|
fun storeSettings(activity: FragmentActivity? = null) {
|
||||||
for (i in 0 until numOfProfiles) {
|
for (i in 0 until numOfProfiles) {
|
||||||
profiles[i].run {
|
profiles[i].run {
|
||||||
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
|
val localProfileNumbered = Constants.LOCAL_PROFILE + "_" + i + "_"
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runOnUiThread(Runnable action) {
|
private void runOnUiThread(Runnable action) {
|
||||||
Activity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(action);
|
activity.runOnUiThread(action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -13,6 +12,7 @@ import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -46,7 +46,7 @@ class AndroidPermission @Inject constructor(
|
||||||
private var permission_battery_optimization_failed = false
|
private var permission_battery_optimization_failed = false
|
||||||
|
|
||||||
@SuppressLint("BatteryLife")
|
@SuppressLint("BatteryLife")
|
||||||
private fun askForPermission(activity: Activity, permission: Array<String>, requestCode: Int) {
|
private fun askForPermission(activity: FragmentActivity, permission: Array<String>, requestCode: Int) {
|
||||||
var test = false
|
var test = false
|
||||||
var testBattery = false
|
var testBattery = false
|
||||||
for (s in permission) {
|
for (s in permission) {
|
||||||
|
@ -73,7 +73,7 @@ class AndroidPermission @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun askForPermission(activity: Activity, permission: String, requestCode: Int) {
|
fun askForPermission(activity: FragmentActivity, permission: String, requestCode: Int) {
|
||||||
val permissions = arrayOf(permission)
|
val permissions = arrayOf(permission)
|
||||||
askForPermission(activity, permissions, requestCode)
|
askForPermission(activity, permissions, requestCode)
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class AndroidPermission @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun notifyForSMSPermissions(activity: Activity, smsCommunicatorPlugin: SmsCommunicatorPlugin) {
|
fun notifyForSMSPermissions(activity: FragmentActivity, smsCommunicatorPlugin: SmsCommunicatorPlugin) {
|
||||||
if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
||||||
if (permissionNotGranted(activity, Manifest.permission.RECEIVE_SMS)) {
|
if (permissionNotGranted(activity, Manifest.permission.RECEIVE_SMS)) {
|
||||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_SMS, resourceHelper.gs(R.string.smscommunicator_missingsmspermission), Notification.URGENT)
|
val notification = NotificationWithAction(injector, Notification.PERMISSION_SMS, resourceHelper.gs(R.string.smscommunicator_missingsmspermission), Notification.URGENT)
|
||||||
|
@ -114,7 +114,7 @@ class AndroidPermission @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun notifyForBatteryOptimizationPermission(activity: Activity) {
|
fun notifyForBatteryOptimizationPermission(activity: FragmentActivity) {
|
||||||
if (permissionNotGranted(activity, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) {
|
if (permissionNotGranted(activity, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) {
|
||||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_BATTERY, String.format(resourceHelper.gs(R.string.needwhitelisting), resourceHelper.gs(R.string.app_name)), Notification.URGENT)
|
val notification = NotificationWithAction(injector, Notification.PERMISSION_BATTERY, String.format(resourceHelper.gs(R.string.needwhitelisting), resourceHelper.gs(R.string.app_name)), Notification.URGENT)
|
||||||
notification.action(R.string.request, Runnable { askForPermission(activity, arrayOf(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS), CASE_BATTERY) })
|
notification.action(R.string.request, Runnable { askForPermission(activity, arrayOf(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS), CASE_BATTERY) })
|
||||||
|
@ -122,7 +122,7 @@ class AndroidPermission @Inject constructor(
|
||||||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_BATTERY))
|
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_BATTERY))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized fun notifyForStoragePermission(activity: Activity) {
|
@Synchronized fun notifyForStoragePermission(activity: FragmentActivity) {
|
||||||
if (permissionNotGranted(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
if (permissionNotGranted(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_STORAGE, resourceHelper.gs(R.string.needstoragepermission), Notification.URGENT)
|
val notification = NotificationWithAction(injector, Notification.PERMISSION_STORAGE, resourceHelper.gs(R.string.needstoragepermission), Notification.URGENT)
|
||||||
notification.action(R.string.request, Runnable {
|
notification.action(R.string.request, Runnable {
|
||||||
|
@ -133,7 +133,7 @@ class AndroidPermission @Inject constructor(
|
||||||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_STORAGE))
|
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_STORAGE))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized fun notifyForLocationPermissions(activity: Activity) {
|
@Synchronized fun notifyForLocationPermissions(activity: FragmentActivity) {
|
||||||
if (permissionNotGranted(activity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
if (permissionNotGranted(activity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_LOCATION, resourceHelper.gs(R.string.needlocationpermission), Notification.URGENT)
|
val notification = NotificationWithAction(injector, Notification.PERMISSION_LOCATION, resourceHelper.gs(R.string.needlocationpermission), Notification.URGENT)
|
||||||
notification.action(R.string.request, Runnable { askForPermission(activity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), CASE_LOCATION) })
|
notification.action(R.string.request, Runnable { askForPermission(activity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), CASE_LOCATION) })
|
||||||
|
@ -141,7 +141,7 @@ class AndroidPermission @Inject constructor(
|
||||||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_LOCATION))
|
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_LOCATION))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized fun notifyForSystemWindowPermissions(activity: Activity) {
|
@Synchronized fun notifyForSystemWindowPermissions(activity: FragmentActivity) {
|
||||||
// Check if Android Q or higher
|
// Check if Android Q or higher
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
||||||
if (!Settings.canDrawOverlays(activity)) {
|
if (!Settings.canDrawOverlays(activity)) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -157,7 +156,6 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
Thread(Runnable {
|
Thread(Runnable {
|
||||||
SystemClock.sleep(5000)
|
SystemClock.sleep(5000)
|
||||||
bolusEnded = true
|
bolusEnded = true
|
||||||
val activity: Activity? = activity
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
if (running) {
|
if (running) {
|
||||||
aapsLogger.debug(LTag.UI, "executing")
|
aapsLogger.debug(LTag.UI, "executing")
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.androidaps.utils.alertDialogs
|
package info.nightscout.androidaps.utils.alertDialogs
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
import info.nightscout.androidaps.utils.extensions.runOnUiThread
|
import info.nightscout.androidaps.utils.extensions.runOnUiThread
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ object OKDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun show(activity: Activity, title: String, message: Spanned, runnable: Runnable? = null) {
|
fun show(activity: FragmentActivity, title: String, message: Spanned, runnable: Runnable? = null) {
|
||||||
var okClicked = false
|
var okClicked = false
|
||||||
var notEmptytitle = title
|
var notEmptytitle = title
|
||||||
if (notEmptytitle.isEmpty()) notEmptytitle = activity.getString(R.string.message)
|
if (notEmptytitle.isEmpty()) notEmptytitle = activity.getString(R.string.message)
|
||||||
|
@ -55,17 +55,17 @@ object OKDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun showConfirmation(activity: Activity, message: String, ok: Runnable?) {
|
fun showConfirmation(activity: FragmentActivity, message: String, ok: Runnable?) {
|
||||||
showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null)
|
showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun showConfirmation(activity: Activity, message: Spanned, ok: Runnable?) {
|
fun showConfirmation(activity: FragmentActivity, message: Spanned, ok: Runnable?) {
|
||||||
showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null)
|
showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun showConfirmation(activity: Activity, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) {
|
fun showConfirmation(activity: FragmentActivity, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
var okClicked = false
|
var okClicked = false
|
||||||
AlertDialogHelper.Builder(activity)
|
AlertDialogHelper.Builder(activity)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
|
@ -93,7 +93,7 @@ object OKDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun showConfirmation(activity: Activity, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) {
|
fun showConfirmation(activity: FragmentActivity, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
var okClicked = false
|
var okClicked = false
|
||||||
AlertDialogHelper.Builder(activity)
|
AlertDialogHelper.Builder(activity)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
|
|
|
@ -14,6 +14,8 @@ import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.support.DaggerDialogFragment;
|
import dagger.android.support.DaggerDialogFragment;
|
||||||
|
@ -59,7 +61,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
runnable = () -> {
|
runnable = () -> {
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
if (pairingEnded) {
|
if (pairingEnded) {
|
||||||
Activity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
progressBar.setProgress(100);
|
progressBar.setProgress(100);
|
||||||
|
@ -80,7 +82,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Activity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
progressBar.setProgress(100);
|
progressBar.setProgress(100);
|
||||||
|
@ -106,7 +108,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
progressBar = view.findViewById(R.id.danars_pairingprogress_progressbar);
|
progressBar = view.findViewById(R.id.danars_pairingprogress_progressbar);
|
||||||
button = view.findViewById(R.id.ok);
|
button = view.findViewById(R.id.ok);
|
||||||
|
|
||||||
setViews();
|
setViews();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ dependencies {
|
||||||
|
|
||||||
implementation "com.google.dagger:dagger-android:$dagger_version"
|
implementation "com.google.dagger:dagger-android:$dagger_version"
|
||||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||||
|
implementation 'androidx.navigation:navigation-runtime:2.2.2'
|
||||||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
||||||
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
|
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||||
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment
|
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment
|
||||||
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase
|
||||||
|
@ -26,13 +26,15 @@ class AttachPodInfoFragment : InfoFragmentBase() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
omnipod_wizard_button_next.setOnClickListener {
|
omnipod_wizard_button_next.setOnClickListener {
|
||||||
AlertDialog.Builder(context)
|
context?.let {
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
AlertDialog.Builder(it)
|
||||||
.setTitle(getString(getTitleId()))
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setMessage(getString(R.string.omnipod_pod_activation_wizard_attach_pod_confirm_insert_cannula_text))
|
.setTitle(getString(getTitleId()))
|
||||||
.setPositiveButton(getString(R.string.omnipod_ok)) { _, _ -> findNavController().navigate(getNextPageActionId()) }
|
.setMessage(getString(R.string.omnipod_pod_activation_wizard_attach_pod_confirm_insert_cannula_text))
|
||||||
.setNegativeButton(getString(R.string.omnipod_cancel), null)
|
.setPositiveButton(getString(R.string.omnipod_ok)) { _, _ -> findNavController().navigate(getNextPageActionId()) }
|
||||||
.show()
|
.setNegativeButton(getString(R.string.omnipod_cancel), null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity
|
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment
|
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment
|
||||||
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
@ -35,16 +35,18 @@ class DeactivatePodActionFragment : ActionFragmentBase() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
omnipod_wizard_button_discard_pod.setOnClickListener {
|
omnipod_wizard_button_discard_pod.setOnClickListener {
|
||||||
AlertDialog.Builder(context)
|
context?.let {
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
AlertDialog.Builder(it)
|
||||||
.setTitle(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod))
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setMessage(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod_confirmation))
|
.setTitle(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod))
|
||||||
.setPositiveButton(getString(R.string.omnipod_yes)) { _, _ ->
|
.setMessage(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod_confirmation))
|
||||||
aapsOmnipodManager.discardPodState()
|
.setPositiveButton(getString(R.string.omnipod_yes)) { _, _ ->
|
||||||
findNavController().navigate(R.id.action_deactivatePodActionFragment_to_podDiscardedInfoFragment)
|
aapsOmnipodManager.discardPodState()
|
||||||
}
|
findNavController().navigate(R.id.action_deactivatePodActionFragment_to_podDiscardedInfoFragment)
|
||||||
.setNegativeButton(getString(R.string.omnipod_no), null)
|
}
|
||||||
.show()
|
.setNegativeButton(getString(R.string.omnipod_no), null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue