Skip to content

Commit c22077c

Browse files
committed
ANDROID: fix access to external storage
1 parent 68c52af commit c22077c

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

ChangeLog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
2020-06-14 (12.19)
1+
2020-07-12 (12.19)
22
ANDROID: fix layout issue with samsung mobiles
3+
ANDROID: save and restore the selected theme
4+
ANDROID: fix access to external storage
35

46
2020-06-14 (12.19)
57
UI: Use theme colours in main display #94

src/platform/android/app/src/main/assets/main.bas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const lineSpacing = 2 + char_h
77
const wnd = window()
88
const theme = wnd.theme
99
const colBkGnd = theme.background
10-
const colText = theme.text1
10+
const colText = theme.text5
1111
const colFile = theme.text2
1212
const colDir = theme.text3
1313
const colText2 = theme.text4
14-
const colNav = theme.text5
14+
const colNav = theme.text1
1515
const colNav2 = theme.text6
1616
const menu_gap = -(char_w / 2)
1717
const is_sdl = instr(sbver, "SDL") != 0

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.media.AudioManager;
2222
import android.media.MediaPlayer;
2323
import android.net.Uri;
24+
import android.os.Build;
2425
import android.os.Bundle;
2526
import android.os.Environment;
2627
import android.os.Handler;
@@ -784,6 +785,10 @@ private String getExternalStorage() {
784785
} else {
785786
result = path;
786787
}
788+
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
789+
// https://commonsware.com/blog/2019/06/07/death-external-storage-end-saga.html
790+
File[] dirs = getExternalMediaDirs();
791+
result = dirs[0].getAbsolutePath();
787792
} else {
788793
result = getInternalStorage();
789794
}

src/platform/android/jni/runtime.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "platform/android/jni/runtime.h"
1616
#include "lib/maapi.h"
1717
#include "ui/utils.h"
18+
#include "ui/theme.h"
1819
#include "languages/messages.en.h"
1920
#include "include/osd.h"
2021
#include "common/sbapp.h"
@@ -33,6 +34,7 @@
3334
#define SERVER_SOCKET_KEY "serverSocket"
3435
#define SERVER_TOKEN_KEY "serverToken"
3536
#define MUTE_AUDIO_KEY "muteAudio"
37+
#define THEME_KEY "theme"
3638
#define OPT_IDE_KEY "optIde"
3739
#define GBOARD_KEY_QUESTION 274
3840
#define EVENT_TYPE_EXIT 100
@@ -545,6 +547,13 @@ void Runtime::loadConfig() {
545547
if (s) {
546548
opt_ide = s->toInteger();
547549
}
550+
s = settings.get(THEME_KEY);
551+
if (s) {
552+
int id = s->toInteger();
553+
if (id > -1 && id < NUM_THEMES) {
554+
g_themeId = id;
555+
}
556+
}
548557
loadEnvConfig(settings, SERVER_SOCKET_KEY);
549558
loadEnvConfig(settings, SERVER_TOKEN_KEY);
550559
loadEnvConfig(settings, FONT_ID_KEY);
@@ -596,6 +605,7 @@ void Runtime::saveConfig() {
596605
fprintf(fp, "%s=%d\n", FONT_SCALE_KEY, _fontScale);
597606
fprintf(fp, "%s=%d\n", MUTE_AUDIO_KEY, opt_mute_audio);
598607
fprintf(fp, "%s=%d\n", OPT_IDE_KEY, opt_ide);
608+
fprintf(fp, "%s=%d\n", THEME_KEY, g_themeId);
599609
for (int i = 0; environ[i] != nullptr; i++) {
600610
char *env = environ[i];
601611
if (strstr(env, SERVER_SOCKET_KEY) != nullptr ||

src/ui/inputs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void FormInput::drawLink(const char *caption, int dx, int dy, int sw, int chw) {
239239

240240
void FormInput::drawText(const char *caption, int dx, int dy, int sw, int chw) {
241241
if (caption != nullptr) {
242-
unsigned strWidth = chw * strlen(caption);
242+
int strWidth = chw * strlen(caption);
243243
int width = sw - dx;
244244
if (width > _width) {
245245
width = _width;

0 commit comments

Comments
 (0)