Browse Source

Created branch and added fix to External Storage issue.

christian 2 years ago
parent
commit
44707900c3

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

@@ -119,8 +119,9 @@ public class AccountRecoveryActivity extends AppCompatActivity {
119 119
     // TODO: IO should be moved to a background task
120 120
     private void restoreConsentForm(String response) {
121 121
         try {
122
+            Context context = getApplicationContext();
122 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 125
             consentForm.write(consentBytes);
125 126
             consentForm.close();
126 127
         } catch (FileNotFoundException e) {

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

@@ -5,6 +5,7 @@ import android.app.ProgressDialog;
5 5
 import android.content.Intent;
6 6
 import android.content.SharedPreferences;
7 7
 import android.content.pm.PackageManager;
8
+import android.content.Context;
8 9
 import android.os.Bundle;
9 10
 import android.os.Environment;
10 11
 import android.util.Base64;
@@ -422,9 +423,11 @@ public class GettingStartedActivity extends AppCompatActivity implements Observe
422 423
 
423 424
         try {
424 425
 
426
+            Context context = getApplicationContext();
425 427
             // Open document
426 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 431
             PdfWriter.getInstance(document, new FileOutputStream(filePath));
429 432
             document.open();
430 433
 

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

@@ -4,6 +4,7 @@ import android.graphics.Canvas;
4 4
 import android.graphics.Color;
5 5
 import android.os.Bundle;
6 6
 import android.os.Environment;
7
+import android.content.Context;
7 8
 import android.view.LayoutInflater;
8 9
 import android.view.MotionEvent;
9 10
 import android.view.View;
@@ -35,8 +36,9 @@ public class ConsentFragment extends Fragment {
35 36
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
36 37
         View view = inflater.inflate(R.layout.fragment_consent, container, false);
37 38
 
39
+        Context context = getContext();
38 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 42
         this.pdfView.fromFile(consentFile)
41 43
                 .password(null)
42 44
                 .defaultPage(0)