Skip to content

Commit 5be1b16

Browse files
committed
ANDROID: use system menu
1 parent 8787639 commit 5be1b16

File tree

11 files changed

+96
-50
lines changed

11 files changed

+96
-50
lines changed

Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ deb:
6565
test:
6666
(cd $(SUBDIRS) && make test)
6767

68+
release:
69+
(cd $(SUBDIRS) && make release)
70+
6871
# produce a stack dump
6972
ndk-stack:
7073
adb logcat | ${NDK}/ndk-stack -sym src/platform/android/obj/local/armeabi

debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
smallbasic (0.11.11) unstable; urgency=low
2+
* Built using common code from the android project and SDL
3+
4+
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 19 July 2014 09:45:25 +1000
5+
16
smallbasic (0.11.10) unstable; urgency=low
27
* Built using common code from the android project and SDL
38

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif
2828
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
2929
cp -f /usr/share/misc/config.guess config.guess
3030
endif
31-
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --enable-sdl
31+
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --enable-fltk
3232

3333
build: build-stamp
3434

ide/android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:versionCode="13"
66
android:versionName="0.11.11">
77
<!-- This is the platform API where NativeActivity was introduced. -->
8-
<uses-sdk android:minSdkVersion="9" />
8+
<uses-sdk android:minSdkVersion="9"/>
99

1010
<!-- support large + xlarge screens to avoid compatibility mode -->
1111
<supports-screens android:largeScreens="true" />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
dim foo
2+
3+
key="blah"
4+
foo(key) = "something"
5+
foo("other") = 123
6+
7+
? foo(key)
8+
? foo("other")
9+
? foo
10+

src/platform/android/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ test: ant-build-test
2222
clean-am:
2323
(cd jni && ${NDK}/ndk-build clean)
2424

25+
ndk-build-release:
26+
(cd jni && ${NDK}/ndk-build NDK_DEBUG=0)
27+
28+
release: ndk-build-release
29+
(cd ../../../ide/android && ant release install)
30+

src/platform/android/jni/Android.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ FREETYPE_HOME := $(HOME)/android-sdk/freetype-2.5.3
1313
include $(call all-subdir-makefiles)
1414
LOCAL_PATH := $(JNI_PATH)
1515

16-
include $(CLEAR_VARS)
17-
LOCAL_MODULE := png
18-
LOCAL_SRC_FILES := $(PNG_HOME)/lib/libpng.a
19-
include $(PREBUILT_STATIC_LIBRARY)
16+
#include $(CLEAR_VARS)
17+
#LOCAL_MODULE := png
18+
#LOCAL_SRC_FILES := $(PNG_HOME)/lib/libpng.a
19+
#include $(PREBUILT_STATIC_LIBRARY)
2020

2121
include $(CLEAR_VARS)
2222
LOCAL_MODULE := smallbasic

src/platform/android/jni/freetype/Android.mk

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,34 @@ LOCAL_CFLAGS := -Wall -std=gnu99 \
1818
"-DFT2_BUILD_LIBRARY" \
1919
"-DFT_CONFIG_MODULES_H=<ftmodule.h>"
2020

21-
LOCAL_SRC_FILES:= \
22-
$(FREETYPE_HOME)/src/type1/type1.c \
23-
$(FREETYPE_HOME)/src/cid/type1cid.c \
24-
$(FREETYPE_HOME)/src/pfr/pfr.c \
25-
$(FREETYPE_HOME)/src/type42/type42.c \
26-
$(FREETYPE_HOME)/src/winfonts/winfnt.c \
27-
$(FREETYPE_HOME)/src/pcf/pcf.c \
28-
$(FREETYPE_HOME)/src/psaux/psaux.c \
29-
$(FREETYPE_HOME)/src/bdf/bdf.c \
30-
$(FREETYPE_HOME)/src/base/ftbbox.c \
31-
$(FREETYPE_HOME)/src/base/ftbitmap.c \
32-
$(FREETYPE_HOME)/src/base/ftglyph.c \
33-
$(FREETYPE_HOME)/src/base/ftstroke.c \
34-
$(FREETYPE_HOME)/src/base/ftxf86.c \
35-
$(FREETYPE_HOME)/src/base/ftbase.c \
36-
$(FREETYPE_HOME)/src/base/ftsystem.c \
37-
$(FREETYPE_HOME)/src/base/ftinit.c \
38-
$(FREETYPE_HOME)/src/base/ftgasp.c \
39-
$(FREETYPE_HOME)/src/raster/raster.c \
40-
$(FREETYPE_HOME)/src/sfnt/sfnt.c \
41-
$(FREETYPE_HOME)/src/smooth/smooth.c \
42-
$(FREETYPE_HOME)/src/autofit/autofit.c \
43-
$(FREETYPE_HOME)/src/truetype/truetype.c \
44-
$(FREETYPE_HOME)/src/cff/cff.c \
45-
$(FREETYPE_HOME)/src/psnames/psnames.c \
46-
$(FREETYPE_HOME)/src/pshinter/pshinter.c \
47-
$(FREETYPE_HOME)/src/gzip/ftgzip.c \
48-
$(FREETYPE_HOME)/src/lzw/ftlzw.c \
21+
LOCAL_SRC_FILES:= \
22+
$(FREETYPE_HOME)/src/type1/type1.c \
23+
$(FREETYPE_HOME)/src/cid/type1cid.c \
24+
$(FREETYPE_HOME)/src/pfr/pfr.c \
25+
$(FREETYPE_HOME)/src/type42/type42.c \
26+
$(FREETYPE_HOME)/src/winfonts/winfnt.c \
27+
$(FREETYPE_HOME)/src/pcf/pcf.c \
28+
$(FREETYPE_HOME)/src/psaux/psaux.c \
29+
$(FREETYPE_HOME)/src/bdf/bdf.c \
30+
$(FREETYPE_HOME)/src/base/ftbbox.c \
31+
$(FREETYPE_HOME)/src/base/ftbitmap.c \
32+
$(FREETYPE_HOME)/src/base/ftglyph.c \
33+
$(FREETYPE_HOME)/src/base/ftstroke.c \
34+
$(FREETYPE_HOME)/src/base/ftxf86.c \
35+
$(FREETYPE_HOME)/src/base/ftbase.c \
36+
$(FREETYPE_HOME)/src/base/ftsystem.c \
37+
$(FREETYPE_HOME)/src/base/ftinit.c \
38+
$(FREETYPE_HOME)/src/base/ftgasp.c \
39+
$(FREETYPE_HOME)/src/raster/raster.c \
40+
$(FREETYPE_HOME)/src/sfnt/sfnt.c \
41+
$(FREETYPE_HOME)/src/smooth/smooth.c \
42+
$(FREETYPE_HOME)/src/autofit/autofit.c \
43+
$(FREETYPE_HOME)/src/truetype/truetype.c \
44+
$(FREETYPE_HOME)/src/cff/cff.c \
45+
$(FREETYPE_HOME)/src/psnames/psnames.c \
46+
$(FREETYPE_HOME)/src/pshinter/pshinter.c \
47+
$(FREETYPE_HOME)/src/gzip/ftgzip.c \
48+
$(FREETYPE_HOME)/src/lzw/ftlzw.c \
4949
$(FREETYPE_HOME)/src/lzw/ftzopen.c
5050

51-
5251
include $(BUILD_STATIC_LIBRARY)

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

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@
4848
import android.util.Log;
4949
import android.util.TypedValue;
5050
import android.view.InputDevice;
51+
import android.view.Menu;
52+
import android.view.MenuItem;
5153
import android.view.View;
5254
import android.view.inputmethod.InputMethodManager;
55+
import android.widget.AdapterView.AdapterContextMenuInfo;
5356

5457
/**
5558
* Extends NativeActivity to provide interface methods for runtime.cpp
@@ -67,6 +70,7 @@ public class MainActivity extends NativeActivity {
6770
private boolean _untrusted = false;
6871
private ExecutorService _audioExecutor = Executors.newSingleThreadExecutor();
6972
private Queue<Sound> _sounds = new ConcurrentLinkedQueue<Sound>();
73+
private String[] options = null;
7074

7175
static {
7276
System.loadLibrary("smallbasic");
@@ -142,19 +146,38 @@ public void onGlobalLayout() {
142146
onResize(rect.width(), rect.height());
143147
}
144148

149+
@Override
150+
public boolean onOptionsItemSelected(MenuItem item) {
151+
if (this.options != null) {
152+
int index = 0;
153+
while (index < this.options.length) {
154+
if (options[index].equals(item.toString())) {
155+
break;
156+
}
157+
index++;
158+
}
159+
Log.i(TAG, "items clicked = " + index);
160+
optionSelected(index);
161+
}
162+
return true;
163+
}
164+
165+
@Override
166+
public boolean onPrepareOptionsMenu(Menu menu) {
167+
if (this.options != null) {
168+
menu.clear();
169+
for (String option : this.options) {
170+
menu.add(option);
171+
}
172+
}
173+
return super.onPrepareOptionsMenu(menu);
174+
}
175+
145176
public void optionsBox(final String[] items) {
146-
final Activity activity = this;
177+
this.options = items;
147178
runOnUiThread(new Runnable() {
148179
public void run() {
149-
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
150-
builder.setItems(items, new DialogInterface.OnClickListener() {
151-
@Override
152-
public void onClick(DialogInterface dialog, int index) {
153-
Log.i(TAG, "items clicked = " + index);
154-
optionSelected(index);
155-
}
156-
});
157-
builder.create().show();
180+
openOptionsMenu();
158181
}
159182
});
160183
}

src/platform/android/src/net/sourceforge/smallbasic/Sound.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
1616
public class Sound {
1717
private static final String TAG = "smallbasic";
18-
static final int AUDIO_SAMPLE_RATE = 8000;
18+
private static final int AUDIO_SAMPLE_RATE = 8000;
19+
private static final int WAVE_MAX = 32000;
1920
private byte[] _sound;
2021
private float _volume;
2122
private int _dur;
@@ -78,7 +79,7 @@ private final byte[] generateTone(int freqOfTone, int durationMillis) {
7879
// Ramp amplitude up (to avoid clicks)
7980
double dVal = sample[i];
8081
// Ramp up to maximum
81-
final short val = (short) ((dVal * 32767 * i / ramp));
82+
final short val = (short) ((dVal * WAVE_MAX * i / ramp));
8283
// in 16 bit wav PCM, first byte is the low order byte
8384
result[idx++] = (byte) (val & 0x00ff);
8485
result[idx++] = (byte) ((val & 0xff00) >>> 8);
@@ -89,7 +90,7 @@ private final byte[] generateTone(int freqOfTone, int durationMillis) {
8990
// Max amplitude for most of the samples
9091
double dVal = sample[i];
9192
// scale to maximum amplitude
92-
final short val = (short) ((dVal * 32767));
93+
final short val = (short) ((dVal * WAVE_MAX));
9394
// in 16 bit wav PCM, first byte is the low order byte
9495
result[idx++] = (byte) (val & 0x00ff);
9596
result[idx++] = (byte) ((val & 0xff00) >>> 8);
@@ -100,7 +101,7 @@ private final byte[] generateTone(int freqOfTone, int durationMillis) {
100101
// Ramp amplitude down
101102
double dVal = sample[i];
102103
// Ramp down to zero
103-
final short val = (short) ((dVal * 32767 * (numSamples - i) / ramp));
104+
final short val = (short) ((dVal * WAVE_MAX * (numSamples - i) / ramp));
104105
// in 16 bit wav PCM, first byte is the low order byte
105106
result[idx++] = (byte) (val & 0x00ff);
106107
result[idx++] = (byte) ((val & 0xff00) >>> 8);

0 commit comments

Comments
 (0)