From 0659946f693a7098402b5bf8c34f03a5425b6444 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Tue, 15 Sep 2020 13:56:48 +0300 Subject: [PATCH 01/12] update target SDK to 30 --- app/build.gradle | 26 +++++++++---------- .../app/AuthenticatorApplication.kt | 16 ++++++------ .../create/ConnectProviderViewModel.kt | 2 +- .../features/qr/QrScannerActivity.kt | 11 +++----- .../passcode/PasscodeEditViewModel.kt | 2 +- .../settings/passcode/saver/PasscodeSaver.kt | 2 +- authenticator_sdk/build.gradle | 6 ++--- build.gradle | 2 +- rasp/build.gradle | 10 +++---- test_tools/build.gradle | 6 ++--- 10 files changed, 39 insertions(+), 44 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9ae339fa5..61f5ed053 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,10 +61,10 @@ android { multiDexEnabled = true vectorDrawables.useSupportLibrary = true - buildToolsVersion '29.0.2' + buildToolsVersion '30.0.2' minSdkVersion 21 - compileSdkVersion 29 - targetSdkVersion 29 + compileSdkVersion 30 + targetSdkVersion 30 versionCode 48 versionName '3.1.1' @@ -126,10 +126,10 @@ androidExtensions { dependencies { //TODO After changing dependencies list, review third-party libraries licenses list implementation fileTree(include: ['*.jar'], dir: 'libs') - kapt 'com.google.dagger:dagger-compiler:2.24' - implementation 'com.google.dagger:dagger:2.24' + kapt 'com.google.dagger:dagger-compiler:2.28.3' + implementation 'com.google.dagger:dagger:2.28.3' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" @@ -138,10 +138,10 @@ dependencies { //TODO After changing dependencies list, review third-party libra implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" - implementation 'com.google.android.material:material:1.1.0' - implementation 'com.google.android.gms:play-services-base:17.3.0' - implementation 'com.google.android.gms:play-services-vision:20.1.0' - implementation 'com.google.firebase:firebase-core:17.4.4' + implementation 'com.google.android.material:material:1.2.1' + implementation 'com.google.android.gms:play-services-base:17.4.0' + implementation 'com.google.android.gms:play-services-vision:20.1.2' + implementation 'com.google.firebase:firebase-core:17.5.0' implementation 'com.google.firebase:firebase-messaging:20.2.4' implementation 'com.squareup.retrofit2:converter-gson:2.7.1' implementation 'net.danlew:android.joda:2.10.2' @@ -159,7 +159,7 @@ dependencies { //TODO After changing dependencies list, review third-party libra androidTestUtil 'com.android.support.test:orchestrator:1.0.2' testImplementation 'junit:junit:4.13' - testImplementation 'androidx.test:core:1.2.0' + testImplementation 'androidx.test:core:1.3.0' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8' testImplementation 'org.robolectric:robolectric:4.3.1' testImplementation 'org.robolectric:shadows-playservices:4.3' @@ -167,8 +167,8 @@ dependencies { //TODO After changing dependencies list, review third-party libra testImplementation "io.mockk:mockk:1.9.3" testImplementation project(':test_tools') - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:runner:1.3.0' androidTestImplementation 'org.hamcrest:hamcrest-core:1.3' androidTestImplementation 'org.hamcrest:hamcrest-integration:1.3' androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt index 851969c75..a69db5a1b 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt @@ -66,23 +66,23 @@ open class AuthenticatorApplication : Application(), Application.ActivityLifecyc setupNightMode() } - override fun onActivityPaused(activity: Activity?) { + override fun onActivityPaused(activity: Activity) { currentActivityName = "" } - override fun onActivityResumed(activity: Activity?) { - currentActivityName = activity?.javaClass?.name ?: "" + override fun onActivityResumed(activity: Activity) { + currentActivityName = activity.javaClass.name ?: "" } - override fun onActivityStarted(activity: Activity?) {} + override fun onActivityStarted(activity: Activity) {} - override fun onActivityDestroyed(activity: Activity?) {} + override fun onActivityDestroyed(activity: Activity) {} - override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {} + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} - override fun onActivityStopped(activity: Activity?) {} + override fun onActivityStopped(activity: Activity) {} - override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {} + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} private fun initFirebaseModules() { Fabric.with(this, createCrashlyticsKit()) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderViewModel.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderViewModel.kt index 85b6295d4..7d5d09f86 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderViewModel.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderViewModel.kt @@ -275,7 +275,7 @@ class ConnectProviderViewModel( } else { sessionFailMessage ?: appContext.getString( R.string.errors_connection_failed_description - ) ?: "" + ) } } } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt index d6ccc99eb..3e2ab55d5 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt @@ -138,19 +138,14 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { private fun setupSurface() { surfaceView?.holder?.addCallback(object : SurfaceHolder.Callback { - override fun surfaceChanged( - holder: SurfaceHolder?, - format: Int, - width: Int, - height: Int - ) { + override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { } - override fun surfaceDestroyed(holder: SurfaceHolder?) { + override fun surfaceDestroyed(holder: SurfaceHolder) { cameraSource?.stop() } - override fun surfaceCreated(holder: SurfaceHolder?) { + override fun surfaceCreated(holder: SurfaceHolder) { startCameraSource() } }) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditViewModel.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditViewModel.kt index 70159dba8..98ec1ebbe 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditViewModel.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditViewModel.kt @@ -76,7 +76,7 @@ class PasscodeEditViewModel( override fun onNewPasscodeConfirmed(passcode: String) { loaderVisibility.postValue(View.VISIBLE) - PasscodeSaver(passcodeTools, callback = this).runNewTask(passcode) + PasscodeSaver(passcodeTools, callback = this).runNewTask(passcode)//TODO use coroutine } override fun passcodeSavedWithResult(result: Boolean) { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/saver/PasscodeSaver.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/saver/PasscodeSaver.kt index 709ba91ce..2a14bee9c 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/saver/PasscodeSaver.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/saver/PasscodeSaver.kt @@ -26,7 +26,7 @@ import com.saltedge.authenticator.tools.PasscodeToolsAbs class PasscodeSaver( private val passcodeTools: PasscodeToolsAbs, override var callback: PasscodeSaveResultListener? -) : AsyncTask(), PasscodeSaverAbs { +) : AsyncTask(), PasscodeSaverAbs {//TODO use coroutine override fun runNewTask(passcode: String) { this.execute(passcode) diff --git a/authenticator_sdk/build.gradle b/authenticator_sdk/build.gradle index e7de1470b..7143c12fb 100644 --- a/authenticator_sdk/build.gradle +++ b/authenticator_sdk/build.gradle @@ -74,8 +74,8 @@ android { dependencies { api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api 'androidx.appcompat:appcompat:1.1.0' - api "androidx.webkit:webkit:1.3.0-rc01" + api 'androidx.appcompat:appcompat:1.2.0' + api "androidx.webkit:webkit:1.3.0" api 'com.squareup.retrofit2:retrofit:2.7.1' api 'com.squareup.retrofit2:converter-gson:2.7.1' api 'com.squareup.okhttp3:logging-interceptor:4.3.1' @@ -83,7 +83,7 @@ dependencies { androidTestUtil 'com.android.support.test:orchestrator:1.0.2' testImplementation 'junit:junit:4.13' - testImplementation 'androidx.test:core:1.2.0' + testImplementation 'androidx.test:core:1.3.0' testImplementation 'org.robolectric:robolectric:4.3.1' testImplementation "io.mockk:mockk:1.9.3" androidTestImplementation 'androidx.test.ext:junit:1.1.1' diff --git a/build.gradle b/build.gradle index 95c02ad50..5e6f17544 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.10' ext.realm_version = '6.1.0' ext.nav_version = '2.3.0' repositories { diff --git a/rasp/build.gradle b/rasp/build.gradle index ec723d57a..6281c0a58 100644 --- a/rasp/build.gradle +++ b/rasp/build.gradle @@ -30,8 +30,8 @@ def libVersionName = "1.0.0" android { defaultConfig { minSdkVersion 19 - targetSdkVersion 29 - compileSdkVersion 29 + targetSdkVersion 30 + compileSdkVersion 30 versionCode libVersionCode versionName libVersionName @@ -58,10 +58,10 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.appcompat:appcompat:1.2.0' testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:runner:1.3.0' } group 'com.saltedge.authenticator.security' diff --git a/test_tools/build.gradle b/test_tools/build.gradle index ebdd59cc8..564e3c565 100644 --- a/test_tools/build.gradle +++ b/test_tools/build.gradle @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 29 - buildToolsVersion "29.0.3" + compileSdkVersion 30 + buildToolsVersion "30.0.2" defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 versionName "1.0" From 66d7e63b01fbff94f6037b4ad88de47c9ae2639d Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Tue, 15 Sep 2020 15:35:49 +0300 Subject: [PATCH 02/12] catch navigation exceptions --- .../saltedge/authenticator/app/ThemeHelper.kt | 9 ------ .../features/actions/SubmitActionFragment.kt | 10 ++----- .../details/AuthorizationDetailsFragment.kt | 4 +-- .../list/AuthorizationsListFragment.kt | 8 ++--- .../create/ConnectProviderFragment.kt | 3 +- .../list/ConnectionsListFragment.kt | 8 ++--- .../select/SelectConnectionsFragment.kt | 3 +- .../details/ConsentDetailsFragment.kt | 4 +-- .../consents/list/ConsentsListFragment.kt | 2 +- .../settings/about/AboutListFragment.kt | 2 +- .../settings/licenses/LicensesFragment.kt | 6 ++-- .../settings/list/SettingsListFragment.kt | 4 +-- .../settings/passcode/PasscodeEditFragment.kt | 4 +-- .../authenticator/tools/NavigationHelper.kt | 30 ++++++++++++++++++- 14 files changed, 50 insertions(+), 47 deletions(-) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/ThemeHelper.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/ThemeHelper.kt index 70acfe81c..b1d224857 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/ThemeHelper.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/ThemeHelper.kt @@ -23,15 +23,10 @@ package com.saltedge.authenticator.app import android.content.Context import android.content.res.Configuration import android.os.Build -import android.os.Bundle import androidx.appcompat.app.AppCompatDelegate -import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity -import androidx.navigation.NavOptions -import androidx.navigation.fragment.findNavController import androidx.navigation.navOptions import com.saltedge.authenticator.R -import com.saltedge.authenticator.tools.ResId import com.saltedge.authenticator.tools.buildVersion28orGreater import com.saltedge.authenticator.widget.security.KEY_SKIP_PIN @@ -73,7 +68,3 @@ val defaultTransition = navOptions { popExit = R.anim.slide_out_right } } - -fun Fragment.navigateTo(actionRes: ResId, bundle: Bundle? = null, transition: NavOptions = defaultTransition) { - findNavController().navigate(actionRes, bundle, transition) -} diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/actions/SubmitActionFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/actions/SubmitActionFragment.kt index 361b9c483..82b96bc80 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/actions/SubmitActionFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/actions/SubmitActionFragment.kt @@ -20,33 +20,29 @@ */ package com.saltedge.authenticator.features.actions -import android.content.DialogInterface import android.content.Intent import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.appcompat.app.AlertDialog import androidx.databinding.DataBindingUtil import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.databinding.SubmitActionBinding import com.saltedge.authenticator.features.main.SharedViewModel import com.saltedge.authenticator.features.main.newAuthorizationListener -import com.saltedge.authenticator.interfaces.DialogHandlerListener import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.sdk.constants.KEY_DATA import com.saltedge.authenticator.sdk.model.GUID import com.saltedge.authenticator.sdk.model.appLink.ActionAppLinkData import com.saltedge.authenticator.sdk.model.authorization.AuthorizationIdentifier import com.saltedge.authenticator.tools.authenticatorApp -import com.saltedge.authenticator.tools.showWarningDialog +import com.saltedge.authenticator.tools.navigateTo +import com.saltedge.authenticator.tools.popBackStack import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_submit_action.* import javax.inject.Inject @@ -99,7 +95,7 @@ class SubmitActionFragment : BaseFragment() { lifecycle.addObserver(viewModel) viewModel.onCloseEvent.observe(this, Observer> { - it.getContentIfNotHandled()?.let { findNavController().popBackStack() } + it.getContentIfNotHandled()?.let { popBackStack() } }) viewModel.onOpenLinkEvent.observe(this, Observer> { it.getContentIfNotHandled()?.let { url -> diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/details/AuthorizationDetailsFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/details/AuthorizationDetailsFragment.kt index ec014d80e..8416d30b7 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/details/AuthorizationDetailsFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/details/AuthorizationDetailsFragment.kt @@ -26,7 +26,6 @@ import android.view.View import android.view.ViewGroup import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import com.google.android.material.snackbar.Snackbar import com.saltedge.authenticator.R import com.saltedge.authenticator.app.KEY_CLOSE_APP @@ -40,6 +39,7 @@ import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.sdk.constants.KEY_TITLE import com.saltedge.authenticator.sdk.model.authorization.AuthorizationIdentifier import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.popBackStack import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_authorization_details.* import java.util.* @@ -124,7 +124,7 @@ class AuthorizationDetailsFragment : BaseFragment(), event.getContentIfNotHandled()?.let { activity?.finish() } }) viewModel.onCloseViewEvent.observe(this, Observer> { event -> - event.getContentIfNotHandled()?.let { findNavController().popBackStack() } + event.getContentIfNotHandled()?.let { popBackStack() } }) viewModel.authorizationModel.observe(this, Observer { headerView?.setTitleAndLogo(title = it.connectionName, logoUrl = it.connectionLogoUrl ?: "") diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/list/AuthorizationsListFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/list/AuthorizationsListFragment.kt index f9fd65321..791e76694 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/list/AuthorizationsListFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/authorizations/list/AuthorizationsListFragment.kt @@ -29,11 +29,9 @@ import androidx.fragment.app.DialogFragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import com.google.android.material.snackbar.Snackbar import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.cloud.clearNotifications import com.saltedge.authenticator.databinding.AuthorizationsListBinding import com.saltedge.authenticator.features.authorizations.common.AuthorizationItemViewModel @@ -45,9 +43,7 @@ import com.saltedge.authenticator.interfaces.AppbarMenuItemClickListener import com.saltedge.authenticator.interfaces.DialogHandlerListener import com.saltedge.authenticator.interfaces.MenuItem import com.saltedge.authenticator.models.ViewModelEvent -import com.saltedge.authenticator.tools.ResId -import com.saltedge.authenticator.tools.authenticatorApp -import com.saltedge.authenticator.tools.showQrScannerActivity +import com.saltedge.authenticator.tools.* import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_authorizations_list.* import javax.inject.Inject @@ -145,7 +141,7 @@ class AuthorizationsListFragment : BaseFragment(), AppbarMenuItemClickListener, }) viewModel.onMoreMenuClickEvent.observe(this, Observer { event -> event.getContentIfNotHandled()?.let { menuItems -> - findNavController().navigate(R.id.bottom_menu_dialog, menuItems) + navigateToDialog(R.id.bottom_menu_dialog, menuItems) } }) viewModel.onShowConnectionsListEvent.observe(this, Observer { event -> diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderFragment.kt index b592ab858..2db2f7f35 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/create/ConnectProviderFragment.kt @@ -31,7 +31,6 @@ import androidx.appcompat.app.AlertDialog import androidx.databinding.DataBindingUtil import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory @@ -134,7 +133,7 @@ class ConnectProviderFragment : BaseFragment(), lifecycle.addObserver(viewModel) viewModel.onCloseEvent.observe(this, Observer> { - it.getContentIfNotHandled()?.let { findNavController().popBackStack() } + it.getContentIfNotHandled()?.let { popBackStack() } }) viewModel.onShowErrorEvent.observe(this, Observer> { it.getContentIfNotHandled()?.let { message -> diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/list/ConnectionsListFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/list/ConnectionsListFragment.kt index 6e03d9ae9..3b5d8533d 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/list/ConnectionsListFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/list/ConnectionsListFragment.kt @@ -34,7 +34,6 @@ import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.databinding.ConnectionsListBinding import com.saltedge.authenticator.features.connections.common.ConnectionItemViewModel import com.saltedge.authenticator.features.connections.list.menu.MenuData @@ -44,10 +43,7 @@ import com.saltedge.authenticator.interfaces.DialogHandlerListener import com.saltedge.authenticator.interfaces.ListItemClickListener import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.sdk.model.GUID -import com.saltedge.authenticator.tools.authenticatorApp -import com.saltedge.authenticator.tools.showQrScannerActivity -import com.saltedge.authenticator.tools.startMailApp -import com.saltedge.authenticator.tools.stopRefresh +import com.saltedge.authenticator.tools.* import com.saltedge.authenticator.widget.fragment.BaseFragment import com.saltedge.authenticator.widget.list.SpaceItemDecoration import kotlinx.android.synthetic.main.fragment_connections_list.* @@ -132,7 +128,7 @@ class ConnectionsListFragment : BaseFragment(), }) viewModel.onRenameClickEvent.observe(this, Observer> { event -> event.getContentIfNotHandled()?.let { bundle -> - findNavController().navigate(R.id.edit_connection_name_dialog, bundle) + navigateToDialog(R.id.edit_connection_name_dialog, bundle) } }) viewModel.onDeleteClickEvent.observe(this, Observer> { event -> diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt index 99027d2b1..d00d5b1f2 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt @@ -41,6 +41,7 @@ import com.saltedge.authenticator.interfaces.OnBackPressListener import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.sdk.model.GUID import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.popBackStack import com.saltedge.authenticator.tools.setVisible import com.saltedge.authenticator.widget.fragment.BaseFragment import com.saltedge.authenticator.widget.list.SpaceItemDecoration @@ -119,7 +120,7 @@ class SelectConnectionsFragment : BaseFragment(), OnBackPressListener, ListItemC }) viewModel.onProceedClickEvent.observe(this, Observer { connectionGuid -> sharedViewModel.onSelectConnection(connectionGuid) - findNavController().popBackStack() + popBackStack() }) (arguments?.getSerializable(KEY_CONNECTIONS) as? List)?.let { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/consents/details/ConsentDetailsFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/consents/details/ConsentDetailsFragment.kt index dee60931c..64215ca6b 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/consents/details/ConsentDetailsFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/consents/details/ConsentDetailsFragment.kt @@ -29,13 +29,13 @@ import androidx.databinding.DataBindingUtil import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory import com.saltedge.authenticator.databinding.ConsentDetailsBinding import com.saltedge.authenticator.features.main.SharedViewModel import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.popBackStack import com.saltedge.authenticator.tools.showConfirmRevokeConsentDialog import com.saltedge.authenticator.tools.showWarningDialog import com.saltedge.authenticator.widget.fragment.BaseFragment @@ -97,7 +97,7 @@ class ConsentDetailsFragment : BaseFragment() { viewModel.revokeSuccessEvent.observe(this, Observer> { event -> event.getContentIfNotHandled()?.let { consentId -> sharedViewModel.onRevokeConsent(consentId) - findNavController().popBackStack() + popBackStack() } }) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/consents/list/ConsentsListFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/consents/list/ConsentsListFragment.kt index 7766be076..104391ae7 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/consents/list/ConsentsListFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/consents/list/ConsentsListFragment.kt @@ -34,7 +34,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.databinding.ConsentsListBinding import com.saltedge.authenticator.features.main.SharedViewModel import com.saltedge.authenticator.features.main.showWarningSnack @@ -42,6 +41,7 @@ import com.saltedge.authenticator.interfaces.ListItemClickListener import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.tools.authenticatorApp import com.saltedge.authenticator.tools.loadRoundedImage +import com.saltedge.authenticator.tools.navigateTo import com.saltedge.authenticator.tools.stopRefresh import com.saltedge.authenticator.widget.fragment.BaseFragment import com.saltedge.authenticator.widget.list.SpaceItemDecoration diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/about/AboutListFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/about/AboutListFragment.kt index 05a84d1cd..c413a8c30 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/about/AboutListFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/about/AboutListFragment.kt @@ -29,10 +29,10 @@ import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.features.settings.common.SettingsAdapter import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.navigateTo import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_base_list.* import javax.inject.Inject diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/licenses/LicensesFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/licenses/LicensesFragment.kt index b7b22a92e..a29e29ced 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/licenses/LicensesFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/licenses/LicensesFragment.kt @@ -26,13 +26,13 @@ import android.view.View import android.view.ViewGroup import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory import com.saltedge.authenticator.features.settings.common.SettingsAdapter import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.navigateTo import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_base_list.* import javax.inject.Inject @@ -72,9 +72,7 @@ class LicensesFragment : BaseFragment() { viewModel = ViewModelProvider(this, viewModelFactory).get(LicensesViewModel::class.java) viewModel.licenseItemClickEvent.observe(this, Observer> { - it.getContentIfNotHandled()?.let { bundle -> - findNavController().navigate(R.id.terms_of_services, bundle) - } + it.getContentIfNotHandled()?.let { bundle -> navigateTo(R.id.terms_of_services, bundle) } }) } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/list/SettingsListFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/list/SettingsListFragment.kt index 1023dda64..408a67b3e 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/list/SettingsListFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/list/SettingsListFragment.kt @@ -28,13 +28,11 @@ import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory import com.saltedge.authenticator.app.applyNightMode -import com.saltedge.authenticator.app.navigateTo import com.saltedge.authenticator.features.main.showWarningSnack import com.saltedge.authenticator.features.settings.common.SettingsAdapter import com.saltedge.authenticator.features.settings.common.SettingsItemViewModel @@ -89,7 +87,7 @@ class SettingsListFragment : BaseFragment(), DialogHandlerListener, AppbarMenuIt viewModel = ViewModelProvider(this, viewModelFactory).get(SettingsListViewModel::class.java) viewModel.languageClickEvent.observe(this, Observer> { event -> - event.getContentIfNotHandled()?.let { findNavController().navigate(R.id.language) } + event.getContentIfNotHandled()?.let { navigateTo(R.id.language) } }) viewModel.passcodeClickEvent.observe(this, Observer> { event -> event.getContentIfNotHandled()?.let { navigateTo(actionRes = R.id.passcode_edit) } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditFragment.kt index e78defc0d..c654eadf4 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/settings/passcode/PasscodeEditFragment.kt @@ -27,13 +27,13 @@ import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import com.google.android.material.snackbar.Snackbar import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory import com.saltedge.authenticator.features.main.showWarningSnack import com.saltedge.authenticator.interfaces.DialogHandlerListener import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.popBackStack import com.saltedge.authenticator.tools.showWarningDialog import com.saltedge.authenticator.widget.fragment.BaseFragment import kotlinx.android.synthetic.main.fragment_edit_passcode.* @@ -114,7 +114,7 @@ class PasscodeEditFragment : BaseFragment(), DialogHandlerListener { } }) viewModel.closeViewEvent.observe(this, Observer { event -> - event.getContentIfNotHandled()?.let { findNavController().popBackStack() } + event.getContentIfNotHandled()?.let { popBackStack() } }) } } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/NavigationHelper.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/NavigationHelper.kt index 41e58195b..b42cedd9e 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/NavigationHelper.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/NavigationHelper.kt @@ -1,7 +1,7 @@ /* * This file is part of the Salt Edge Authenticator distribution * (https://github.com/saltedge/sca-authenticator-android). - * Copyright (c) 2019 Salt Edge Inc. + * Copyright (c) 2020 Salt Edge Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,12 +23,16 @@ package com.saltedge.authenticator.tools import android.content.ActivityNotFoundException import android.content.Intent import android.net.Uri +import android.os.Bundle import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity +import androidx.navigation.NavOptions import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.fragment.findNavController import com.saltedge.authenticator.R import com.saltedge.authenticator.app.QR_SCAN_REQUEST_CODE +import com.saltedge.authenticator.app.defaultTransition import com.saltedge.authenticator.features.qr.QrScannerActivity import com.saltedge.authenticator.sdk.constants.DEFAULT_SUPPORT_EMAIL_LINK import com.saltedge.authenticator.widget.security.KEY_SKIP_PIN @@ -113,3 +117,27 @@ fun FragmentActivity.restartApp() { } catch (ignored: Exception) { } } + +fun Fragment.navigateTo(actionRes: ResId, bundle: Bundle? = null, transition: NavOptions = defaultTransition) { + try { + findNavController().navigate(actionRes, bundle, transition) + } catch (e: Exception) { + e.log() + } +} + +fun Fragment.navigateToDialog(actionRes: ResId, bundle: Bundle) { + try { + findNavController().navigate(actionRes, bundle) + } catch (e: Exception) { + e.log() + } +} + +fun Fragment.popBackStack() { + try { + findNavController().popBackStack() + } catch (e: Exception) { + e.log() + } +} From 556f67ecd5aafaba93893fcfcce24c7b71e8b81b Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Mon, 5 Oct 2020 12:08:36 +0300 Subject: [PATCH 03/12] update Kotlin, Crashlitics --- app/build.gradle | 35 +++++++++---------- .../app/AuthenticatorApplication.kt | 19 +++++----- .../features/qr/QrScannerActivity.kt | 6 ++-- .../saltedge/authenticator/tools/AppTools.kt | 3 +- .../saltedge/authenticator/tools/LogTools.kt | 12 +++---- authenticator_sdk/build.gradle | 18 +++++----- build.gradle | 9 +++-- rasp/build.gradle | 11 +++--- 8 files changed, 54 insertions(+), 59 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9ae339fa5..330e2ce1b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,7 @@ /* * This file is part of the Salt Edge Authenticator distribution * (https://github.com/saltedge/sca-authenticator-android). - * Copyright (c) 2019 Salt Edge Inc. + * Copyright (c) 2020 Salt Edge Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,10 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' -apply plugin: 'io.fabric' apply plugin: 'idea' apply plugin: 'realm-android' apply plugin: 'androidx.navigation.safeargs.kotlin' +apply plugin: 'com.google.firebase.crashlytics' apply from: './jacoco.gradle' apply from: './common-methods.gradle' @@ -61,10 +61,10 @@ android { multiDexEnabled = true vectorDrawables.useSupportLibrary = true - buildToolsVersion '29.0.2' + buildToolsVersion '29.0.3' minSdkVersion 21 - compileSdkVersion 29 - targetSdkVersion 29 + compileSdkVersion 30 + targetSdkVersion 30 versionCode 48 versionName '3.1.1' @@ -129,7 +129,7 @@ dependencies { //TODO After changing dependencies list, review third-party libra kapt 'com.google.dagger:dagger-compiler:2.24' implementation 'com.google.dagger:dagger:2.24' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" @@ -138,16 +138,15 @@ dependencies { //TODO After changing dependencies list, review third-party libra implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" - implementation 'com.google.android.material:material:1.1.0' - implementation 'com.google.android.gms:play-services-base:17.3.0' - implementation 'com.google.android.gms:play-services-vision:20.1.0' - implementation 'com.google.firebase:firebase-core:17.4.4' - implementation 'com.google.firebase:firebase-messaging:20.2.4' + implementation 'com.google.android.material:material:1.2.1' + implementation 'com.google.android.gms:play-services-base:17.4.0' + implementation 'com.google.android.gms:play-services-vision:20.1.2' + implementation 'com.google.firebase:firebase-core:17.5.0' + implementation 'com.google.firebase:firebase-messaging:20.3.0' + implementation 'com.google.firebase:firebase-crashlytics:17.2.2' + implementation 'com.google.firebase:firebase-analytics:17.5.0' implementation 'com.squareup.retrofit2:converter-gson:2.7.1' implementation 'net.danlew:android.joda:2.10.2' - implementation('com.crashlytics.sdk.android:crashlytics:2.10.1') { - transitive = true - } implementation('com.github.bumptech.glide:glide:4.11.0') { exclude group: "com.android.support" } @@ -159,16 +158,16 @@ dependencies { //TODO After changing dependencies list, review third-party libra androidTestUtil 'com.android.support.test:orchestrator:1.0.2' testImplementation 'junit:junit:4.13' - testImplementation 'androidx.test:core:1.2.0' + testImplementation 'androidx.test:core:1.3.0' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8' testImplementation 'org.robolectric:robolectric:4.3.1' testImplementation 'org.robolectric:shadows-playservices:4.3' testImplementation 'org.mockito:mockito-core:3.2.4' - testImplementation "io.mockk:mockk:1.9.3" + testImplementation "io.mockk:mockk:1.10.2" testImplementation project(':test_tools') - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:runner:1.3.0' androidTestImplementation 'org.hamcrest:hamcrest-core:1.3' androidTestImplementation 'org.hamcrest:hamcrest-integration:1.3' androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt index 851969c75..5dbacc4d0 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt @@ -34,7 +34,6 @@ import com.saltedge.authenticator.sdk.AuthenticatorApiManager import com.saltedge.authenticator.tools.AppTools import com.saltedge.authenticator.tools.createCrashlyticsKit import com.saltedge.authenticator.tools.log -import io.fabric.sdk.android.Fabric import net.danlew.android.joda.JodaTimeAndroid open class AuthenticatorApplication : Application(), Application.ActivityLifecycleCallbacks { @@ -66,26 +65,26 @@ open class AuthenticatorApplication : Application(), Application.ActivityLifecyc setupNightMode() } - override fun onActivityPaused(activity: Activity?) { + override fun onActivityPaused(activity: Activity) { currentActivityName = "" } - override fun onActivityResumed(activity: Activity?) { - currentActivityName = activity?.javaClass?.name ?: "" + override fun onActivityResumed(activity: Activity) { + currentActivityName = activity.javaClass.name ?: "" } - override fun onActivityStarted(activity: Activity?) {} + override fun onActivityStarted(activity: Activity) {} - override fun onActivityDestroyed(activity: Activity?) {} + override fun onActivityDestroyed(activity: Activity) {} - override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {} + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} - override fun onActivityStopped(activity: Activity?) {} + override fun onActivityStopped(activity: Activity) {} - override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {} + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} private fun initFirebaseModules() { - Fabric.with(this, createCrashlyticsKit()) + createCrashlyticsKit() } private fun patchSecurityProvider() { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt index d6ccc99eb..b5a306f01 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt @@ -139,18 +139,18 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { private fun setupSurface() { surfaceView?.holder?.addCallback(object : SurfaceHolder.Callback { override fun surfaceChanged( - holder: SurfaceHolder?, + holder: SurfaceHolder, format: Int, width: Int, height: Int ) { } - override fun surfaceDestroyed(holder: SurfaceHolder?) { + override fun surfaceDestroyed(holder: SurfaceHolder) { cameraSource?.stop() } - override fun surfaceCreated(holder: SurfaceHolder?) { + override fun surfaceCreated(holder: SurfaceHolder) { startCameraSource() } }) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt index 0fbed376f..be877cb72 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt @@ -28,7 +28,6 @@ import android.os.Bundle import android.view.WindowManager import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity -import com.crashlytics.android.Crashlytics import com.saltedge.authenticator.app.AuthenticatorApplication import com.saltedge.authenticator.app.KEY_GUID import com.saltedge.authenticator.sdk.model.GUID @@ -84,7 +83,7 @@ object AppTools : AppToolsAbs { return appContext.packageManager?.getPackageInfo(appContext.packageName, 0)?.versionName ?: "unknown" } catch (e: PackageManager.NameNotFoundException) { - Crashlytics.logException(e) + e.log() } catch (ignored: Exception) { } return "unknown" diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/LogTools.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/LogTools.kt index 35c3ef85c..04dec085b 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/LogTools.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/LogTools.kt @@ -21,8 +21,7 @@ package com.saltedge.authenticator.tools import android.util.Log -import com.crashlytics.android.Crashlytics -import com.crashlytics.android.core.CrashlyticsCore +import com.google.firebase.crashlytics.FirebaseCrashlytics import com.saltedge.authenticator.BuildConfig private const val MAX_LOG_SIZE = 1000 @@ -38,9 +37,9 @@ fun Throwable.log(message: String = "") { if (BuildConfig.DEBUG) { printToLogcat("${this.cause}", message) printStackTrace() - } else Crashlytics.logException(this) + } else FirebaseCrashlytics.getInstance().recordException(this) } catch (e: Exception) { - Crashlytics.logException(e) + FirebaseCrashlytics.getInstance().recordException(e) } } @@ -49,8 +48,9 @@ fun Throwable.log(message: String = "") { * * @return crashlytics */ -fun createCrashlyticsKit(): Crashlytics = - Crashlytics.Builder().core(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build() +fun createCrashlyticsKit() { + FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG) +} /** * Show log/logs with given message and tag diff --git a/authenticator_sdk/build.gradle b/authenticator_sdk/build.gradle index e7de1470b..20e1201ea 100644 --- a/authenticator_sdk/build.gradle +++ b/authenticator_sdk/build.gradle @@ -1,7 +1,7 @@ /* * This file is part of the Salt Edge Authenticator distribution * (https://github.com/saltedge/sca-authenticator-android). - * Copyright (c) 2019 Salt Edge Inc. + * Copyright (c) 2020 Salt Edge Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ def libVersionName = "1.2.0" android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 - compileSdkVersion 29 + targetSdkVersion 30 + compileSdkVersion 30 versionCode libVersionCode versionName libVersionName @@ -74,8 +74,8 @@ android { dependencies { api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api 'androidx.appcompat:appcompat:1.1.0' - api "androidx.webkit:webkit:1.3.0-rc01" + api 'androidx.appcompat:appcompat:1.2.0' + api "androidx.webkit:webkit:1.4.0-alpha01" api 'com.squareup.retrofit2:retrofit:2.7.1' api 'com.squareup.retrofit2:converter-gson:2.7.1' api 'com.squareup.okhttp3:logging-interceptor:4.3.1' @@ -83,11 +83,11 @@ dependencies { androidTestUtil 'com.android.support.test:orchestrator:1.0.2' testImplementation 'junit:junit:4.13' - testImplementation 'androidx.test:core:1.2.0' + testImplementation 'androidx.test:core:1.3.0' testImplementation 'org.robolectric:robolectric:4.3.1' - testImplementation "io.mockk:mockk:1.9.3" - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.2.0' + testImplementation "io.mockk:mockk:1.10.2" + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:runner:1.3.0' testImplementation project(':test_tools') } diff --git a/build.gradle b/build.gradle index 95c02ad50..1a4e57292 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ /* * This file is part of the Salt Edge Authenticator distribution * (https://github.com/saltedge/sca-authenticator-android). - * Copyright (c) 2019 Salt Edge Inc. + * Copyright (c) 2020 Salt Edge Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,23 +22,22 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.10' ext.realm_version = '6.1.0' ext.nav_version = '2.3.0' repositories { jcenter() google() mavenLocal() - maven { url 'https://maven.fabric.io/public' } gradlePluginPortal() } dependencies { classpath 'com.android.tools.build:gradle:4.0.1' classpath "org.jacoco:org.jacoco.core:0.8.4" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.3.3' + classpath 'com.google.gms:google-services:4.3.4' classpath "io.realm:realm-gradle-plugin:$realm_version" - classpath 'io.fabric.tools:gradle:1.28.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0' classpath "org.jlleitschuh.gradle:ktlint-gradle:8.2.0" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0" } diff --git a/rasp/build.gradle b/rasp/build.gradle index ec723d57a..94d58ac99 100644 --- a/rasp/build.gradle +++ b/rasp/build.gradle @@ -1,7 +1,7 @@ /* * This file is part of the Salt Edge Authenticator distribution * (https://github.com/saltedge/sca-authenticator-android). - * Copyright (c) 2019 Salt Edge Inc. + * Copyright (c) 2020 Salt Edge Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ def libVersionName = "1.0.0" android { defaultConfig { minSdkVersion 19 - targetSdkVersion 29 - compileSdkVersion 29 + targetSdkVersion 30 + compileSdkVersion 30 versionCode libVersionCode versionName libVersionName @@ -58,10 +58,9 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.1.0' testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:runner:1.3.0' } group 'com.saltedge.authenticator.security' From bd8681d92fb168e4e04db8ea98b85151e18cab81 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Mon, 5 Oct 2020 16:31:32 +0300 Subject: [PATCH 04/12] update QrScannerViewModel --- .../app/AuthenticatorApplication.kt | 2 + .../features/main/MainActivity.kt | 14 ++- .../features/qr/QrScannerActivity.kt | 27 ++--- .../features/qr/QrScannerViewModel.kt | 33 ++++-- .../features/qr/QrScannerViewModelTest.kt | 105 +++++++++++++++--- 5 files changed, 130 insertions(+), 51 deletions(-) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt index 5dbacc4d0..cf5d41474 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt @@ -25,6 +25,7 @@ import android.app.Application import android.os.Bundle import androidx.appcompat.app.AppCompatDelegate import com.google.android.gms.security.ProviderInstaller +import com.google.firebase.FirebaseApp import com.saltedge.android.security.BuildConfig import com.saltedge.authenticator.app.di.AppComponent import com.saltedge.authenticator.app.di.AppModule @@ -84,6 +85,7 @@ open class AuthenticatorApplication : Application(), Application.ActivityLifecyc override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} private fun initFirebaseModules() { + FirebaseApp.initializeApp(this); createCrashlyticsKit() } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/main/MainActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/main/MainActivity.kt index f107557db..cfe0ce947 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/main/MainActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/main/MainActivity.kt @@ -51,9 +51,9 @@ class MainActivity : LockableActivity(), ViewModelContract, SnackbarAnchorContai override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) this.updateScreenshotLocking() - binding = DataBindingUtil.setContentView(this, R.layout.activity_main) authenticatorApp?.appComponent?.inject(this)//inject ViewModelsFactory - setupViewModel()//setup ViewModel + setupViewModel() + setupBinding() viewModel.onLifeCycleCreate(savedInstanceState, intent) } @@ -93,9 +93,6 @@ class MainActivity : LockableActivity(), ViewModelContract, SnackbarAnchorContai private fun setupViewModel() { viewModel = ViewModelProvider(this, viewModelFactory).get(MainActivityViewModel::class.java) viewModel.bindLifecycleObserver(lifecycle = lifecycle) - binding.viewModel = viewModel - binding.executePendingBindings() - binding.lifecycleOwner = this viewModel.onAppbarMenuItemClickEvent.observe(this, Observer { event -> event.getContentIfNotHandled()?.let { @@ -132,6 +129,13 @@ class MainActivity : LockableActivity(), ViewModelContract, SnackbarAnchorContai event.getContentIfNotHandled()?.let { this.showQrScannerActivity() } }) } + + private fun setupBinding() { + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + binding.viewModel = viewModel + binding.executePendingBindings() + binding.lifecycleOwner = this + } } val FragmentActivity.newAuthorizationListener: NewAuthorizationListener? diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt index 3e2ab55d5..c19237056 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt @@ -27,7 +27,6 @@ import android.os.Bundle import android.util.SparseArray import android.view.SurfaceHolder import android.view.View -import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.core.app.ActivityCompat import androidx.lifecycle.Observer @@ -44,7 +43,6 @@ import com.saltedge.authenticator.features.main.SnackbarAnchorContainer import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.tools.AppTools.getDisplayHeight import com.saltedge.authenticator.tools.AppTools.getDisplayWidth -import com.saltedge.authenticator.tools.ResId import com.saltedge.authenticator.tools.authenticatorApp import com.saltedge.authenticator.tools.log import com.saltedge.authenticator.widget.security.LockableActivity @@ -79,13 +77,7 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) - if (requestCode == CAMERA_PERMISSION_REQUEST_CODE - && grantResults.firstOrNull() == PackageManager.PERMISSION_GRANTED - ) { - startCameraSource() - } else { - showError(R.string.errors_permission_denied) - } + viewModel.onRequestPermissionsResult(requestCode, grantResults) } override fun onDestroy() { @@ -104,16 +96,17 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { viewModel.onCloseEvent.observe(this, Observer> { it.getContentIfNotHandled()?.let { finish() } }) - viewModel.setActivityResult.observe(this, Observer { deeplink -> - this.setResult( - Activity.RESULT_OK, - intent.putExtra(KEY_DEEP_LINK, deeplink) - ) + viewModel.permissionGrantEvent.observe(this, Observer> { + it.getContentIfNotHandled()?.let { startCameraSource() } + }) + viewModel.setActivityResult.observe(this, Observer { deepLink -> + this.setResult(Activity.RESULT_OK, intent.putExtra(KEY_DEEP_LINK, deepLink)) }) viewModel.errorMessageResId.observe(this, Observer { errorMessageResId -> errorDialog = AlertDialog.Builder(this) .setTitle(android.R.string.dialog_alert_title) .setMessage(getString(errorMessageResId ?: R.string.errors_invalid_qr)) + .setPositiveButton(android.R.string.ok) { _, _ -> viewModel.onErrorConfirmed() } .show() }) } @@ -187,12 +180,8 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { ) } } catch (e: IOException) { - showError(R.string.errors_camera_init) + viewModel.onCameraInitException() e.log() } } - - private fun showError(@StringRes errorName: ResId?) { - viewModel.showErrorMessage(errorName) - } } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerViewModel.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerViewModel.kt index 744080268..3f27243d5 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerViewModel.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerViewModel.kt @@ -21,6 +21,7 @@ package com.saltedge.authenticator.features.qr import android.content.Context +import android.content.pm.PackageManager import android.util.SparseArray import androidx.core.util.forEach import androidx.lifecycle.LifecycleObserver @@ -28,6 +29,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import com.google.android.gms.vision.barcode.Barcode import com.saltedge.authenticator.R +import com.saltedge.authenticator.app.CAMERA_PERMISSION_REQUEST_CODE import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.models.repository.ConnectionsRepositoryAbs import com.saltedge.authenticator.sdk.tools.isValidDeeplink @@ -39,28 +41,41 @@ class QrScannerViewModel( val connectionsRepository: ConnectionsRepositoryAbs ) : ViewModel(), LifecycleObserver { val onCloseEvent = MutableLiveData>() + val permissionGrantEvent = MutableLiveData>() val setActivityResult = MutableLiveData() val errorMessageResId = MutableLiveData() val descriptionRes: ResId = if (connectionsRepository.isEmpty()) R.string.scan_qr_description_first else R.string.scan_qr_description fun onViewClick(viewId: Int) { - when (viewId) { - R.id.closeImageView -> onCloseEvent.postUnitEvent() - } + if (viewId == R.id.closeImageView) onCloseEvent.postUnitEvent() } fun onReceivedCodes(codes: SparseArray) { - val deeplinks = mutableListOf() + val deepLinks = mutableListOf() codes.forEach { _, value -> - if (value.displayValue.isValidDeeplink()) deeplinks.add(value.displayValue) + if (value.displayValue.isValidDeeplink()) deepLinks.add(value.displayValue) } - deeplinks.firstOrNull()?.let { deeplink -> - setActivityResult.postValue(deeplink) + deepLinks.firstOrNull()?.let { deepLink -> + setActivityResult.postValue(deepLink) onCloseEvent.postUnitEvent() } } - fun showErrorMessage(errorNameResId: ResId?) { - errorMessageResId.postValue(errorNameResId) + fun onCameraInitException() { + errorMessageResId.postValue(R.string.errors_camera_init) + } + + fun onRequestPermissionsResult(requestCode: Int, grantResults: IntArray) { + if (requestCode == CAMERA_PERMISSION_REQUEST_CODE + && grantResults.firstOrNull() == PackageManager.PERMISSION_GRANTED + ) { + permissionGrantEvent.postUnitEvent() + } else { + errorMessageResId.postValue(R.string.errors_permission_denied) + } + } + + fun onErrorConfirmed() { + onCloseEvent.postUnitEvent() } } diff --git a/app/src/test/java/com/saltedge/authenticator/features/qr/QrScannerViewModelTest.kt b/app/src/test/java/com/saltedge/authenticator/features/qr/QrScannerViewModelTest.kt index 7ee496aeb..0c02cc76b 100644 --- a/app/src/test/java/com/saltedge/authenticator/features/qr/QrScannerViewModelTest.kt +++ b/app/src/test/java/com/saltedge/authenticator/features/qr/QrScannerViewModelTest.kt @@ -20,12 +20,15 @@ */ package com.saltedge.authenticator.features.qr +import android.content.pm.PackageManager import android.util.SparseArray import com.google.android.gms.vision.barcode.Barcode import com.saltedge.authenticator.R +import com.saltedge.authenticator.TestAppTools +import com.saltedge.authenticator.app.CAMERA_PERMISSION_REQUEST_CODE +import com.saltedge.authenticator.app.QR_SCAN_REQUEST_CODE import com.saltedge.authenticator.models.ViewModelEvent import com.saltedge.authenticator.models.repository.ConnectionsRepositoryAbs -import com.saltedge.authenticator.TestAppTools import org.hamcrest.CoreMatchers.equalTo import org.junit.Assert.* import org.junit.Before @@ -54,8 +57,13 @@ class QrScannerViewModelTest { @Test @Throws(Exception::class) fun onViewClickTestCase1() { - viewModel.onViewClick(R.id.closeImageView) + //given + val viewId = R.id.closeImageView + + //when + viewModel.onViewClick(viewId = viewId) + //then assertNotNull(viewModel.onCloseEvent.value) } @@ -65,30 +73,26 @@ class QrScannerViewModelTest { @Test @Throws(Exception::class) fun onViewClickTestCase2() { - viewModel.onViewClick(-1) + //given + val viewId = -1 - assertNull(viewModel.onCloseEvent.value) - } + //when + viewModel.onViewClick(viewId = viewId) - @Test - @Throws - fun showErrorMessageTest() { - viewModel.showErrorMessage(null) - - assertNull(viewModel.errorMessageResId.value) - - viewModel.showErrorMessage(R.string.errors_camera_init) - - assertThat(viewModel.errorMessageResId.value, equalTo(R.string.errors_camera_init)) + //then + assertNull(viewModel.onCloseEvent.value) } @Test @Throws fun onReceivedCodesTestCase1() { + //given val codes = SparseArray() + //when viewModel.onReceivedCodes(codes) + //then assertNull(viewModel.setActivityResult.value) assertNull(viewModel.onCloseEvent.value) } @@ -96,15 +100,80 @@ class QrScannerViewModelTest { @Test @Throws fun onReceivedCodesTestCase2() { - val validDeeplink = "authenticator://saltedge.com/connect?configuration=https://example.com/configuration&connect_query=1234567890" + //given + val validDeepLink = "authenticator://saltedge.com/connect?configuration=https://example.com/configuration&connect_query=1234567890" val barcode = Barcode() - barcode.displayValue = validDeeplink + barcode.displayValue = validDeepLink val codes = SparseArray() codes.put((0), barcode) + //when viewModel.onReceivedCodes(codes) - assertThat(viewModel.setActivityResult.value, equalTo(validDeeplink)) + //then + assertThat(viewModel.setActivityResult.value, equalTo(validDeepLink)) + assertThat(viewModel.onCloseEvent.value, equalTo(ViewModelEvent(Unit))) + } + + @Test + @Throws + fun onCameraInitExceptionTest() { + //when + viewModel.onCameraInitException() + + //then + assertThat(viewModel.errorMessageResId.value, equalTo(R.string.errors_camera_init)) + } + + @Test + @Throws + fun onRequestPermissionsResultTestCase1() { + //given + val requestCode: Int = CAMERA_PERMISSION_REQUEST_CODE + val grantResults = IntArray(0) + + //when + viewModel.onRequestPermissionsResult(requestCode, grantResults) + + //then + assertThat(viewModel.errorMessageResId.value, equalTo(R.string.errors_permission_denied)) + } + + @Test + @Throws + fun onRequestPermissionsResultTestCase2() { + //given + val requestCode: Int = QR_SCAN_REQUEST_CODE + val grantResults = IntArray(1) { PackageManager.PERMISSION_GRANTED } + + //when + viewModel.onRequestPermissionsResult(requestCode, grantResults) + + //then + assertThat(viewModel.errorMessageResId.value, equalTo(R.string.errors_permission_denied)) + } + + @Test + @Throws + fun onRequestPermissionsResultTestCase3() { + //given + val requestCode: Int = CAMERA_PERMISSION_REQUEST_CODE + val grantResults = IntArray(1) { PackageManager.PERMISSION_GRANTED } + + //when + viewModel.onRequestPermissionsResult(requestCode, grantResults) + + //then + assertThat(viewModel.permissionGrantEvent.value, equalTo(ViewModelEvent(Unit))) + } + + @Test + @Throws + fun onErrorConfirmedTest() { + //when + viewModel.onErrorConfirmed() + + //then assertThat(viewModel.onCloseEvent.value, equalTo(ViewModelEvent(Unit))) } } From 5e0fbf74fd15315956b2d27d1e2b4d80f1647956 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Wed, 7 Oct 2020 15:58:15 +0300 Subject: [PATCH 05/12] fix proguard --- app/proguard-rules.pro | 3 +++ .../saltedge/authenticator/app/AuthenticatorApplication.kt | 4 ++-- .../authenticator/features/launcher/LauncherActivity.kt | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 9b09bf4cb..d461c2a13 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -61,6 +61,9 @@ -dontwarn sun.misc.SignalHandler -dontwarn java.lang.instrument.Instrumentation -dontwarn sun.misc.Signal +-dontwarn kotlin.time.Duration$Companion # Blur effect -keep class androidx.renderscript.** { *; } + +-dontwarn module-info diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt index cf5d41474..cf5da7298 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt @@ -26,7 +26,7 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatDelegate import com.google.android.gms.security.ProviderInstaller import com.google.firebase.FirebaseApp -import com.saltedge.android.security.BuildConfig +import com.saltedge.authenticator.BuildConfig import com.saltedge.authenticator.app.di.AppComponent import com.saltedge.authenticator.app.di.AppModule import com.saltedge.authenticator.app.di.DaggerAppComponent @@ -86,7 +86,7 @@ open class AuthenticatorApplication : Application(), Application.ActivityLifecyc private fun initFirebaseModules() { FirebaseApp.initializeApp(this); - createCrashlyticsKit() +// createCrashlyticsKit() } private fun patchSecurityProvider() { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt index 0f74daf38..10fff4f50 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt @@ -53,6 +53,7 @@ class LauncherActivity : AppCompatActivity() { this.applyPreferenceLocale() this.registerNotificationChannels() setContentView(R.layout.activity_launcher) + throw RuntimeException("Test Crash") } override fun onStop() { From e172036882b840c0a83c748198108b8eb573c15a Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Wed, 7 Oct 2020 16:29:03 +0300 Subject: [PATCH 06/12] update view tools --- .../app/AuthenticatorApplication.kt | 2 +- .../select/SelectConnectionsFragment.kt | 1 - .../features/launcher/LauncherActivity.kt | 1 - .../features/qr/QrScannerActivity.kt | 8 ++--- .../saltedge/authenticator/tools/AppTools.kt | 31 +---------------- .../authenticator/tools/AppToolsAbs.kt | 2 -- .../saltedge/authenticator/tools/ViewTools.kt | 33 +++++++++++++++++-- 7 files changed, 36 insertions(+), 42 deletions(-) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt index cf5da7298..feb54c2d3 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/app/AuthenticatorApplication.kt @@ -86,7 +86,7 @@ open class AuthenticatorApplication : Application(), Application.ActivityLifecyc private fun initFirebaseModules() { FirebaseApp.initializeApp(this); -// createCrashlyticsKit() + createCrashlyticsKit() } private fun patchSecurityProvider() { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt index d00d5b1f2..fc95fbf4d 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/connections/select/SelectConnectionsFragment.kt @@ -29,7 +29,6 @@ import android.view.ViewGroup import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.saltedge.authenticator.R import com.saltedge.authenticator.app.ViewModelsFactory diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt index 10fff4f50..0f74daf38 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/launcher/LauncherActivity.kt @@ -53,7 +53,6 @@ class LauncherActivity : AppCompatActivity() { this.applyPreferenceLocale() this.registerNotificationChannels() setContentView(R.layout.activity_launcher) - throw RuntimeException("Test Crash") } override fun onStop() { diff --git a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt index c19237056..38c6a1de5 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/features/qr/QrScannerActivity.kt @@ -41,9 +41,9 @@ import com.saltedge.authenticator.app.KEY_DEEP_LINK import com.saltedge.authenticator.app.ViewModelsFactory import com.saltedge.authenticator.features.main.SnackbarAnchorContainer import com.saltedge.authenticator.models.ViewModelEvent -import com.saltedge.authenticator.tools.AppTools.getDisplayHeight -import com.saltedge.authenticator.tools.AppTools.getDisplayWidth import com.saltedge.authenticator.tools.authenticatorApp +import com.saltedge.authenticator.tools.getDisplayHeight +import com.saltedge.authenticator.tools.getDisplayWidth import com.saltedge.authenticator.tools.log import com.saltedge.authenticator.widget.security.LockableActivity import com.saltedge.authenticator.widget.security.UnlockAppInputView @@ -120,8 +120,8 @@ class QrScannerActivity : LockableActivity(), SnackbarAnchorContainer { } private fun setupCameraSource() { - val height = getDisplayHeight(this) - val width = getDisplayWidth(this) + val height = this.getDisplayHeight() + val width = this.getDisplayWidth() cameraSource = CameraSource.Builder(applicationContext, barcodeDetector) .setRequestedPreviewSize(height, width) .setFacing(CameraSource.CAMERA_FACING_BACK) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt index be877cb72..34521e05b 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt @@ -22,16 +22,15 @@ package com.saltedge.authenticator.tools import android.content.Context import android.content.pm.PackageManager -import android.graphics.Point import android.os.Build import android.os.Bundle -import android.view.WindowManager import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import com.saltedge.authenticator.app.AuthenticatorApplication import com.saltedge.authenticator.app.KEY_GUID import com.saltedge.authenticator.sdk.model.GUID + object AppTools : AppToolsAbs { /** @@ -44,34 +43,6 @@ object AppTools : AppToolsAbs { return appContext.classLoader?.toString()?.contains("test") ?: false } - /** - * Get display height - * - * @param appContext - application context - * @return height size - */ - override fun getDisplayHeight(appContext: Context): Int { - val display = - (appContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay - val size = Point() - display?.getSize(size) - return size.y - } - - /** - * Get display width - * - * @param appContext - application context - * @return width size - */ - override fun getDisplayWidth(appContext: Context): Int { - val display = - (appContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay - val size = Point() - display?.getSize(size) - return size.x - } - /** * Get application version name * diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppToolsAbs.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppToolsAbs.kt index f838a6626..59ba3a6b3 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppToolsAbs.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppToolsAbs.kt @@ -24,8 +24,6 @@ import android.content.Context interface AppToolsAbs { fun isTestsSuite(appContext: Context): Boolean - fun getDisplayHeight(appContext: Context): Int - fun getDisplayWidth(appContext: Context): Int fun getAppVersionName(appContext: Context): String fun getSDKVersion(): Int } diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/ViewTools.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/ViewTools.kt index e53b0375d..8d9f7af95 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/ViewTools.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/ViewTools.kt @@ -20,10 +20,11 @@ */ package com.saltedge.authenticator.tools +import android.app.Activity import android.content.Context -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup +import android.graphics.Point +import android.util.DisplayMetrics +import android.view.* import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.TextView @@ -105,3 +106,29 @@ fun ViewGroup.inflateListItemView(resId: Int): View = fun TextView.setTextColorResId(colorResId: Int) { ContextCompat.getColor(this.context, colorResId).also { this.setTextColor(it) } } + +/** + * Get display height + * + * @receiver Activity - Activity object + * @return height size + */ +fun Activity.getDisplayHeight(): Int { + val display = (this.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay + val size = Point() + display?.getSize(size) + return size.y +} + +/** + * Get display width + * + * @receiver Activity - Activity object + * @return width size + */ +fun Activity.getDisplayWidth(): Int { + val display = (this.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay + val size = Point() + display?.getSize(size) + return size.x +} From 5bf27512e74e666f91f932c46f94dafac8c91879 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Wed, 7 Oct 2020 16:33:53 +0300 Subject: [PATCH 07/12] 3.2.0 (49) --- app/build.gradle | 4 ++-- .../features/settings/about/AboutViewModelTest.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1cf2afbb3..a9919f86a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,8 +66,8 @@ android { compileSdkVersion 30 targetSdkVersion 30 - versionCode 48 - versionName '3.1.1' + versionCode 49 + versionName '3.2.0' renderscriptTargetApi 21 renderscriptSupportModeEnabled true diff --git a/app/src/test/java/com/saltedge/authenticator/features/settings/about/AboutViewModelTest.kt b/app/src/test/java/com/saltedge/authenticator/features/settings/about/AboutViewModelTest.kt index dfa367ffb..b9fcdaf54 100644 --- a/app/src/test/java/com/saltedge/authenticator/features/settings/about/AboutViewModelTest.kt +++ b/app/src/test/java/com/saltedge/authenticator/features/settings/about/AboutViewModelTest.kt @@ -90,7 +90,7 @@ class AboutViewModelTest { equalTo(listOf( SettingsItemViewModel( titleId = R.string.about_app_version, - description = "3.1.1" + description = "3.2.0" ), SettingsItemViewModel( titleId = R.string.about_copyright, From 3a4a3cf8334e48ce3a6f0d297c5ac81e7ad1bf92 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Wed, 7 Oct 2020 17:13:54 +0300 Subject: [PATCH 08/12] UiToolsTest fix --- .../com/saltedge/authenticator/tools/UiToolsTest.kt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/src/test/java/com/saltedge/authenticator/tools/UiToolsTest.kt b/app/src/test/java/com/saltedge/authenticator/tools/UiToolsTest.kt index c6bfaba89..40f12a5c6 100644 --- a/app/src/test/java/com/saltedge/authenticator/tools/UiToolsTest.kt +++ b/app/src/test/java/com/saltedge/authenticator/tools/UiToolsTest.kt @@ -41,18 +41,6 @@ class UiToolsTest { assertEquals(Color.argb(128, 0, 0, 255), Color.BLUE.applyAlphaToColor(0.5f)) } - @Test - @Throws(Exception::class) - fun getDisplayHeightTest() { - assertTrue(AppTools.getDisplayHeight(TestAppTools.applicationContext) > 0) - } - - @Test - @Throws(Exception::class) - fun getDisplayWidthTest() { - assertTrue(AppTools.getDisplayWidth(TestAppTools.applicationContext) > 0) - } - @Test @Throws(Exception::class) fun getEnabledStateColorResIdTest() { From c869d08940f1066c39137fdc1686410472143942 Mon Sep 17 00:00:00 2001 From: Constantin Chelban Date: Thu, 8 Oct 2020 11:42:46 +0300 Subject: [PATCH 09/12] clean code --- app/proguard-rules.pro | 5 ++++- .../main/kotlin/com/saltedge/authenticator/tools/AppTools.kt | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index d461c2a13..e14264a40 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -61,9 +61,12 @@ -dontwarn sun.misc.SignalHandler -dontwarn java.lang.instrument.Instrumentation -dontwarn sun.misc.Signal --dontwarn kotlin.time.Duration$Companion # Blur effect -keep class androidx.renderscript.** { *; } +# Solve module-info conflicts -dontwarn module-info + +# Solve https://github.com/Kotlin/kotlinx.coroutines/issues/2046 +-dontwarn kotlin.time.Duration$Companion diff --git a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt index 34521e05b..fbc3b0ce7 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/tools/AppTools.kt @@ -30,7 +30,6 @@ import com.saltedge.authenticator.app.AuthenticatorApplication import com.saltedge.authenticator.app.KEY_GUID import com.saltedge.authenticator.sdk.model.GUID - object AppTools : AppToolsAbs { /** From 04d0b254993e8b80c46badbb71ff5ed2087214bf Mon Sep 17 00:00:00 2001 From: mnewlive Date: Tue, 13 Oct 2020 15:43:41 +0300 Subject: [PATCH 10/12] Fix npe in WebViewFragment --- .../widget/fragment/WebViewFragment.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/WebViewFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/WebViewFragment.kt index 0f15774bf..a06b78d27 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/WebViewFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/WebViewFragment.kt @@ -44,6 +44,11 @@ class WebViewFragment : BaseFragment() { } } + override fun onResume() { + super.onResume() + customWebView?.onResume() + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -62,6 +67,16 @@ class WebViewFragment : BaseFragment() { customWebView?.loadUrl(url) } + override fun onPause() { + super.onPause() + customWebView?.onPause() + } + + override fun onDestroyView() { + super.onDestroyView() + customWebView?.stopLoading() + } + private val webViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { From e2e83f4a7a14798d546b34933f13397b041076ef Mon Sep 17 00:00:00 2001 From: mnewlive Date: Thu, 15 Oct 2020 10:30:24 +0300 Subject: [PATCH 11/12] Add nullable --- .../saltedge/authenticator/widget/fragment/BaseFragment.kt | 2 +- .../com/saltedge/authenticator/widget/passcode/KeypadView.kt | 2 ++ .../authenticator/widget/passcode/PasscodeInputView.kt | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/BaseFragment.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/BaseFragment.kt index 1dbd8904a..170e51152 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/BaseFragment.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/fragment/BaseFragment.kt @@ -43,7 +43,7 @@ abstract class BaseFragment : Fragment() { } private fun createProgressDialog(): ProgressDialog? { - val dialog = ProgressDialog(activity, R.style.ProgressDialogTheme) + val dialog = ProgressDialog(activity ?: return null, R.style.ProgressDialogTheme) dialog.setCancelable(false) dialog.setProgressStyle(android.R.style.Widget_ProgressBar_Large) return dialog diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt index 27442d762..d1871b112 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt @@ -26,6 +26,7 @@ import android.os.Build import android.os.VibrationEffect import android.os.Vibrator import android.util.AttributeSet +import android.util.Log import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout @@ -61,6 +62,7 @@ class KeypadView(context: Context, attrs: AttributeSet) : LinearLayout(context, } fun setupFingerAction(active: Boolean) { + Log.d("some", "active: $active") fingerActionView?.setVisible(active) forgotActionView?.setVisible(active) deleteActionView?.setVisible(!active) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt index fa7754be7..ffe2777b7 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt @@ -25,6 +25,7 @@ import android.content.Context import android.os.VibrationEffect import android.os.Vibrator import android.util.AttributeSet +import android.util.Log import android.view.LayoutInflater import android.widget.LinearLayout import androidx.annotation.StringRes @@ -70,6 +71,7 @@ class PasscodeInputView(context: Context, attrs: AttributeSet) : LinearLayout(co var biometricsActionIsAvailable: Boolean = false set(value) { field = value + Log.d("some", "value: $value") keypadView?.setupFingerAction(active = value) } @@ -101,6 +103,8 @@ class PasscodeInputView(context: Context, attrs: AttributeSet) : LinearLayout(co descriptionView?.alpha = 0f updatePasscodeOutput("") + Log.d("some", "biometricsActionIsAvailable: $biometricsActionIsAvailable") + keypadView?.setupFingerAction(active = biometricsActionIsAvailable) keypadView?.clickListener = this submitView?.setOnClickListener { From 947230e607c39d74a9fbd9c4cefa6e67f11673a1 Mon Sep 17 00:00:00 2001 From: mnewlive Date: Thu, 15 Oct 2020 10:34:58 +0300 Subject: [PATCH 12/12] RM logs --- .../com/saltedge/authenticator/widget/passcode/KeypadView.kt | 2 -- .../authenticator/widget/passcode/PasscodeInputView.kt | 3 --- 2 files changed, 5 deletions(-) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt index d1871b112..27442d762 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/KeypadView.kt @@ -26,7 +26,6 @@ import android.os.Build import android.os.VibrationEffect import android.os.Vibrator import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout @@ -62,7 +61,6 @@ class KeypadView(context: Context, attrs: AttributeSet) : LinearLayout(context, } fun setupFingerAction(active: Boolean) { - Log.d("some", "active: $active") fingerActionView?.setVisible(active) forgotActionView?.setVisible(active) deleteActionView?.setVisible(!active) diff --git a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt index ffe2777b7..b15e1d7e9 100644 --- a/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt +++ b/app/src/main/kotlin/com/saltedge/authenticator/widget/passcode/PasscodeInputView.kt @@ -25,7 +25,6 @@ import android.content.Context import android.os.VibrationEffect import android.os.Vibrator import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.widget.LinearLayout import androidx.annotation.StringRes @@ -71,7 +70,6 @@ class PasscodeInputView(context: Context, attrs: AttributeSet) : LinearLayout(co var biometricsActionIsAvailable: Boolean = false set(value) { field = value - Log.d("some", "value: $value") keypadView?.setupFingerAction(active = value) } @@ -103,7 +101,6 @@ class PasscodeInputView(context: Context, attrs: AttributeSet) : LinearLayout(co descriptionView?.alpha = 0f updatePasscodeOutput("") - Log.d("some", "biometricsActionIsAvailable: $biometricsActionIsAvailable") keypadView?.setupFingerAction(active = biometricsActionIsAvailable) keypadView?.clickListener = this