Skip to content

Commit 9593c6a

Browse files
committed
add screen lock protection alert again
1 parent be65d7c commit 9593c6a

File tree

4 files changed

+70
-38
lines changed

4 files changed

+70
-38
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.33.2]
5+
6+
### Fixed
7+
- Require screen lock for adding secure payment methods
8+
49
## [0.33.1]
510

611
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ allprojects {
2929
}
3030

3131
project.ext {
32-
sdkVersion='0.33.1'
32+
sdkVersion='0.33.2'
3333
versionCode=1
3434

3535
compileSdkVersion=30

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentOptionsView.kt

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.snabble.sdk.ui.payment
22

33
import android.content.Context
4-
import android.graphics.Rect
54
import android.os.Bundle
65
import android.util.AttributeSet
76
import android.view.LayoutInflater
@@ -10,6 +9,7 @@ import android.view.ViewGroup
109
import android.widget.FrameLayout
1110
import android.widget.ImageView
1211
import android.widget.TextView
12+
import androidx.appcompat.app.AlertDialog
1313
import androidx.fragment.app.FragmentActivity
1414
import androidx.lifecycle.Lifecycle
1515
import androidx.lifecycle.LifecycleObserver
@@ -23,10 +23,7 @@ import io.snabble.sdk.payment.PaymentCredentials
2323
import io.snabble.sdk.payment.PaymentCredentialsStore
2424
import io.snabble.sdk.ui.R
2525
import io.snabble.sdk.ui.SnabbleUI
26-
import io.snabble.sdk.ui.utils.UIUtils
27-
import io.snabble.sdk.ui.utils.executeUiAction
28-
import io.snabble.sdk.ui.utils.getFragmentActivity
29-
import io.snabble.sdk.ui.utils.loadAsset
26+
import io.snabble.sdk.ui.utils.*
3027
import java.util.*
3128
import kotlin.collections.ArrayList
3229
import kotlin.collections.HashMap
@@ -100,7 +97,15 @@ open class PaymentOptionsView @JvmOverloads constructor(
10097
args.putSerializable(PaymentCredentialsListView.ARG_PAYMENT_TYPE, PaymentCredentials.Type.SEPA)
10198
executeUiAction(SnabbleUI.Action.SHOW_PAYMENT_CREDENTIALS_LIST, args)
10299
} else {
103-
executeUiAction(SnabbleUI.Action.SHOW_SEPA_CARD_INPUT)
100+
if (KeyguardUtils.isDeviceSecure()) {
101+
executeUiAction(SnabbleUI.Action.SHOW_SEPA_CARD_INPUT)
102+
} else {
103+
AlertDialog.Builder(context)
104+
.setMessage(R.string.Snabble_Keyguard_requireScreenLock)
105+
.setPositiveButton(R.string.Snabble_OK, null)
106+
.setCancelable(false)
107+
.show()
108+
}
104109
}
105110
}
106111
)
@@ -124,7 +129,15 @@ open class PaymentOptionsView @JvmOverloads constructor(
124129
args.putSerializable(PaymentCredentialsListView.ARG_PAYMENT_TYPE, PaymentCredentials.Type.PAYDIREKT)
125130
executeUiAction(SnabbleUI.Action.SHOW_PAYMENT_CREDENTIALS_LIST, args)
126131
} else {
127-
executeUiAction(SnabbleUI.Action.SHOW_PAYDIREKT_INPUT)
132+
if (KeyguardUtils.isDeviceSecure()) {
133+
executeUiAction(SnabbleUI.Action.SHOW_PAYDIREKT_INPUT)
134+
} else {
135+
AlertDialog.Builder(context)
136+
.setMessage(R.string.Snabble_Keyguard_requireScreenLock)
137+
.setPositiveButton(R.string.Snabble_OK, null)
138+
.setCancelable(false)
139+
.show()
140+
}
128141
}
129142
}
130143
)
@@ -159,20 +172,28 @@ open class PaymentOptionsView @JvmOverloads constructor(
159172
args.putSerializable(PaymentCredentialsListView.ARG_PROJECT_ID, project.id)
160173
executeUiAction(SnabbleUI.Action.SHOW_PAYMENT_CREDENTIALS_LIST, args)
161174
} else {
162-
val activity = UIUtils.getHostActivity(context)
163-
if (activity is FragmentActivity) {
164-
val dialogFragment = SelectPaymentMethodFragment()
165-
val args = Bundle()
166-
args.putSerializable(SelectPaymentMethodFragment.ARG_PAYMENT_METHOD_LIST, ArrayList(listOf(
167-
PaymentMethod.VISA,
168-
PaymentMethod.MASTERCARD,
169-
PaymentMethod.AMEX))
170-
)
171-
args.putString(SelectPaymentMethodFragment.ARG_PROJECT_ID, project.id)
172-
dialogFragment.arguments = args
173-
dialogFragment.show(activity.supportFragmentManager, null)
175+
if (KeyguardUtils.isDeviceSecure()) {
176+
val activity = UIUtils.getHostActivity(context)
177+
if (activity is FragmentActivity) {
178+
val dialogFragment = SelectPaymentMethodFragment()
179+
val args = Bundle()
180+
args.putSerializable(SelectPaymentMethodFragment.ARG_PAYMENT_METHOD_LIST, ArrayList(listOf(
181+
PaymentMethod.VISA,
182+
PaymentMethod.MASTERCARD,
183+
PaymentMethod.AMEX))
184+
)
185+
args.putString(SelectPaymentMethodFragment.ARG_PROJECT_ID, project.id)
186+
dialogFragment.arguments = args
187+
dialogFragment.show(activity.supportFragmentManager, null)
188+
} else {
189+
throw RuntimeException("Host activity must be a FragmentActivity")
190+
}
174191
} else {
175-
throw RuntimeException("Host activity must be a FragmentActivity")
192+
AlertDialog.Builder(context)
193+
.setMessage(R.string.Snabble_Keyguard_requireScreenLock)
194+
.setPositiveButton(R.string.Snabble_OK, null)
195+
.setCancelable(false)
196+
.show()
176197
}
177198
}
178199
}

ui/src/main/java/io/snabble/sdk/ui/payment/ProjectPaymentOptionsView.kt

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.view.ViewGroup
99
import android.widget.FrameLayout
1010
import android.widget.ImageView
1111
import android.widget.TextView
12+
import androidx.appcompat.app.AlertDialog
1213
import androidx.fragment.app.FragmentActivity
1314
import androidx.lifecycle.Lifecycle
1415
import androidx.lifecycle.LifecycleObserver
@@ -21,10 +22,7 @@ import io.snabble.sdk.payment.PaymentCredentials
2122
import io.snabble.sdk.payment.PaymentCredentialsStore
2223
import io.snabble.sdk.ui.R
2324
import io.snabble.sdk.ui.SnabbleUI
24-
import io.snabble.sdk.ui.utils.UIUtils
25-
import io.snabble.sdk.ui.utils.executeUiAction
26-
import io.snabble.sdk.ui.utils.getFragmentActivity
27-
import io.snabble.sdk.ui.utils.loadAsset
25+
import io.snabble.sdk.ui.utils.*
2826
import java.util.*
2927

3028
open class ProjectPaymentOptionsView @JvmOverloads constructor(
@@ -113,20 +111,28 @@ open class ProjectPaymentOptionsView @JvmOverloads constructor(
113111
args.putString(PaymentCredentialsListView.ARG_PROJECT_ID, project.id)
114112
executeUiAction(SnabbleUI.Action.SHOW_PAYMENT_CREDENTIALS_LIST, args)
115113
} else {
116-
val activity = UIUtils.getHostActivity(context)
117-
if (activity is FragmentActivity) {
118-
val dialogFragment = SelectPaymentMethodFragment()
119-
val args = Bundle()
120-
args.putSerializable(SelectPaymentMethodFragment.ARG_PAYMENT_METHOD_LIST, ArrayList(listOf(
121-
PaymentMethod.VISA,
122-
PaymentMethod.MASTERCARD,
123-
PaymentMethod.AMEX))
124-
)
125-
args.putString(SelectPaymentMethodFragment.ARG_PROJECT_ID, project.id)
126-
dialogFragment.arguments = args
127-
dialogFragment.show(activity.supportFragmentManager, null)
114+
if (KeyguardUtils.isDeviceSecure()) {
115+
val activity = UIUtils.getHostActivity(context)
116+
if (activity is FragmentActivity) {
117+
val dialogFragment = SelectPaymentMethodFragment()
118+
val args = Bundle()
119+
args.putSerializable(SelectPaymentMethodFragment.ARG_PAYMENT_METHOD_LIST, ArrayList(listOf(
120+
PaymentMethod.VISA,
121+
PaymentMethod.MASTERCARD,
122+
PaymentMethod.AMEX))
123+
)
124+
args.putString(SelectPaymentMethodFragment.ARG_PROJECT_ID, project.id)
125+
dialogFragment.arguments = args
126+
dialogFragment.show(activity.supportFragmentManager, null)
127+
} else {
128+
throw RuntimeException("Host activity must be a FragmentActivity")
129+
}
128130
} else {
129-
throw RuntimeException("Host activity must be a FragmentActivity")
131+
AlertDialog.Builder(context)
132+
.setMessage(R.string.Snabble_Keyguard_requireScreenLock)
133+
.setPositiveButton(R.string.Snabble_OK, null)
134+
.setCancelable(false)
135+
.show()
130136
}
131137
}
132138
}

0 commit comments

Comments
 (0)