Browse Source

Created branch and added fix to External Storage issue.

christian 3 years ago
parent
commit
44707900c3

+ 2
- 1
app/src/main/java/uprrp/tania/activities/AccountRecoveryActivity.java View File

119
     // TODO: IO should be moved to a background task
119
     // TODO: IO should be moved to a background task
120
     private void restoreConsentForm(String response) {
120
     private void restoreConsentForm(String response) {
121
         try {
121
         try {
122
+            Context context = getApplicationContext();
122
             byte[] consentBytes = Base64.decode(response, Base64.NO_WRAP);
123
             byte[] consentBytes = Base64.decode(response, Base64.NO_WRAP);
123
-            FileOutputStream consentForm = new FileOutputStream(Environment.getExternalStorageDirectory().getPath() + getString(R.string.consentFileName));
124
+            FileOutputStream consentForm = new FileOutputStream(context.getExternalFilesDir(null).getPath() + getString(R.string.consentFileName));
124
             consentForm.write(consentBytes);
125
             consentForm.write(consentBytes);
125
             consentForm.close();
126
             consentForm.close();
126
         } catch (FileNotFoundException e) {
127
         } catch (FileNotFoundException e) {

+ 4
- 1
app/src/main/java/uprrp/tania/activities/GettingStartedActivity.java View File

5
 import android.content.Intent;
5
 import android.content.Intent;
6
 import android.content.SharedPreferences;
6
 import android.content.SharedPreferences;
7
 import android.content.pm.PackageManager;
7
 import android.content.pm.PackageManager;
8
+import android.content.Context;
8
 import android.os.Bundle;
9
 import android.os.Bundle;
9
 import android.os.Environment;
10
 import android.os.Environment;
10
 import android.util.Base64;
11
 import android.util.Base64;
422
 
423
 
423
         try {
424
         try {
424
 
425
 
426
+            Context context = getApplicationContext();
425
             // Open document
427
             // Open document
426
             Document document = new Document();
428
             Document document = new Document();
427
-            String filePath = Environment.getExternalStorageDirectory().getPath() + getString(R.string.consentFileName);
429
+            String filePath = context.getExternalFilesDir(null).getPath();
430
+            //String filePath = Environment.getExternalStorageDirectory().getPath() + getString(R.string.consentFileName);
428
             PdfWriter.getInstance(document, new FileOutputStream(filePath));
431
             PdfWriter.getInstance(document, new FileOutputStream(filePath));
429
             document.open();
432
             document.open();
430
 
433
 

+ 3
- 1
app/src/main/java/uprrp/tania/fragments/ConsentFragment.java View File

4
 import android.graphics.Color;
4
 import android.graphics.Color;
5
 import android.os.Bundle;
5
 import android.os.Bundle;
6
 import android.os.Environment;
6
 import android.os.Environment;
7
+import android.content.Context;
7
 import android.view.LayoutInflater;
8
 import android.view.LayoutInflater;
8
 import android.view.MotionEvent;
9
 import android.view.MotionEvent;
9
 import android.view.View;
10
 import android.view.View;
35
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
36
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
36
         View view = inflater.inflate(R.layout.fragment_consent, container, false);
37
         View view = inflater.inflate(R.layout.fragment_consent, container, false);
37
 
38
 
39
+        Context context = getContext();
38
         this.pdfView = view.findViewById(R.id.pdf_viewer);
40
         this.pdfView = view.findViewById(R.id.pdf_viewer);
39
-        File consentFile = new File(Environment.getExternalStorageDirectory().getPath() + getString(R.string.consentFileName));
41
+        File consentFile = new File(context.getExternalFilesDir(null).getPath() + getString(R.string.consentFileName));
40
         this.pdfView.fromFile(consentFile)
42
         this.pdfView.fromFile(consentFile)
41
                 .password(null)
43
                 .password(null)
42
                 .defaultPage(0)
44
                 .defaultPage(0)