Commit graph

9934 commits

Author SHA1 Message Date
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
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
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
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
Eric House
7c39bf6064 call via activity in common case too 2017-02-09 06:41:38 -08:00
Eric House
939688e3cd change DlgClickNotify methods to return boolean
So dispatching over possible targets can stop when one has handled it.
2017-02-09 06:23:41 -08:00
Eric House
796192380f switch not-again alerts to being fragments
Since associated DlgDelegate instance doesn't survive a rotation, needed
to pipe results through a DlgClickNotify implementation on XWActivity
that then dispatches in the DualpaneDelegate case to all visible
fragments. I hope this turns out to work for all DlgClickNotify
implementations as I switch them over. We'll see.
2017-02-09 06:19:37 -08:00
Eric House
e863cc1a4b experimental on-device log-saving script
Add script that when copied to device and run from 'adb shell' captures
all app and OS logs to file. Next: add code to XWApp.java to copy it
from assets/ and run it on launch.
2017-02-08 07:01:38 -08:00
Eric House
b1f095b56e prevent loading of WiDirService on older android
On 2.3 anyway there's a java.lang.VerifyError trying to load that
class. So wrap the loading in a new class that catches the error and
sets a boolean so subsequent calls don't need it. There are other calls
that could load the class, but they may not be reachable. To be tested.
2017-02-08 06:33:06 -08:00
Eric House
683eb8e14b don't remove alerts in onStop()
Required to fix alerts going away now that orientations are handled by
the OS (which in turn is the preferred way to do things now since not
ALL config changes CAN be handled by the OS.) With this change some
alerts will probably cause crashes during a rotation. Those all need to
be fixed.
2017-02-07 07:04:27 -08:00
Eric House
0e23c191b5 convert About alert to DialogFragment
As a first experiment. Untested on non-dualpane and on older OS
versions.
2017-02-07 07:02:16 -08:00
Eric House
121c35b728 don't expect View to survive a rotation 2017-02-06 19:18:15 -08:00
Eric House
69eee734e2 cleanup: switch on ids rather than test views 2017-02-04 10:28:23 -08:00