diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt index 1222785a..a40d352d 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/EnterTanDialog.kt @@ -11,8 +11,8 @@ import android.view.View import android.view.ViewGroup import android.widget.Spinner import androidx.appcompat.app.AlertDialog -import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentActivity import kotlinx.android.synthetic.main.dialog_enter_tan.* import kotlinx.android.synthetic.main.dialog_enter_tan.view.* import kotlinx.android.synthetic.main.view_collapsible_text.view.* @@ -54,7 +54,7 @@ open class EnterTanDialog : DialogFragment() { } - open fun show(bank: TypedBankData, tanChallenge: TanChallenge, activity: AppCompatActivity, + open fun show(bank: TypedBankData, tanChallenge: TanChallenge, activity: FragmentActivity, fullscreen: Boolean = false, tanEnteredCallback: (EnterTanResult) -> Unit) { this.bank = bank diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt index b14408c3..445ab7c8 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt @@ -170,8 +170,8 @@ open class TransferMoneyDialog : DialogFragment() { protected open fun adjustCheckBoxRealTimeTransferWidth() { // wait some time till CheckBox is layout and lineCount is set val timer = Timer() - timer.schedule(10) { requireActivity().runOnUiThread { adjustCheckBoxRealTimeTransferWidthOnUiThread() }} - timer.schedule(2500) { requireActivity().runOnUiThread { adjustCheckBoxRealTimeTransferWidthOnUiThread() }} + timer.schedule(10) { activity?.runOnUiThread { adjustCheckBoxRealTimeTransferWidthOnUiThread() }} + timer.schedule(2500) { activity?.runOnUiThread { adjustCheckBoxRealTimeTransferWidthOnUiThread() }} } protected open fun adjustCheckBoxRealTimeTransferWidthOnUiThread() { @@ -193,7 +193,10 @@ open class TransferMoneyDialog : DialogFragment() { } protected open fun showRealTimeTransferInfo(btnShowRealTimeTransferInfo: ImageButton) { - InfoPopupWindow(requireActivity(), R.string.dialog_transfer_money_real_time_transfer_info).show(btnShowRealTimeTransferInfo) + activity?.let { activity -> + InfoPopupWindow(activity, R.string.dialog_transfer_money_real_time_transfer_info) + .show(btnShowRealTimeTransferInfo) + } } private fun transferMoneyIfEnterPressed(editText: EditText) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt index 03876aa0..b17831fe 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt @@ -3,7 +3,7 @@ package net.dankito.banking.ui.android.dialogs.settings import android.content.Intent import android.os.Bundle import android.view.* -import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.FragmentActivity import kotlinx.android.synthetic.main.dialog_bank_account_settings.* import kotlinx.android.synthetic.main.dialog_bank_account_settings.view.* import net.dankito.banking.ui.android.R @@ -24,7 +24,7 @@ open class BankAccountSettingsDialog : SettingsDialogBase() { - fun show(account: TypedBankAccount, activity: AppCompatActivity) { + fun show(account: TypedBankAccount, activity: FragmentActivity) { this.account = account show(activity, DialogTag) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankSettingsDialog.kt index 6101b513..1f836054 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankSettingsDialog.kt @@ -3,6 +3,7 @@ package net.dankito.banking.ui.android.dialogs.settings import android.os.Bundle import android.view.* import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.FragmentActivity import kotlinx.android.synthetic.main.dialog_bank_settings.edtxtBankName import kotlinx.android.synthetic.main.dialog_bank_settings.edtxtUserName import kotlinx.android.synthetic.main.dialog_bank_settings.edtxtPassword @@ -37,7 +38,7 @@ open class BankSettingsDialog : SettingsDialogBase() { - fun show(bank: TypedBankData, activity: AppCompatActivity) { + fun show(bank: TypedBankData, activity: FragmentActivity) { this.bank = bank this.selectedTanMethod = bank.selectedTanMethod @@ -109,7 +110,9 @@ open class BankSettingsDialog : SettingsDialogBase() { protected open fun navigationToBankAccountSettingsDialog(account: TypedBankAccount) { - BankAccountSettingsDialog().show(account, requireActivity() as AppCompatActivity) + (activity as? AppCompatActivity)?.let { activity -> + BankAccountSettingsDialog().show(account, requireActivity() as AppCompatActivity) + } } protected open fun reorderedBankAccounts(oldPosition: Int, oldItem: TypedBankAccount, newPosition: Int, newItem: TypedBankAccount) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt index 666b79c6..fa82b24a 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/ProtectAppSettingsDialog.kt @@ -4,8 +4,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.appcompat.app.AppCompatActivity import androidx.core.view.doOnNextLayout +import androidx.fragment.app.FragmentActivity import kotlinx.android.synthetic.main.dialog_protect_app_settings.* import kotlinx.android.synthetic.main.dialog_protect_app_settings.view.* import net.dankito.banking.ui.android.R @@ -37,7 +37,7 @@ open class ProtectAppSettingsDialog : SettingsDialogBase() { } - fun show(activity: AppCompatActivity) { + fun show(activity: FragmentActivity) { show(activity, SettingsDialog.DialogTag) } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt index a1bcec1a..ddd61e8e 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialog.kt @@ -2,8 +2,8 @@ package net.dankito.banking.ui.android.dialogs.settings import android.os.Bundle import android.view.* -import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.content.res.AppCompatResources +import androidx.fragment.app.FragmentActivity import kotlinx.android.synthetic.main.dialog_settings.* import kotlinx.android.synthetic.main.dialog_settings.view.* import net.dankito.banking.ui.android.R @@ -26,7 +26,7 @@ open class SettingsDialog : SettingsDialogBase() { } - fun show(activity: AppCompatActivity) { + fun show(activity: FragmentActivity) { show(activity, DialogTag) } @@ -54,7 +54,7 @@ open class SettingsDialog : SettingsDialogBase() { swtchUpdateAccountsAutomatically.isChecked = presenter.appSettings.updateAccountsAutomatically - btnSetAppProtection.setOnClickListener { ProtectAppSettingsDialog().show(requireActivity() as AppCompatActivity) } + btnSetAppProtection.setOnClickListener { navigateToProtectAppSettingsDialog() } // on Pre Lollipop devices setting vector drawables in xml is not supported -> set left drawable here val sendIcon = AppCompatResources.getDrawable(context, R.drawable.ic_baseline_send_24) @@ -81,7 +81,15 @@ open class SettingsDialog : SettingsDialogBase() { protected open fun navigationToBankSettingsDialog(bank: TypedBankData) { - BankSettingsDialog().show(bank, requireActivity() as AppCompatActivity) + activity?.let { activity -> + BankSettingsDialog().show(bank, activity) + } + } + + protected open fun navigateToProtectAppSettingsDialog() { + activity?.let { activity -> + ProtectAppSettingsDialog().show(activity) + } } protected open fun reorderedBanks(oldPosition: Int, oldItem: TypedBankData, newPosition: Int, newItem: TypedBankData) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialogBase.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialogBase.kt index af7fb57c..8fed6f77 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialogBase.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/SettingsDialogBase.kt @@ -1,9 +1,9 @@ package net.dankito.banking.ui.android.dialogs.settings import android.view.* -import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentActivity import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.alerts.AskDismissChangesAlert import net.dankito.banking.ui.android.di.BankingComponent @@ -29,7 +29,7 @@ abstract class SettingsDialogBase : DialogFragment() { - fun show(activity: AppCompatActivity, dialogTag: String, fullscreen: Boolean = true) { + fun show(activity: FragmentActivity, dialogTag: String, fullscreen: Boolean = true) { val style = if (fullscreen) R.style.FullscreenDialogWithStatusBar else R.style.FloatingDialog setStyle(STYLE_NORMAL, style) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt index e69746c0..48371bbb 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt @@ -319,12 +319,15 @@ class HomeFragment : Fragment() { } private fun showFetchAllTransactionsInfo(btnShowFetchAllTransactionsInfo: ImageButton) { - val account = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.first() + activity?.let { activity -> + val account = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched.first() - val dateOfFirstRetrievedTransaction = account.retrievedTransactionsFromOn?.let { presenter.formatToMediumDate(it) } ?: "" - val info = requireContext().getString(R.string.popup_fetch_all_transactions_info, dateOfFirstRetrievedTransaction, - account.countDaysForWhichTransactionsAreKept, presenter.formatToMediumDate(presenter.getDayOfFirstTransactionStoredOnBankServer(account))) - InfoPopupWindow(requireActivity(), info).show(btnShowFetchAllTransactionsInfo, Gravity.BOTTOM) + val dateOfFirstRetrievedTransaction = account.retrievedTransactionsFromOn?.let { presenter.formatToMediumDate(it) } ?: "" + val info = activity.getString(R.string.popup_fetch_all_transactions_info, dateOfFirstRetrievedTransaction, + account.countDaysForWhichTransactionsAreKept, presenter.formatToMediumDate(presenter.getDayOfFirstTransactionStoredOnBankServer(account))) + + InfoPopupWindow(activity, info).show(btnShowFetchAllTransactionsInfo, Gravity.BOTTOM) + } }