diff --git a/build.gradle b/build.gradle index fa7c048..d56d2d1 100644 --- a/build.gradle +++ b/build.gradle @@ -4,13 +4,13 @@ buildscript { repositories { google() - jcenter() + mavenCentral() maven{ url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' - classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2' - classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0" + classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0' + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -22,7 +22,7 @@ apply plugin: 'io.codearte.nexus-staging' allprojects { repositories { google() - jcenter() + mavenCentral() maven { url "https://s3.amazonaws.com/repo.commonsware.com" } @@ -41,10 +41,11 @@ ext { group = GROUP version = VERSION_NAME - androidBuildToolsVersion = "28.0.3" - androidMinSdkVersion = 18 - androidCompileSdkVersion = 28 - androidTargetSdkVersion = 28 + ext.androidToolsBuildGradle = '4.2.2' + ext.androidBuildToolsVersion = '30.0.3' + ext.androidMinSdkVersion = 19 + ext.androidCompileSdkVersion = 31 + ext.androidTargetSdkVersion = 31 } ext { diff --git a/gradle.properties b/gradle.properties index 9441322..259e2ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,8 +11,8 @@ org.gradle.jvmargs=-Xmx1536m # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -android.enableUnitTestBinaryResources=true -VERSION_NAME=0.3.7-SNAPSHOT +android.enableUnitTestBinaryResources=false +VERSION_NAME=0.4.0-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=Android Peer-to-Peer Sync @@ -26,5 +26,8 @@ POM_SETTING_LICENCE_DIST=repo POM_SETTING_DEVELOPER_ID=opensrp POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev POM_SETTING_NAME=Android Peer-to-Peer Sync +android.useAndroidX=true +android.enableJetifier=true POM_SETTING_ARTIFACT_ID=android-p2p-sync POM_SETTING_PACKAGING=aar +android.jetifier.blacklist=bcprov diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 71771a5..8fd2646 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Mar 07 16:20:14 EAT 2019 +#Thu Feb 02 12:10:28 EAT 2023 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index 3305731..bd0cacb 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -8,6 +8,11 @@ jacoco { } android { + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + compileSdkVersion androidCompileSdkVersion buildToolsVersion androidBuildToolsVersion @@ -16,8 +21,6 @@ android { defaultConfig { minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion - versionCode 1 - versionName version testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -42,8 +45,15 @@ android { } } - testOptions.unitTests.includeAndroidResources = true - lintOptions.abortOnError = false + testOptions { + unitTests { + includeAndroidResources = true + } + } + lintOptions { + lintConfig file("lint.xml") + abortOnError false + } } dependencies { @@ -51,28 +61,29 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.android.gms:play-services-nearby:16.0.0' - implementation ('com.google.android.gms:play-services-location:16.0.0') { + implementation('com.google.android.gms:play-services-location:16.0.0') { exclude group: 'com.android.support', module: 'support-v4' } - implementation 'com.google.android.gms:play-services-vision:17.0.2' + implementation 'com.google.android.gms:play-services-vision:20.1.3' - implementation 'com.jakewharton.timber:timber:4.7.1' + implementation 'com.jakewharton.timber:timber:5.0.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13.2' + testImplementation project(path: ':p2p-sync') androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' testImplementation 'org.mockito:mockito-inline:2.25.0' - testImplementation "org.robolectric:robolectric:4.2" + testImplementation "org.robolectric:robolectric:4.3.1" // ZXING DEPENDENCIES - implementation('com.journeyapps:zxing-android-embedded:3.6.0') { + implementation('com.journeyapps:zxing-android-embedded:4.3.0') { exclude group: 'com.android.support', module: 'support-v4' } - implementation 'com.google.zxing:core:3.3.0' - implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.google.zxing:core:3.5.1' + implementation 'com.google.code.gson:gson:2.10.1' // Room implementation "android.arch.persistence.room:runtime:$room_version" @@ -81,7 +92,7 @@ dependencies { testImplementation "android.arch.persistence.room:testing:$room_version" // Encrypted SQLite help - implementation "com.commonsware.cwac:saferoom:1.0.2" + implementation 'com.commonsware.cwac:saferoom.x:1.1.2' } @@ -99,15 +110,16 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter) def mainSrc = "$project.projectDir/src/main/java" - sourceDirectories = files([mainSrc]) - classDirectories = files([debugTree]) - executionData = fileTree(dir: project.buildDir, includes: [ + getSourceDirectories().setFrom([mainSrc]) + getClassDirectories().setFrom([debugTree]) + getExecutionData().setFrom(dir: project.buildDir, includes: [ 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' ]) } tasks.withType(Test) { jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } coveralls { diff --git a/p2p-sync/src/main/AndroidManifest.xml b/p2p-sync/src/main/AndroidManifest.xml index d17ffe7..13e9920 100644 --- a/p2p-sync/src/main/AndroidManifest.xml +++ b/p2p-sync/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + @@ -19,7 +20,8 @@ + android:exported="true" + android:name="org.smartregister.p2p.activity.P2pModeSelectActivity"/> (onActivityRequestPermissionHandlers)) { if (requestCode == onActivityRequestPermissionHandler.getRequestCode()) { onActivityRequestPermissionHandler.handlePermissionResult(permissions, grantResults); } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/BaseSyncConnectionAuthenticator.java b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/BaseSyncConnectionAuthenticator.java index e0fd485..a3a28d6 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/BaseSyncConnectionAuthenticator.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/BaseSyncConnectionAuthenticator.java @@ -1,7 +1,8 @@ package org.smartregister.p2p.authenticator; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; +import org.smartregister.p2p.P2PLibrary; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.sync.DiscoveredDevice; @@ -31,4 +32,8 @@ public interface AuthenticationCallback { void onAuthenticationCancelled(@NonNull String reason); } + + public boolean allowSkipQrCodeScan(){ + return P2PLibrary.getInstance().getOptions().allowSkipQrCodeScan(); + } } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticator.java b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticator.java index b8a1b96..cf5fcd4 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticator.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticator.java @@ -1,12 +1,14 @@ package org.smartregister.p2p.authenticator; import android.content.DialogInterface; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.fragment.QRCodeGeneratorFragment; import org.smartregister.p2p.sync.DiscoveredDevice; +import org.smartregister.p2p.util.Constants; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 14/03/2019 @@ -23,31 +25,59 @@ public void authenticate(@NonNull final DiscoveredDevice discoveredDevice, @NonN if (discoveredDevice.getConnectionInfo() != null && discoveredDevice.getConnectionInfo().isIncomingConnection()) { - getPresenter().getView().showQRCodeGeneratorFragment(discoveredDevice.getConnectionInfo().getAuthenticationToken() - , discoveredDevice.getEndpointName() - , new QRCodeGeneratorFragment.QRCodeGeneratorCallback() { - - @Override - public void onSkipped() { - getPresenter().sendSkipClicked(); - getPresenter().getView().showConnectingDialog(new P2pModeSelectContract.View.DialogCancelCallback() { - @Override - public void onCancelClicked(DialogInterface dialogInterface) { - getPresenter().getView().removeConnectingDialog(); - authenticationCallback.onAuthenticationCancelled("User rejected the connection"); - } - }); - } - - @Override - public void onErrorOccurred(@NonNull Exception e) { - authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.unknown_error_occurred), e); - } - }); + if (allowSkipQrCodeScan()) { + displaySenderInfoDialog(discoveredDevice, authenticationCallback); + } else { + displayQRCodeGeneratorFragment(discoveredDevice, authenticationCallback); + } } else { authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.device_information_passed_is_invalid) , new Exception("DiscoveredDevice information passed is invalid")); } } + + + private void displayQRCodeGeneratorFragment(@NonNull final DiscoveredDevice discoveredDevice, @NonNull final AuthenticationCallback authenticationCallback) { + getPresenter().getView().showQRCodeGeneratorFragment(discoveredDevice.getConnectionInfo().getAuthenticationToken() + , discoveredDevice.getEndpointName() + , new QRCodeGeneratorFragment.QRCodeGeneratorCallback() { + + @Override + public void onSkipped() { + getPresenter().sendSkipClicked(); + getPresenter().getView().showConnectingDialog(new P2pModeSelectContract.View.DialogCancelCallback() { + @Override + public void onCancelClicked(DialogInterface dialogInterface) { + getPresenter().getView().removeConnectingDialog(); + authenticationCallback.onAuthenticationCancelled("User rejected the connection"); + } + }); + } + + @Override + public void onErrorOccurred(@NonNull Exception e) { + authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.unknown_error_occurred), e); + } + }); + } + + private void displaySenderInfoDialog(@NonNull final DiscoveredDevice discoveredDevice, @NonNull final AuthenticationCallback authenticationCallback) { + getPresenter().getView().showReceiverApprovalDialog(discoveredDevice.getConnectionInfo().getAuthenticationToken() + , discoveredDevice.getEndpointName(), + new P2pModeSelectContract.View.DialogCancelCallback() { + @Override + public void onCancelClicked(DialogInterface dialogInterface) { + getPresenter().getView().removeDialog(Constants.Dialog.DISPLAY_APPROVAL_KEY); + authenticationCallback.onAuthenticationCancelled("User rejected the connection"); + } + }, + new P2pModeSelectContract.View.DialogApprovedCallback() { + @Override + public void onApprovedClicked(DialogInterface dialogInterface) { + getPresenter().sendConnectionAccept(); + getPresenter().getView().removeDialog(Constants.Dialog.DISPLAY_APPROVAL_KEY); + } + }); + } } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticator.java b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticator.java index 39bcc71..e547e36 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticator.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticator.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.authenticator; import android.content.DialogInterface; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import android.util.SparseArray; import com.google.android.gms.nearby.connection.ConnectionInfo; @@ -11,6 +11,7 @@ import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.fragment.QRCodeScanningFragment; import org.smartregister.p2p.sync.DiscoveredDevice; +import org.smartregister.p2p.util.Constants; import timber.log.Timber; @@ -28,54 +29,84 @@ public SenderConnectionAuthenticator(@NonNull P2pModeSelectContract.SenderPresen public void authenticate(@NonNull final DiscoveredDevice discoveredDevice, @NonNull final AuthenticationCallback authenticationCallback) { if (discoveredDevice.getConnectionInfo() != null && !discoveredDevice.getConnectionInfo().isIncomingConnection()) { - final ConnectionInfo connectionInfo = discoveredDevice.getConnectionInfo(); - - getPresenter().getView().showQRCodeScanningFragment(discoveredDevice.getEndpointName(), new QRCodeScanningFragment.QRCodeScanDialogCallback() { - @Override - public void qrCodeScanned(final @NonNull SparseArray qrCodeResult) { - getPresenter().getView().runOnUiThread(new Runnable() { - @Override - public void run() { - String authenticationCode = connectionInfo.getAuthenticationToken(); - boolean authenticationCodeFound = false; - - for (int i = 0; i < qrCodeResult.size(); i++) { - if (authenticationCode.equals(qrCodeResult.valueAt(i).rawValue)) { - authenticationCodeFound = true; - break; - } - } - if (authenticationCodeFound) { - getPresenter().sendConnectionAccept(); - authenticationCallback.onAuthenticationSuccessful(); - } else { - authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.authentication_tokens_dont_match) - , new Exception("Authentication tokens do not match")); - } - } - }); - } - - @Override - public void onErrorOccurred(@NonNull Exception e) { - Timber.e(e); - } - - @Override - public void onSkipClicked() { - getPresenter().sendSkipClicked(); - getPresenter().getView().showConnectingDialog(new P2pModeSelectContract.View.DialogCancelCallback() { - @Override - public void onCancelClicked(DialogInterface dialogInterface) { - authenticationCallback.onAuthenticationCancelled("User rejected the connection"); - } - }); - } - }); + if (allowSkipQrCodeScan()) { + displaySenderApprovalDialog(discoveredDevice, authenticationCallback); + } else { + displayQRCodeScanFragment(discoveredDevice, authenticationCallback); + } + } else { authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.device_information_passed_is_invalid) , new Exception("DiscoveredDevice information passed is invalid")); } } + + private void displayQRCodeScanFragment(@NonNull final DiscoveredDevice discoveredDevice, @NonNull final AuthenticationCallback authenticationCallback) { + final ConnectionInfo connectionInfo = discoveredDevice.getConnectionInfo(); + getPresenter().getView().showQRCodeScanningFragment(discoveredDevice.getEndpointName(), new QRCodeScanningFragment.QRCodeScanDialogCallback() { + @Override + public void qrCodeScanned(final @NonNull SparseArray qrCodeResult) { + getPresenter().getView().runOnUiThread(new Runnable() { + @Override + public void run() { + String authenticationCode = connectionInfo.getAuthenticationToken(); + boolean authenticationCodeFound = false; + + for (int i = 0; i < qrCodeResult.size(); i++) { + if (authenticationCode.equals(qrCodeResult.valueAt(i).rawValue)) { + authenticationCodeFound = true; + break; + } + } + + if (authenticationCodeFound) { + getPresenter().sendConnectionAccept(); + authenticationCallback.onAuthenticationSuccessful(); + } else { + authenticationCallback.onAuthenticationFailed(getPresenter().getView().getString(R.string.authentication_tokens_dont_match) + , new Exception("Authentication tokens do not match")); + } + } + }); + } + + @Override + public void onErrorOccurred(@NonNull Exception e) { + Timber.e(e); + } + + @Override + public void onSkipClicked() { + getPresenter().sendSkipClicked(); + getPresenter().getView().showConnectingDialog(new P2pModeSelectContract.View.DialogCancelCallback() { + @Override + public void onCancelClicked(DialogInterface dialogInterface) { + authenticationCallback.onAuthenticationCancelled("User rejected the connection"); + } + }); + } + }); + } + + private void displaySenderApprovalDialog(@NonNull final DiscoveredDevice discoveredDevice, @NonNull final AuthenticationCallback authenticationCallback) { + getPresenter().getView().showSenderApprovalDialog(discoveredDevice.getConnectionInfo().getAuthenticationToken() + , discoveredDevice.getEndpointName(), + new P2pModeSelectContract.View.DialogCancelCallback() { + @Override + public void onCancelClicked(DialogInterface dialogInterface) { + getPresenter().getView().removeDialog(Constants.Dialog.DISPLAY_APPROVAL_KEY); + authenticationCallback.onAuthenticationCancelled("User rejected the connection"); + } + }, + new P2pModeSelectContract.View.DialogApprovedCallback() { + @Override + public void onApprovedClicked(DialogInterface dialogInterface) { + getPresenter().getView().removeDialog(Constants.Dialog.DISPLAY_APPROVAL_KEY); + getPresenter().sendConnectionAccept(); + authenticationCallback.onAuthenticationSuccessful(); + } + }); + } + } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/authorizer/P2PAuthorizationService.java b/p2p-sync/src/main/java/org/smartregister/p2p/authorizer/P2PAuthorizationService.java index 91fcd51..97c87d6 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/authorizer/P2PAuthorizationService.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/authorizer/P2PAuthorizationService.java @@ -1,6 +1,8 @@ package org.smartregister.p2p.authorizer; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; + import java.util.Map; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/callback/OnResultCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/callback/OnResultCallback.java index dcd88c0..0ef1a94 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/callback/OnResultCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/callback/OnResultCallback.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.callback; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 14/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/callback/SyncFinishedCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/callback/SyncFinishedCallback.java index 19d487f..80285ba 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/callback/SyncFinishedCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/callback/SyncFinishedCallback.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.callback; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.UiThread; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import java.util.HashMap; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/contract/BaseView.java b/p2p-sync/src/main/java/org/smartregister/p2p/contract/BaseView.java index d7e72e9..936d8b6 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/contract/BaseView.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/contract/BaseView.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.contract; import android.content.Context; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import org.smartregister.p2p.handler.ActivityRequestPermissionResultHandler; import org.smartregister.p2p.handler.ActivityResultHandler; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/contract/P2pModeSelectContract.java b/p2p-sync/src/main/java/org/smartregister/p2p/contract/P2pModeSelectContract.java index d03d9f3..a6bc606 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/contract/P2pModeSelectContract.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/contract/P2pModeSelectContract.java @@ -2,9 +2,9 @@ import android.content.Context; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import com.google.android.gms.nearby.connection.ConnectionLifecycleCallback; import com.google.android.gms.nearby.connection.Payload; @@ -15,8 +15,8 @@ import org.smartregister.p2p.fragment.ErrorFragment; import org.smartregister.p2p.fragment.QRCodeGeneratorFragment; import org.smartregister.p2p.fragment.QRCodeScanningFragment; -import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.fragment.SyncCompleteTransferFragment; +import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.model.SendingDevice; import org.smartregister.p2p.sync.DiscoveredDevice; import org.smartregister.p2p.sync.IReceiverSyncLifecycleCallback; @@ -53,6 +53,8 @@ interface View extends BaseView { boolean removeDiscoveringProgressDialog(); + boolean removeDialog(@NonNull String tag); + void showQRCodeScanningFragment(@NonNull String deviceName, @NonNull QRCodeScanningFragment.QRCodeScanDialogCallback qrCodeScanDialogCallback); void removeQRCodeScanningFragment(); @@ -62,6 +64,18 @@ void showQRCodeGeneratorFragment(@NonNull String authenticationCode, @NonNull St void removeQRCodeGeneratorFragment(); + void showSenderApprovalDialog(@NonNull String authenticationCode, + @NonNull String deviceName, + @Nullable DialogCancelCallback dialogCancelCallback, + @NonNull DialogApprovedCallback dialogApprovedCallback + ); + + void showReceiverApprovalDialog(@NonNull String authenticationCode, + @NonNull String deviceName, + @Nullable DialogCancelCallback dialogCancelCallback, + @NonNull DialogApprovedCallback dialogApprovedCallback + ); + void showConnectionAcceptDialog(@NonNull String receiverDeviceName, @NonNull String authenticationCode , @NonNull DialogInterface.OnClickListener onClickListener); @@ -97,6 +111,10 @@ interface DialogCancelCallback { void onCancelClicked(DialogInterface dialogInterface); } + interface DialogApprovedCallback { + void onApprovedClicked(DialogInterface dialogInterface); + } + interface OnLocationEnabled { void locationEnabled(); } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/contract/RecalledIdentifier.java b/p2p-sync/src/main/java/org/smartregister/p2p/contract/RecalledIdentifier.java index 15c51b9..f0c8387 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/contract/RecalledIdentifier.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/contract/RecalledIdentifier.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.contract; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; +import androidx.annotation.NonNull; +import androidx.annotation.WorkerThread; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ConnectingDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ConnectingDialog.java index edae5eb..b68880f 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ConnectingDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ConnectingDialog.java @@ -1,14 +1,15 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java new file mode 100644 index 0000000..6f210bc --- /dev/null +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java @@ -0,0 +1,99 @@ +package org.smartregister.p2p.dialog; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + +import org.smartregister.p2p.R; +import org.smartregister.p2p.contract.P2pModeSelectContract; + +public class ReceiverConnectionInfoDialog extends DialogFragment { + + private P2pModeSelectContract.View.DialogCancelCallback dialogCancelCallback; + private String deviceName; + private String connectionKey; + private P2pModeSelectContract.View.DialogApprovedCallback dialogApprovedCallback; + + public void setDialogCancelCallback(@NonNull P2pModeSelectContract.View.DialogCancelCallback dialogCancelCallback) { + this.dialogCancelCallback = dialogCancelCallback; + } + + public void setDialogApprovedCallback(@NonNull P2pModeSelectContract.View.DialogApprovedCallback dialogApprovedCallback) { + this.dialogApprovedCallback = dialogApprovedCallback; + } + + public void setConnectionDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public void setConnectionKey(String connectionKey) { + this.connectionKey = connectionKey; + } + + @NonNull + @Override + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View rootView = inflater.inflate(R.layout.dialog_pair_receiver_approval, null); + + TextView tvCode = rootView.findViewById(R.id.tv_connection_id); + tvCode.setText(connectionKey); + + TextView tvMessage = rootView.findViewById(R.id.tv_message); + tvMessage.setText(getString(R.string.pair_request_sender_prompt, deviceName)); + + builder.setView(rootView) + .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (dialogCancelCallback != null) { + dialogCancelCallback.onCancelClicked(new DialogInterface() { + @Override + public void cancel() { + ReceiverConnectionInfoDialog.this.dismiss(); + } + + @Override + public void dismiss() { + ReceiverConnectionInfoDialog.this.dismiss(); + } + }); + } + } + }) + .setPositiveButton(R.string.approve, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (dialogApprovedCallback != null) { + dialogApprovedCallback.onApprovedClicked(new DialogInterface() { + @Override + public void cancel() { + ReceiverConnectionInfoDialog.this.dismiss(); + } + + @Override + public void dismiss() { + ReceiverConnectionInfoDialog.this.dismiss(); + } + }); + } + } + }); + + + AlertDialog dialog = builder.create(); + setCancelable(false); + + return dialog; + } +} diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java new file mode 100644 index 0000000..75c4c75 --- /dev/null +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java @@ -0,0 +1,99 @@ +package org.smartregister.p2p.dialog; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + +import org.smartregister.p2p.R; +import org.smartregister.p2p.contract.P2pModeSelectContract; + +public class SenderApprovalDialog extends DialogFragment { + + private P2pModeSelectContract.View.DialogCancelCallback dialogCancelCallback; + private P2pModeSelectContract.View.DialogApprovedCallback dialogApprovedCallback; + private String deviceName; + private String connectionKey; + + public void setDialogCancelCallback(@Nullable P2pModeSelectContract.View.DialogCancelCallback dialogCancelCallback) { + this.dialogCancelCallback = dialogCancelCallback; + } + + public void setDialogApprovedCallback(@NonNull P2pModeSelectContract.View.DialogApprovedCallback dialogApprovedCallback) { + this.dialogApprovedCallback = dialogApprovedCallback; + } + + public void setConnectionDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public void setConnectionKey(String connectionKey) { + this.connectionKey = connectionKey; + } + + @NonNull + @Override + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View rootView = inflater.inflate(R.layout.dialog_pair_sender_info, null); + + TextView tvCode = rootView.findViewById(R.id.tv_connection_id); + tvCode.setText(connectionKey); + + TextView tvMessage = rootView.findViewById(R.id.tv_message); + tvMessage.setText(getString(R.string.you_are_attempting_to_send_data_to_device, deviceName)); + + builder.setView(rootView) + .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (dialogCancelCallback != null) { + dialogCancelCallback.onCancelClicked(new DialogInterface() { + @Override + public void cancel() { + SenderApprovalDialog.this.dismiss(); + } + + @Override + public void dismiss() { + SenderApprovalDialog.this.dismiss(); + } + }); + } + } + }) + .setPositiveButton(R.string.approve, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (dialogApprovedCallback != null) { + dialogApprovedCallback.onApprovedClicked(new DialogInterface() { + @Override + public void cancel() { + SenderApprovalDialog.this.dismiss(); + } + + @Override + public void dismiss() { + SenderApprovalDialog.this.dismiss(); + } + }); + } + } + }); + + + AlertDialog dialog = builder.create(); + setCancelable(false); + + return dialog; + } +} diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SkipQRScanDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SkipQRScanDialog.java index 83658ef..4d0acbf 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SkipQRScanDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SkipQRScanDialog.java @@ -1,15 +1,16 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + import org.smartregister.p2p.R; import org.smartregister.p2p.util.Constants; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialog.java index b55f05a..db2b5a6 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialog.java @@ -1,14 +1,15 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialog.java index c2fbe24..5ece5fc 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialog.java @@ -1,14 +1,15 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/DevicesConnectedFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/DevicesConnectedFragment.java index 6b18b52..de58624 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/DevicesConnectedFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/DevicesConnectedFragment.java @@ -1,9 +1,10 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/ErrorFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/ErrorFragment.java index 4f74165..4e0b7b6 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/ErrorFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/ErrorFragment.java @@ -1,9 +1,10 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/P2PModeSelectFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/P2PModeSelectFragment.java index 9346cea..6eb86f5 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/P2PModeSelectFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/P2PModeSelectFragment.java @@ -1,9 +1,9 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeGeneratorFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeGeneratorFragment.java index 3cc9726..879bf79 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeGeneratorFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeGeneratorFragment.java @@ -2,9 +2,9 @@ import android.graphics.Bitmap; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.*; +import androidx.fragment.app.Fragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeScanningFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeScanningFragment.java index 089c864..19ef51c 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeScanningFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/QRCodeScanningFragment.java @@ -1,10 +1,9 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; -import android.support.v4.app.Fragment; +import androidx.annotation.*; +import androidx.fragment.app.Fragment; + import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncCompleteTransferFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncCompleteTransferFragment.java index 4319e39..4290933 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncCompleteTransferFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncCompleteTransferFragment.java @@ -1,9 +1,6 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,6 +8,9 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.*; +import androidx.fragment.app.Fragment; + import org.smartregister.p2p.R; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncProgressFragment.java b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncProgressFragment.java index ae7160a..abd9288 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncProgressFragment.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/fragment/SyncProgressFragment.java @@ -1,15 +1,16 @@ package org.smartregister.p2p.fragment; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + import org.smartregister.p2p.R; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityRequestPermissionResultHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityRequestPermissionResultHandler.java index 02f9552..1af2bc0 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityRequestPermissionResultHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityRequestPermissionResultHandler.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.handler; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 12/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResultHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResultHandler.java index 8d0f2aa..5d15c30 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResultHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResultHandler.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.handler; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 11/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResumeHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResumeHandler.java index c610e94..f6ca1de 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResumeHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/handler/ActivityResumeHandler.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.handler; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 11/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/handler/AdvertisingResumeHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/handler/AdvertisingResumeHandler.java index 6837301..8b892c7 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/handler/AdvertisingResumeHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/handler/AdvertisingResumeHandler.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.handler; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import org.smartregister.p2p.contract.P2pModeSelectContract; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/handler/OnActivityRequestPermissionHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/handler/OnActivityRequestPermissionHandler.java index 4a41e7a..cd83a61 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/handler/OnActivityRequestPermissionHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/handler/OnActivityRequestPermissionHandler.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.handler; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 12/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/interactor/P2pModeSelectInteractor.java b/p2p-sync/src/main/java/org/smartregister/p2p/interactor/P2pModeSelectInteractor.java index 46aaec8..667136c 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/interactor/P2pModeSelectInteractor.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/interactor/P2pModeSelectInteractor.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.interactor; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import android.widget.Toast; import com.google.android.gms.common.api.ApiException; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/AppDatabase.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/AppDatabase.java index 9ba57a4..ba9d9f2 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/AppDatabase.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/AppDatabase.java @@ -1,12 +1,14 @@ package org.smartregister.p2p.model; -import android.arch.persistence.room.Database; -import android.arch.persistence.room.Room; -import android.arch.persistence.room.RoomDatabase; + import android.content.Context; -import android.support.annotation.NonNull; import android.text.SpannableStringBuilder; +import androidx.annotation.NonNull; +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; + import com.commonsware.cwac.saferoom.SafeHelperFactory; import org.smartregister.p2p.model.dao.P2pReceivedHistoryDao; @@ -27,7 +29,7 @@ public static AppDatabase getInstance(@NonNull Context context, @NonNull String SafeHelperFactory safeHelperFactory = SafeHelperFactory.fromUser(new SpannableStringBuilder(passphrase)); instance = Room.databaseBuilder(context.getApplicationContext(), - AppDatabase.class, DB_NAME) + AppDatabase.class, DB_NAME) .openHelperFactory(safeHelperFactory) .build(); } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/DataType.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/DataType.java index 84fe295..3154576 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/DataType.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/DataType.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.model; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 28/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/P2pReceivedHistory.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/P2pReceivedHistory.java index 4a6c40c..fbac8d8 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/P2pReceivedHistory.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/P2pReceivedHistory.java @@ -1,8 +1,9 @@ package org.smartregister.p2p.model; -import android.arch.persistence.room.ColumnInfo; -import android.arch.persistence.room.Entity; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; +import androidx.room.ColumnInfo; +import androidx.room.Entity; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 26/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/SendingDevice.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/SendingDevice.java index acf3b04..229c531 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/SendingDevice.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/SendingDevice.java @@ -1,9 +1,10 @@ package org.smartregister.p2p.model; -import android.arch.persistence.room.ColumnInfo; -import android.arch.persistence.room.Entity; -import android.arch.persistence.room.PrimaryKey; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.PrimaryKey; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 26/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/P2pReceivedHistoryDao.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/P2pReceivedHistoryDao.java index 813d77a..0f30856 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/P2pReceivedHistoryDao.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/P2pReceivedHistoryDao.java @@ -1,11 +1,12 @@ package org.smartregister.p2p.model.dao; -import android.arch.persistence.room.Dao; -import android.arch.persistence.room.Insert; -import android.arch.persistence.room.Query; -import android.arch.persistence.room.Update; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; import org.smartregister.p2p.model.P2pReceivedHistory; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/ReceiverTransferDao.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/ReceiverTransferDao.java index b8f2331..d93523e 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/ReceiverTransferDao.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/ReceiverTransferDao.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.model.dao; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.WorkerThread; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.WorkerThread; import org.json.JSONArray; import org.smartregister.p2p.model.DataType; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SenderTransferDao.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SenderTransferDao.java index 4474f95..f3dcc8f 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SenderTransferDao.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SenderTransferDao.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.model.dao; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.WorkerThread; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.WorkerThread; import org.smartregister.p2p.model.DataType; import org.smartregister.p2p.sync.data.MultiMediaData; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SendingDeviceDao.java b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SendingDeviceDao.java index 3636830..9809f3e 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SendingDeviceDao.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/model/dao/SendingDeviceDao.java @@ -1,10 +1,11 @@ package org.smartregister.p2p.model.dao; -import android.arch.persistence.room.Dao; -import android.arch.persistence.room.Insert; -import android.arch.persistence.room.Query; -import android.arch.persistence.room.Update; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; +import androidx.room.Update; import org.smartregister.p2p.model.SendingDevice; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenter.java b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenter.java index e154207..44332f1 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenter.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenter.java @@ -2,7 +2,7 @@ import android.app.Activity; import android.content.Context; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import android.view.WindowManager; import org.smartregister.p2p.P2PLibrary; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PReceiverPresenter.java b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PReceiverPresenter.java index 53724e1..24e53cc 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PReceiverPresenter.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PReceiverPresenter.java @@ -1,10 +1,10 @@ package org.smartregister.p2p.presenter; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; -import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.ConnectionResolution; @@ -23,8 +23,8 @@ import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.dialog.SkipQRScanDialog; import org.smartregister.p2p.fragment.ErrorFragment; -import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.fragment.SyncCompleteTransferFragment; +import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.handler.OnActivityRequestPermissionHandler; import org.smartregister.p2p.model.AppDatabase; import org.smartregister.p2p.model.P2pReceivedHistory; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PSenderPresenter.java b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PSenderPresenter.java index 2a7b090..f2fbfc4 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PSenderPresenter.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/presenter/P2PSenderPresenter.java @@ -1,10 +1,10 @@ package org.smartregister.p2p.presenter; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; -import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.ConnectionResolution; @@ -27,8 +27,8 @@ import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.dialog.SkipQRScanDialog; import org.smartregister.p2p.fragment.ErrorFragment; -import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.fragment.SyncCompleteTransferFragment; +import org.smartregister.p2p.fragment.SyncProgressFragment; import org.smartregister.p2p.handler.OnActivityRequestPermissionHandler; import org.smartregister.p2p.model.DataType; import org.smartregister.p2p.model.P2pReceivedHistory; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/DiscoveredDevice.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/DiscoveredDevice.java index d158b14..e1bdeed 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/DiscoveredDevice.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/DiscoveredDevice.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.DiscoveredEndpointInfo; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/IReceiverSyncLifecycleCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/IReceiverSyncLifecycleCallback.java index 45934b9..39c151d 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/IReceiverSyncLifecycleCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/IReceiverSyncLifecycleCallback.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.sync; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.google.android.gms.nearby.connection.Payload; import org.smartregister.p2p.model.P2pReceivedHistory; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/ISenderSyncLifecycleCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/ISenderSyncLifecycleCallback.java index 88f2bee..c7aec39 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/ISenderSyncLifecycleCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/ISenderSyncLifecycleCallback.java @@ -1,11 +1,10 @@ package org.smartregister.p2p.sync; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.android.gms.nearby.connection.DiscoveredEndpointInfo; import com.google.android.gms.nearby.connection.Payload; -import com.google.android.gms.nearby.connection.PayloadTransferUpdate; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncConnectionLifecycleCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncConnectionLifecycleCallback.java index c2b6c2b..f667238 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncConnectionLifecycleCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncConnectionLifecycleCallback.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.sync; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.ConnectionLifecycleCallback; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncLifecycleCallback.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncLifecycleCallback.java index 41613a2..5ab2e91 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncLifecycleCallback.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/SyncLifecycleCallback.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.ConnectionResolution; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/JsonData.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/JsonData.java index 372673b..053058f 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/JsonData.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/JsonData.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.sync.data; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import org.json.JSONArray; /** diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/MultiMediaData.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/MultiMediaData.java index d2dc76b..31a2397 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/MultiMediaData.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/MultiMediaData.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync.data; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.io.File; import java.util.HashMap; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/ProcessedChunk.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/ProcessedChunk.java index c5119a0..b1251ec 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/ProcessedChunk.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/ProcessedChunk.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync.data; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.android.gms.nearby.connection.Payload; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/SyncPackageManifest.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/SyncPackageManifest.java index def2d3d..8adbc95 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/SyncPackageManifest.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/data/SyncPackageManifest.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync.data; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.smartregister.p2p.model.DataType; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/BaseSyncHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/BaseSyncHandler.java index f5e7185..04ca3c1 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/BaseSyncHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/BaseSyncHandler.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sync.handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.gson.Gson; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncReceiverHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncReceiverHandler.java index df0c2d9..b2aa30c 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncReceiverHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncReceiverHandler.java @@ -1,10 +1,10 @@ package org.smartregister.p2p.sync.handler; import android.os.AsyncTask; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; -import android.support.v4.util.SimpleArrayMap; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.collection.SimpleArrayMap; import com.google.android.gms.nearby.connection.Payload; import com.google.android.gms.nearby.connection.PayloadTransferUpdate; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncSenderHandler.java b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncSenderHandler.java index ba3a34f..644a31d 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncSenderHandler.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/sync/handler/SyncSenderHandler.java @@ -3,9 +3,9 @@ import android.os.Handler; import android.os.Looper; import android.os.ParcelFileDescriptor; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import android.text.TextUtils; import com.google.android.gms.nearby.connection.Payload; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/ConnectionTimeout.java b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/ConnectionTimeout.java index b85a9b1..59e2cc0 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/ConnectionTimeout.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/ConnectionTimeout.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.tasks; import android.os.AsyncTask; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; +import androidx.annotation.NonNull; import org.smartregister.p2p.contract.P2pModeSelectContract; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/GenericAsyncTask.java b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/GenericAsyncTask.java index 0a1455e..2113adf 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/GenericAsyncTask.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/GenericAsyncTask.java @@ -1,8 +1,9 @@ package org.smartregister.p2p.tasks; import android.os.AsyncTask; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.smartregister.p2p.exceptions.AsyncTaskCancelledException; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/Tasker.java b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/Tasker.java index d1f7875..d5f099e 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/tasks/Tasker.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/tasks/Tasker.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.tasks; import android.os.AsyncTask; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import java.util.concurrent.Callable; import java.util.concurrent.Executor; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/Constants.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/Constants.java index 91ad981..eff229c 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/Constants.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/Constants.java @@ -25,6 +25,7 @@ interface Dialog { String START_RECEIVE_MODE_PROGRESS = "dialog_start_receive_mode_progress"; String SKIP_QR_SCAN = "skip_qr_scan"; String CONNECTING = "connecting"; + String DISPLAY_APPROVAL_KEY = "display_approval"; } interface Fragment { diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/Device.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/Device.java index e0b33fa..04a7e21 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/Device.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/Device.java @@ -2,8 +2,8 @@ import android.content.Context; import android.net.wifi.WifiManager; -import android.support.annotation.Nullable; -import android.support.annotation.WorkerThread; +import androidx.annotation.Nullable; +import androidx.annotation.WorkerThread; import java.net.NetworkInterface; import java.net.SocketException; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/DialogUtils.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/DialogUtils.java index 17ad150..ed11984 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/DialogUtils.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/DialogUtils.java @@ -1,9 +1,11 @@ package org.smartregister.p2p.util; -import android.support.annotation.NonNull; -import android.support.v4.app.DialogFragment; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; + + +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; import java.util.List; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/NearbyStorageUtil.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/NearbyStorageUtil.java index c5257f8..664e9ee 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/NearbyStorageUtil.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/NearbyStorageUtil.java @@ -3,7 +3,7 @@ import android.Manifest; import android.content.Context; import android.os.Environment; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import java.io.File; @@ -26,11 +26,12 @@ public static void deleteFilesInNearbyFolder(@NonNull Context context) { if (nearbyFolder.exists()) { File[] nearbyDirectoryFiles = nearbyFolder.listFiles(); - for(File nearbyFile: nearbyDirectoryFiles) { - if (nearbyFile.delete()) { - Timber.e("Could not delete %s", nearbyFile.getAbsoluteFile()); + if (nearbyDirectoryFiles != null) + for (File nearbyFile : nearbyDirectoryFiles) { + if (nearbyFile.delete()) { + Timber.e("Could not delete %s", nearbyFile.getAbsoluteFile()); + } } - } } } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/Permissions.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/Permissions.java index 753d8ed..24271d7 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/Permissions.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/Permissions.java @@ -4,9 +4,9 @@ import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; -import android.support.annotation.NonNull; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; +import androidx.annotation.NonNull; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import java.util.ArrayList; import java.util.List; @@ -25,6 +25,7 @@ public abstract class Permissions { Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA }; @@ -34,6 +35,7 @@ public abstract class Permissions { Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/Settings.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/Settings.java index 26819b9..c3bb398 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/Settings.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/Settings.java @@ -2,8 +2,8 @@ import android.content.Context; import android.content.SharedPreferences; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Created by Ephraim Kigamba - ekigamba@ona.io on 26/03/2019 diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/util/SyncDataConverterUtil.java b/p2p-sync/src/main/java/org/smartregister/p2p/util/SyncDataConverterUtil.java index dcc7681..184a3fe 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/util/SyncDataConverterUtil.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/util/SyncDataConverterUtil.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.util; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.smartregister.p2p.R; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/view/CameraSourcePreview.java b/p2p-sync/src/main/java/org/smartregister/p2p/view/CameraSourcePreview.java index 52f2985..4b2f663 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/view/CameraSourcePreview.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/view/CameraSourcePreview.java @@ -2,7 +2,7 @@ import android.Manifest; import android.content.Context; -import android.support.annotation.RequiresPermission; +import androidx.annotation.RequiresPermission; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/view/QRCodeScannerView.java b/p2p-sync/src/main/java/org/smartregister/p2p/view/QRCodeScannerView.java index 227482f..20db7d8 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/view/QRCodeScannerView.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/view/QRCodeScannerView.java @@ -3,16 +3,17 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.app.Dialog; -import android.arch.lifecycle.Lifecycle; -import android.arch.lifecycle.LifecycleObserver; -import android.arch.lifecycle.LifecycleOwner; -import android.arch.lifecycle.OnLifecycleEvent; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Vibrator; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleObserver; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.OnLifecycleEvent; + import android.util.AttributeSet; import android.util.SparseArray; import android.widget.LinearLayout; diff --git a/p2p-sync/src/main/res/layout/activity_p2p_mode_select.xml b/p2p-sync/src/main/res/layout/activity_p2p_mode_select.xml index 0d1e303..0a1e93b 100644 --- a/p2p-sync/src/main/res/layout/activity_p2p_mode_select.xml +++ b/p2p-sync/src/main/res/layout/activity_p2p_mode_select.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/dialog_pair_receiver_approval.xml b/p2p-sync/src/main/res/layout/dialog_pair_receiver_approval.xml new file mode 100644 index 0000000..fe37df7 --- /dev/null +++ b/p2p-sync/src/main/res/layout/dialog_pair_receiver_approval.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/dialog_pair_sender_info.xml b/p2p-sync/src/main/res/layout/dialog_pair_sender_info.xml new file mode 100644 index 0000000..a5e93fc --- /dev/null +++ b/p2p-sync/src/main/res/layout/dialog_pair_sender_info.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/fragment_devices_connected.xml b/p2p-sync/src/main/res/layout/fragment_devices_connected.xml index e47f53d..5984d82 100644 --- a/p2p-sync/src/main/res/layout/fragment_devices_connected.xml +++ b/p2p-sync/src/main/res/layout/fragment_devices_connected.xml @@ -1,10 +1,10 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/fragment_error.xml b/p2p-sync/src/main/res/layout/fragment_error.xml index 7e9be3e..65e54b9 100644 --- a/p2p-sync/src/main/res/layout/fragment_error.xml +++ b/p2p-sync/src/main/res/layout/fragment_error.xml @@ -1,10 +1,10 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/fragment_mode_select.xml b/p2p-sync/src/main/res/layout/fragment_mode_select.xml index ad428ec..d8a9b69 100644 --- a/p2p-sync/src/main/res/layout/fragment_mode_select.xml +++ b/p2p-sync/src/main/res/layout/fragment_mode_select.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/p2p-sync/src/main/res/layout/fragment_successful_transfer.xml b/p2p-sync/src/main/res/layout/fragment_successful_transfer.xml index 68cdd0d..f754bae 100644 --- a/p2p-sync/src/main/res/layout/fragment_successful_transfer.xml +++ b/p2p-sync/src/main/res/layout/fragment_successful_transfer.xml @@ -1,10 +1,10 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/p2p-sync/src/main/res/values-fr/strings.xml b/p2p-sync/src/main/res/values-fr/strings.xml index 5951604..cfc0a56 100644 --- a/p2p-sync/src/main/res/values-fr/strings.xml +++ b/p2p-sync/src/main/res/values-fr/strings.xml @@ -32,15 +32,15 @@ Destination finale perdue %s La connexion à %s est interrompue CONNECTÉ - Connexion initié par : %s Nom de destination finale (%s) code d\'auth(%s) - Rejetant la connexion initiée par l\'autre apareil %s, %s, %s - Destination final identifiée : %s Info destination finale: (%s, %s) + Connexion initié par : %1$s Nom de destination finale (%2$s) code d\'auth(%3$s) + Rejetant la connexion initiée par l\'autre apareil %1$s, %2$s, %3$s + Destination final identifiée : %1$s Info destination finale: (%2$s, %3$s) Charge utile reçu de %s DEMANDE DE CONNEXION RÉUSSIE IMPOSSIBLE D\'INITIER LA DEMANDE DE CONNEXION À L\'APPAREIL DÉCONNECTÉ Authentification réussie! Récepteur peut accepter la connexion - %s: %s + %1$s: %2$s Dépendences détecteur ne sont pas encore disponibles Dépendences de codes de barre ne peuvent être téléchargés en raison du niveau bas de stockage de l\'appareil Impossible de démarrer la source de la caméra @@ -64,12 +64,12 @@ Une erreur est survenu en essayant de traiter les données non-médiatiques Une erreur est survenu en essayant de traiter les données non-médiatiques Manifeste invalide reçu de la destination finale %s - Ignorant la charge utile %d puisqu\'elle ne correspond pas avec la charge utile attendue %d + Ignorant la charge utile %1$d puisqu\'elle ne correspond pas avec la charge utile attendue %2$d Manifeste invalide reçu de la destination finale %s Charge utile reçu sans manifeste Partager données avec un appareil à proximité Sauter cette étape - Initialisation... + Initialisation… Réception de données Transmission de données Transfert réussi @@ -82,22 +82,22 @@ onConnectionAccepted pour la destination finale %s sans appareil pair onConnectionUnknownError à la destination finale %s sans appareil pair onAuthenticationSuccessful sans appareil pair - %,d records %s + %1$,d records %2$s Inconnu - %s | %s | %s | %d | %s - Appareil mobile %s %s %,d de %s. More device info(%s) + %1$s | %2$s | %3$s | %4$d | %5$s + Appareil mobile %1$s %2$s %3$,d de %4$s. More device info(%5$s) Envoyée Reçue Transfer de %,d dossiers Transfer de %,d dossiers Connexion echouée SAUTER - Veuillez vous assurer que l\'appareil de \"%s\" est allumé et à proximité. %s fichiers ont été transféré. Veuillez reconnecter pour transférer les données restants. + Veuillez vous assurer que l\'appareil de \"%1$s\" est allumé et à proximité. %2$s fichiers ont été transféré. Veuillez reconnecter pour transférer les données restants. Sauter le scan du code QR L\'appareil récepteur, «l\'appareil de%s», à choisi de sauter le scan du code QR. Si vous choisissez de sauter cette étape vous allez pouvoir envoyer les données à l\'autre appareil sans confirmation par scan du code QR. L\'appareil émetteur, «l\'appareil de %s», à choisi de sauter le scan du code QR. Si vous choisissez de sauter cette étape vous allez pouvoir envoyer les données à l\'autre appareil sans confirmation par scan du code QR. Connexion - S\'il vous plaît, attendez... + S\'il vous plaît, attendez… Authorisation échouée L\'information de l\'appareil partagé is invalide Une erreure inconnue s\'est produite @@ -110,5 +110,16 @@ Commencer le transfert Appareils connectés Veuillez vous assurer que les appareils demeurent à proximité durant le transfert de données - + Clause de non-responsabilité + Services Google Play requis + Les services Google Play sont requis pour que ce service fonctionne + Vous devez mettre à jour le service Google Play de votre appareil + Veuillez activer le matériel Wi-Fi de votre appareil + Mettez à jour maintenant + Peut-être plus tard + L\'appareil de %s aimerait aimerait vous envoyer des données, le jumelage connecte l\'appareil afin que les données puissent être transférées + Code d\'appariement de l\'appareil + Approuver la demande d\'association? + Vous essayez d\'envoyer des données à l\'appareil %s + Approuvering> diff --git a/p2p-sync/src/main/res/values/strings.xml b/p2p-sync/src/main/res/values/strings.xml index a6513da..4bedc12 100644 --- a/p2p-sync/src/main/res/values/strings.xml +++ b/p2p-sync/src/main/res/values/strings.xml @@ -32,15 +32,15 @@ Endpoint lost %s The connection to %s has broken CONNECTED - Connection initiated by : %s Endpoint name(%s) auth code(%s) - Rejecting connection initiated by the other device %s, %s, %s - Endpoint found : %s Endpoint info: (%s, %s) + Connection initiated by : %1$s Endpoint name(%2$s) auth code(%3$s) + Rejecting connection initiated by the other device %1$s, %2$s, %3$s + Endpoint found : %1$s Endpoint info: (%2$s, %3$s) Received a payload from %s CONNECTION REQUEST WAS SUCCESSFUL COULD NOT INITIATE CONNECTION REQUEST TO THE DEVICE DISCONNECTED Authentication successful! Receiver can accept connection - %s: %s + %1$s: %2$s Detector dependencies are not yet available. Barcode detector dependencies cannot be downloaded due to low device storage Unable to start camera source. @@ -64,7 +64,7 @@ An error occurred trying to process non-media data An error occurred trying to process non-media data Received invalid manifest from endpoint %s - Ignoring payload %d since it does not match the expected payload %d + Ignoring payload %1$d since it does not match the expected payload %2$d Received invalid manifest from endpoint %s Received a payload without a corresponding manifest Share data with nearby device @@ -82,17 +82,17 @@ onConnectionAccepted to endpoint %s without a peer device onConnectionUnknownError to endpoint %s without a peer device onAuthenticationSuccessful without a peer device - %,d records %s + %1$,d records %2$s Unknown - %s|%s|%s|%d|%s - Device %s %s %,d of %s. More device info(%s) + %1$s|%2$s|%3$s|%4$d|%5$s + Device %1$s %2$s %3$,d of %4$s. More device info(%5$s) Sent Received Transferring %,d records Transferring %,d records Connection Lost SKIP - Please make sure \"%s\'s device\" is turned on and in range. %s records were transferred. Reconnect to transfer the remaining data. + Please make sure \"%1$s\'s device\" is turned on and in range. %2$s records were transferred. Reconnect to transfer the remaining data. Skip QR Scan? The receiving device, \"%s\'s device\", chose to skip the QR scan step. Choosing skip will let you send data to the other device without a QR scan confirmation. The sending device, \"%s\'s device\", chose to skip the QR scan step. Choosing skip will let the data be transferred to your device without a QR scan confirmation. @@ -110,11 +110,16 @@ Start Transfer Devices Connected Please make sure the devices remain within range during data transfer - + Disclaimer Google Play Services Required Google play services in required for this service to work You need to update your device\'s google play service Please turn on your device\'s WiFi hardware Update Now Maybe Later + "%s's device" would like to would like to send you data, Pairing connects the device so that data can be transferred + Device pairing code + Approve pairing request? + You are attempting to send data to %s device + Approve diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/activity/P2pModeSelectActivityTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/activity/P2pModeSelectActivityTest.java index dad0c3c..6048a6f 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/activity/P2pModeSelectActivityTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/activity/P2pModeSelectActivityTest.java @@ -8,10 +8,10 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.wifi.WifiManager; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.tasks.OnFailureListener; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticatorTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticatorTest.java index c0e71e3..545cebc 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticatorTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/ReceiverConnectionAuthenticatorTest.java @@ -60,7 +60,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable { .when(view) .getString(Mockito.anyInt()); - receiverConnectionAuthenticator = new ReceiverConnectionAuthenticator(senderPresenter); + receiverConnectionAuthenticator = Mockito.spy(new ReceiverConnectionAuthenticator(senderPresenter)); + Mockito.doReturn(false).when(receiverConnectionAuthenticator).allowSkipQrCodeScan(); } @Test diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticatorTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticatorTest.java index 4617495..2696e59 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticatorTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/authenticator/SenderConnectionAuthenticatorTest.java @@ -61,7 +61,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable { .when(view) .getString(Mockito.anyInt()); - senderConnectionAuthenticator = new SenderConnectionAuthenticator(senderPresenter); + senderConnectionAuthenticator = Mockito.spy(new SenderConnectionAuthenticator(senderPresenter)); + Mockito.doReturn(false).when(senderConnectionAuthenticator).allowSkipQrCodeScan(); } @Test diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialogTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialogTest.java index 1b702f2..b966d9c 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialogTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartDiscoveringModeProgressDialogTest.java @@ -1,12 +1,13 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; -import android.support.v7.app.AlertDialog; import android.widget.Button; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialogTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialogTest.java index 7478e7d..4d3f3b4 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialogTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/dialog/StartReceiveModeProgressDialogTest.java @@ -1,12 +1,13 @@ package org.smartregister.p2p.dialog; +import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; -import android.support.v7.app.AlertDialog; import android.widget.Button; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenterTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenterTest.java index 16ac5c0..a020c7a 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenterTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/presenter/BaseP2pModeSelectPresenterTest.java @@ -1,10 +1,11 @@ package org.smartregister.p2p.presenter; import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.view.WindowManager; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.google.android.gms.nearby.connection.DiscoveredEndpointInfo; import org.junit.Assert; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/presenter/P2PSenderPresenterTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/presenter/P2PSenderPresenterTest.java index afd8188..ee6ae60 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/presenter/P2PSenderPresenterTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/presenter/P2PSenderPresenterTest.java @@ -1,8 +1,11 @@ package org.smartregister.p2p.presenter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import android.Manifest; import android.content.DialogInterface; -import android.widget.Toast; import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.nearby.connection.ConnectionLifecycleCallback; @@ -55,12 +58,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.TreeSet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - /** * Created by Ephraim Kigamba - ekigamba@ona.io on 19/03/2019 */ @@ -827,7 +827,7 @@ public void onPayloadTransferUpdateShouldResetHashKeyPayloadIdWhenHashKeyPayload ReflectionHelpers.setField(p2PSenderPresenter, "hashKeyPayloadId", payloadId); p2PSenderPresenter.onPayloadTransferUpdate(endpointId, update); - assertEquals(0l, ReflectionHelpers.getField(p2PSenderPresenter, "hashKeyPayloadId")); + assertEquals(Optional.of(0L), ReflectionHelpers.getField(p2PSenderPresenter, "hashKeyPayloadId")); } @Test diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowAppDatabase.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowAppDatabase.java index 12010e6..c06c7ad 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowAppDatabase.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowAppDatabase.java @@ -1,8 +1,9 @@ package org.smartregister.p2p.shadows; -import android.arch.persistence.room.Room; import android.content.Context; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; +import androidx.room.Room; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowConnectionsClient.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowConnectionsClient.java index 961381f..9a6397e 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowConnectionsClient.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowConnectionsClient.java @@ -1,5 +1,6 @@ package org.smartregister.p2p.shadows; + import com.google.android.gms.nearby.connection.ConnectionsClient; import org.robolectric.annotation.Implements; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowNearby.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowNearby.java index e7e64d8..69686df 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowNearby.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowNearby.java @@ -1,7 +1,8 @@ package org.smartregister.p2p.shadows; import android.content.Context; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; import com.google.android.gms.internal.nearby.zzbd; import com.google.android.gms.nearby.Nearby; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowPayload.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowPayload.java index bedfecc..4aaf275 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowPayload.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowPayload.java @@ -1,7 +1,8 @@ package org.smartregister.p2p.shadows; import android.os.ParcelFileDescriptor; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; import com.google.android.gms.nearby.connection.Payload; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowTasker.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowTasker.java index bfa7159..9659562 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowTasker.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowTasker.java @@ -1,6 +1,6 @@ package org.smartregister.p2p.shadows; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/Shadowzzbd.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/Shadowzzbd.java index b2d2250..9889c15 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/Shadowzzbd.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/Shadowzzbd.java @@ -2,8 +2,9 @@ import android.app.Activity; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.android.gms.internal.nearby.zzbd; import com.google.android.gms.nearby.connection.AdvertisingOptions; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncReceiverHandlerTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncReceiverHandlerTest.java index b77600b..086551c 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncReceiverHandlerTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncReceiverHandlerTest.java @@ -1,6 +1,12 @@ package org.smartregister.p2p.sync.handler; -import android.support.v4.util.SimpleArrayMap; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import androidx.collection.SimpleArrayMap; import com.google.android.gms.nearby.connection.DiscoveredEndpointInfo; import com.google.android.gms.nearby.connection.Payload; @@ -41,12 +47,6 @@ import java.io.File; import java.util.HashMap; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * Created by Ephraim Kigamba - ekigamba@ona.io on 04/04/2019 */ diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java index 726c6f8..a20a7a9 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java @@ -1,5 +1,13 @@ package org.smartregister.p2p.sync.handler; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; + import com.google.android.gms.nearby.connection.Payload; import com.google.android.gms.nearby.connection.PayloadTransferUpdate; @@ -39,14 +47,9 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.TreeSet; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * Created by Ephraim Kigamba - ekigamba@ona.io on 29/03/2019 */ @@ -55,29 +58,25 @@ @Config(shadows = {ShadowAppDatabase.class, ShadowTasker.class, ShadowPayload.class}) public class SyncSenderHandlerTest { + private final DataType event = new DataType("event", DataType.Type.NON_MEDIA, 1); + private final DataType client = new DataType("client", DataType.Type.NON_MEDIA, 2); + private final DataType profilePic = new DataType("profile-pic", DataType.Type.MEDIA, 3); @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); - private TestSyncSenderHandler syncSenderHandler; @Mock private P2pModeSelectContract.SenderPresenter senderPresenter; - @Mock private P2PAuthorizationService authorizationService; @Mock private SenderTransferDao senderTransferDao; @Mock private ReceiverTransferDao receiverTransferDao; - private TreeSet dataSyncOrder; - private DataType event = new DataType("event", DataType.Type.NON_MEDIA, 1); - private DataType client = new DataType("client", DataType.Type.NON_MEDIA, 2); - private DataType profilePic = new DataType("profile-pic", DataType.Type.MEDIA, 3); - @Before public void setUp() throws Exception { - P2PLibrary.init(new P2PLibrary.Options(RuntimeEnvironment.application, "some password", "username" + P2PLibrary.init(new P2PLibrary.Options(RuntimeEnvironment.application, "somepassword", "username" , authorizationService, receiverTransferDao, senderTransferDao)); dataSyncOrder = new TreeSet<>(); @@ -154,7 +153,7 @@ public void sendNextManifestShouldCallSendJSONDataManifestWhenNonMediaDataTypeIs syncSenderHandler.sendNextManifest(); Mockito.verify(syncSenderHandler, Mockito.times(1)) - .sendJsonDataManifest(Mockito.any(DataType.class)); + .sendJsonDataManifest(any(DataType.class)); } @Test @@ -169,7 +168,7 @@ public void sendNextManifestShouldCallSendMultimediaDataManifestWhenMediaDataTyp syncSenderHandler.sendNextManifest(); Mockito.verify(syncSenderHandler, Mockito.times(1)) - .sendMultimediaDataManifest(Mockito.any(DataType.class)); + .sendMultimediaDataManifest(any(DataType.class)); } @Test @@ -206,7 +205,7 @@ public void onPayloadTransferUpdateShouldCallSendNextPayloadAndResetFlagsWhenMan .when(syncSenderHandler) .sendNextPayload(); - PayloadTransferUpdate payloadTransferUpdate = Mockito.mock(PayloadTransferUpdate.class); + PayloadTransferUpdate payloadTransferUpdate = mock(PayloadTransferUpdate.class); Mockito.doReturn(payloadId) .when(payloadTransferUpdate) @@ -224,7 +223,7 @@ public void onPayloadTransferUpdateShouldCallSendNextPayloadAndResetFlagsWhenMan .sendNextPayload(); assertFalse((boolean) ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestTransfer")); - assertEquals(0l, ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestId")); + assertEquals(Optional.of(0L), ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestId")); assertNull(ReflectionHelpers.getField(syncSenderHandler, "payloadRetry")); } @@ -237,7 +236,7 @@ public void onPayloadTransferUpdateShouldRetrySendingManifestWhenStatusManifestU .when(syncSenderHandler) .sendNextPayload(); - PayloadTransferUpdate payloadTransferUpdate = Mockito.mock(PayloadTransferUpdate.class); + PayloadTransferUpdate payloadTransferUpdate = mock(PayloadTransferUpdate.class); Mockito.doReturn(payloadId) .when(payloadTransferUpdate) @@ -247,7 +246,7 @@ public void onPayloadTransferUpdateShouldRetrySendingManifestWhenStatusManifestU .when(payloadTransferUpdate) .getStatus(); - SyncPackageManifest syncPackageManifest = Mockito.mock(SyncPackageManifest.class); + SyncPackageManifest syncPackageManifest = mock(SyncPackageManifest.class); ReflectionHelpers.setField(syncSenderHandler, "awaitingManifestTransfer", true); ReflectionHelpers.setField(syncSenderHandler, "awaitingManifestId", payloadId); @@ -270,7 +269,7 @@ public void onPayloadTransferUpdateShouldReportFatalSyncErrorToPresenterWhenMani .when(syncSenderHandler) .sendNextPayload(); - PayloadTransferUpdate payloadTransferUpdate = Mockito.mock(PayloadTransferUpdate.class); + PayloadTransferUpdate payloadTransferUpdate = mock(PayloadTransferUpdate.class); Mockito.doReturn(payloadId) .when(payloadTransferUpdate) @@ -285,7 +284,7 @@ public void onPayloadTransferUpdateShouldReportFatalSyncErrorToPresenterWhenMani syncSenderHandler.onPayloadTransferUpdate(payloadTransferUpdate); Mockito.verify(senderPresenter, Mockito.times(1)) - .errorOccurredSync(Mockito.any(Exception.class)); + .errorOccurredSync(any(Exception.class)); } @Test @@ -296,7 +295,7 @@ public void onProcessStringShouldCallSendNextManifestWhenPayloadStatusUpdateForP .when(syncSenderHandler) .sendNextManifest(); - Payload awaitingPayload = Mockito.mock(Payload.class); + Payload awaitingPayload = mock(Payload.class); Mockito.doReturn(payloadId) .when(awaitingPayload) @@ -329,7 +328,7 @@ public void onPayloadTransferUpdateShouldRetrySendingPayloadWhenPayloadStatusUpd long payloadId = 9; int status = PayloadTransferUpdate.Status.FAILURE; - PayloadTransferUpdate payloadTransferUpdate = Mockito.mock(PayloadTransferUpdate.class); + PayloadTransferUpdate payloadTransferUpdate = mock(PayloadTransferUpdate.class); Mockito.doReturn(payloadId) .when(payloadTransferUpdate) @@ -339,7 +338,7 @@ public void onPayloadTransferUpdateShouldRetrySendingPayloadWhenPayloadStatusUpd .when(payloadTransferUpdate) .getStatus(); - Payload awaitingPayload = Mockito.mock(Payload.class); + Payload awaitingPayload = mock(Payload.class); Mockito.doReturn(payloadId) .when(awaitingPayload) @@ -369,7 +368,7 @@ public void onPayloadTransferUpdateShouldReportFatalErrorToPresenterWhenPayloadS long payloadId = 9; int status = PayloadTransferUpdate.Status.CANCELED; - PayloadTransferUpdate payloadTransferUpdate = Mockito.mock(PayloadTransferUpdate.class); + PayloadTransferUpdate payloadTransferUpdate = mock(PayloadTransferUpdate.class); Mockito.doReturn(payloadId) .when(payloadTransferUpdate) @@ -379,7 +378,7 @@ public void onPayloadTransferUpdateShouldReportFatalErrorToPresenterWhenPayloadS .when(payloadTransferUpdate) .getStatus(); - Payload awaitingPayload = Mockito.mock(Payload.class); + Payload awaitingPayload = mock(Payload.class); Mockito.doReturn(payloadId) .when(awaitingPayload) @@ -390,14 +389,14 @@ public void onPayloadTransferUpdateShouldReportFatalErrorToPresenterWhenPayloadS syncSenderHandler.onPayloadTransferUpdate(payloadTransferUpdate); Mockito.verify(senderPresenter, Mockito.times(1)) - .errorOccurredSync(Mockito.any(Exception.class)); + .errorOccurredSync(any(Exception.class)); } @Test public void sendMultimediaDataManifestShouldCallPresenterSendManifest() { DataType dataType = new DataType("pic", DataType.Type.MEDIA, 5); - File mockFile = Mockito.mock(File.class); + File mockFile = mock(File.class); MultiMediaData multiMediaData = new MultiMediaData(mockFile, 8923); HashMap details = new HashMap<>(); details.put("fileRecordId", "928"); @@ -407,7 +406,7 @@ public void sendMultimediaDataManifestShouldCallPresenterSendManifest() { HashMap remainingLastRecords = ReflectionHelpers.getField(syncSenderHandler, "remainingLastRecordIds"); remainingLastRecords.put("pic", 0L); - Payload payload = Mockito.mock(Payload.class); + Payload payload = mock(Payload.class); Mockito.doReturn(898L) .when(payload) .getId(); @@ -426,7 +425,7 @@ public void sendMultimediaDataManifestShouldCallPresenterSendManifest() { syncSenderHandler.sendMultimediaDataManifest(dataType); Mockito.verify(senderPresenter, Mockito.times(1)) - .sendManifest(Mockito.any(SyncPackageManifest.class)); + .sendManifest(any(SyncPackageManifest.class)); } @Test @@ -434,7 +433,7 @@ public void sendJsonDataManifestShouldCallPresenterSendManifest() { DataType dataType = new DataType("Person", DataType.Type.NON_MEDIA, 5); JsonData multiMediaData = new JsonData(new JSONArray(), 8923); - Payload payload = Mockito.mock(Payload.class); + Payload payload = mock(Payload.class); Mockito.doReturn(898L) .when(payload) .getId(); diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java index 0a0bd8e..8a47be6 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java @@ -1,7 +1,8 @@ package org.smartregister.p2p.sync.handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.model.DataType; diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/tasks/GenericAsyncTaskTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/tasks/GenericAsyncTaskTest.java index 5f1a051..d81fa0f 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/tasks/GenericAsyncTaskTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/tasks/GenericAsyncTaskTest.java @@ -1,6 +1,7 @@ package org.smartregister.p2p.tasks; -import android.support.annotation.Nullable; + +import androidx.annotation.Nullable; import org.junit.Rule; import org.junit.Test; diff --git a/p2p-sync/src/test/resources/robolectric.properties b/p2p-sync/src/test/resources/robolectric.properties new file mode 100644 index 0000000..30af026 --- /dev/null +++ b/p2p-sync/src/test/resources/robolectric.properties @@ -0,0 +1 @@ +sdk=29 \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 75e6c09..d8f3b47 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,35 +1,126 @@ -apply plugin: 'com.android.application' +apply plugin: 'com.android.library' +apply plugin: 'jacoco' +apply plugin: 'com.github.kt3k.coveralls' + + +jacoco { + toolVersion = "0.8.2" +} android { compileSdkVersion androidCompileSdkVersion buildToolsVersion androidBuildToolsVersion + defaultPublishConfig !isReleaseBuild() ? "debug" : "release" + defaultConfig { - applicationId "org.smartregister.p2p.sample" minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion versionCode 1 versionName version + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + javaCompileOptions { + annotationProcessorOptions { + arguments = ["room.schemaLocation": "$projectDir/schemas".toString()] + } + } } buildTypes { + + debug { + testCoverageEnabled true + minifyEnabled false + } + release { minifyEnabled false + testCoverageEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + testOptions.unitTests.includeAndroidResources = true + lintOptions.abortOnError = false } dependencies { - implementation project(":p2p-sync") - implementation 'com.jakewharton.timber:timber:4.7.1' + implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'com.google.android.gms:play-services-nearby:16.0.0' + implementation ('com.google.android.gms:play-services-location:16.0.0') { + exclude group: 'com.android.support', module: 'support-v4' + } + + implementation 'com.google.android.gms:play-services-vision:17.0.2' + + implementation 'com.jakewharton.timber:timber:4.7.1' + implementation project(path: ':p2p-sync') + testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + testImplementation 'org.mockito:mockito-inline:2.25.0' + testImplementation "org.robolectric:robolectric:4.2" + // ZXING DEPENDENCIES + implementation('com.journeyapps:zxing-android-embedded:3.6.0') { + exclude group: 'com.android.support', module: 'support-v4' + } + implementation 'com.google.zxing:core:3.3.0' implementation 'com.google.code.gson:gson:2.8.5' + + // Room + implementation "android.arch.persistence.room:runtime:$room_version" + annotationProcessor "android.arch.persistence.room:compiler:$room_version" + // Room Test helpers + testImplementation "android.arch.persistence.room:testing:$room_version" + + // Encrypted SQLite help + implementation "com.commonsware.cwac:saferoom:1.0.2" + +} + +task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { + + reports { + xml.enabled = true + html.enabled = true + } + + getReports().getXml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/merged.xml")) + getReports().getHtml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/html")) + + def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$ViewBinder*.*'] + def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter) + def mainSrc = "$project.projectDir/src/main/java" + + getSourceDirectories().setFrom([mainSrc]) + getClassDirectories().setFrom([debugTree]) + getExecutionData().setFrom(dir: project.buildDir, includes: [ + 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' + ]) + } + +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true +} + +coveralls { + jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/merged.xml" + // Re-add the line below if coveralls still cannot shows "No source file found on the project: "p2p-sync" + // after adding some code files + //sourceDirs += ["src/main/java"] +} + +def isReleaseBuild() { + return version.contains("SNAPSHOT") == false +} + +apply from: '../maven.gradle' \ No newline at end of file diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 2f19613..12a72b1 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ - + @@ -12,9 +11,10 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:name=".SampleApplication" + android:name="org.smartregister.p2p.sample.SampleApplication" android:theme="@style/AppTheme"> - + diff --git a/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java b/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java index acc8b1b..da06424 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java @@ -2,8 +2,10 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; + +import org.smartregister.p2p.R; import org.smartregister.p2p.activity.P2pModeSelectActivity; public class MainActivity extends AppCompatActivity { diff --git a/sample/src/main/java/org/smartregister/p2p/sample/SampleApplication.java b/sample/src/main/java/org/smartregister/p2p/sample/SampleApplication.java index a4e35eb..84f0dba 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/SampleApplication.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/SampleApplication.java @@ -2,7 +2,7 @@ import android.app.Application; import android.os.Build; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import org.smartregister.p2p.P2PLibrary; import org.smartregister.p2p.authorizer.P2PAuthorizationService; diff --git a/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleReceiverDao.java b/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleReceiverDao.java index b56a3c1..4afe9b6 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleReceiverDao.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleReceiverDao.java @@ -1,7 +1,7 @@ package org.smartregister.p2p.sample.dao; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.json.JSONArray; import org.smartregister.p2p.model.DataType; diff --git a/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleSenderDao.java b/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleSenderDao.java index a370c44..4594a9e 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleSenderDao.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/dao/SampleSenderDao.java @@ -1,8 +1,8 @@ package org.smartregister.p2p.sample.dao; import android.os.AsyncTask; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.json.JSONArray; import org.smartregister.p2p.model.DataType; diff --git a/sample/src/main/java/org/smartregister/p2p/sample/util/FailSafeRecalledID.java b/sample/src/main/java/org/smartregister/p2p/sample/util/FailSafeRecalledID.java index 91d2b51..816c773 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/util/FailSafeRecalledID.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/util/FailSafeRecalledID.java @@ -2,10 +2,10 @@ import android.content.Context; import android.content.SharedPreferences; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; import org.smartregister.p2p.contract.RecalledIdentifier; -import org.smartregister.p2p.util.Constants; import org.smartregister.p2p.util.Device; import java.util.UUID; @@ -22,7 +22,7 @@ public String getUniqueID(Context context) { if (uniqueAddress == null) { // save a uuid in SharedPreferences sharedPreferences = - context.getSharedPreferences(Constants.Prefs.NAME, Context.MODE_PRIVATE); + context.getSharedPreferences(Constants.NAMES, Context.MODE_PRIVATE); uniqueAddress = sharedPreferences.getString(FAIL_SAFE_ID, null);