Skip to content

Commit 220efb8

Browse files
committed
Moved the all files access prompt from the LoadingActivity to the AccessActivity
1 parent 536c1be commit 220efb8

2 files changed

Lines changed: 31 additions & 23 deletions

File tree

app/src/main/java/nie/translator/rtranslator/LoadingActivity.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public void onResume() {
8383
super.onResume();
8484
isVisible = true;
8585
global = (Global) getApplication();
86-
checkAllFilesPermission(); //todo: remove before the final release
8786
if (global.isFirstStart()) {
8887
Intent intent = new Intent(this, AccessActivity.class);
8988
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -312,26 +311,4 @@ private void onFailure(int[] reasons, long value) {
312311
}
313312
}
314313
}
315-
316-
//todo: remove before the final release
317-
private void checkAllFilesPermission() {
318-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
319-
if (!Environment.isExternalStorageManager()) {
320-
requestAllFilesPermission();
321-
}
322-
}
323-
}
324-
325-
//todo: remove before the final release
326-
private void requestAllFilesPermission() {
327-
try {
328-
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
329-
intent.setData(Uri.parse("package:" + getPackageName()));
330-
startActivityForResult(intent, 100);
331-
} catch (Exception e) {
332-
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
333-
startActivityForResult(intent, 100);
334-
}
335-
}
336-
337314
}

app/src/main/java/nie/translator/rtranslator/access/AccessActivity.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818

1919
import android.Manifest;
2020
import android.content.Context;
21+
import android.content.Intent;
2122
import android.content.SharedPreferences;
23+
import android.net.Uri;
2224
import android.os.Build;
2325
import android.os.Bundle;
26+
import android.os.Environment;
27+
import android.provider.Settings;
2428
import android.view.View;
2529

2630
import androidx.fragment.app.Fragment;
@@ -78,6 +82,12 @@ protected void onStart() {
7882
super.onStart(); //called here because otherwise the onStart of the DownloadFragment is called before this onStart, and this could cause problems.
7983
}
8084

85+
@Override
86+
protected void onResume() {
87+
super.onResume();
88+
checkAllFilesPermission(); //todo: remove before the final release
89+
}
90+
8191
@Override
8292
protected void onStop() {
8393
super.onStop();
@@ -151,6 +161,27 @@ public void onBackPressed() {
151161
}
152162
super.onBackPressed();
153163
}
164+
165+
//todo: remove before the final release
166+
private void checkAllFilesPermission() {
167+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
168+
if (!Environment.isExternalStorageManager()) {
169+
requestAllFilesPermission();
170+
}
171+
}
172+
}
173+
174+
//todo: remove before the final release
175+
private void requestAllFilesPermission() {
176+
try {
177+
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
178+
intent.setData(Uri.parse("package:" + getPackageName()));
179+
startActivityForResult(intent, 100);
180+
} catch (Exception e) {
181+
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
182+
startActivityForResult(intent, 100);
183+
}
184+
}
154185
}
155186

156187

0 commit comments

Comments
 (0)