Skip to content

Commit 8db539b

Browse files
authored
Merge pull request #80 from chrisws/0_12_15
0 12 15
2 parents 228bd7f + 3ffe0d7 commit 8db539b

File tree

20 files changed

+198
-53
lines changed

20 files changed

+198
-53
lines changed

ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2019-08-23 (0.12.15)
2+
ANDROID: fix ChromeOS crash when restarting over existing instance
3+
4+
2019-08-19 (0.12.15)
5+
ANDROID: fix issue with crash on minimise with ChromeOS
6+
ANDROID: fix permission issue with share command
7+
ANDROID: (internal) update to androidx
8+
9+
2019-07-27 (0.12.15)
10+
SDL: added -n command line option to run then not pause for back key
11+
12+
2019-07-10 (0.12.15)
13+
SDL: update editor find and replace
14+
115
2019-06-27 (0.12.15)
216
FLTK: file file save as
317
UI: fix reported crash in android printing null

configure.ac

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [0.12.15])
10+
AC_INIT([smallbasic], [0.12.16])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET
@@ -344,7 +344,7 @@ function buildFLTK() {
344344

345345
FLTK_CXXFLAGS="${PACKAGE_CFLAGS} `fltk-config --cxxflags`"
346346
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -fno-exceptions -fno-rtti -std=c++11 -Wno-unknown-pragmas"
347-
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk-config --ldstaticflags --use-images` -no-pie"
347+
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk-config --ldstaticflags --use-images`"
348348

349349
dnl do not depend on cygwin.dll under cygwin build
350350
case "${host_os}" in
@@ -354,9 +354,14 @@ function buildFLTK() {
354354
AC_DEFINE(_Win32, 1, [Windows build])
355355
;;
356356

357+
*darwin*)
358+
(cd images && xxd -i sb-desktop-128x128.png > ../src/platform/fltk/icon.h)
359+
;;
360+
357361
*)
358362
(cd images && xxd -i sb-desktop-128x128.png > ../src/platform/fltk/icon.h)
359-
xxd
363+
PACKAGE_LIBS="${PACKAGE_LIBS} -no-pie"
364+
;;
360365
esac
361366

362367
defaultConditionals

debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
smallbasic (0.12.16) unstable; urgency=low
2+
* Various see web site
3+
4+
-- Chris Warren-Smith <[email protected]> Fri, 25 Aug 2019 09:45:25 +1000
5+
16
smallbasic (0.12.15) unstable; urgency=low
27
* Various see web site
38

src/platform/android/app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ apply plugin: 'com.android.application'
22

33
android {
44
// app can use the API features included in this API level and lower.
5-
compileSdkVersion 27
5+
compileSdkVersion 28
66

77
// can override some attributes in main/AndroidManifest.xml
88
defaultConfig {
99
applicationId 'net.sourceforge.smallbasic'
1010
minSdkVersion 16
11-
targetSdkVersion 27
12-
versionCode 36
13-
versionName "0.12.15.3"
11+
targetSdkVersion 28
12+
versionCode 38
13+
versionName "0.12.16"
1414
resConfigs "en"
1515
}
1616

@@ -47,6 +47,6 @@ android {
4747
}
4848

4949
dependencies {
50-
implementation 'com.android.support:support-compat:27.1.1'
50+
implementation 'androidx.core:core:1.0.2'
5151
testImplementation 'junit:junit:4.12'
5252
}

src/platform/android/app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
<data android:scheme="smallbasic" />
5353
</intent-filter>
5454
</activity>
55+
<provider
56+
android:name="androidx.core.content.FileProvider"
57+
android:authorities="net.sourceforge.smallbasic.provider"
58+
android:exported="false"
59+
android:grantUriPermissions="true">
60+
<meta-data
61+
android:name="android.support.FILE_PROVIDER_PATHS"
62+
android:resource="@xml/file_paths"/>
63+
</provider>
5564
</application>
5665
<!-- Permissions -->
5766
<uses-permission android:name="android.permission.INTERNET" />

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

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
import android.os.Bundle;
2525
import android.os.Environment;
2626
import android.os.Handler;
27-
import android.support.annotation.NonNull;
28-
import android.support.v4.app.ActivityCompat;
29-
import android.support.v4.content.ContextCompat;
3027
import android.util.Base64;
3128
import android.util.DisplayMetrics;
3229
import android.util.Log;
@@ -46,11 +43,15 @@
4643
import java.io.ByteArrayOutputStream;
4744
import java.io.DataInputStream;
4845
import java.io.File;
46+
import java.io.FileInputStream;
4947
import java.io.FileNotFoundException;
48+
import java.io.FileOutputStream;
5049
import java.io.FileReader;
5150
import java.io.FileWriter;
5251
import java.io.IOException;
52+
import java.io.InputStream;
5353
import java.io.InputStreamReader;
54+
import java.io.OutputStream;
5455
import java.io.UnsupportedEncodingException;
5556
import java.net.Inet4Address;
5657
import java.net.InetAddress;
@@ -72,6 +73,11 @@
7273
import java.util.concurrent.Semaphore;
7374
import java.util.zip.GZIPInputStream;
7475

76+
import androidx.annotation.NonNull;
77+
import androidx.core.app.ActivityCompat;
78+
import androidx.core.content.ContextCompat;
79+
import androidx.core.content.FileProvider;
80+
7581
/**
7682
* Extends NativeActivity to provide interface methods for runtime.cpp
7783
*
@@ -539,7 +545,8 @@ public void share(final byte[] pathBytes) {
539545
Intent sendIntent = new Intent();
540546
sendIntent.setAction(Intent.ACTION_SEND);
541547
sendIntent.putExtra(Intent.EXTRA_TEXT, buffer);
542-
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
548+
sendIntent.putExtra(Intent.EXTRA_STREAM, getSharedFile(file));
549+
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
543550
sendIntent.putExtra(Intent.EXTRA_SUBJECT, file.getName());
544551
sendIntent.setType("text/plain");
545552
startActivity(Intent.createChooser(sendIntent, "Share"));
@@ -669,6 +676,24 @@ public void run() {
669676
});
670677
}
671678

679+
private void copy(File src, File dst) throws IOException {
680+
InputStream in = new FileInputStream(src);
681+
try {
682+
OutputStream out = new FileOutputStream(dst);
683+
try {
684+
byte[] buf = new byte[1024];
685+
int len;
686+
while ((len = in.read(buf)) > 0) {
687+
out.write(buf, 0, len);
688+
}
689+
} finally {
690+
out.close();
691+
}
692+
} finally {
693+
in.close();
694+
}
695+
}
696+
672697
private String execBuffer(final String buffer, final String name, boolean run) throws IOException {
673698
File outputFile = getApplication().getFileStreamPath(name);
674699
BufferedWriter output = new BufferedWriter(new FileWriter(outputFile));
@@ -773,6 +798,23 @@ private Map<String, String> getPostData(DataInputStream inputStream, final Strin
773798
return result;
774799
}
775800

801+
private Uri getSharedFile(File file) {
802+
Uri result;
803+
try {
804+
File sharesPath = new File(getExternalFilesDir(null), "shares");
805+
if (sharesPath.mkdirs()) {
806+
Log.i(TAG, "created folder: " + sharesPath.toString());
807+
}
808+
File shareFile = new File(sharesPath, file.getName());
809+
copy(file, sharesPath);
810+
result = FileProvider.getUriForFile(this, "net.sourceforge.smallbasic.provider", shareFile);
811+
} catch (Exception e) {
812+
result = null;
813+
Log.e(TAG, "failed to create shared file", e);
814+
}
815+
return result;
816+
}
817+
776818
private String getString(final byte[] promptBytes) {
777819
try {
778820
return new String(promptBytes, CP1252);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<paths>
2+
<external-files-path name="shares" path="shares/" />
3+
</paths>

src/platform/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.2'
9-
classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"
8+
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath "com.github.ben-manes:gradle-versions-plugin:0.22.0"
1010
}
1111
}
1212

src/platform/android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
12+
android.enableJetifier=true
13+
android.useAndroidX=true
1214
org.gradle.jvmargs=-Xmx1536m
1315

1416
# When configured, Gradle will run in incubating parallel mode.

src/platform/android/jni/display.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool Graphics::construct(int fontId) {
143143
if (_screen && _screen->create(_w, _h)) {
144144
_drawTarget = _screen;
145145
maSetColor(DEFAULT_BACKGROUND);
146-
ANativeWindow_setBuffersGeometry(_app->window, 0, 0, WINDOW_FORMAT_RGBA_8888);
146+
ANativeWindow_setBuffersGeometry(_app->window, 0, 0, AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM);
147147
result = true;
148148
} else {
149149
trace("Failed to create canvas");
@@ -157,18 +157,27 @@ bool Graphics::construct(int fontId) {
157157
void Graphics::redraw() {
158158
if (_app->window != NULL && !_paused) {
159159
ANativeWindow_Buffer buffer;
160-
if (ANativeWindow_lock(_app->window, &buffer, NULL) < 0) {
160+
bool locked = ANativeWindow_lock(_app->window, &buffer, NULL) == 0;
161+
if (!locked) {
161162
trace("Unable to lock window buffer");
162163
} else {
163-
void *pixels = buffer.bits;
164-
int width = MIN(_w, MIN(buffer.width, _screen->_w));
165-
int height = MIN(_h, MIN(buffer.height, _screen->_h));
166-
for (int y = 0; y < height; y++) {
167-
pixel_t *line = _screen->getLine(y);
168-
memcpy((pixel_t *)pixels, line, width * sizeof(pixel_t));
169-
pixels = (pixel_t*)pixels + buffer.stride;
164+
if (buffer.format != AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) {
165+
ANativeWindow_unlockAndPost(_app->window);
166+
ANativeWindow_setBuffersGeometry(_app->window, 0, 0, AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM);
167+
locked = ANativeWindow_lock(_app->window, &buffer, NULL) == 0;
168+
trace("Restore format %d", locked);
169+
}
170+
if (locked) {
171+
void *pixels = buffer.bits;
172+
int width = MIN(_w, MIN(buffer.width, _screen->_w));
173+
int height = MIN(_h, MIN(buffer.height, _screen->_h));
174+
for (int y = 0; y < height; y++) {
175+
pixel_t *line = _screen->getLine(y);
176+
memcpy((pixel_t *)pixels, line, width * sizeof(pixel_t));
177+
pixels = (pixel_t*)pixels + buffer.stride;
178+
}
179+
ANativeWindow_unlockAndPost(_app->window);
170180
}
171-
ANativeWindow_unlockAndPost(_app->window);
172181
}
173182
}
174183
}

0 commit comments

Comments
 (0)