Skip to content

Commit

Permalink
Attention flags issue #811 done
Browse files Browse the repository at this point in the history
pdf nameing issue #820 done
  • Loading branch information
junaidwarsivd committed Apr 25, 2022
1 parent ee41246 commit cd6e988
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion opensrp-anc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ tasks.withType(Test) {

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation('org.smartregister:opensrp-client-native-form:2.1.17-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:2.1.16-PREVIEW-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down
2 changes: 1 addition & 1 deletion opensrp-anc/src/main/assets/config/attention-flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ group: red_attention_flag
fields:

- template: "{{attention_flags.red.danger_sign}}: {danger_signs_value}"
relevance: "!danger_signs.isEmpty() && !danger_signs.contains('danger_none')"
relevance: "!danger_signs.isEmpty() && !danger_signs.contains('none') || !danger_signs.isEmpty() && !danger_signs.contains('danger_none')"

- template: "{{attention_flags.red.occupation_informal_employment_sex_worker}}"
relevance: "occupation.contains('informal_employment_sex_worker')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {

mProfilePresenter = new ProfilePresenter(this);
imageRenderHelper = new ImageRenderHelper(this);
loadContactSummaryData();


}

Expand Down Expand Up @@ -107,9 +107,17 @@ protected void loadContactSummaryData() {
@Override
public void onResume() {
super.onResume();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && Environment.isExternalStorageManager())
if(isPermissionGranted())
{
loadContactSummaryData();
}
else if(!isPermissionGranted() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
{
generateFileinStorage();
Intent intent = new Intent();
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", this.getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
}

Expand Down Expand Up @@ -239,10 +247,10 @@ public void setTaskCount(String taskCount) {
}

@Override
public void createContactSummaryPdf() {
public void createContactSummaryPdf(String womanName) {

if (isPermissionGranted() && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) {
generateFileinStorage();
generateFileinStorage(womanName);
}
else if (!isPermissionGranted() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
{
Expand All @@ -254,10 +262,10 @@ else if (!isPermissionGranted() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.
}
}

public void generateFileinStorage()
public void generateFileinStorage(String womanName)
{
try {
new Utils().createSavePdf(this, yamlConfigList, facts);
new Utils().createSavePdf(this, yamlConfigList, facts,womanName);
} catch (FileNotFoundException e) {
Timber.e(e, "%s createContactSummaryPdf()", this.getClass().getCanonicalName());
}
Expand All @@ -279,7 +287,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PermissionUtils.WRITE_EXTERNAL_STORAGE_REQUEST_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
createContactSummaryPdf();
loadContactSummaryData();
} else {
displayToast(R.string.allow_phone_call_management);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public void setTaskCount(String taskCount) {
}

@Override
public void createContactSummaryPdf() {
public void createContactSummaryPdf(String womanName) {
//overridden
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Presenter extends BaseProfileContract.Presenter {

void getTaskCount(String baseEntityId);

void createContactSummaryPdf();
void createContactSummaryPdf(String womanName);
}

interface View extends BaseProfileContract.View {
Expand All @@ -48,7 +48,7 @@ interface View extends BaseProfileContract.View {

void setTaskCount(String taskCount);

void createContactSummaryPdf();
void createContactSummaryPdf(String womanName);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void getTaskCount(String baseEntityId) {
}

@Override
public void createContactSummaryPdf() {
getProfileView().createContactSummaryPdf();
public void createContactSummaryPdf(String womanName) {
getProfileView().createContactSummaryPdf(womanName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ protected void onPostExecute(Void result) {
//load profile details

mProfilePresenter.refreshProfileView(baseEntityId);
String name = clientDetails.get(DBConstantsUtils.KeyUtils.FIRST_NAME);
if(clientDetails.get(DBConstantsUtils.KeyUtils.LAST_NAME)!= null)
name = name +" "+ clientDetails.get(DBConstantsUtils.KeyUtils.LAST_NAME);

//Create PDF file stuff
mProfilePresenter.createContactSummaryPdf();
mProfilePresenter.createContactSummaryPdf(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,9 @@ public String getManifestVersion(Context context) {
}
}

public void createSavePdf(Context context, List<YamlConfig> yamlConfigList, Facts facts) throws FileNotFoundException {
public void createSavePdf(Context context, List<YamlConfig> yamlConfigList, Facts facts,String womanName) throws FileNotFoundException {

String FILENAME = context.getResources().getString(R.string.contact_summary_data_file);
String FILENAME = womanName+"_"+context.getResources().getString(R.string.contact_summary_data_file);
String filePath = getAppPath(context) + FILENAME;

if ((new File(filePath)).exists()) {
Expand All @@ -1004,7 +1004,7 @@ public void createSavePdf(Context context, List<YamlConfig> yamlConfigList, Fact
Document layoutDocument = new Document(pdfDocument);


addTitle(layoutDocument, context.getResources().getString(R.string.contact_summary_data, getTodaysDate()));
addTitle(layoutDocument, context.getResources().getString(R.string.contact_summary_data, getTodaysDate(),womanName));


for (YamlConfig yamlConfig : yamlConfigList) {
Expand Down
2 changes: 1 addition & 1 deletion opensrp-anc/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
<string name="accordion_partner_hiv">Partner HIV test</string>
<string name="accordion_blood_glucose">Blood Glucose test</string>
<string name="accordion_other_tests">Other test</string>
<string name="contact_summary_data">Contact Summary Data - %1$s</string>
<string name="contact_summary_data">Contact Summary Data - %1$s \n %2$s</string>
<string name="pdf_saved_successfully">\"Pdf saved successfully to location \"</string>
<string name="contact_summary_data_file">contactSummaryData.pdf</string>

Expand Down
2 changes: 1 addition & 1 deletion reference-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
def powerMockVersion = '2.0.7'
implementation project(":opensrp-anc")
implementation('org.smartregister:opensrp-client-native-form:2.1.17-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:2.1.16-PREVIEW-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down

0 comments on commit cd6e988

Please sign in to comment.