Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ks simprint changes #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions opensrp-simprints/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))

def getVersionName = { ->
return "1.1.40-SNAPSHOT" // Library version
return "1.1.45-STANDARD-SNAPSHOT" // Library version
}

def getArtificatId = { ->
Expand Down Expand Up @@ -166,7 +166,7 @@ dependencies {
transitive = true
}

implementation('org.smartregister:opensrp-client-family:1.2.26-SNAPSHOT') {
implementation('org.smartregister:opensrp-client-family:1.2.26-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public Intent identify(String moduleId){
return simHelper.identify(moduleId);
}

public void confirmIdentity(Context context, String sessionId, String selectedGuid){
simHelper.confirmIdentity(context, sessionId, selectedGuid);
public Intent confirmIdentity(Context context, String sessionId, String selectedGuid){
return simHelper.confirmIdentity(context, sessionId, selectedGuid);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.smartregister.simprint;

import android.content.Intent;
import android.provider.SyncStateContract;

import com.simprints.libsimprints.Constants;

public class SimPrintsHelperResearch {

final private String projectId;
final private String userId;
private String age;

public SimPrintsHelperResearch(String projectId, String userId, String age) {
this.projectId = projectId;
this.userId = userId;
this.age = age;
}

public Intent register(String moduleId) {
Intent intent = new Intent("com.simprints.afyatek.REGISTER");
intent.putExtra("projectId", projectId);
intent.putExtra(Constants.SIMPRINTS_MODULE_ID, moduleId);
intent.putExtra("userId", userId);
intent.putExtra("age", age);
return intent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;

import static com.simprints.libsimprints.Constants.SIMPRINTS_PACKAGE_NAME;
import static com.simprints.libsimprints.Constants.SIMPRINTS_REFUSAL_FORM;

/**
* Author : Isaya Mollel on 2019-10-30.
Expand Down Expand Up @@ -70,27 +71,39 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
if (data != null && resultCode == RESULT_OK && requestCode == REQUEST_CODE){

Boolean check = data.getBooleanExtra(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK, false);
ArrayList<Identification> identifications = data
.getParcelableArrayListExtra(Constants.SIMPRINTS_IDENTIFICATIONS);

ArrayList<String> resultsGuids = new ArrayList<>();
String sessionId = "";
sessionId = data.getStringExtra("sessionId");
if (check) {

if (check && identifications != null && identifications.size() > 0){
ArrayList<Identification> topResults = getTopResults(identifications);
for (Identification identification : topResults){
resultsGuids.add(identification.getGuid());
if (data.getParcelableExtra(SIMPRINTS_REFUSAL_FORM) == null) {

ArrayList<Identification> identifications = data
.getParcelableArrayListExtra(Constants.SIMPRINTS_IDENTIFICATIONS);

ArrayList<String> resultsGuids = new ArrayList<>();
String sessionId = "";
sessionId = data.getStringExtra("sessionId");

if (check && identifications != null && identifications.size() > 0){
ArrayList<Identification> topResults = getTopResults(identifications);
for (Identification identification : topResults){
resultsGuids.add(identification.getGuid());
}
}

Intent intent = new Intent(this, SimprintsIdentificationRegisterActivity.class);
intent.putExtra(SimprintsIdentificationRegisterActivity.CURRENT_SESSION_EXTRA, sessionId);
intent.putExtra(SimprintsIdentificationRegisterActivity.RESULTS_LIST_EXTRA, resultsGuids);
startActivity(intent);
finish();

} else {
Toast.makeText(this, R.string.biometric_declined_message, Toast.LENGTH_SHORT).show();
finish();
}
}

Intent intent = new Intent(this, SimprintsIdentificationRegisterActivity.class);
intent.putExtra(SimprintsIdentificationRegisterActivity.CURRENT_SESSION_EXTRA, sessionId);
intent.putExtra(SimprintsIdentificationRegisterActivity.RESULTS_LIST_EXTRA, resultsGuids);
startActivity(intent);
finish();
} else { finish(); }

}else {
} else {
showFingerPrintFail(this, new OnDialogButtonClick() {
@Override
public void onOkButtonClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.simprints.libsimprints.Verification;

import static com.simprints.libsimprints.Constants.SIMPRINTS_PACKAGE_NAME;
import static com.simprints.libsimprints.Constants.SIMPRINTS_REFUSAL_FORM;

public class SimPrintsVerifyActivity extends AppCompatActivity {

Expand Down Expand Up @@ -58,29 +59,32 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
if( data!=null && resultCode == RESULT_OK && requestCode == REQUEST_CODE){
Boolean check = data.getBooleanExtra(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK,false);
if(check){
SimPrintsVerification simprintsVerification;
Verification verification = data.getParcelableExtra(Constants.SIMPRINTS_VERIFICATION);
if(verification == null || TextUtils.isEmpty(verification.getGuid())){
simprintsVerification = new SimPrintsVerification(null);
simprintsVerification.setCheckStatus(false);
simprintsVerification.setTier(null);
}else{
simprintsVerification = new SimPrintsVerification(verification.getGuid());
simprintsVerification.setCheckStatus(true);
simprintsVerification.setTier(verification.getTier());
if (data.getParcelableExtra(SIMPRINTS_REFUSAL_FORM) == null) {
SimPrintsVerification simprintsVerification;
Verification verification = data.getParcelableExtra(Constants.SIMPRINTS_VERIFICATION);
if(verification == null || TextUtils.isEmpty(verification.getGuid())){
simprintsVerification = new SimPrintsVerification(null);
simprintsVerification.setCheckStatus(false);
simprintsVerification.setTier(null);
}else{
simprintsVerification = new SimPrintsVerification(verification.getGuid());
simprintsVerification.setCheckStatus(true);
simprintsVerification.setTier(verification.getTier());
}
Intent returnIntent = new Intent();
returnIntent.putExtra(SimPrintsConstantHelper.INTENT_DATA,simprintsVerification);
setResult(RESULT_OK,returnIntent);
finish();
} else {
Toast.makeText(this, R.string.biometric_declined_message, Toast.LENGTH_SHORT).show();
finish();
}
Intent returnIntent = new Intent();
returnIntent.putExtra(SimPrintsConstantHelper.INTENT_DATA,simprintsVerification);
setResult(RESULT_OK,returnIntent);
finish();
}else{
} else{
Intent returnIntent = new Intent();
setResult(RESULT_CANCELED,returnIntent);
finish();
}



}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package org.smartregister.simprint.activity;

import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.simprints.libsimprints.Constants;
import com.simprints.libsimprints.SimHelper;

import androidx.fragment.app.Fragment;

import android.util.Pair;
import android.view.View;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.smartregister.commonregistry.CommonPersonObject;
import org.smartregister.family.util.Utils;
import org.smartregister.simprint.R;
import org.smartregister.simprint.SimPrintsLibrary;
import org.smartregister.simprint.contract.SimprintsIdentificationRegisterContract;
import org.smartregister.simprint.fragment.EmptyResultFragment;
import org.smartregister.simprint.fragment.SimprintsIdentificationRegisterFragment;
Expand All @@ -35,6 +43,8 @@ public class SimprintsIdentificationRegisterActivity extends BaseRegisterActivit
public String sessionId = "";

private ArrayList<String> resultsList = new ArrayList<>();
public static final int REQUEST_CODE = 3322;
private CommonPersonObject selectedClient;

public SimprintsIdentificationRegisterActivity(){

Expand Down Expand Up @@ -112,4 +122,78 @@ public List<String> getViewIdentifiers() {
public void startRegistration() {

}

@Override
protected void onDestroy() {
super.onDestroy();
}

public void startSimPrintsConfirmation(String sessionId, String selectedGuid, CommonPersonObject selectedClient) {
this.selectedClient = selectedClient;
SimHelper simPrintsHelper = new SimHelper(SimPrintsLibrary.getInstance().getProjectId(),
SimPrintsLibrary.getInstance().getUserId());
Intent intent = simPrintsHelper.confirmIdentity(this, sessionId, selectedGuid);
startActivityForResult(intent, REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null && requestCode == REQUEST_CODE) {
Boolean check = data.getBooleanExtra(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK, false);
if (check) {
goTotheFamilyProfileOfSelected();
}
}
}

private void goTotheFamilyProfileOfSelected() {

if (selectedClient != null) {
Intent intent = new Intent(this, org.smartregister.family.util.Utils.metadata().profileActivity);
intent.putExtra("family_base_entity_id", selectedClient.getCaseId());
intent.putExtra("family_head",
org.smartregister.family.util.Utils.getValue(selectedClient.getColumnmaps(), "family_head", false));
intent.putExtra("primary_caregiver",
org.smartregister.family.util.Utils.getValue(selectedClient.getColumnmaps(), "primary_caregiver", false));
intent.putExtra("village_town",
org.smartregister.family.util.Utils.getValue(selectedClient.getColumnmaps(), "village_town", false));
intent.putExtra("family_name",
org.smartregister.family.util.Utils.getValue(selectedClient.getColumnmaps(), "first_name", false));
intent.putExtra("go_to_due_page", false);
startActivity(intent);
finish();
} else {
finish();
}

}



////////////////////////////////////////////////////////////////////
// Inner Class | SimPrints Identification Confirmation
///////////////////////////////////////////////////////////////////

private class ConfirmIdentificationTask extends AsyncTask<Void, Void, Void> {

private String sessiodId;
private String selectedGuid;
private Context context;

private ConfirmIdentificationTask(Context context, String sessiodId, String selectedGuid) {
this.sessiodId = sessiodId;
this.selectedGuid = selectedGuid;
this.context = context;
}

@Override
protected Void doInBackground(Void... voids) {
SimHelper simPrintsHelper = new SimHelper(SimPrintsLibrary.getInstance().getProjectId(),
SimPrintsLibrary.getInstance().getUserId());
Intent intent = simPrintsHelper.confirmIdentity(context, sessiodId, selectedGuid);
startActivityForResult(intent, REQUEST_CODE);
return null;
}
}

}
Loading