Commit graph

10251 commits

Author SHA1 Message Date
Eric House
58fc0e9b81 snapshot on the way to working tile picker
New classes implement custom alert and its view, where most of the logic
for putting up one button per tile, hiding and showing buttons based on
what's left, etc. lives. Rough, but works well until rotated, when gets
redrawn without spaces for the buttons that could come back.
2017-03-14 07:23:30 -07:00
Eric House
a804983b8e fix makeIntArray to work for non-32-bit array sources 2017-03-13 19:32:20 -07:00
Eric House
aa4d7e3d97 remove blocking alert stuff
The crazy hack to get around Android's lack of modal dialogs is at long
last gone. Remove semaphore and code that uses it. Will leave the
background thread in place, at least for now, as removing it would be a
huge change.
2017-03-10 08:48:37 -08:00
Eric House
1cd863b877 fix assertion around out-of-order tile assignment
Got a crash opening games where tile pick was on and first player was a
robot. Cause: non-robot player's tiles were being assigned before the
robot's, and the move stack didn't like the out-of-order assignments.
Now we assign tiles in order as before, but pause each time we find a
non-robot that needs to pick its own.
2017-03-09 21:40:19 -08:00
Eric House
6e5973c55b toward making tile picking work through rotations
Make face-up tile picker util method return void and add mechanism for
passing in selected tiles asynchronously, as has been done recently with
the rest of the once-blocking util callbacks. Works perfectly in the gtk
case. Likely crashes in curses (if picking face-up option is on.) In
java all the callbacks are there but rather than put up a UI we pretend
the user says "pick 'em for me" each time. Putting up a UI is next.
2017-03-09 20:36:14 -08:00
Eric House
70b3aaa263 modify function to be more useful 2017-03-09 19:35:07 -08:00
Eric House
618f9cf20a toward rotation-safe invite dialog
Rewrite the overly-complex invite dialog that's posted when a game opens
and is missing players so that it doesn't crash after an orientation
change. It's still possible to dismiss it yet have the game stay open.
The goal is that a game in that state always has a dialog on top of it
so you don't get confused about e.g. why you don't have tiles, but
there's more work to be done there.

Also added a common superclass for all my DialogFragments. It may be
useful e.g. for having each DelegateBase instance able to track what
dialogs it currently has up, e.g. to have a policy about how many of the
same class can be live. I'm thinking here of how to prevent a
robot-vs-robot game from ending with a stack of 25 move reports. (The
change here is that the old activity.showDialog(int) only allowed one at
a time, and some of my logic takes that for granted.)
2017-03-07 07:48:46 -08:00
Eric House
0980bcfbe5 fix another class cast exception
But this is by inspection and, involving a dialog that is no longer
posted, could probably never occur.
2017-03-07 07:35:16 -08:00
Eric House
9211d6b765 fix class cast exception
Problem with subverting type checking is compile time errors become
runtime...
2017-03-07 07:08:48 -08:00
Eric House
83f7a9cec1 fix dismissal of invite/wait alert
There were multiple places launching it, which in a DialogFragment
world (in the absence of other per-dlg-id controls) means stacked
multiple alerts. And dismissDialog() didn't work. So use a boolean to
prevent more than one being posted and keep a reference to the
DialogFragment behind it in order to be able to call dismiss() on
it. That's the only place I was calling dismissDialog() (other
than the tile-picking stuff which has to be rewritten anyway) so this
little hack is probably ok.

This alert still gets messed up with the screen config changes. Fixing
that is next.
2017-03-01 07:23:50 -08:00
Eric House
5e23d6fc75 remove unused variable 2017-03-01 06:14:35 -08:00
Eric House
05d583a324 fix timers: don't clear in snapshot case
Back in August I "fixed" timers running after the board was cleared but
didn't realize that util contexts were shared by snapshot
boards. Clearing those timers when the board's destroyed was stopping
timers for a visible board as well. So I added a boolean indicating
whether to clear timers. Ref counting or similar would be better, but a
lot of work given the concept isn't really in the common/ code at
all (outside of dicts...)
2017-02-27 20:20:25 -08:00
Eric House
b849ad4db3 Merge branch 'android_branch' into rotation_fix 2017-02-27 18:49:57 -08:00
Eric House
d865812002 failing to find an .apk is not an error 2017-02-27 18:31:17 -08:00
Eric House
19a7b7e146 fix assertion: we do handle that case 2017-02-24 09:12:11 -08:00
Eric House
48bd5d7f1d fix posting of dialogfragments from preferences
I can't get preference fragments working in my world (mostly because
nested PreferenceScreens don't open when clicked on and the workarounds
for that are too complex) so next best thing is to fix alerts to work on
top of prefs activity. That involves creating a new transparent activity
that subclasses XWActivity and has a DelegateBase subclass. Launching an
alert is then just a matter of passing DlgState into the new activity
via an Intent, at which point everything Just Works. Button clicks are
returned via an intent as well.
2017-02-24 08:56:31 -08:00
Eric House
ff99e89e9d fix compiler warning 2017-02-22 22:39:32 -08:00
Eric House
70a99b39fb remove dictGone dialog
There's no way to get it invoked. I think that's a bug, but when it
comes back it'll come back in different form.
2017-02-22 22:35:19 -08:00
Eric House
2a4bce4ad1 remove Context ivar from CurGameInfo
It claimed to be Serializable but wasn't: Crash. Now it is.
2017-02-22 22:29:02 -08:00
Eric House
1de838171b make sms enabling alert dialog-fragment-based 2017-02-22 22:11:24 -08:00
Eric House
56dfef828d move launch into PrefsDelegate
Following pattern for most, though may never have dual-pane option.
2017-02-22 07:46:14 -08:00
Eric House
cfd467f7d6 fix class-cast exception 2017-02-21 21:35:35 -08:00
Bernard Massot
c0c2527258 Translated using Weblate (French)
Currently translated at 99.3% (765 of 770 strings)
2017-02-21 12:44:53 +01:00
Eric House
c271202faa make bad phonies alert non-blocking
Continue conversion of alerts that required blocking the JNI thread. Now
board_commitTurn() takes a second boolean indicating whether phonies
found have been approved by user. Common code informs user, and if he
approves client code calls board_commitTurn() again. In case where
turn's lost there's no call to make back, but there's the undesirable
change that if a robot moves next its move will be reported on top of
the turn-lost alert. Ideally new alerts would appear under, not on top
of, those that have not yet been dismissed.
2017-02-20 07:20:19 -08:00
Eric House
42aef7b85c add UI to set phoniesAction creating new gtk games 2017-02-19 15:05:40 -08:00
naofum
ba780692e6 Translated using Weblate (Japanese)
Currently translated at 100.0% (770 of 770 strings)
2017-02-19 12:34:43 +01:00
Weblate
380ae5bf1f Merge remote-tracking branch 'origin/android_translate' into android_translate 2017-02-19 06:39:12 +01:00
Eric House
81d428a16d fix crash by adding missing param 2017-02-18 19:20:14 -08:00
Eric House
5f12d1a03b assign faces to blanks asynchronously
Next step in converting util_ methods that required blocking: blank tile
assignment. Now post a query and add a method that the client code can
call when the user's decided. Include enough state (col, row, and
playerNum) so that it's probably pretty safe.
2017-02-18 19:16:32 -08:00
Eric House
ca6edcfc9a make trade and move confirm non-blocking
Probably breaks curses build, but for gtk and Android
turn move and trade confirmation into a two-step process, making
board_commitTurn() non-interactive when called with a second
parameter. The old blocking util methods now return void and it's up to
the client code to interact (on the main thread) then re-call
board_commitTurn() if appropriate.
2017-02-17 08:58:20 -08:00
Eric House
1f2f4506c4 remove unused query option. Less to convert. 2017-02-17 06:30:54 -08:00
Eric House
2a0b21e5e8 make password fetching non-blocking
First attempt to stop blocking the jni thread: instead of returning a
password from a util_ method, have it include enough state that the UI
can return, put up a dialog, and then pass that state and the password
back and have them matched up again. I think this will work for the
remaining blocking Alerts too.
2017-02-17 06:23:44 -08:00
Joan Montané
081fa7b0f3 Translated using Weblate (Catalan)
Currently translated at 92.9% (714 of 768 strings)
2017-02-17 09:44:16 +01:00
Eric House
4d5278704e symlink changed! 2017-02-16 19:05:34 -08:00
Eric House
c088e36113 fix crash; use params
Pass blank-picking params through rather than using instance variables.
2017-02-16 07:59:10 -08:00
Eric House
e631d57e9b convert remaining DelegateBase Alerts
Includes a hack in DBAlert that's required I think because
GameConfigDelegate is launched "for result". onCreateDialog() always
fails after a rotation the first time because GameConfigDelegate isn't
there to have its makeDialog() dispatched to. So it puts up a dummy
alert and then post()s code that is successful in calling makeDialog()
to get an alert from GameConfigDelegate that can replace the
dummy. Nothing shows on the screen on simulator anyway.

The major problem remaining is that blocking alerts in BoardDelegate are
recreated after rotation but the thread that was blocking has been freed
so nothing can be done after the new alert returns. E.g. blank tile
picker will be posted again, user will pick a tile, but the common
code's not in a state to do anything with that choice (which cannot even
be "returned.") Options are to find a way to make the JNIThread survive
the configuration change without unblocking or to rewrite all the common
code to not expect return values from util_ methods.

This commit is not well tested, and diffs don't allow a thorough check
of the conversion of each DlgID type.
2017-02-16 07:25:20 -08:00
Eric House
13adebdc51 support alert onDismiss listener
New way of adding onDismiss listener to DialogFragment-based alerts
required API change to DBAlert and the makeDialog() method.  Fixes
customizing default player name.
2017-02-15 07:28:39 -08:00
Eric House
f5c022bb72 move show(DialogFragment) to XWActivity
First of probably many bugs running new alert changes in
non-dualpane-mode: Activities get to show dialogs too!
2017-02-15 06:44:01 -08:00
Eric House
8e874fa45c fix dispatch of extra actions
Had left out dispatch of "negative" buttons populated from an
ActionPair. Tested for offer to remove redundant new game buttons at
bottom of games list.
2017-02-15 06:37:25 -08:00
Eric House
a526ec6529 new gradle version (recommended by AS) 2017-02-15 06:35:23 -08:00
Eric House
507f6001fa convert another to DialogFragment 2017-02-13 06:09:25 -08:00
Eric House
07da48db73 replace activity.show(dlgID) with fragment-based
For GamesListDelegate only so far, replace calling <activity>.show(int)
to launch an Alert with something producing and showing a
DialogFragment. Replaces passing and saving state inside the
DelegateBase subclass with saving it as part of the fragment's bundle,
and it looks as if a single class will work for nearly all of the alerts
managed by DelegateBase.{onCreateDialog,prepareDialog}(), which will
eventually go away. The beauty is that the implementations of
onCreateDialog and onPrepareDialog remain, but as the body of a new
makeDialog() that's called by the fragment's onCreateView. Less code
changes, but now it's all called every time an alert's created.
2017-02-12 15:33:35 -08:00
Eric House
c66764bd77 make lookup alert fragment-based 2017-02-10 08:41:28 -08:00
Eric House
b69eb30e9c use the recommended pattern for DialogFragment construction
Empty constructors only...
2017-02-10 07:17:53 -08:00
Eric House
8c92f2012e file/class name change 2017-02-10 06:40:56 -08:00
Eric House
92e150bb1e convert confirmThen alert 2017-02-10 06:00:26 -08:00
Eric House
c9bc7b6c49 convert ok-only dialog to fragments 2017-02-10 05:47:17 -08:00
Eric House
a724ef734f add forgotten file 2017-02-10 05:40:18 -08:00
Eric House
e69824ece0 remove Runnable from DlgState
Can't be serializing Runnables, so replace with an Action that's sent
via onPosButton.
2017-02-09 09:08:03 -08:00
Eric House
470ee6eaa4 rebase invite choices alert on fragments
And create a common superclass for alerts coming out of DlgDelegate
2017-02-09 08:14:44 -08:00