Commit Graph

558 Commits

Author SHA1 Message Date
Burcu Dogan 5651add1eb exp/sensor: initiate the darwin/{arm,arm64} backend
The CL provides accelerometer events only, upcoming CLs will add
support for gyroscope and magnetometer.

Change-Id: Ib5629ca7c49c9dfc8ca533fe7acde371efc102b2
Reviewed-on: https://go-review.googlesource.com/14036
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-03 02:10:28 +00:00
Hyang-Ah (Hana) Kim 9e2ad8c60e example/ivy/android: configure version code/name (3/1.0.2)
Change-Id: I378f41a54c7bb6cf81988c344a086e6a506e9dfe
Reviewed-on: https://go-review.googlesource.com/14202
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 21:16:25 +00:00
Hyang-Ah (Hana) Kim e565eadcd6 example/ivy/android: fix problems caused by old bugs in WebView.
1) Clear button did not shrink the WebView size. It's an old bug in
Android WebView, and fixed recently (android-L, maybe). This CL avoids
the problem by replacing the webview with a freshly allocated new webview
object. It's heavy-weight, but the Clear event should be rare.

2) ScrollToBottom from the java side and the java script side interacted
strangely and prevented long results from displayed properly.

Also,

- now the gomobile bind generates the Java class in the
org.golang.ivy package. (ivy/build.gradle)

- modified the javascript in tape.html so long result texts are not
shortened initially. (tape.html)

Change-Id: I60660f3392cf17719daad4af89e05c2d82788175
Reviewed-on: https://go-review.googlesource.com/14201
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 14:49:09 +00:00
David Crawshaw 471eeebd99 cmd/gomobile: always display stdout from abd
Fixes golang/go#12418

Change-Id: Ie0f2e669b3e516787b548c69a624e9063cd7f68f
Reviewed-on: https://go-review.googlesource.com/14160
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-02 14:17:25 +00:00
Hyang-Ah (Hana) Kim fee22db634 example/ivy/android: initial check in.
This version is not yet released to Play store.
Compared to the version in the play store

- fixed the reappearing keyboard bug
- allows app install on SD card
- when demo is enabled, the demo mode message is displayed
- when demo is enabled, the submit action button appears next to the
  edit text.
- use robpike.io/ivy/mobile instead of the wrapper in my personal repo.
- the demo script read code was moved from go to java.
- use the up-to-date help message retrieved with mobile.Help.
- textview was replaced with webview with javascript.

TODO: the app built from this code doesn't work in old android devices.
Next cl will fix it.

TODO: build instruction - not very different from
golang.org/x/mobile/example/bind/android.

Change-Id: Ifb594b79f31091b6864ec3e0d8dbaff7986a5afc
Reviewed-on: https://go-review.googlesource.com/13870
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-02 05:29:24 +00:00
Hyang-Ah (Hana) Kim 4a6caa5fd7 cmd/gomobile: bind allows custom package path/prefix.
New option -javapkg for -target=android, and -prefix for -target=ios.
Fixes golang/go#9660.

Change-Id: I9143f30672672527876524b38f450629452a3161
Reviewed-on: https://go-review.googlesource.com/14023
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-01 19:17:05 +00:00
Meir Fischer 00865a642f bind: improve readability for float default values
To improve readability for default numeric types
represented as strings, use 0.0 for floating point types.
(No tests make use of this change so golden update
not necessary; not significant enough for new test/test mod.)
Fix spelling on error statement; this was the only
instance of that spelling error in the repository.

Change-Id: I373890725b33da11c6780ba93674d89541bf758c
Reviewed-on: https://go-review.googlesource.com/13645
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-09-01 18:16:37 +00:00
Burcu Dogan 9ddeada810 exp/sensor: provide sensor events from the app event channel
We are also limiting the number of sensor managers to one.
The application provide sensor events to third-party packages
by consuming them in the main.

An application will be able to consume the sensor events similar
to the other events.

package main

func main() {
  app.Main(func(a app.App) {
    // enables the accelerometer
    sensor.Enable(a, sensor.Accelerometer, 100*time.Millisecond)

    var sz size.Event
    for e := range a.Events() {
      switch e := app.Filter(e).(type) {
      case sensor.Event:
        log.Println(e)
      }
    }
  })
}

Change-Id: Iaad1c59f8d2322c7620df62ed9b9283c91746fa8
Reviewed-on: https://go-review.googlesource.com/13983
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-01 04:44:55 +00:00
Nigel Tao b5b6051b23 event/size: add an Event.Size method.
This is similar to the Event.Bounds method. Some functions in other
packages take an image.Rectangle (i.e. bounds), others take an
image.Point (i.e size).

Change-Id: Ie892a8902992d4e6b9edfbf6d12342297fae4068
Reviewed-on: https://go-review.googlesource.com/14003
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-01 00:58:08 +00:00
Hyang-Ah (Hana) Kim 671f57b233 bind: fix interface methods' multiple return values handling.
Fixes golang/go#12403

Change-Id: I9b8e6d69beb1ceb27e991348212acb5054497e47
Reviewed-on: https://go-review.googlesource.com/14077
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-31 16:32:47 +00:00
David Crawshaw 0c8c4ad3bc cmd/gomobile: revert dex change made in 54c0a36
There is no change to GoNativeActivity.java in cl/14039, so there
should be no change to the generated dex file. Confirmed with go
generate in a clean client.

Change-Id: I37ad615716d6ab6cd6e492b2145e1a71228f79ae
Reviewed-on: https://go-review.googlesource.com/14078
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-31 13:19:12 +00:00
Burcu Dogan 54c0a36309 cmd/gomobile: *.aar and *.framework files are libraries
It seems like shared library terminology has left as a legacy
from the days bind command only supported Android and bind was
generating shared libraries as an output.

Additionally, rewording the mention of apks and apps.
These libraries aren't generated for apk or apps but Android IDE
or Xcode projects.

Change-Id: I46dd56ddccde2d2526fa9b69f700c48c5dd474db
Reviewed-on: https://go-review.googlesource.com/14039
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-31 05:15:54 +00:00
Burcu Dogan 1b518ad9d6 cmd/gomobile: capitalize the app name on android
Fixes golang/go#12376.

Change-Id: Ibc48d309a6f15953939550c271033d889721553c
Reviewed-on: https://go-review.googlesource.com/13982
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-28 15:23:09 +00:00
Hyang-Ah (Hana) Kim c384607ef3 bind: support for custom java package name and objective-c prefix.
Introduce options -javapkg and -prefix for gobind command.

The following generates java class Testpkg with package name com.example.

gobind -lang=java -javapkg=com.example testpkg

The following generates objective-c files where function and type names
are prefixed with ExampleTestpkg.

gobind -lang=objc -prefix=Example testpkg

As discussed in golang/go#9660 and golang/go#12245.

Gomobile support is not yet implemented.

Change-Id: Ib9e39997ce915580a5a2e25643c0c28373f27ee1
Reviewed-on: https://go-review.googlesource.com/13969
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-28 13:57:06 +00:00
David Crawshaw 4628c38e0f bind: handle unimplementable interfaces
Fixes golang/go#12330

Change-Id: I1568d04b7e48242105a7028ca471e2138f684eeb
Reviewed-on: https://go-review.googlesource.com/13946
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-27 21:36:14 +00:00
Hyang-Ah (Hana) Kim ac03bee8c3 exp/sprite/portable: fix broken build
Change-Id: I4eb6dc6a98366ad978f9fa2367b518ccfffee363
Reviewed-on: https://go-review.googlesource.com/13970
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-27 17:25:15 +00:00
David Crawshaw 11fe695b54 bind: support fields with type error
Fixes golang/go#12328

Change-Id: I42872d26acb1c44522a64405cfa2d0f10fb24485
Reviewed-on: https://go-review.googlesource.com/13919
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-26 20:25:55 +00:00
David Crawshaw 905c19f8c0 internal/mobileinit: remove format string warning
Change-Id: I9b0e9680395dcfdf0e6c03a5847ea619e570a2ed
Reviewed-on: https://go-review.googlesource.com/13918
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-25 16:39:13 +00:00
Hyang-Ah (Hana) Kim da28dd9045 bind/objc: fix error return type handling
Fixes golang/go#12307.

Change-Id: I5560b616a3cd51c536d9e5529745681effe26e9a
Reviewed-on: https://go-review.googlesource.com/13913
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-25 15:22:55 +00:00
Hana Kim 979ebcea99 cmd/gomobile: make test pass in windows.
Change-Id: I189524ddf853b9fd0c5510878cfb2cf33b973345
Reviewed-on: https://go-review.googlesource.com/13875
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-24 21:39:25 +00:00
Hana Kim 49a82fefe3 all: support go get golang.org/x/mobile/... on Windows
Fixes golang/go#12212
Workaround for golang/go#12261 until golang/go#9306 is fixed.

Change-Id: I51c1bcfc92c1553fe2132586a0234b1c1af6aeb1
Reviewed-on: https://go-review.googlesource.com/13745
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-24 21:09:04 +00:00
David Crawshaw 48bd7cbbc7 bind: adjust invalid java package names
Updates golang/go#12273

Change-Id: I8eac3e84d5a473e9ffe45705cea88537573aef61
Reviewed-on: https://go-review.googlesource.com/13873
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-24 21:08:09 +00:00
David Crawshaw 8bf23706cf cmd/gomobile: only install app pkgs on darwin
Unfortunately GLES is not a common package for a linux desktop
to have installed. To avoid bind-based users having to jump
through the hoop of installing GL, disable this performance
optimization on linux for now.

Change-Id: Ic00baef6237dca360f191ec291b6c165eda7ad6e
Reviewed-on: https://go-review.googlesource.com/13874
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-24 21:04:37 +00:00
David Crawshaw 128f53db6d cmd/gomobile: install common dev packages
I often forget to do this. I can't be the only one.

Change-Id: Ia5dfaa6811242758f996de614f80cb42badf327b
Reviewed-on: https://go-review.googlesource.com/13742
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-24 16:01:42 +00:00
Hyang-Ah Hana Kim f9f0ffafe3 cmd/gomobile: reset readonly bits of downloaded files in Windows
os.Rename in init fails in Windows for various reasons. One of them
is the temporary files extracted from NDK, OpenAL archives. For
some reason, some of them have read-only properties.
(golang/go#12212)

> gomobile init
gomobile: rename
 C:\Users\foo\pkg\gomobile\work-427911983\openal\include\AL
 C:\Users\foo\pkg\gomobile\android-ndk-r10e\arm\sysroot\usr\include\AL:
 Access is denied.

We reset the read-only bits of all the extracted files.

Change-Id: Ib958cbedf1b7527ecb5b9318f23fe9437dc7c241
Reviewed-on: https://go-review.googlesource.com/12970
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-24 13:08:21 +00:00
Nigel Tao f4bcb3cc2e exp/sensor: fix nsec to usec conversion.
Also remove an unnecessary constant type conversion.

Change-Id: Iff466553fac450bd531785f4fb4e2be97a991a52
Reviewed-on: https://go-review.googlesource.com/13715
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-08-21 01:49:41 +00:00
Nigel Tao 3a0fcd575e event/key: make Event implement fmt.Stringer.
Change-Id: I453bed283767e0adf5efd271b329a469c0073d69
Reviewed-on: https://go-review.googlesource.com/13733
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-21 01:21:32 +00:00
David Crawshaw ab223cffc9 internal/mobileinit: send iOS logs to ASL
Fixes golang/go#12194

Change-Id: I9ff771336996c19ca43da56e3f8944e79c980a2b
Reviewed-on: https://go-review.googlesource.com/13703
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-20 14:33:19 +00:00
Nigel Tao e959dea03d event/key: implement Code.String, via stringer.
Change-Id: I4acf4f351a30ee64192ed9f896ca31d29fe0397f
Reviewed-on: https://go-review.googlesource.com/13712
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-19 23:59:47 +00:00
Tim Cooijmans 78ac81ee2f cmd/gomobile: Fix issue in init when downloading full NDK.
Fixes an issue where the full NDK could not be downloaded due to a missing execute permission.

Fixes golang/go#12208

Change-Id: I6f432b5021b082693a02a293f50caf6da4d4e379
Reviewed-on: https://go-review.googlesource.com/13669
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-19 19:55:24 +00:00
David Crawshaw 9308ad61ea app: android key code mapping to USB HID codes
Change-Id: I1225f51fd06a5f9a9f0fdf09096982df761b5a51
Reviewed-on: https://go-review.googlesource.com/13678
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-19 14:09:33 +00:00
David Crawshaw b5d916ab12 exp/gl/glutil: extra context error checking
Hoping to learn more so I can debug or replicate the darwin/amd64
builder failure, which is not creating a GL context.

Change-Id: I9f2fe54fbd9a072c65cd37c3b711554d4c71171f
Reviewed-on: https://go-review.googlesource.com/13693
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-18 19:25:21 +00:00
David Crawshaw da78c710f3 bind/testdata: update golden files
Tests now pass on OS X.

Change-Id: Id2e6c5bd9ddd4070962ff9bc121d7902e8c9a647
Reviewed-on: https://go-review.googlesource.com/13694
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-18 17:57:47 +00:00
David Crawshaw 377063dfa4 app: plumbing for physical android key events
This is only the first half of physical key event mapping. The
modifiers and hardware key codes will be in a followup CL. I'm
splitting this out because it covers two other parts of the problem:
first is maintaining a JNIEnv pointer for the main routine, the
second is access to the Android unicode key map. The NDK does not have
a method to give us the key mapping, so we get to it via
GoNativeActivity.

Tested with a USB keyboard. I'll attempt an abd-based unit test later,
but I suspect it will be difficult to set a device ID.

Change-Id: Ie93700d1f2a5d382a9b17cdd668cb4acaa6e4bcc
Reviewed-on: https://go-review.googlesource.com/13649
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-18 13:10:55 +00:00
David Crawshaw 0cfb79fc77 app: test painting using a screenshot
Also catches any bugs that cause painting to lock up after
rotation (of which there have been many).

Change-Id: I3783030efd2c342afebf2b861e9e9dc32e96f659
Reviewed-on: https://go-review.googlesource.com/13616
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-17 16:26:32 +00:00
David Crawshaw 99aacab40d app: attach main thread to the JNI
Ran into this while working on keyboard events. I'm a little surprised
this hasn't been a problem so far -- my understanding of the NDK
functions for working with a NativeActivity is that the require you
hold a valid JNI context before calling them.

Change-Id: Ifd322ef5e8406df648d1a8f667e5ce08ffef954d
Reviewed-on: https://go-review.googlesource.com/13648
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-17 14:38:43 +00:00
Burcu Dogan bb4db21edc readme: link to Mobile wiki page
Change-Id: Iaf87969a9d9c3d324349fa7b3b668c820d5d73ae
Reviewed-on: https://go-review.googlesource.com/13635
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-15 00:05:54 +00:00
Burcu Dogan 25faf494e1 exp/sensor: use a better prefix in C not to pollute the namespace
Change-Id: Iac80d3ca61812ece64ae5127e4b5d1f8c54ff5b3
Reviewed-on: https://go-review.googlesource.com/13620
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-13 17:46:42 +00:00
Burcu Dogan 6ba2a15710 gitignore: ignore builds and IDE configuration files
Change-Id: Ie86cab2161e296471a1b9eb1232b69f360d3240e
Reviewed-on: https://go-review.googlesource.com/13583
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-13 17:32:33 +00:00
Nigel Tao f632204bcc event/config: rename to event/size.
Change-Id: I908b5f0818da32b2b040f430ebcc3762eb6f7570
Reviewed-on: https://go-review.googlesource.com/13601
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-13 13:31:00 +00:00
Burcu Dogan b5583e233e exp/sensor: reorg package to create space for darwin/arm,arm64 impl
Change-Id: I41e4088a92fff2f411dd82102fc3c421d2679c21
Reviewed-on: https://go-review.googlesource.com/13582
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-12 22:18:05 +00:00
David Crawshaw df7e121d2f cmd/gomobile: cleanup and link to wiki docs
Change-Id: Iaaa5208c663f8d1ff8acf1a632b5fe05976d86a4
Reviewed-on: https://go-review.googlesource.com/13610
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-12 16:21:55 +00:00
David Crawshaw ec91477003 app: mention wiki docs in app package docs
Change-Id: I5fc7fe86f47e117e2b09dd16d7a588374b32dd66
Reviewed-on: https://go-review.googlesource.com/13611
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-12 16:21:36 +00:00
Nigel Tao 4ee6e2bd6d app: fix s/spaces/tabs/.
Change-Id: I795a82a8549d250fb9ca33134248fb4ff12bd0a0
Reviewed-on: https://go-review.googlesource.com/13491
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-12 04:16:58 +00:00
David Crawshaw c2f4676407 app: fix X11 build
Change-Id: Ida7cd57eefac66bcff89720ac5c82015d1d37f00
Reviewed-on: https://go-review.googlesource.com/13540
Reviewed-by: Jeffrey Regan <jregan@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-11 19:16:57 +00:00
Hyang-Ah (Hana) Kim 5c55c26446 bind/objc: don't expose internal class types mapped to Go interface.
For interface binding, we need only protocols.

Change-Id: I377ec9c8de0a3414d48272892b169fb94823e8ff
Reviewed-on: https://go-review.googlesource.com/13541
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-11 19:16:10 +00:00
Hyang-Ah (Hana) Kim 73792b1db2 bind: update doc to include objective-C interface type support.
Also mention the current limitation in byte slice binding.
golang/go#12113.

Change-Id: Ie75780c2d203431ca26a188dfdb8f000f6805c18
Reviewed-on: https://go-review.googlesource.com/13531
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-11 16:37:26 +00:00
David Crawshaw 0f9ce16152 app: plumb through android orientation
While I'm here, make pixelsPerPt local on android and darwin/amd64.
The one place where it's global is darwin/arm, which has another
similar global (screenScale).

Change-Id: I5897e7e5341afca1976fdf0215fb4f6fe2f411be
Reviewed-on: https://go-review.googlesource.com/13446
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-11 15:19:09 +00:00
David Crawshaw 354679495a app: always send paint event when bumping gen
When the generation number is bumped, the <-endPaint case will drop
any old paints. So if a new paint isn't sent to replace it, the app
locks up.

This is a bug that looks like it crept into cl/12533 just before it
was submitted. (Sorry.) I'm working on tests as part of adding
android orientation support.

Change-Id: I6b62bdc6774e090b67a5577c3eae7355e3937894
Reviewed-on: https://go-review.googlesource.com/13445
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-11 14:52:42 +00:00
Hyang-Ah (Hana) Kim 2a7a6f0949 cmd/gomobile: use the app names as bundle id in ios.
This fixes the bug - all apps built with gomobile build had the same
bundle id (org.golang.todo.main).

As part of this fix, rfc1034Label function is used to sanitize the app
name (in a similar way of 'rfc1034identifier' formatter). We use this
for Android app package name as well.

Change-Id: Iae1985614a55771bf1849fe66180c4ac736497d7
Reviewed-on: https://go-review.googlesource.com/13041
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-11 14:39:38 +00:00