From d362d7d06ad734028cec269659b45af9c54d6f04 Mon Sep 17 00:00:00 2001
From: SebaMutuku <sebastian.muthiani@gmail.com>
Date: Thu, 9 Feb 2023 10:32:46 +0300
Subject: [PATCH] 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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout
+<androidx.constraintlayout.widget.ConstraintLayout
     android:id="@+id/cl_p2pModeSelectActivity_parentLayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
@@ -8,4 +8,4 @@
     tools:context=".activity.P2pModeSelectActivity">
 
 
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout >
\ 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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <android.support.constraint.Guideline
+    <androidx.constraintlayout.widget.Guideline
         android:id="@+id/imageViewGuideline"
         android:layout_width="1dp"
         android:layout_height="wrap_content"
@@ -61,4 +61,4 @@
         app:layout_constraintLeft_toLeftOf="@id/tv_devicesConnectedFragment_message"/>
 
 
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout >
\ 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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <android.support.constraint.Guideline
+    <androidx.constraintlayout.widget.Guideline
         android:id="@+id/imageViewGuideline"
         android:layout_width="1dp"
         android:layout_height="wrap_content"
@@ -60,4 +60,4 @@
         app:layout_constraintLeft_toLeftOf="@id/tv_errorFragment_message"/>
 
 
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
\ 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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout
+<androidx.constraintlayout.widget.ConstraintLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
@@ -28,4 +28,4 @@
         android:layout_marginBottom="20dp"
         app:layout_constraintBottom_toTopOf="@id/btn_p2pModeSelectActivity_send"/>
 
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
\ 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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <android.support.constraint.Guideline
+    <androidx.constraintlayout.widget.Guideline
         android:id="@+id/imageViewGuideline"
         android:layout_width="1dp"
         android:layout_height="wrap_content"
@@ -76,4 +76,4 @@
         app:layout_constraintLeft_toLeftOf="@id/tv_successfulTransferFragment_transferSuccessText"/>
 
 
-</android.support.constraint.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
\ 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 @@
     <string name="log_endpoint_lost">Endpoint lost %s</string>
     <string name="connection_to_endpoint_broken">The connection to %s has broken</string>
     <string name="connected">CONNECTED</string>
-    <string name="log_connection_initiated_endpoint_auth_code">Connection initiated by : %1$s  Endpoint name(%2%s) auth code(%3$s)</string>
+    <string name="log_connection_initiated_endpoint_auth_code">Connection initiated by : %1$s  Endpoint name(%2$s) auth code(%3$s)</string>
     <string name="log_rejecting_connection_initiated_by_other_device">Rejecting connection initiated by the other device %1$s, %2$s, %3$s</string>
     <string name="log_endpoint_found">Endpoint found : %1$s   Endpoint info: (%2$s, %3$s)</string>
     <string name="log_received_payload_from_endpoint">Received a payload from %s</string>
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 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest
-    xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.smartregister.p2p">
 
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
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);