From b0a9a93120b5a457a4ec180f49f5c810b4fe53fd Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Thu, 5 Nov 2020 19:49:47 +0300 Subject: [PATCH 01/13] Adds authentication by dialog confirmation --- .../org/smartregister/p2p/P2PLibrary.java | 14 ++ .../p2p/activity/P2pModeSelectActivity.java | 30 ++++- .../ReceiverConnectionAuthenticator.java | 72 ++++++++--- .../SenderConnectionAuthenticator.java | 120 +++++++++++------- .../p2p/contract/P2pModeSelectContract.java | 20 ++- .../dialog/ReceiverConnectionInfoDialog.java | 98 ++++++++++++++ .../p2p/dialog/SenderApprovalDialog.java | 98 ++++++++++++++ .../org/smartregister/p2p/util/Constants.java | 1 + .../layout/dialog_pair_receiver_approval.xml | 51 ++++++++ .../res/layout/dialog_pair_sender_info.xml | 51 ++++++++ p2p-sync/src/main/res/values/strings.xml | 5 + 11 files changed, 493 insertions(+), 67 deletions(-) create mode 100644 p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java create mode 100644 p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java create mode 100644 p2p-sync/src/main/res/layout/dialog_pair_receiver_approval.xml create mode 100644 p2p-sync/src/main/res/layout/dialog_pair_sender_info.xml diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java index 38740f5..c3aadf0 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java @@ -158,6 +158,10 @@ public SyncFinishedCallback getSyncFinishedCallback() { return options.getSyncFinishedCallback(); } + public Options getOptions() { + return options; + } + public static class Options { private Context context; @@ -167,6 +171,8 @@ public static class Options { private ReceiverTransferDao receiverTransferDao; private SenderTransferDao senderTransferDao; private SyncFinishedCallback syncFinishedCallback; + private Boolean skipQrCodeScan; + @Nullable private RecalledIdentifier recalledIdentifier; private int batchSize = Constants.DEFAULT_SHARE_BATCH_SIZE; @@ -247,5 +253,13 @@ public RecalledIdentifier getRecalledIdentifier() { public void setRecalledIdentifier(@Nullable RecalledIdentifier recalledIdentifier) { this.recalledIdentifier = recalledIdentifier; } + + public boolean allowSkipQrCodeScan() { + return skipQrCodeScan != null && skipQrCodeScan; + } + + public void setSkipQrCodeScan(boolean skipQrCodeScan) { + this.skipQrCodeScan = skipQrCodeScan; + } } } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java index 02db3ec..413a4b3 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java @@ -40,6 +40,8 @@ import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.dialog.ConnectingDialog; +import org.smartregister.p2p.dialog.ReceiverConnectionInfoDialog; +import org.smartregister.p2p.dialog.SenderApprovalDialog; import org.smartregister.p2p.dialog.SkipQRScanDialog; import org.smartregister.p2p.dialog.StartDiscoveringModeProgressDialog; import org.smartregister.p2p.dialog.StartReceiveModeProgressDialog; @@ -300,7 +302,8 @@ public boolean removeDiscoveringProgressDialog() { return removeDialog(Constants.Dialog.START_SEND_MODE_PROGRESS); } - private boolean removeDialog(@NonNull String tag) { + @Override + public boolean removeDialog(@NonNull String tag) { Fragment fragment = getSupportFragmentManager() .findFragmentByTag(tag); @@ -347,6 +350,7 @@ public void showQRCodeScanningFragment(@NonNull String deviceName, @NonNull QRCo @Override public void showQRCodeGeneratorFragment(@NonNull String authenticationCode, @NonNull String deviceName , @NonNull QRCodeGeneratorFragment.QRCodeGeneratorCallback qrCodeGeneratorCallback) { + // here QRCodeGeneratorFragment newFragment = new QRCodeGeneratorFragment(); newFragment.setAuthenticationCode(authenticationCode); newFragment.setDeviceName(deviceName); @@ -362,6 +366,30 @@ public void showQRCodeGeneratorFragment(@NonNull String authenticationCode, @Non transaction.commit(); } + @Override + public void showSenderApprovalDialog(@NonNull String authenticationCode, @NonNull String deviceName, @Nullable DialogCancelCallback dialogCancelCallback, @NonNull DialogApprovedCallback dialogApprovedCallback) { + FragmentManager fragmentManager = getSupportFragmentManager(); + SenderApprovalDialog newFragment = new SenderApprovalDialog(); + newFragment.setConnectionDeviceName(deviceName); + newFragment.setConnectionKey(authenticationCode); + newFragment.setDialogCancelCallback(dialogCancelCallback); + newFragment.setDialogApprovedCallback(dialogApprovedCallback); + + newFragment.show(fragmentManager, Constants.Dialog.DISPLAY_APPROVAL_KEY); + } + + @Override + public void showReceiverApprovalDialog(@NonNull String authenticationCode, @NonNull String deviceName, @Nullable DialogCancelCallback dialogCancelCallback, @NonNull DialogApprovedCallback dialogApprovedCallback) { + FragmentManager fragmentManager = getSupportFragmentManager(); + ReceiverConnectionInfoDialog newFragment = new ReceiverConnectionInfoDialog(); + newFragment.setConnectionDeviceName(deviceName); + newFragment.setConnectionKey(authenticationCode); + newFragment.setDialogCancelCallback(dialogCancelCallback); + newFragment.setDialogApprovedCallback(dialogApprovedCallback); + + newFragment.show(fragmentManager, Constants.Dialog.DISPLAY_APPROVAL_KEY); + } + @Override public void showConnectionAcceptDialog(@NonNull String receiverDeviceName, @NonNull String authenticationCode , @NonNull final DialogInterface.OnClickListener onClickListener) { 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..4140618 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 @@ -3,10 +3,12 @@ import android.content.DialogInterface; import android.support.annotation.NonNull; +import org.smartregister.p2p.P2PLibrary; 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 (P2PLibrary.getInstance().getOptions().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..1a5670b 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 @@ -7,10 +7,12 @@ import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.vision.barcode.Barcode; +import org.smartregister.p2p.P2PLibrary; import org.smartregister.p2p.R; 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 +30,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 (P2PLibrary.getInstance().getOptions().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/contract/P2pModeSelectContract.java b/p2p-sync/src/main/java/org/smartregister/p2p/contract/P2pModeSelectContract.java index d03d9f3..b4a8fec 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 @@ -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/dialog/ReceiverConnectionInfoDialog.java b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java new file mode 100644 index 0000000..6737eae --- /dev/null +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java @@ -0,0 +1,98 @@ +package org.smartregister.p2p.dialog; + +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.view.View; +import android.widget.TextView; + +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..e45a379 --- /dev/null +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java @@ -0,0 +1,98 @@ +package org.smartregister.p2p.dialog; + +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.view.View; +import android.widget.TextView; + +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/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/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/values/strings.xml b/p2p-sync/src/main/res/values/strings.xml index a6513da..a1cc2c2 100644 --- a/p2p-sync/src/main/res/values/strings.xml +++ b/p2p-sync/src/main/res/values/strings.xml @@ -117,4 +117,9 @@ 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 From bb21cd437ae26b7209eb3fb2448055f6cd484cc3 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 2 Dec 2020 13:49:17 +0300 Subject: [PATCH 02/13] Add missing andorid 10 permissions for p2p --- .../src/main/java/org/smartregister/p2p/util/Permissions.java | 2 ++ 1 file changed, 2 insertions(+) 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..dd50097 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 @@ -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 From 1da0305e98db6d32b58f29156ccf59409f8a1440 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:22:40 +0300 Subject: [PATCH 03/13] Fix broken tests --- gradle.properties | 2 +- .../src/main/java/org/smartregister/p2p/P2PLibrary.java | 2 +- .../p2p/activity/P2pModeSelectActivity.java | 3 ++- .../authenticator/BaseSyncConnectionAuthenticator.java | 5 +++++ .../authenticator/ReceiverConnectionAuthenticator.java | 2 +- .../p2p/authenticator/SenderConnectionAuthenticator.java | 3 +-- .../org/smartregister/p2p/util/NearbyStorageUtil.java | 9 +++++---- .../ReceiverConnectionAuthenticatorTest.java | 3 ++- .../authenticator/SenderConnectionAuthenticatorTest.java | 3 ++- 9 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9441322..5044c8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m # 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 +VERSION_NAME=0.3.8-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=Android Peer-to-Peer Sync diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java index c3aadf0..9ec83b9 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java @@ -171,7 +171,7 @@ public static class Options { private ReceiverTransferDao receiverTransferDao; private SenderTransferDao senderTransferDao; private SyncFinishedCallback syncFinishedCallback; - private Boolean skipQrCodeScan; + private Boolean skipQrCodeScan = true; @Nullable private RecalledIdentifier recalledIdentifier; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java index 413a4b3..fbf3a55 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java @@ -665,7 +665,8 @@ protected void onResume() { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); - for (OnActivityRequestPermissionHandler onActivityRequestPermissionHandler : onActivityRequestPermissionHandlers) { + // prevent concurrent modification error + for (OnActivityRequestPermissionHandler onActivityRequestPermissionHandler : new ArrayList<>(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..cc4eeb4 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 @@ -2,6 +2,7 @@ import android.support.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 4140618..40a8974 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 @@ -25,7 +25,7 @@ public void authenticate(@NonNull final DiscoveredDevice discoveredDevice, @NonN if (discoveredDevice.getConnectionInfo() != null && discoveredDevice.getConnectionInfo().isIncomingConnection()) { - if (P2PLibrary.getInstance().getOptions().allowSkipQrCodeScan()) { + if (allowSkipQrCodeScan()) { displaySenderInfoDialog(discoveredDevice, authenticationCallback); } else { displayQRCodeGeneratorFragment(discoveredDevice, authenticationCallback); 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 1a5670b..11d4cca 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 @@ -7,7 +7,6 @@ import com.google.android.gms.nearby.connection.ConnectionInfo; import com.google.android.gms.vision.barcode.Barcode; -import org.smartregister.p2p.P2PLibrary; import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.fragment.QRCodeScanningFragment; @@ -31,7 +30,7 @@ public void authenticate(@NonNull final DiscoveredDevice discoveredDevice, @NonN if (discoveredDevice.getConnectionInfo() != null && !discoveredDevice.getConnectionInfo().isIncomingConnection()) { - if (P2PLibrary.getInstance().getOptions().allowSkipQrCodeScan()) { + if (allowSkipQrCodeScan()) { displaySenderApprovalDialog(discoveredDevice, authenticationCallback); } else { displayQRCodeScanFragment(discoveredDevice, authenticationCallback); 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..4a39070 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 @@ -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/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 From 5d7f976a7e9de402f4cd41fcbee42b8a4e293edc Mon Sep 17 00:00:00 2001 From: SebaMutuku <36365043+SebaMutuku@users.noreply.github.com> Date: Mon, 13 Jun 2022 20:24:52 +0300 Subject: [PATCH 04/13] Android 11 and 12 support --- build.gradle | 10 +++++----- gradle.properties | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 6 +++--- p2p-sync/build.gradle | 6 +++--- p2p-sync/src/main/AndroidManifest.xml | 2 ++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index fa7c048..5e9f268 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven{ url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:4.0.0' 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" @@ -40,11 +40,11 @@ task clean(type: Delete) { ext { group = GROUP version = VERSION_NAME - - androidBuildToolsVersion = "28.0.3" + ext.androidToolsBuildGradle = '30.0.3' + ext.androidBuildToolsVersion = '30.0.3' androidMinSdkVersion = 18 - androidCompileSdkVersion = 28 - androidTargetSdkVersion = 28 + androidCompileSdkVersion = 31 + androidTargetSdkVersion = 31 } ext { diff --git a/gradle.properties b/gradle.properties index 5044c8b..85d5474 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.8-SNAPSHOT +android.enableUnitTestBinaryResources=false +VERSION_NAME=0.3.9-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=Android Peer-to-Peer Sync diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 71771a5..f5083e2 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 +#Mon Jun 06 12:40:33 EAT 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-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..0490232 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -99,9 +99,9 @@ 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' ]) } diff --git a/p2p-sync/src/main/AndroidManifest.xml b/p2p-sync/src/main/AndroidManifest.xml index d17ffe7..e10aa67 100644 --- a/p2p-sync/src/main/AndroidManifest.xml +++ b/p2p-sync/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + @@ -19,6 +20,7 @@ Date: Tue, 14 Jun 2022 11:25:53 +0300 Subject: [PATCH 05/13] String refactoring --- p2p-sync/src/main/res/values-fr/strings.xml | 22 ++++++++++----------- p2p-sync/src/main/res/values/strings.xml | 18 ++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/p2p-sync/src/main/res/values-fr/strings.xml b/p2p-sync/src/main/res/values-fr/strings.xml index 5951604..a7a216b 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 diff --git a/p2p-sync/src/main/res/values/strings.xml b/p2p-sync/src/main/res/values/strings.xml index a1cc2c2..896306b 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. From 7a7e9cfe53d3bb124da0bdf3e5be00afd51e9a4a Mon Sep 17 00:00:00 2001 From: SebaMutuku <36365043+SebaMutuku@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:19:20 +0300 Subject: [PATCH 06/13] Support Android X --- gradle.properties | 4 +++- p2p-sync/build.gradle | 2 +- .../org/smartregister/p2p/P2PLibrary.java | 5 ++-- .../p2p/activity/P2pModeSelectActivity.java | 23 ++++++++++--------- .../BaseSyncConnectionAuthenticator.java | 2 +- .../ReceiverConnectionAuthenticator.java | 4 ++-- .../SenderConnectionAuthenticator.java | 2 +- .../authorizer/P2PAuthorizationService.java | 4 +++- .../p2p/callback/OnResultCallback.java | 4 ++-- .../p2p/callback/SyncFinishedCallback.java | 6 ++--- .../smartregister/p2p/contract/BaseView.java | 2 +- .../p2p/contract/P2pModeSelectContract.java | 6 ++--- .../p2p/contract/RecalledIdentifier.java | 4 ++-- .../p2p/dialog/ConnectingDialog.java | 9 ++++---- .../dialog/ReceiverConnectionInfoDialog.java | 9 ++++---- .../p2p/dialog/SenderApprovalDialog.java | 9 ++++---- .../p2p/dialog/SkipQRScanDialog.java | 9 ++++---- .../StartDiscoveringModeProgressDialog.java | 9 ++++---- .../StartReceiveModeProgressDialog.java | 9 ++++---- .../fragment/DevicesConnectedFragment.java | 7 +++--- .../p2p/fragment/ErrorFragment.java | 7 +++--- .../p2p/fragment/P2PModeSelectFragment.java | 6 ++--- .../p2p/fragment/QRCodeGeneratorFragment.java | 6 ++--- .../p2p/fragment/QRCodeScanningFragment.java | 7 +++--- .../SyncCompleteTransferFragment.java | 6 ++--- .../p2p/fragment/SyncProgressFragment.java | 7 +++--- ...ctivityRequestPermissionResultHandler.java | 2 +- .../p2p/handler/ActivityResultHandler.java | 2 +- .../p2p/handler/ActivityResumeHandler.java | 2 +- .../p2p/handler/AdvertisingResumeHandler.java | 2 +- .../OnActivityRequestPermissionHandler.java | 2 +- .../interactor/P2pModeSelectInteractor.java | 4 ++-- .../smartregister/p2p/model/AppDatabase.java | 12 ++++++---- .../org/smartregister/p2p/model/DataType.java | 2 +- .../p2p/model/P2pReceivedHistory.java | 7 +++--- .../p2p/model/SendingDevice.java | 9 ++++---- .../p2p/model/dao/P2pReceivedHistoryDao.java | 13 ++++++----- .../p2p/model/dao/ReceiverTransferDao.java | 6 ++--- .../p2p/model/dao/SenderTransferDao.java | 6 ++--- .../p2p/model/dao/SendingDeviceDao.java | 11 +++++---- .../presenter/BaseP2pModeSelectPresenter.java | 2 +- .../p2p/presenter/P2PReceiverPresenter.java | 10 ++++---- .../p2p/presenter/P2PSenderPresenter.java | 10 ++++---- .../p2p/sync/DiscoveredDevice.java | 4 ++-- .../sync/IReceiverSyncLifecycleCallback.java | 2 +- .../sync/ISenderSyncLifecycleCallback.java | 5 ++-- .../sync/SyncConnectionLifecycleCallback.java | 2 +- .../p2p/sync/SyncLifecycleCallback.java | 2 +- .../smartregister/p2p/sync/data/JsonData.java | 2 +- .../p2p/sync/data/MultiMediaData.java | 4 ++-- .../p2p/sync/data/ProcessedChunk.java | 4 ++-- .../p2p/sync/data/SyncPackageManifest.java | 4 ++-- .../p2p/sync/handler/BaseSyncHandler.java | 4 ++-- .../p2p/sync/handler/SyncReceiverHandler.java | 8 +++---- .../p2p/sync/handler/SyncSenderHandler.java | 6 ++--- .../p2p/tasks/ConnectionTimeout.java | 4 ++-- .../p2p/tasks/GenericAsyncTask.java | 5 ++-- .../org/smartregister/p2p/tasks/Tasker.java | 2 +- .../org/smartregister/p2p/util/Device.java | 4 ++-- .../smartregister/p2p/util/DialogUtils.java | 10 ++++---- .../p2p/util/NearbyStorageUtil.java | 2 +- .../smartregister/p2p/util/Permissions.java | 6 ++--- .../org/smartregister/p2p/util/Settings.java | 4 ++-- .../p2p/util/SyncDataConverterUtil.java | 4 ++-- .../p2p/view/CameraSourcePreview.java | 2 +- .../p2p/view/QRCodeScannerView.java | 13 ++++++----- .../p2p/sample/MainActivity.java | 3 ++- .../p2p/sample/SampleApplication.java | 2 +- .../p2p/sample/dao/SampleReceiverDao.java | 4 ++-- .../p2p/sample/dao/SampleSenderDao.java | 4 ++-- .../p2p/sample/util/FailSafeRecalledID.java | 2 +- 71 files changed, 206 insertions(+), 182 deletions(-) diff --git a/gradle.properties b/gradle.properties index 85d5474..af1c6d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.enableUnitTestBinaryResources=false -VERSION_NAME=0.3.9-SNAPSHOT +VERSION_NAME=0.4.0-DEV-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=Android Peer-to-Peer Sync @@ -26,5 +26,7 @@ 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 diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index 0490232..1b16e7e 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -81,7 +81,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' } diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java index 9ec83b9..5a88c53 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/P2PLibrary.java @@ -2,8 +2,9 @@ import android.content.Context; 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.authorizer.P2PAuthorizationService; import org.smartregister.p2p.callback.SyncFinishedCallback; diff --git a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java index fbf3a55..f58a9ec 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java @@ -11,18 +11,19 @@ import android.net.Uri; import android.net.wifi.WifiManager; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.support.annotation.VisibleForTesting; -import android.support.v4.app.DialogFragment; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.annotation.VisibleForTesting; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.ResolvableApiException; @@ -393,7 +394,7 @@ public void showReceiverApprovalDialog(@NonNull String authenticationCode, @NonN @Override public void showConnectionAcceptDialog(@NonNull String receiverDeviceName, @NonNull String authenticationCode , @NonNull final DialogInterface.OnClickListener onClickListener) { - new android.support.v7.app.AlertDialog.Builder(this) + new AlertDialog.Builder(this) .setMessage(String.format(getString(R.string.accept_connection_dialog_content), authenticationCode)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override 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 cc4eeb4..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,6 +1,6 @@ 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; 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 40a8974..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,9 +1,9 @@ package org.smartregister.p2p.authenticator; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import org.smartregister.p2p.P2PLibrary; +import androidx.annotation.NonNull; + import org.smartregister.p2p.R; import org.smartregister.p2p.contract.P2pModeSelectContract; import org.smartregister.p2p.fragment.QRCodeGeneratorFragment; 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 11d4cca..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; 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 b4a8fec..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; 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 index 6737eae..6f210bc 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/ReceiverConnectionInfoDialog.java @@ -1,16 +1,17 @@ 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.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; 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 index e45a379..75c4c75 100644 --- a/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java +++ b/p2p-sync/src/main/java/org/smartregister/p2p/dialog/SenderApprovalDialog.java @@ -1,16 +1,17 @@ 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.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; 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..3aaa8f0 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/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 4a39070..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; 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 dd50097..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; 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/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java b/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java index acc8b1b..d65d058 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java @@ -2,7 +2,8 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; + +import androidx.appcompat.app.AppCompatActivity; import org.smartregister.p2p.activity.P2pModeSelectActivity; 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..186d207 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,7 +2,7 @@ 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; From aa22a3d2045c62f31f05f793023558f988dc2647 Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 19 Jan 2023 11:40:09 +0300 Subject: [PATCH 07/13] resolve build.gradle --- build.gradle | 10 ++++---- gradle.properties | 3 ++- p2p-sync/build.gradle | 23 +++++++++++-------- .../p2p/fragment/P2PModeSelectFragment.java | 2 +- .../activity/P2pModeSelectActivityTest.java | 4 ++-- ...tartDiscoveringModeProgressDialogTest.java | 7 +++--- .../StartReceiveModeProgressDialogTest.java | 7 +++--- .../BaseP2pModeSelectPresenterTest.java | 5 ++-- .../p2p/shadows/ShadowAppDatabase.java | 5 ++-- .../p2p/shadows/ShadowNearby.java | 3 ++- .../p2p/shadows/ShadowPayload.java | 3 ++- .../p2p/shadows/ShadowTasker.java | 2 +- .../smartregister/p2p/shadows/Shadowzzbd.java | 5 ++-- .../sync/handler/SyncReceiverHandlerTest.java | 14 +++++------ .../sync/handler/TestSyncSenderHandler.java | 5 ++-- .../p2p/tasks/GenericAsyncTaskTest.java | 3 ++- 16 files changed, 58 insertions(+), 43 deletions(-) diff --git a/build.gradle b/build.gradle index 5e9f268..12b7324 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:4.0.0' - 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.0.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" } diff --git a/gradle.properties b/gradle.properties index af1c6d8..259e2ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.enableUnitTestBinaryResources=false -VERSION_NAME=0.4.0-DEV-SNAPSHOT +VERSION_NAME=0.4.0-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=Android Peer-to-Peer Sync @@ -30,3 +30,4 @@ android.useAndroidX=true android.enableJetifier=true POM_SETTING_ARTIFACT_ID=android-p2p-sync POM_SETTING_PACKAGING=aar +android.jetifier.blacklist=bcprov diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index 1b16e7e..a21fd53 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -43,7 +43,10 @@ android { } testOptions.unitTests.includeAndroidResources = true - lintOptions.abortOnError = false + lintOptions { + lintConfig file("lint.xml") + abortOnError false + } } dependencies { @@ -51,28 +54,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.android.support.constraint:constraint-layout:2.0.4' 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' - 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.9" // 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' + implementation 'com.google.zxing:core:3.3.2' + implementation 'com.google.code.gson:gson:2.10' // Room implementation "android.arch.persistence.room:runtime:$room_version" @@ -108,6 +112,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea tasks.withType(Test) { jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } coveralls { 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 3aaa8f0..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 @@ -3,7 +3,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment;; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; 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/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/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/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/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; From cbe46db709a4e21feaadbb514e77e355479e5450 Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 19 Jan 2023 13:08:24 +0300 Subject: [PATCH 08/13] Fix app not found issue on AndroidManifest --- gradle/wrapper/gradle-wrapper.properties | 2 +- p2p-sync/build.gradle | 2 -- p2p-sync/src/main/AndroidManifest.xml | 2 +- .../src/main/java/org/smartregister/p2p/P2PLibrary.java | 2 +- sample/build.gradle | 8 ++++---- sample/src/main/AndroidManifest.xml | 5 +++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f5083e2..eb5f997 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Mon Jun 06 12:40:33 EAT 2022 +#Thu Jan 19 12:26:01 EAT 2023 distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip distributionPath=wrapper/dists diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index a21fd53..4291148 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -16,8 +16,6 @@ android { defaultConfig { minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion - versionCode 1 - versionName version testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/p2p-sync/src/main/AndroidManifest.xml b/p2p-sync/src/main/AndroidManifest.xml index e10aa67..13e9920 100644 --- a/p2p-sync/src/main/AndroidManifest.xml +++ b/p2p-sync/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ android:label="@string/peer_to_peer_activity_title" android:windowSoftInputMode="stateHidden|adjustResize" android:exported="true" - android:name=".activity.P2pModeSelectActivity"/> + android:name="org.smartregister.p2p.activity.P2pModeSelectActivity"/> - + From c392e0b0a29c5a81c2565cce6755d8cdec0aa113 Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 19 Jan 2023 13:19:39 +0300 Subject: [PATCH 09/13] Gradle plugin upgrade --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- p2p-sync/build.gradle | 1 + p2p-sync/src/main/AndroidManifest.xml | 3 +-- sample/build.gradle | 1 + sample/src/main/AndroidManifest.xml | 3 +-- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 12b7324..4f9994f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven{ url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' + 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" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index eb5f997..1147304 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Jan 19 12:26:01 EAT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index 4291148..3ae2d91 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -45,6 +45,7 @@ android { lintConfig file("lint.xml") abortOnError false } + namespace 'org.smartregister.p2p' } dependencies { diff --git a/p2p-sync/src/main/AndroidManifest.xml b/p2p-sync/src/main/AndroidManifest.xml index 13e9920..14271f5 100644 --- a/p2p-sync/src/main/AndroidManifest.xml +++ b/p2p-sync/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/sample/build.gradle b/sample/build.gradle index 365c275..27f157f 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -19,6 +19,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + namespace 'org.smartregister.p2p.sample' } dependencies { diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 653c0fb..fd39358 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:android="http://schemas.android.com/apk/res/android"> From f36e428c6739a3dbca8181723efb87d24847e7ed Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 19 Jan 2023 14:50:07 +0300 Subject: [PATCH 10/13] Translate Strings --- p2p-sync/src/main/res/values-fr/strings.xml | 24 ++++++++++++++++++- p2p-sync/src/main/res/values/strings.xml | 2 +- .../p2p/presenter/P2PSenderPresenterTest.java | 12 +++++----- .../sync/handler/SyncSenderHandlerTest.java | 3 ++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/p2p-sync/src/main/res/values-fr/strings.xml b/p2p-sync/src/main/res/values-fr/strings.xml index a7a216b..f6bff01 100644 --- a/p2p-sync/src/main/res/values-fr/strings.xml +++ b/p2p-sync/src/main/res/values-fr/strings.xml @@ -110,5 +110,27 @@ 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 + Services Google Play requis + Les services Google Play sont requis pour que ce service fonctionne + Les services Google Play sont requis pour que ce service fonctionne + Vous devez mettre à jour le service Google Play de votre appareil + Vous devez mettre à jour le service Google Play de votre appareil + Veuillez activer le matériel Wi-Fi de votre appareil + Veuillez activer le matériel Wi-Fi de votre appareil + Mettez à jour maintenant + Mettez à jour maintenant + Peut-être plus tard + 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 + 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 + Code d\'appariement de l\'appareil + Approuver la demande d\'association ? + Approuver la demande d\'association ? + Vous essayez d\'envoyer des données à l\'appareil %s + Vous essayez d\'envoyer des données à l\'appareil %s + Approuver + Approuver diff --git a/p2p-sync/src/main/res/values/strings.xml b/p2p-sync/src/main/res/values/strings.xml index 896306b..67e2076 100644 --- a/p2p-sync/src/main/res/values/strings.xml +++ b/p2p-sync/src/main/res/values/strings.xml @@ -110,7 +110,7 @@ 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 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/sync/handler/SyncSenderHandlerTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java index 726c6f8..a51e505 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 @@ -39,6 +39,7 @@ 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; @@ -224,7 +225,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")); } From 3f83f8db2c1a0f59f134bdb6ad1d1a4609848354 Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 19 Jan 2023 14:58:42 +0300 Subject: [PATCH 11/13] Remove Duplicate Strings --- p2p-sync/src/main/res/values-fr/strings.xml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/p2p-sync/src/main/res/values-fr/strings.xml b/p2p-sync/src/main/res/values-fr/strings.xml index f6bff01..cfc0a56 100644 --- a/p2p-sync/src/main/res/values-fr/strings.xml +++ b/p2p-sync/src/main/res/values-fr/strings.xml @@ -112,25 +112,14 @@ Veuillez vous assurer que les appareils demeurent à proximité durant le transfert de données Clause de non-responsabilité Services Google Play requis - Services Google Play requis - Les services Google Play sont requis pour que ce service fonctionne Les services Google Play sont requis pour que ce service fonctionne Vous devez mettre à jour le service Google Play de votre appareil - Vous devez mettre à jour le service Google Play de votre appareil Veuillez activer le matériel Wi-Fi de votre appareil - Veuillez activer le matériel Wi-Fi de votre appareil - Mettez à jour maintenant Mettez à jour maintenant Peut-être plus tard - 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 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 - Code d\'appariement de l\'appareil - Approuver la demande d\'association ? - Approuver la demande d\'association ? - Vous essayez d\'envoyer des données à l\'appareil %s + Approuver la demande d\'association? Vous essayez d\'envoyer des données à l\'appareil %s - Approuver - Approuver + Approuvering> From 4dce939935bc6439ef100b810564871383375fec Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Tue, 31 Jan 2023 15:33:19 +0300 Subject: [PATCH 12/13] Amendment of gradle wrapper properties --- build.gradle | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- p2p-sync/build.gradle | 20 +++- p2p-sync/src/main/AndroidManifest.xml | 3 +- .../p2p/shadows/ShadowConnectionsClient.java | 1 + .../sync/handler/SyncSenderHandlerTest.java | 62 +++++------ sample/build.gradle | 105 ++++++++++++++++-- 7 files changed, 148 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index 4f9994f..59eb471 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven{ url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:4.0.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" @@ -42,9 +42,9 @@ ext { version = VERSION_NAME ext.androidToolsBuildGradle = '30.0.3' ext.androidBuildToolsVersion = '30.0.3' - androidMinSdkVersion = 18 + androidMinSdkVersion = 19 androidCompileSdkVersion = 31 - androidTargetSdkVersion = 31 + androidTargetSdkVersion = 29 } ext { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1147304..b19777b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Jan 19 12:26:01 EAT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index 3ae2d91..ecd514f 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 @@ -40,12 +45,15 @@ android { } } - testOptions.unitTests.includeAndroidResources = true + testOptions { + unitTests { + includeAndroidResources = true + } + } lintOptions { lintConfig file("lint.xml") abortOnError false } - namespace 'org.smartregister.p2p' } dependencies { @@ -68,14 +76,14 @@ dependencies { 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.9" + 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.2' - implementation 'com.google.code.gson:gson:2.10' + 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" diff --git a/p2p-sync/src/main/AndroidManifest.xml b/p2p-sync/src/main/AndroidManifest.xml index 14271f5..13e9920 100644 --- a/p2p-sync/src/main/AndroidManifest.xml +++ b/p2p-sync/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - + 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/sync/handler/SyncSenderHandlerTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java index a51e505..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; @@ -42,12 +50,6 @@ 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 */ @@ -56,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<>(); @@ -155,7 +153,7 @@ public void sendNextManifestShouldCallSendJSONDataManifestWhenNonMediaDataTypeIs syncSenderHandler.sendNextManifest(); Mockito.verify(syncSenderHandler, Mockito.times(1)) - .sendJsonDataManifest(Mockito.any(DataType.class)); + .sendJsonDataManifest(any(DataType.class)); } @Test @@ -170,7 +168,7 @@ public void sendNextManifestShouldCallSendMultimediaDataManifestWhenMediaDataTyp syncSenderHandler.sendNextManifest(); Mockito.verify(syncSenderHandler, Mockito.times(1)) - .sendMultimediaDataManifest(Mockito.any(DataType.class)); + .sendMultimediaDataManifest(any(DataType.class)); } @Test @@ -207,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) @@ -225,7 +223,7 @@ public void onPayloadTransferUpdateShouldCallSendNextPayloadAndResetFlagsWhenMan .sendNextPayload(); assertFalse((boolean) ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestTransfer")); - assertEquals(Optional.of(0l), ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestId")); + assertEquals(Optional.of(0L), ReflectionHelpers.getField(syncSenderHandler, "awaitingManifestId")); assertNull(ReflectionHelpers.getField(syncSenderHandler, "payloadRetry")); } @@ -238,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) @@ -248,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); @@ -271,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) @@ -286,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 @@ -297,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) @@ -330,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) @@ -340,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) @@ -370,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) @@ -380,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) @@ -391,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"); @@ -408,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(); @@ -427,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 @@ -435,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/sample/build.gradle b/sample/build.gradle index 27f157f..0134dfe 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,36 +1,125 @@ -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' } } - namespace 'org.smartregister.p2p.sample' + + testOptions.unitTests.includeAndroidResources = true + lintOptions.abortOnError = false } dependencies { - implementation project(":p2p-sync") - implementation 'com.jakewharton.timber:timber:5.0.1' + implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:2.0.4' - testImplementation 'junit:junit:4.13.2' + 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' + + 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" - implementation 'com.google.code.gson:gson:2.10' } + +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 From d362d7d06ad734028cec269659b45af9c54d6f04 Mon Sep 17 00:00:00 2001 From: SebaMutuku Date: Thu, 9 Feb 2023 10:32:46 +0300 Subject: [PATCH 13/13] Intermittend push --- build.gradle | 11 ++++++----- gradle/wrapper/gradle-wrapper.properties | 4 ++-- p2p-sync/build.gradle | 2 +- .../src/main/res/layout/activity_p2p_mode_select.xml | 4 ++-- .../main/res/layout/fragment_devices_connected.xml | 6 +++--- p2p-sync/src/main/res/layout/fragment_error.xml | 6 +++--- p2p-sync/src/main/res/layout/fragment_mode_select.xml | 4 ++-- .../main/res/layout/fragment_successful_transfer.xml | 6 +++--- p2p-sync/src/main/res/values/strings.xml | 2 +- p2p-sync/src/test/resources/robolectric.properties | 1 + sample/build.gradle | 1 + sample/src/main/AndroidManifest.xml | 4 ++-- .../org/smartregister/p2p/sample/MainActivity.java | 1 + .../p2p/sample/util/FailSafeRecalledID.java | 4 ++-- 14 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 p2p-sync/src/test/resources/robolectric.properties diff --git a/build.gradle b/build.gradle index 59eb471..d56d2d1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven{ url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' + 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" @@ -40,11 +40,12 @@ task clean(type: Delete) { ext { group = GROUP version = VERSION_NAME - ext.androidToolsBuildGradle = '30.0.3' + + ext.androidToolsBuildGradle = '4.2.2' ext.androidBuildToolsVersion = '30.0.3' - androidMinSdkVersion = 19 - androidCompileSdkVersion = 31 - androidTargetSdkVersion = 29 + ext.androidMinSdkVersion = 19 + ext.androidCompileSdkVersion = 31 + ext.androidTargetSdkVersion = 31 } ext { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b19777b..8fd2646 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jan 19 12:26:01 EAT 2023 +#Thu Feb 02 12:10:28 EAT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/p2p-sync/build.gradle b/p2p-sync/build.gradle index ecd514f..bd0cacb 100644 --- a/p2p-sync/build.gradle +++ b/p2p-sync/build.gradle @@ -61,7 +61,6 @@ 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:2.0.4' 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' @@ -70,6 +69,7 @@ dependencies { implementation 'com.google.android.gms:play-services-vision:20.1.3' implementation 'com.jakewharton.timber:timber:5.0.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' testImplementation project(path: ':p2p-sync') 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/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/strings.xml b/p2p-sync/src/main/res/values/strings.xml index 67e2076..4bedc12 100644 --- a/p2p-sync/src/main/res/values/strings.xml +++ b/p2p-sync/src/main/res/values/strings.xml @@ -32,7 +32,7 @@ Endpoint lost %s The connection to %s has broken CONNECTED - Connection initiated by : %1$s Endpoint name(%2%s) auth code(%3$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 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 0134dfe..d8f3b47 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -60,6 +60,7 @@ dependencies { 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' diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index fd39358..12a72b1 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ - + 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 d65d058..da06424 100644 --- a/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java +++ b/sample/src/main/java/org/smartregister/p2p/sample/MainActivity.java @@ -5,6 +5,7 @@ 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/util/FailSafeRecalledID.java b/sample/src/main/java/org/smartregister/p2p/sample/util/FailSafeRecalledID.java index 186d207..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 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);