Commit Graph

517 Commits

Author SHA1 Message Date
David Crawshaw bd8a095b54 event/key: add Code type
Also add a few missing codes.

Change-Id: I26b6db31067c67107fe4db142ec9f48ff13cc53e
Reviewed-on: https://go-review.googlesource.com/12536
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-24 12:23:42 +00:00
Meir Fischer a34303262d exp/audio: fix inability to use mono 8 format
There is no way to distinguish an unknown format from
Mono8 because Mono8 is zero. The current CL fixes this
issue by starting the format constants from iota + 1.

Change-Id: I8c709cdaff3bc46bcc15ab770cfcfd04c186034d
Reviewed-on: https://go-review.googlesource.com/12386
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-07-24 05:53:18 +00:00
Nigel Tao e5bb9c1e6f exp/gl/glutil: don't embed the *image.RGBA.
Embedding is more trouble than it's worth. For example, the image/draw
package will pick the slow code paths for an embedded *image.RGBA.

Change-Id: I64bd20a80814b838850950c05dd8257e5901aef7
Reviewed-on: https://go-review.googlesource.com/12567
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-24 05:26:20 +00:00
Hyang-Ah (Hana) Kim 4755f4ad8f bind/objc: fixes miscalculation of string length.
Also, fixes the memory allocation bug - misuse of mem_ensure that caused
to allocate 72 bytes of memory to carry 16 bytes of data for instance.

Fixes golang/go#11842.

Change-Id: I21798be2ec7adfb68cc2897bb46a924f05f3478c
Reviewed-on: https://go-review.googlesource.com/12577
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-23 22:35:14 +00:00
Hyang-Ah (Hana) Kim c039090cf1 bind/java: fix misuse of mem_ensure.
mem_ensure is to ensure the remaining space in buffer
is large enough to hold extra size bytes. We've been passing
the target capacity instead of the number of extra bytes we
need.

Change-Id: Ic6f6ddb4ad22cbcdbc44eb4a58e6a415ae771fb2
Reviewed-on: https://go-review.googlesource.com/12578
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-23 22:34:55 +00:00
Hyang-Ah (Hana) Kim 354c023467 cmd/gomobile: version command
Finding the revision info from compiled binary (gomobile) built with
'go get' is not currently possible. What we can do instead is to check
if the current mobile repository found from GOPATH builds the same
binary by running 'go install -x -n' and checking if it outputs any
output. If so, this command prints out the revision info of the
repository. Otherwise, prints 'unknown'.

Sample output:

./gomobile version
gomobile version +27329c5 Wed Jul 22 19:29:08 2015 -0400 (android,ios);
androidSDK=/Users/hakim/Library/Android/sdk/platforms/android-22

./gomobile version
gomobile version unknown

Change-Id: Idc26c8a1dd3b43cc47a5c15ce130e2b97a460cec
Reviewed-on: https://go-review.googlesource.com/12455
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-23 15:25:54 +00:00
David Crawshaw 2341c96d9d app: use isARepeat method instead of ARepeat prop
The property was only introduced in 10.10, and doesn't offer us
anything more than what the method gives us.

Fixes golang/go#11827.

Change-Id: I5a9f9b068b9f18acc85a68a37dae11f19df686a1
Reviewed-on: https://go-review.googlesource.com/12552
Reviewed-by: Andrey Petrov <shazow@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-23 12:08:15 +00:00
Hyang-Ah (Hana) Kim 8c8ee830af misc/androidstudio: source code for gomobile bind gradle plugin.
Currently version 0.2.1

I messed up previous versions and plugins.gradle.org doesn't let me
remove the bad versions.

Change-Id: I9eef512633b461ff5a7fcbe11a3e104efb250d61
Reviewed-on: https://go-review.googlesource.com/12538
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-22 22:16:26 +00:00
Hyang-Ah (Hana) Kim 103c0611a8 bind/java: suppress compiler warning
non-varargs call of varargs method with inexact argument type for last
parameter

Change-Id: I7623951c365b8cf899a17ee784c8d4f3b4bdb198
Reviewed-on: https://go-review.googlesource.com/12528
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-22 21:01:20 +00:00
David Crawshaw de4ba64cf5 app, event/key: keyboard events
First cut of events from physical keyboards.
Simple darwin/amd64 implementation.

Change-Id: I6e9d0a253387c841864ca9845ee729ea4f7573c7
Reviewed-on: https://go-review.googlesource.com/11815
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-22 20:09:27 +00:00
David Crawshaw 34f7142b5a app: be more careful about android redraw events
EGL is a poor source of window dimensions. On some fraction of
rotations, it reported the old dimensions. Switch to extracting the
data from ANativeWindow, which appears to be more reliable.

While here, plumb through orientation, and follow the recommendation
in the Android platform docs to block onNativeWindowRedrawNeeded
until the draw is complete.

Fixes golang/go#11741.

Change-Id: I6b29b6a1e5743c612c9af2a8cce4260c5d7e9ca6
Reviewed-on: https://go-review.googlesource.com/12381
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-22 15:25:30 +00:00
Burcu Dogan 09206a7c58 cmd/gomobile: test ios builds
iOS builds have been broken due to missing main executable. Xcode
doesn't complain and buildling the target .app bundle even if a
referenced objects doesn't exist.

Fixing .app builds and adding a unit test.

Change-Id: Ie9aec6c8c982a96c10bf07344e44bd501fcabd19
Reviewed-on: https://go-review.googlesource.com/12492
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-21 22:09:02 +00:00
Burcu Dogan a1efd1d6c6 cmd/gomobile: use package path as the app name
If the application main package is in

  golang.org/x/mobile/example/basic

the generated application will have "Basic" as its name.

Change-Id: Ic59fae6e18c26e406ab352265aa2d6b11619c102
Reviewed-on: https://go-review.googlesource.com/12435
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-21 21:11:27 +00:00
Florin Patan 6256dc3e64 example/network: use correct app event filter
This change allows the example/network from gomobile to compile
correctly.

Change-Id: Id0f722796e0224ec4a7c06b163a25a4f3a5fbcb3
Reviewed-on: https://go-review.googlesource.com/12471
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-21 14:54:22 +00:00
David Crawshaw 5f9cda1c8a cmd/gomobile: build .framework for iOS bind
Tested manually, I can bind github.com/hyangah/ivy and include it
in an Xcode project.

Change-Id: I7dfa7828da7288841bc930d3e506ee97bf2ca520
Reviewed-on: https://go-review.googlesource.com/12388
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-20 20:49:37 +00:00
David Crawshaw bebbf49ba9 cmd/gomobile: consolidate os/exec Run calls
Tested:
	go test golang.org/x/mobile/bind/java
	gomobile bind -target={ios,android} github.com/hyangah/ivy
	gobuild build -target={ios,android} golang.org/x/mobile/example/basic

	(With various takes on -x and -v.)

Change-Id: I15c8f605490381feb6fefb482110f2a1c210529d
Reviewed-on: https://go-review.googlesource.com/12411
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-20 17:45:43 +00:00
David Crawshaw c9adc5b29d cmd/gomobile: build for iOS with -tags=ios
Fixes golang/go#11782.

Change-Id: Ifa23a3cbe0032972f7c5c122ac1689441b63334e
Reviewed-on: https://go-review.googlesource.com/12387
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-19 20:54:12 +00:00
Nigel Tao c4654583ad event/touch: rename TypeStart to TypeBegin.
Change-Id: Ie8392cd6167fca1c0a7f10192824300d7885151d
Reviewed-on: https://go-review.googlesource.com/12342
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-18 04:39:45 +00:00
Jae Kwon 96f72abd68 cmd/gomobile: expect GoNativeActivity in external manifests
gomobile expects GoNativeActivity, otherwise current_ctx_clazz stays
null.
Fixed cmd/gomobile/manifest.go to expect GoNativeActivity, and fixed the
network example app.

Change-Id: Idad6f9bec2fcbc876fbd6013009582868ad3e133
Reviewed-on: https://go-review.googlesource.com/12374
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-18 02:39:09 +00:00
Hyang-Ah (Hana) Kim 32ad533813 example/audio: use the latest config.Event in arranger func.
Change-Id: I452e9e7e37a983421acac23ab265b822fbc3db19
Reviewed-on: https://go-review.googlesource.com/12339
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 19:53:07 +00:00
David Crawshaw 9359647d9e app: remove Callbacks and Run
It has to go sometime.

Fixes golang/go#10896.

Change-Id: I2ac1437e1d5913c09060931454bf11c3f742ef87
Reviewed-on: https://go-review.googlesource.com/12337
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 17:58:59 +00:00
David Crawshaw c8a8acd495 example/sprite: move to events
Change-Id: I5f5b2aee9edebc7b50ee98e23da5f0fa7e06112d
Reviewed-on: https://go-review.googlesource.com/12335
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 17:57:13 +00:00
David Crawshaw 3ee73d9a25 example/audio: move to events
Change-Id: Ib6971e48abfa16b995d815ab37077c83940b9096
Reviewed-on: https://go-review.googlesource.com/12336
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 17:42:28 +00:00
Hyang-Ah (Hana) Kim 4e8e86aef1 README.md: add caution. shorten the README.md.
Change-Id: I0af72721dcb6ef9115fde7fa2223f6884b6fe52e
Reviewed-on: https://go-review.googlesource.com/12334
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 17:06:14 +00:00
David Crawshaw ea6f260cd0 cmd/gomobile: update tests and add bind tests
Change-Id: I9e2fdf179b1e07a8b0d9b612913814768f8284dc
Reviewed-on: https://go-review.googlesource.com/12331
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 16:18:56 +00:00
David Crawshaw 7d5958d761 cmd/gomobile: pass -gcflags and -ldflags
Allows the use of -X, and similar flags.

Fixes golang/go#11645.

Change-Id: I0ca097059f5f70c277c79eb89f2cbb10890db802
Reviewed-on: https://go-review.googlesource.com/12333
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-17 14:09:01 +00:00
Nigel Tao 0d322895cb exp/sprite/portable: use golang.org/x/image/draw.
Change-Id: Ib41fd6614e3a5504d0cebe9a84b23a675d0e88fd
Reviewed-on: https://go-review.googlesource.com/12289
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 04:52:29 +00:00
Nigel Tao 84f8e5edcc event: move event.Filter to app.Filter.
Change-Id: I11044a6e01b53e441c05fc1baec36718e783622f
Reviewed-on: https://go-review.googlesource.com/12288
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-17 01:18:36 +00:00
Hyang-Ah (Hana) Kim 136fa9bbbb bind/java: reenable asset access.
This is done by moving app.Context to internal/mobileinit,
introducing mobileinit.SetCurrentContext and,
making bind/java depend on it.

TODO: check gomobile bind's proguard rule - context lookup
was implemented through reflection on android.app.AppGlobals class.

Change-Id: Ieb6ad503eeef8c2c1c5836a21c667938c5a701a2
Reviewed-on: https://go-review.googlesource.com/12279
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 21:15:37 +00:00
David Crawshaw c6888a7bae example/network: rewrite to use event loop
Change-Id: Ibcf8fa9aec7327e98d4a0cdb5c37bb39bcc41bf8
Reviewed-on: https://go-review.googlesource.com/12278
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-16 20:19:15 +00:00
David Crawshaw 9300366e65 cmd/gomobile: use new -pkgdir flag
The go command now has a -pkgdir flag, which specifies a directory
for all install output, including the standard library. Use it to
build the mobile compilers under $GOMOBILE, so that targets like
the iOS simulator (darwin/386) do not conflict with system targets.
The result is we no longer need GOROOT to be writable.

The iOS simulator now works with gomobile bind.

Fixes golang/go#11342.

Change-Id: I0bc6378e0cb82e3175b2a1efe355e3ce39533649
Reviewed-on: https://go-review.googlesource.com/12303
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-16 20:10:22 +00:00
David Crawshaw d709f21793 app: fix darwin/arm build
Change-Id: I5ce658362ff24c7ed16a269eab7a5fcdcb5ad019
Reviewed-on: https://go-review.googlesource.com/12302
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-16 18:09:48 +00:00
David Crawshaw ec5d8df4c0 cmd/gomobile: bind -target=ios support
First pass at bind support, simply produces .a/.h files.

In future CLs:

- Take the type defintion from seq.h and place it directly in the
  generated header, breaking the user's dependency on seq.h.

Open question for future CLs:

- Should we create a framework directory?
  If we bundle assets in the directory, can the asset package
  find them automatically?

In 1.6: support multiple archives.

Change-Id: I7c3f655e7653018333e3ce3c89807edfcf62906d
Reviewed-on: https://go-review.googlesource.com/12199
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-16 17:25:44 +00:00
Hyang-Ah (Hana) Kim 6fb2670129 bind/objc: Remove reference of seq.h from generated header file.
This allows gomobile bind to stop copying seq.h to the destination.

Change-Id: I4a23613fe0407500ad483ae9d8f6bb823d82f082
Reviewed-on: https://go-review.googlesource.com/12300
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 14:02:16 +00:00
Nigel Tao b43065626f app: rename EndDraw to EndPaint.
Change-Id: I3e38df0e21be2246dd16886fa00c9360d42db145
Reviewed-on: https://go-review.googlesource.com/12282
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 03:33:11 +00:00
David Crawshaw 460bd28e6c example/basic: rewrite to use event loop
Change-Id: Ic7d8557c42b17238f3dae7fc9287a7cdb5f55eb1
Reviewed-on: https://go-review.googlesource.com/12272
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-16 03:17:43 +00:00
Nigel Tao e4c6af17e3 event: rename event.Foo to foo.Event.
Fixes golang/go#10444

Change-Id: Ie5a8ab8a09b1b1a4f7037da7cf945d39ab6a98fc
Reviewed-on: https://go-review.googlesource.com/12225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-16 01:03:51 +00:00
Nigel Tao a2120ea61f app: make gl.Viewport calls happen on 'the event thread'.
The gl package is not safe for concurrent use.

Change-Id: Ib0e7908746ea3a6520b2ce2f5d8aa7233ab2642c
Reviewed-on: https://go-review.googlesource.com/12165
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-15 01:03:17 +00:00
Burcu Dogan ac3e8010d5 cmd/gomobile: install should fail for target!=android
Change-Id: I1c21e7aab2b283927e732a5ec8420b4c36cfae91
Reviewed-on: https://go-review.googlesource.com/12090
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-14 19:23:04 +00:00
David Crawshaw c8fe70554f cmd/gomobile: use standard env to run Go tool
Now that we no longer modify the user's $GOROOT and run make.bash,
the need for isolating the environment is gone. Pass through
whatever users want, overriding only those necesssary for corss
compilation.

While here, remove some dead code.

Fixes golang/go#11672.

Change-Id: Iaf867913eaa1311519a4d5a7a8169228ebf21346
Reviewed-on: https://go-review.googlesource.com/12128
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-14 10:24:28 +00:00
David Crawshaw 83f38234e7 Dockerfile: delete
No longer necessary now we have the gomobile tool.

Fixes golang/go#10522.
Fixes golang/go#9823.

Change-Id: I21a793507cfd4d72c37a9e5c9f2d16d9b5622bd2
Reviewed-on: https://go-review.googlesource.com/12126
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-14 10:24:05 +00:00
David Crawshaw 7deab368af app: ensure gl work is drained before endDraw
If a frame draw cycle does not end in a blocking GL call,
then the app package may process the <-endDraw before the
final <-gl.WorkAvailable, meaning some GL calls miss the
frame.

So we make sure the final GL call for a frame is blocking.

Fixes golang/go#11696.
Fixes golang/go#10688.

Change-Id: I39772a3308c98947b1f0838ad58d1d406a711e7f
Reviewed-on: https://go-review.googlesource.com/12123
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-14 10:21:53 +00:00
David Crawshaw 21587585e9 cmd/gomobile: switch to Android NDK r10e
Tested darwin/amd64, carefully inspected linux/amd64.

Change-Id: I237ffe446ea275911e2d44a33fc27d179924b528
Reviewed-on: https://go-review.googlesource.com/12122
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-13 23:41:23 +00:00
David Crawshaw fa6f31145f cmd/gomobile/release.go: add NDK r10e
Note that darwin/386 is no longer released by the Android NDK.

Change-Id: Ie9d5105884db45a10716637980e8352c855293a0
Reviewed-on: https://go-review.googlesource.com/12121
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-13 19:56:57 +00:00
David Crawshaw 8f20c3e9d3 app, cmd/gomobile: subclass NativeActivity
Subclassing NativeActivity makes two things possible. Firstly, we can
implement an InputConnection to offer good support for IMEs,
necessary for good keyboard support. Secondly, we can use it to
overlay WebViews onto the NativeActivity.

But to sublcass NativeActivity, we need to compile Java. To keep the
toolchain go gettable, this is done with go generate.

While here, check the exception after FindClass. Apparently it can
throw an exception.

Updates golang/go#9361.
Updates golang/go#10247.

Change-Id: I672545997f0c9a7580f06988a273c03404772247
Reviewed-on: https://go-review.googlesource.com/11980
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-13 19:05:26 +00:00
David Crawshaw e5193c59b3 cmd/gomobile: reorganize build logic
The goal here is to remove several inconsistencies between
-target=android and -target=ios support, along with making the flow
of the command follow the path you might expect given a certain set
of flags, and preparing for `gomobile bind` support of ios. In
particular, building non-main packages now works with both targets
and the initialization of global build state is clearer.

The reorg also is designed around an nm trick I thought of
yesterday to do better package import scanning without a slow
all-file scan. This will give better detection of x/mobile/app and
x/mobile/exp/audio/al packages. There's a TODO about it, and I'll do
it in a future CL.

Tested with:

	go test golang.org/x/mobile/cmd/gomobile
	gomobile init
	gomobile bind golang.org/x/mobile/asset
	go test golang.org/x/mobile/bind/java
	gomobile build -target=ios golang.org/x/mobile/example/basic
	gomobile build -target=ios golang.org/x/mobile/gl
	gomobile build -target=android golang.org/x/mobile/gl
	gomobile build -target=android golang.org/x/mobile/example/basic
	(Along with manual testing of basic on an android device.)

That might make a pretty good _test.go.

Change-Id: I41230008c3c15db25a11c33b9eaca4abada9f411
Reviewed-on: https://go-review.googlesource.com/12051
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-13 18:54:16 +00:00
Meir Fischer 7fb893ba43 mobile/exp/audio: use correct indefinite article prior to PCM
There is currently one usage of "an" prior to "PCM". The indefinite
article usage prior to an acronym is determined by the
pronunciation of that acronym's first letter. If the pronunciation
starts with a consonant, "a" is used. If the pronunciation starts
with a vowel, "an" is used.

Usage
https://en.wikipedia.org/wiki/Pulse-code_modulation

Note that there is currently a correct usage in the same file on a
different line: "a PCM header"

Change-Id: Id7749d20722a5cc9b96ecfe466be66fe3c76ab2b
Reviewed-on: https://go-review.googlesource.com/12083
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-13 15:00:26 +00:00
Burcu Dogan c39753dbd1 cmd/gomobile: pipe xcodebuild stdout in verbose mode
Fixes golang/go#11488.

Change-Id: I1ff2ca25dd1013d603d6f60d1e8f6e5c58c5b0ee
Reviewed-on: https://go-review.googlesource.com/12002
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-11 18:26:50 +00:00
Burcu Dogan adcf40b30c exp/audio/al: avoid creation of multiple contexts
This CL reverts the changes made in golang/go#11299.

Allowing creation of multiple contexts break the case of multiple
third party packages depending on the al bindings. These packages
need to make sure that there is a valid current context or initiate
and make a context current. Packages racing to create and make a
context current is what we would like to avoid.

Therefore, al bindings will support only a single context that is
initiated during OpenDevice.

Fixes golang/go#11385.

Change-Id: I662f70e49d12833a545005cf0724cc21f67bea09
Reviewed-on: https://go-review.googlesource.com/12001
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-11 16:23:18 +00:00
Elias Naur ca1abe50ca x/mobile/internal/mobileinit: revert Android log prefix
CL 11981 changed the Android logcat prefix from "GoLog" to "GoStdio".
Revert the prefix to "GoLog".

Also remove a global variable left unused by CL 11981.

Change-Id: I500313652cd618d8573640d5165e5069a0ba0ba7
Reviewed-on: https://go-review.googlesource.com/11991
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-11 11:50:45 +00:00