Skip to content

Commit 64c0f0b

Browse files
committed
Projects - continue using downloads folder on Android 10
1 parent 46b9bbb commit 64c0f0b

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ android {
66
applicationId "com.samsung.microbit"
77
minSdkVersion 21
88
targetSdk 33
9-
// Once target SDK version is 30, requestLegacyExternalStorage will no longer work
9+
// When target SDK version is 30+,
10+
// requestLegacyExternalStorage will continue to work for 29 Android 10
1011
}
1112
buildTypes {
1213
release {

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<uses-permission android:name="android.permission.INTERNET"/>
2323
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
2424
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
25-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
26-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
25+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
26+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
2727
<uses-permission android:name="android.permission.VIBRATE"/>
2828
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
2929
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" android:protectionLevel="signature"/>
@@ -60,7 +60,7 @@
6060
android:icon="@mipmap/ic_launcher"
6161
android:label="@string/app_name"
6262
android:theme="@style/AppTheme.NoActionBar"
63-
android:requestLegacyExternalStorage="false">
63+
android:requestLegacyExternalStorage="true">
6464

6565
<activity
6666
android:name=".ui.activity.HomeActivity"

app/src/main/java/com/samsung/microbit/ui/activity/HomeActivity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,12 @@ private void setFirstRun300( boolean yes) {
501501
* flash on a micro:bit board.
502502
*/
503503
private void installSamples( boolean withThanks) {
504-
if(isFirstRun() || isFirstRun300() && !ProjectsHelper.legacyStorage()) {
505-
setFirstRun(false);
506-
setFirstRun300(false);
504+
boolean firstRun = isFirstRun();
505+
boolean firstRun300 = isFirstRun300();
506+
if ( firstRun) setFirstRun(false);
507+
if ( firstRun300) setFirstRun300(false);
508+
509+
if( firstRun || firstRun300 && !ProjectsHelper.legacyStorage()) {
507510
//First Run. Install the Sample applications
508511
if ( withThanks) {
509512
new Thread(new Runnable() {
@@ -516,7 +519,6 @@ public void run() {
516519
PopUp.TYPE_ALERT,
517520
null, null);
518521
ProjectsHelper.installSamples(MBApp.getApp().getBaseContext());
519-
520522
}
521523
}).start();
522524
} else {

app/src/main/java/com/samsung/microbit/utils/ProjectsHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static String prefsGetString(String name, String def) {
5858
}
5959

6060
public static boolean legacyStorage() {
61-
return Build.VERSION.SDK_INT <= Build.VERSION_CODES.P;
61+
return Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q;
6262
}
6363

6464
public static File getDownloadsDirectory() {

0 commit comments

Comments
 (0)