From f5fbb2bc4f3b6a7090b316f8b5ee9355902d949f Mon Sep 17 00:00:00 2001 From: ganfra Date: Fri, 17 Jul 2020 13:29:18 +0200 Subject: [PATCH 01/12] Setup screens for Pin --- build.gradle | 2 + vector/build.gradle | 1 + .../riotx/features/debug/DebugMenuActivity.kt | 6 +++ .../debug/res/layout/activity_debug_menu.xml | 7 +++ vector/src/main/AndroidManifest.xml | 1 + .../im/vector/riotx/core/di/FragmentModule.kt | 6 +++ .../features/navigation/DefaultNavigator.kt | 7 +++ .../riotx/features/navigation/Navigator.kt | 2 + .../im/vector/riotx/features/pin/PinAction.kt | 21 ++++++++ .../vector/riotx/features/pin/PinActivity.kt | 47 +++++++++++++++++ .../vector/riotx/features/pin/PinFragment.kt | 49 +++++++++++++++++ .../vector/riotx/features/pin/PinViewModel.kt | 52 +++++++++++++++++++ .../vector/riotx/features/pin/PinViewState.kt | 21 ++++++++ vector/src/main/res/layout/fragment_pin.xml | 19 +++++++ 14 files changed, 241 insertions(+) create mode 100644 vector/src/main/java/im/vector/riotx/features/pin/PinAction.kt create mode 100644 vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt create mode 100644 vector/src/main/java/im/vector/riotx/features/pin/PinFragment.kt create mode 100644 vector/src/main/java/im/vector/riotx/features/pin/PinViewModel.kt create mode 100644 vector/src/main/java/im/vector/riotx/features/pin/PinViewState.kt create mode 100644 vector/src/main/res/layout/fragment_pin.xml diff --git a/build.gradle b/build.gradle index 47b3ab240d..5593a56f6e 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,8 @@ allprojects { includeGroupByRegex 'com\\.github\\.BillCarsonFr' // PhotoView includeGroupByRegex 'com\\.github\\.chrisbanes' + // PFLockScreen-Android + includeGroupByRegex 'com\\.github\\.thealeksandr' } } maven { diff --git a/vector/build.gradle b/vector/build.gradle index 2b033790bc..0d654438f5 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -346,6 +346,7 @@ dependencies { implementation 'me.saket:better-link-movement-method:2.2.0' implementation 'com.google.android:flexbox:1.1.1' implementation "androidx.autofill:autofill:$autofill_version" + implementation 'com.github.thealeksandr:PFLockScreen-Android:1.0.0-beta7' // Custom Tab implementation 'androidx.browser:browser:1.2.0' diff --git a/vector/src/debug/java/im/vector/riotx/features/debug/DebugMenuActivity.kt b/vector/src/debug/java/im/vector/riotx/features/debug/DebugMenuActivity.kt index a197a6f93e..29ed6d101c 100644 --- a/vector/src/debug/java/im/vector/riotx/features/debug/DebugMenuActivity.kt +++ b/vector/src/debug/java/im/vector/riotx/features/debug/DebugMenuActivity.kt @@ -36,6 +36,7 @@ import im.vector.riotx.core.utils.allGranted import im.vector.riotx.core.utils.checkPermissions import im.vector.riotx.core.utils.toast import im.vector.riotx.features.debug.sas.DebugSasEmojiActivity +import im.vector.riotx.features.pin.PinActivity import im.vector.riotx.features.qrcode.QrCodeScannerActivity import kotlinx.android.synthetic.debug.activity_debug_menu.* import timber.log.Timber @@ -81,6 +82,11 @@ class DebugMenuActivity : VectorBaseActivity() { startActivity(Intent(this, DebugSasEmojiActivity::class.java)) } + @OnClick(R.id.debug_open_pin_code) + fun openPinCode() { + startActivity(PinActivity.newIntent(this)) + } + @OnClick(R.id.debug_test_notification) fun testNotification() { val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager diff --git a/vector/src/debug/res/layout/activity_debug_menu.xml b/vector/src/debug/res/layout/activity_debug_menu.xml index 6578258e70..d0e94f49a4 100644 --- a/vector/src/debug/res/layout/activity_debug_menu.xml +++ b/vector/src/debug/res/layout/activity_debug_menu.xml @@ -61,6 +61,13 @@ android:layout_height="wrap_content" android:text="Crash the app" /> + + + diff --git a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt index 8e4f95ed54..9efe0e6adb 100644 --- a/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/riotx/core/di/FragmentModule.kt @@ -66,6 +66,7 @@ import im.vector.riotx.features.login.LoginSplashFragment import im.vector.riotx.features.login.LoginWaitForEmailFragment import im.vector.riotx.features.login.LoginWebFragment import im.vector.riotx.features.login.terms.LoginTermsFragment +import im.vector.riotx.features.pin.PinFragment import im.vector.riotx.features.qrcode.QrCodeScannerFragment import im.vector.riotx.features.reactions.EmojiChooserFragment import im.vector.riotx.features.reactions.EmojiSearchResultFragment @@ -534,4 +535,9 @@ interface FragmentModule { @IntoMap @FragmentKey(ContactsBookFragment::class) fun bindPhoneBookFragment(fragment: ContactsBookFragment): Fragment + + @Binds + @IntoMap + @FragmentKey(PinFragment::class) + fun bindPinFragment(fragment: PinFragment): Fragment } diff --git a/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt index 8267ba4c99..7d17545309 100644 --- a/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/riotx/features/navigation/DefaultNavigator.kt @@ -52,6 +52,7 @@ import im.vector.riotx.features.invite.InviteUsersToRoomActivity import im.vector.riotx.features.media.AttachmentData import im.vector.riotx.features.media.BigImageViewerActivity import im.vector.riotx.features.media.VectorAttachmentViewerActivity +import im.vector.riotx.features.pin.PinActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity @@ -250,6 +251,7 @@ class DefaultNavigator @Inject constructor( } } + override fun openTerms(fragment: Fragment, serviceType: TermsService.ServiceType, baseUrl: String, token: String?, requestCode: Int) { val intent = ReviewTermsActivity.intent(fragment.requireContext(), serviceType, baseUrl, token) fragment.startActivityForResult(intent, requestCode) @@ -272,6 +274,11 @@ class DefaultNavigator @Inject constructor( context.startActivity(WidgetActivity.newIntent(context, widgetArgs)) } + override fun openPinCode(activity: Activity, requestCode: Int) { + val intent = PinActivity.newIntent(activity) + activity.startActivity(intent) + } + override fun openMediaViewer(activity: Activity, roomId: String, mediaData: AttachmentData, diff --git a/vector/src/main/java/im/vector/riotx/features/navigation/Navigator.kt b/vector/src/main/java/im/vector/riotx/features/navigation/Navigator.kt index 2d817183be..7ffef9aa34 100644 --- a/vector/src/main/java/im/vector/riotx/features/navigation/Navigator.kt +++ b/vector/src/main/java/im/vector/riotx/features/navigation/Navigator.kt @@ -78,6 +78,8 @@ interface Navigator { fun openBigImageViewer(activity: Activity, sharedElement: View?, matrixItem: MatrixItem) + fun openPinCode(activity: Activity, requestCode: Int = ReviewTermsActivity.TERMS_REQUEST_CODE) + fun openTerms(fragment: Fragment, serviceType: TermsService.ServiceType, baseUrl: String, diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinAction.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinAction.kt new file mode 100644 index 0000000000..fd8aac90bb --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinAction.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.pin + +import im.vector.riotx.core.platform.VectorViewModelAction + +sealed class PinAction : VectorViewModelAction diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt new file mode 100644 index 0000000000..27322c1539 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.pin + +import android.content.Context +import android.content.Intent +import androidx.appcompat.widget.Toolbar +import im.vector.riotx.R +import im.vector.riotx.core.extensions.addFragment +import im.vector.riotx.core.platform.ToolbarConfigurable +import im.vector.riotx.core.platform.VectorBaseActivity + +class PinActivity : VectorBaseActivity(), ToolbarConfigurable { + + companion object { + + fun newIntent(context: Context): Intent { + return Intent(context, PinActivity::class.java) + } + } + + override fun getLayoutRes() = R.layout.activity_simple + + override fun initUiAndData() { + if (isFirstCreation()) { + addFragment(R.id.simpleFragmentContainer, PinFragment::class.java) + } + } + + override fun configure(toolbar: Toolbar) { + configureToolbar(toolbar) + } +} diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinFragment.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinFragment.kt new file mode 100644 index 0000000000..07c426a31d --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinFragment.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.pin + +import android.os.Bundle +import android.view.View +import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState +import im.vector.riotx.R +import im.vector.riotx.core.platform.VectorBaseFragment +import timber.log.Timber +import javax.inject.Inject + +class PinFragment @Inject constructor( + private val viewModelFactory: PinViewModel.Factory +) : VectorBaseFragment(), PinViewModel.Factory by viewModelFactory { + + private val viewModel: PinViewModel by fragmentViewModel() + + override fun getLayoutResId() = R.layout.fragment_pin + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + // Initialize your view, subscribe to viewModel... + } + + override fun onDestroyView() { + super.onDestroyView() + // Clear your view, unsubscribe... + } + + override fun invalidate() = withState(viewModel) { state -> + Timber.v("Invalidate $state") + } +} diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinViewModel.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinViewModel.kt new file mode 100644 index 0000000000..9a5cdfd8f9 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinViewModel.kt @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.pin + +import com.airbnb.mvrx.ActivityViewModelContext +import com.airbnb.mvrx.FragmentViewModelContext +import com.airbnb.mvrx.MvRxViewModelFactory +import com.airbnb.mvrx.ViewModelContext +import com.squareup.inject.assisted.Assisted +import com.squareup.inject.assisted.AssistedInject +import im.vector.riotx.core.platform.EmptyViewEvents +import im.vector.riotx.core.platform.VectorViewModel +import timber.log.Timber + +class PinViewModel @AssistedInject constructor(@Assisted initialState: PinViewState) + : VectorViewModel(initialState) { + + @AssistedInject.Factory + interface Factory { + fun create(initialState: PinViewState): PinViewModel + } + + companion object : MvRxViewModelFactory { + + @JvmStatic + override fun create(viewModelContext: ViewModelContext, state: PinViewState): PinViewModel? { + val factory = when (viewModelContext) { + is FragmentViewModelContext -> viewModelContext.fragment as? Factory + is ActivityViewModelContext -> viewModelContext.activity as? Factory + } + return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface") + } + } + + override fun handle(action: PinAction) { + Timber.v("$action not handled by viewModel") + } +} diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinViewState.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinViewState.kt new file mode 100644 index 0000000000..45eb9f72c2 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinViewState.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.pin + +import com.airbnb.mvrx.MvRxState + +data class PinViewState(val flag: Boolean = false) : MvRxState diff --git a/vector/src/main/res/layout/fragment_pin.xml b/vector/src/main/res/layout/fragment_pin.xml new file mode 100644 index 0000000000..31742cce30 --- /dev/null +++ b/vector/src/main/res/layout/fragment_pin.xml @@ -0,0 +1,19 @@ + + + + + + From c5f06386bd0171f4b72366c5923338d2eabca841 Mon Sep 17 00:00:00 2001 From: ganfra Date: Fri, 17 Jul 2020 17:13:50 +0200 Subject: [PATCH 02/12] Continue trying to configure Pin library, stil WIP --- .../vector/riotx/features/pin/PinActivity.kt | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt index 27322c1539..1fc1270192 100644 --- a/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt @@ -19,10 +19,15 @@ package im.vector.riotx.features.pin import android.content.Context import android.content.Intent import androidx.appcompat.widget.Toolbar +import com.beautycoder.pflockscreen.PFFLockScreenConfiguration +import com.beautycoder.pflockscreen.fragments.PFLockScreenFragment +import com.beautycoder.pflockscreen.fragments.PFLockScreenFragment.OnPFLockScreenCodeCreateListener import im.vector.riotx.R import im.vector.riotx.core.extensions.addFragment +import im.vector.riotx.core.extensions.replaceFragment import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.VectorBaseActivity +import timber.log.Timber class PinActivity : VectorBaseActivity(), ToolbarConfigurable { @@ -37,11 +42,58 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigurable { override fun initUiAndData() { if (isFirstCreation()) { - addFragment(R.id.simpleFragmentContainer, PinFragment::class.java) + showCreateFragment() } } override fun configure(toolbar: Toolbar) { configureToolbar(toolbar) } + + private fun showCreateFragment() { + val createFragment = PFLockScreenFragment() + val builder = PFFLockScreenConfiguration.Builder(this) + .setNewCodeValidation(true) + .setTitle("Choose a PIN for security") + .setNewCodeValidationTitle("Confirm PIN") + .setMode(PFFLockScreenConfiguration.MODE_CREATE) + createFragment.setConfiguration(builder.build()) + createFragment.setCodeCreateListener(object : OnPFLockScreenCodeCreateListener { + override fun onNewCodeValidationFailed() { + } + + override fun onCodeCreated(encodedCode: String) { + showAuthFragment(encodedCode) + } + }) + addFragment(R.id.simpleFragmentContainer, createFragment) + } + + private fun showAuthFragment(encodedCode: String) { + val authFragment = PFLockScreenFragment() + val builder = PFFLockScreenConfiguration.Builder(this) + .setUseFingerprint(true) + .setTitle("Enter your PIN") + .setLeftButton("Forgot PIN?") + .setMode(PFFLockScreenConfiguration.MODE_AUTH) + authFragment.setConfiguration(builder.build()) + authFragment.setEncodedPinCode(encodedCode) + authFragment.setOnLeftButtonClickListener { + + } + authFragment.setLoginListener(object : PFLockScreenFragment.OnPFLockScreenLoginListener { + override fun onPinLoginFailed() { + } + + override fun onFingerprintSuccessful() { + } + + override fun onFingerprintLoginFailed() { + } + + override fun onCodeInputSuccessful() { + } + }) + replaceFragment(R.id.simpleFragmentContainer, authFragment) + } } From ecdef52829ed0cadf39c60b53924e488b371a800 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 28 Jul 2020 20:22:59 +0200 Subject: [PATCH 03/12] Continue PIN code library integration (fork required) --- build.gradle | 2 +- vector/build.gradle | 2 +- .../vector/riotx/features/pin/PinActivity.kt | 29 +++++++++--- .../main/res/drawable/pin_code_dot_empty.xml | 13 ++++++ .../main/res/drawable/pin_code_dot_fill.xml | 12 +++++ .../src/main/res/drawable/pin_code_dots.xml | 9 ++++ .../src/main/res/values/styles_pin_code.xml | 44 +++++++++++++++++++ vector/src/main/res/values/theme_dark.xml | 10 +++++ vector/src/main/res/values/theme_light.xml | 10 +++++ 9 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 vector/src/main/res/drawable/pin_code_dot_empty.xml create mode 100644 vector/src/main/res/drawable/pin_code_dot_fill.xml create mode 100644 vector/src/main/res/drawable/pin_code_dots.xml create mode 100644 vector/src/main/res/values/styles_pin_code.xml diff --git a/build.gradle b/build.gradle index 5593a56f6e..12c5181ea4 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ allprojects { // PhotoView includeGroupByRegex 'com\\.github\\.chrisbanes' // PFLockScreen-Android - includeGroupByRegex 'com\\.github\\.thealeksandr' + includeGroupByRegex 'com\\.github\\.ganfra' } } maven { diff --git a/vector/build.gradle b/vector/build.gradle index 0d654438f5..f60f74629f 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -346,7 +346,7 @@ dependencies { implementation 'me.saket:better-link-movement-method:2.2.0' implementation 'com.google.android:flexbox:1.1.1' implementation "androidx.autofill:autofill:$autofill_version" - implementation 'com.github.thealeksandr:PFLockScreen-Android:1.0.0-beta7' + implementation 'com.github.ganfra:PFLockScreen-Android:1.0.0-beta8' // Custom Tab implementation 'androidx.browser:browser:1.2.0' diff --git a/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt index 1fc1270192..fc0d3b1bcb 100644 --- a/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/pin/PinActivity.kt @@ -18,16 +18,16 @@ package im.vector.riotx.features.pin import android.content.Context import android.content.Intent +import android.widget.Toast +import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.Toolbar import com.beautycoder.pflockscreen.PFFLockScreenConfiguration import com.beautycoder.pflockscreen.fragments.PFLockScreenFragment import com.beautycoder.pflockscreen.fragments.PFLockScreenFragment.OnPFLockScreenCodeCreateListener import im.vector.riotx.R -import im.vector.riotx.core.extensions.addFragment import im.vector.riotx.core.extensions.replaceFragment import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.VectorBaseActivity -import timber.log.Timber class PinActivity : VectorBaseActivity(), ToolbarConfigurable { @@ -41,9 +41,7 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigurable { override fun getLayoutRes() = R.layout.activity_simple override fun initUiAndData() { - if (isFirstCreation()) { - showCreateFragment() - } + showCreateFragment() } override fun configure(toolbar: Toolbar) { @@ -57,6 +55,7 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigurable { .setTitle("Choose a PIN for security") .setNewCodeValidationTitle("Confirm PIN") .setMode(PFFLockScreenConfiguration.MODE_CREATE) + createFragment.setConfiguration(builder.build()) createFragment.setCodeCreateListener(object : OnPFLockScreenCodeCreateListener { override fun onNewCodeValidationFailed() { @@ -66,7 +65,7 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigurable { showAuthFragment(encodedCode) } }) - addFragment(R.id.simpleFragmentContainer, createFragment) + replaceFragment(R.id.simpleFragmentContainer, createFragment) } private fun showAuthFragment(encodedCode: String) { @@ -75,25 +74,41 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigurable { .setUseFingerprint(true) .setTitle("Enter your PIN") .setLeftButton("Forgot PIN?") + .setClearCodeOnError(true) .setMode(PFFLockScreenConfiguration.MODE_AUTH) authFragment.setConfiguration(builder.build()) authFragment.setEncodedPinCode(encodedCode) authFragment.setOnLeftButtonClickListener { - + displayForgotPinWarningDialog() } authFragment.setLoginListener(object : PFLockScreenFragment.OnPFLockScreenLoginListener { override fun onPinLoginFailed() { } override fun onFingerprintSuccessful() { + Toast.makeText(this@PinActivity, "Pin successful", Toast.LENGTH_LONG).show() + finish() } override fun onFingerprintLoginFailed() { } override fun onCodeInputSuccessful() { + Toast.makeText(this@PinActivity, "Pin successful", Toast.LENGTH_LONG).show() + finish() } }) replaceFragment(R.id.simpleFragmentContainer, authFragment) } + + private fun displayForgotPinWarningDialog() { + AlertDialog.Builder(this) + .setTitle("Reset pin") + .setMessage("To reset your PIN, you'll need to re-login and create a new one.") + .setPositiveButton("Reset pin") { _, _ -> + showCreateFragment() + } + .setNegativeButton(R.string.cancel, null) + .show() + } } diff --git a/vector/src/main/res/drawable/pin_code_dot_empty.xml b/vector/src/main/res/drawable/pin_code_dot_empty.xml new file mode 100644 index 0000000000..6ee800a07d --- /dev/null +++ b/vector/src/main/res/drawable/pin_code_dot_empty.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pin_code_dot_fill.xml b/vector/src/main/res/drawable/pin_code_dot_fill.xml new file mode 100644 index 0000000000..799ea30174 --- /dev/null +++ b/vector/src/main/res/drawable/pin_code_dot_fill.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pin_code_dots.xml b/vector/src/main/res/drawable/pin_code_dots.xml new file mode 100644 index 0000000000..29e445e511 --- /dev/null +++ b/vector/src/main/res/drawable/pin_code_dots.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/styles_pin_code.xml b/vector/src/main/res/values/styles_pin_code.xml new file mode 100644 index 0000000000..498b791e05 --- /dev/null +++ b/vector/src/main/res/values/styles_pin_code.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/theme_dark.xml b/vector/src/main/res/values/theme_dark.xml index fae33cf6bf..a391e48cfb 100644 --- a/vector/src/main/res/values/theme_dark.xml +++ b/vector/src/main/res/values/theme_dark.xml @@ -222,6 +222,16 @@ @style/VectorSnackBarButton @style/VectorSnackBarText + + @style/PinCodeScreenStyle + @style/PinCodeKeyButtonStyle + @style/PinCodeTitleStyle + @style/PinCodeHintStyle + @style/PinCodeDotsViewStyle + @style/PinCodeDeleteButtonStyle + @style/PinCodeFingerprintButtonStyle + @style/PinCodeNextButtonStyle +