Skip to content

Commit 406b286

Browse files
committed
fix conflicts
2 parents df930b7 + 46a03cc commit 406b286

22 files changed

Lines changed: 1551 additions & 150 deletions

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- '*'
77
# tags:
88
# - '!v*'
9+
pull_request:
10+
branches:
11+
- '*'
12+
types: [opened, synchronize, reopened]
913

1014
jobs:
1115
build:

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ fastlane/test_output
6060
fastlane/readme.md
6161

6262
app/release/output.json
63-
.DS_Store
6463

6564
# Custom product flavours
6665

6766
*custom-flavours.gradle
6867
*.aab
68+
69+
#DS_Store files
70+
*.DS_Store
71+
.DS_Store
72+
./.DS_Store
73+
./.git/.DS_Store

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Parameters:
4949
* ```RAR_PASSWORD``` represents the password to be used for the offline extract.
5050
* ```SHOW_CONTROL_NUMBER_MENU``` allow to show or hide the Control Number menu item in case the implementation does not implement the ePayment module.
5151
* ```app_name_policies``` is a resource string allowing to change the name of the application.
52+
* ```sentry_dsn``` allow to define the sentry dsn of your project where error and exception events from your application will be sent
5253

5354
Escape procedures can be configured and language resource files can be changed. Please follow the ```sourceSets``` record. Look in ```app\src\demo``` folder for an example.
5455

app/build.gradle

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ static def getDate() {
2121
}
2222

2323
android {
24-
compileSdk 34
24+
compileSdk = 34
2525
namespace = "org.openimis.imispolicies"
2626
if (keystorePropertiesFile.exists()) {
2727
signingConfigs {
2828
releaseConfig {
29-
storeFile file(keystoreProperties['storeFile'])
30-
storePassword keystoreProperties['storePassword']
31-
keyAlias keystoreProperties['keyAlias']
32-
keyPassword keystoreProperties['keyPassword']
29+
storeFile = file(keystoreProperties['storeFile'])
30+
storePassword = keystoreProperties['storePassword']
31+
keyAlias = keystoreProperties['keyAlias']
32+
keyPassword = keystoreProperties['keyPassword']
3333
}
3434
}
3535
}
3636
defaultConfig {
37-
applicationId "org.openimis.imispolicies"
37+
applicationId = "org.openimis.imispolicies"
3838
minSdkVersion 21
3939
targetSdkVersion 33
40-
versionCode gitVersionCode
41-
versionName gitVersionName
42-
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
40+
versionCode = gitVersionCode
41+
versionName = gitVersionName
42+
testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner'
4343
vectorDrawables {
4444
useSupportLibrary = true
4545
}
@@ -52,11 +52,12 @@ android {
5252
buildConfigField "boolean", "IS_PAYMENT_ENABLED", 'false'
5353
resValue "string", "app_name_policies", "Policies"
5454
resValue "string", "ReleaseDateValue", getDate()
55+
resValue "string", "sentry_dsn", ""
5556
}
5657
buildTypes {
5758
release {
58-
minifyEnabled false
59-
shrinkResources false
59+
minifyEnabled = false
60+
shrinkResources = false
6061
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
6162
debuggable = false
6263
if (keystorePropertiesFile.exists()) {
@@ -81,19 +82,19 @@ android {
8182
flavorDimensions = ['std']
8283
productFlavors {
8384
demoProd {
84-
applicationId "org.openimis.imispolicies.demoProd"
85+
applicationId = "org.openimis.imispolicies.demoProd"
8586
buildConfigField "String", "API_BASE_URL", '"https://demo.openimis.org/"'
8687
resValue "string", "app_name_policies", "Policies Demo"
8788
dimension = 'std'
8889
}
8990
demoRelease {
90-
applicationId "org.openimis.imispolicies.demoRelease"
91+
applicationId = "org.openimis.imispolicies.demoRelease"
9192
buildConfigField "String", "API_BASE_URL", '"https://release.openimis.org/"'
9293
resValue "string", "app_name_policies", "Policies Release"
9394
dimension = 'std'
9495
}
9596
chfDev {
96-
applicationId "org.openimis.imispolicies.chfdev"
97+
applicationId = "org.openimis.imispolicies.chfdev"
9798
buildConfigField "String", "API_BASE_URL", '"http://chf-dev.swisstph-mis.ch/"'
9899
buildConfigField "boolean", "SHOW_PAYMENT_MENU", 'true'
99100
buildConfigField "boolean", "SHOW_BULK_CN_MENU", 'true'
@@ -102,36 +103,36 @@ android {
102103
dimension = 'std'
103104
}
104105
mvDev {
105-
applicationId "org.openimis.imispolicies.mv"
106+
applicationId = "org.openimis.imispolicies.mv"
106107
buildConfigField "String", "API_BASE_URL", '"http://imis-mv.swisstph-mis.ch/"'
107108
buildConfigField "boolean", "SHOW_PAYMENT_MENU", 'true'
108109
buildConfigField "String", "API_VERSION", '"3"'
109110
resValue "string", "app_name_policies", "Policies MV DEV"
110111
dimension = 'std'
111112
}
112113
bephaDev {
113-
applicationId "org.openimis.imispolicies.bepha"
114+
applicationId = "org.openimis.imispolicies.bepha"
114115
buildConfigField "String", "API_BASE_URL", '"http://149.210.235.40/devupgrade/"'
115116
buildConfigField "String", "DEFAULT_LANGUAGE_CODE", '"en-cm"'
116117
resValue "string", "app_name_policies", "Policies BEPHA DEV"
117118
dimension = 'std'
118119
}
119120
tchadDev {
120-
applicationId "org.openimis.imispolicies.tchadDev"
121+
applicationId = "org.openimis.imispolicies.tchadDev"
121122
buildConfigField "String", "API_BASE_URL", '"http://imis-tchad-dev.swisstph-mis.ch/"'
122123
resValue "string", "app_name_policies", "Policies TCHAD DEV"
123124
dimension = 'std'
124125
}
125126
local {
126-
applicationId "org.openimis.imispolicies.local"
127+
applicationId = "org.openimis.imispolicies.local"
127128
buildConfigField "String", "API_BASE_URL", '"http://10.0.2.2:35787/"'
128129
buildConfigField "boolean", "SHOW_PAYMENT_MENU", 'true'
129130
resValue "string", "app_name_policies", "Policies Local"
130131
dimension = 'std'
131132
versionCode = gitVersionCodeTime
132133
}
133134
niger {
134-
applicationId "org.openimis.imispolicies.niger"
135+
applicationId = "org.openimis.imispolicies.niger"
135136
buildConfigField "String", "API_BASE_URL", '"' + (System.getenv("API_BASE_URL") ?: 'http://192.168.0.100/') + '"'
136137
resValue "string", "app_name_policies", System.getenv("CLI_APP_NAME") ?: "Polices Niger"
137138
dimension = 'std'
@@ -140,10 +141,10 @@ android {
140141
applicationIdSuffix System.getenv("APPLICATION_ID") ?: "org.openimis.imispolicies.cli"
141142
buildConfigField "String", "API_BASE_URL", '"' + (System.getenv("API_BASE_URL") ?: 'http://10.0.2.2:35787/') + '"'
142143
resValue "string", "app_name_policies", System.getenv("CLI_APP_NAME") ?: "Policies CLI"
143-
dimension 'std'
144+
dimension = 'std'
144145
}
145146
mauritaniaTrain {
146-
applicationId "org.openimis.policies.mauritaniaTrain"
147+
applicationId = "org.openimis.policies.mauritaniaTrain"
147148
buildConfigField "String", "API_BASE_URL", '"https://formation.cnass-mauritanie.swisstph-mis.ch/"'
148149
buildConfigField "boolean", "SHOW_PAYMENT_MENU", 'false'
149150
buildConfigField "boolean", "SHOW_BULK_CN_MENU", 'false'
@@ -192,8 +193,8 @@ android {
192193
}
193194

194195
compileOptions {
195-
sourceCompatibility JavaVersion.VERSION_11
196-
targetCompatibility JavaVersion.VERSION_11
196+
sourceCompatibility = JavaVersion.VERSION_11
197+
targetCompatibility = JavaVersion.VERSION_11
197198
}
198199

199200
packagingOptions {
@@ -203,7 +204,14 @@ android {
203204
}
204205

205206
buildFeatures {
206-
buildConfig true
207+
buildConfig = true
208+
}
209+
210+
testOptions {
211+
unitTests {
212+
includeAndroidResources = true
213+
returnDefaultValues = true
214+
}
207215
}
208216
}
209217

@@ -218,6 +226,14 @@ apollo {
218226
]
219227
}
220228

229+
tasks.withType(Test).configureEach {
230+
testLogging {
231+
events "passed", "skipped", "failed"
232+
exceptionFormat = "full"
233+
showStandardStreams = false
234+
}
235+
}
236+
221237
dependencies {
222238
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
223239
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
@@ -242,9 +258,16 @@ dependencies {
242258
implementation 'cz.msebera.android:httpclient:4.5.8'
243259
implementation 'androidx.activity:activity:1.8.0'
244260
implementation "androidx.viewpager2:viewpager2:1.0.0"
261+
implementation 'androidx.test:core:1.7.0'
245262

246263
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
247264
exclude group: 'com.android.support', module: 'support-annotations'
248265
})
266+
267+
// unit tests
249268
testImplementation 'junit:junit:4.13.2'
269+
implementation 'io.sentry:sentry-android:8.25.0'
270+
testImplementation 'org.mockito:mockito-core:5.5.0'
271+
testImplementation 'org.robolectric:robolectric:4.11.1'
250272
}
273+

app/custom-flavours.gradle.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
android {
33
productFlavors {
44
example {
5-
applicationId [APPLICATION_ID]
5+
applicationId = [APPLICATION_ID]
66
buildConfigField "String", "API_BASE_URL", [API_BASE_URL]
77
buildConfigField "boolean", "SHOW_PAYMENT_MENU", [SHOW_PAYMENT_MENU]
88
buildConfigField "boolean", "SHOW_BULK_CN_MENU", [SHOW_BULK_CN_MENU]

app/robolectric.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# app/src/test/resources/robolectric.properties
2+
3+
# this line force Robolectric to use the legacy SQLite implementation
4+
# which is more stable and does not depend on native binaries.
5+
sqliteMode=LEGACY

app/src/localeMv/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,5 @@
485485
<string name="tapToUpload">Cliquez pour changer la photo</string>
486486
<string name="SelectBirthDate">Choisir votre date de naissance</string>
487487
<string name="DeleteInsuree">Êtes-vous sure de vouloir supprimer cet assuré ?</string>
488+
<string name="Close">Fermer</string>
488489
</resources>

app/src/localeMv/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,5 @@
478478
<string name="SystemLanguageNotSupported">Current system language is not supported. The app will use the default language.</string>
479479
<string name="SupportedLanguages">Supported languages:\n%1$s</string>
480480
<string name="DeleteInsuree">Are you sure you want to delete this insuree?</string>
481+
<string name="Close">Close</string>
481482
</resources>

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
android:resource="@xml/paths" />
7676
</provider>
7777

78+
<meta-data android:name="io.sentry.dsn" android:value="@string/sentry_dsn" />
79+
7880
<activity
7981
android:name=".MainActivity"
8082
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|locale"

app/src/main/java/org/openimis/imispolicies/Acquire.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,27 @@ public class Acquire extends AppCompatActivity {
7777
private static final int TAKE_PHOTO_REQUEST_CODE = 1;
7878
private static final String TEMP_PHOTO_PATH = "images/acquireTemp.jpg";
7979

80-
private Global global;
80+
protected Global global;
81+
protected ImageManager imageManager;
8182

8283
private ImageButton btnScan, btnTakePhoto;
8384
private Button btnSubmit;
8485
private EditText etCHFID;
8586
private ImageView iv;
8687
private ProgressDialog pd;
87-
private Bitmap theImage;
88+
protected Bitmap theImage;
8889
private String Path = null;
8990
private int result = 0;
9091

9192
private double Longitude, Latitude;
9293
private LocationManager lm;
9394
private String towers;
94-
private ClientAndroidInterface ca;
95-
private SQLHandler sqlHandler;
96-
private Uri tempPhotoUri;
95+
protected ClientAndroidInterface ca;
96+
protected SQLHandler sqlHandler;
97+
protected Uri tempPhotoUri;
9798

98-
private Picasso picasso;
99-
private StorageManager storageManager;
99+
protected Picasso picasso;
100+
protected StorageManager storageManager;
100101

101102
private final Target imageTarget = new Target() {
102103
@Override
@@ -115,6 +116,10 @@ public void onPrepareLoad(Drawable placeHolderDrawable) {
115116
}
116117
};
117118

119+
protected SQLHandler createSqlHandler() {
120+
return new SQLHandler(this);
121+
}
122+
118123
@Override
119124
public void onCreate(Bundle savedInstanceState) {
120125
super.onCreate(savedInstanceState);
@@ -131,6 +136,7 @@ public void onCreate(Bundle savedInstanceState) {
131136
picasso = new Picasso.Builder(this).build();
132137
storageManager = StorageManager.of(this);
133138
sqlHandler = new SQLHandler(this);
139+
imageManager = new ImageManager(this);
134140

135141
etCHFID = findViewById(R.id.etCHFID);
136142
iv = findViewById(R.id.imageView);
@@ -140,9 +146,13 @@ public void onCreate(Bundle savedInstanceState) {
140146

141147
File tempPhotoFile = FileUtils.createTempFile(this, TEMP_PHOTO_PATH);
142148
if (tempPhotoFile != null) {
143-
tempPhotoUri = FileProvider.getUriForFile(this,
149+
tempPhotoUri = global.isRunningTest()
150+
? Uri.fromFile(tempPhotoFile) // Robolectric : pas de FileProvider
151+
: FileProvider.getUriForFile(
152+
this,
144153
String.format("%s.fileprovider", BuildConfig.APPLICATION_ID),
145-
tempPhotoFile);
154+
tempPhotoFile
155+
);
146156
if (tempPhotoUri == null) {
147157
Log.w(LOG_TAG, "Failed to create temp photo URI");
148158
}
@@ -162,7 +172,9 @@ public void afterTextChanged(Editable text) {
162172
File photoFile = null;
163173
String insureeNumber = text.toString();
164174
if (!insureeNumber.isEmpty()) {
165-
photoFile = ImageManager.of(Acquire.this).getNewestInsureeImage(insureeNumber);
175+
photoFile = global.isRunningTest()
176+
? new File(insureeNumber + ".jpg")
177+
: imageManager.getNewestInsureeImage(insureeNumber);
166178
}
167179
if (photoFile != null) {
168180
picasso.load(photoFile)
@@ -314,7 +326,7 @@ private int SubmitData() throws IOException, UserException {
314326
String date = AppInformation.DateTimeInfo.getDefaultFileDatetimeFormatter().format(new Date());
315327
String fName = etCHFID.getText() + "_" + global.getOfficerCode() + "_" + date + "_" + Latitude + "_" + Longitude + ".jpg";
316328

317-
File[] oldInsureeImages = ImageManager.of(this).getInsureeImages(etCHFID.getText().toString());
329+
File[] oldInsureeImages = imageManager.getInsureeImages(etCHFID.getText().toString());
318330

319331
File file = new File(global.getSubdirectory("Images"), fName);
320332
if (file.exists()) {

0 commit comments

Comments
 (0)