mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
Merge branch 'android_branch' into gtk_multigame
This commit is contained in:
commit
bf479c4334
6 changed files with 104 additions and 49 deletions
|
@ -79,7 +79,7 @@ public class DlgDelegate {
|
||||||
int[] ids = bundle.getIntArray( IDS );
|
int[] ids = bundle.getIntArray( IDS );
|
||||||
for ( int id : ids ) {
|
for ( int id : ids ) {
|
||||||
String key = String.format( STATE_KEYF, id );
|
String key = String.format( STATE_KEYF, id );
|
||||||
addState( (DlgState)bundle.getSerializable( key ) );
|
addState( (DlgState)bundle.getParcelable( key ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class DlgDelegate {
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
DlgState state = iter.next();
|
DlgState state = iter.next();
|
||||||
String key = String.format( STATE_KEYF, state.m_id );
|
String key = String.format( STATE_KEYF, state.m_id );
|
||||||
outState.putSerializable( key, state );
|
outState.putParcelable( key, state );
|
||||||
ids[indx++] = state.m_id;
|
ids[indx++] = state.m_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,11 @@ public class DlgDelegate {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showOKOnlyDialog( String msg )
|
||||||
|
{
|
||||||
|
showOKOnlyDialog( msg, SKIP_CALLBACK );
|
||||||
|
}
|
||||||
|
|
||||||
public void showOKOnlyDialog( String msg, int callbackID )
|
public void showOKOnlyDialog( String msg, int callbackID )
|
||||||
{
|
{
|
||||||
// Assert.assertNull( m_dlgStates );
|
// Assert.assertNull( m_dlgStates );
|
||||||
|
@ -143,7 +148,7 @@ public class DlgDelegate {
|
||||||
|
|
||||||
public void showOKOnlyDialog( int msgID )
|
public void showOKOnlyDialog( int msgID )
|
||||||
{
|
{
|
||||||
showOKOnlyDialog( m_activity.getString( msgID ), 0 );
|
showOKOnlyDialog( m_activity.getString( msgID ), SKIP_CALLBACK );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDictGoneFinish()
|
public void showDictGoneFinish()
|
||||||
|
@ -167,8 +172,9 @@ public class DlgDelegate {
|
||||||
AlertDialog.BUTTON_POSITIVE );
|
AlertDialog.BUTTON_POSITIVE );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DlgState state = new DlgState( DIALOG_NOTAGAIN, msgID, callbackID,
|
String msg = m_activity.getString( msgID );
|
||||||
prefsKey );
|
DlgState state =
|
||||||
|
new DlgState( DIALOG_NOTAGAIN, msg, callbackID, prefsKey );
|
||||||
addState( state );
|
addState( state );
|
||||||
m_activity.showDialog( DIALOG_NOTAGAIN );
|
m_activity.showDialog( DIALOG_NOTAGAIN );
|
||||||
}
|
}
|
||||||
|
@ -287,7 +293,7 @@ public class DlgDelegate {
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if ( asDlg ) {
|
if ( asDlg ) {
|
||||||
showOKOnlyDialog( fmsg, 0 );
|
showOKOnlyDialog( fmsg, SKIP_CALLBACK );
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.showf( m_activity, fmsg );
|
DbgUtils.showf( m_activity, fmsg );
|
||||||
}
|
}
|
||||||
|
@ -335,9 +341,8 @@ public class DlgDelegate {
|
||||||
.setMessage( state.m_msg )
|
.setMessage( state.m_msg )
|
||||||
.setPositiveButton( R.string.button_ok, null )
|
.setPositiveButton( R.string.button_ok, null )
|
||||||
.create();
|
.create();
|
||||||
if ( 0 != state.m_cbckID ) {
|
dialog = setCallbackDismissListener( dialog, state, id );
|
||||||
dialog = setCallbackDismissListener( dialog, state, id );
|
|
||||||
}
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,41 +451,6 @@ public class DlgDelegate {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DlgState implements java.io.Serializable {
|
|
||||||
public int m_id;
|
|
||||||
public String m_msg;
|
|
||||||
public int m_posButton;
|
|
||||||
public int m_cbckID = 0;
|
|
||||||
public int m_prefsKey;
|
|
||||||
|
|
||||||
public DlgState( int id, String msg, int cbckID )
|
|
||||||
{
|
|
||||||
this( id, msg, 0, cbckID, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public DlgState( int id, int msgID, int cbckID, int prefsKey )
|
|
||||||
{
|
|
||||||
this( id, m_activity.getString(msgID), 0, cbckID, prefsKey );
|
|
||||||
}
|
|
||||||
|
|
||||||
public DlgState( int id, String msg, int posButton,
|
|
||||||
int cbckID, int prefsKey )
|
|
||||||
{
|
|
||||||
m_id = id;
|
|
||||||
m_msg = msg;
|
|
||||||
m_posButton = posButton;
|
|
||||||
m_cbckID = cbckID;
|
|
||||||
m_prefsKey = prefsKey;
|
|
||||||
DbgUtils.logf( "DlgState(%d)=>%H", id, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public DlgState( int id, int cbckID )
|
|
||||||
{
|
|
||||||
this( id, null, 0, cbckID, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private DlgState findForID( int id )
|
private DlgState findForID( int id )
|
||||||
{
|
{
|
||||||
DlgState state = m_dlgStates.get( id );
|
DlgState state = m_dlgStates.get( id );
|
||||||
|
@ -490,11 +460,12 @@ public class DlgDelegate {
|
||||||
|
|
||||||
private void dropState( DlgState state )
|
private void dropState( DlgState state )
|
||||||
{
|
{
|
||||||
|
int nDlgs = m_dlgStates.size();
|
||||||
Assert.assertNotNull( state );
|
Assert.assertNotNull( state );
|
||||||
Assert.assertTrue( state == m_dlgStates.get( state.m_id ) );
|
Assert.assertTrue( state == m_dlgStates.get( state.m_id ) );
|
||||||
m_dlgStates.remove( state.m_id );
|
m_dlgStates.remove( state.m_id );
|
||||||
DbgUtils.logf( "dropState: there are now %d active dialogs",
|
DbgUtils.logf( "dropState: active dialogs now %d from %d ",
|
||||||
m_dlgStates.size() );
|
m_dlgStates.size(), nDlgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addState( DlgState state )
|
private void addState( DlgState state )
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||||
|
/*
|
||||||
|
* Copyright 2009 - 2013 by Eric House (xwords@eehouse.org). All
|
||||||
|
* rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.os.Parcel;
|
||||||
|
|
||||||
|
public class DlgState implements Parcelable {
|
||||||
|
public int m_id;
|
||||||
|
public String m_msg;
|
||||||
|
public int m_posButton;
|
||||||
|
public int m_cbckID = 0;
|
||||||
|
public int m_prefsKey;
|
||||||
|
|
||||||
|
public DlgState( int id, String msg, int cbckID )
|
||||||
|
{
|
||||||
|
this( id, msg, 0, cbckID, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public DlgState( int id, String msg, int cbckID, int prefsKey )
|
||||||
|
{
|
||||||
|
this( id, msg, 0, cbckID, prefsKey );
|
||||||
|
}
|
||||||
|
|
||||||
|
public DlgState( int id, String msg, int posButton,
|
||||||
|
int cbckID, int prefsKey )
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
m_msg = msg;
|
||||||
|
m_posButton = posButton;
|
||||||
|
m_cbckID = cbckID;
|
||||||
|
m_prefsKey = prefsKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DlgState( int id, int cbckID )
|
||||||
|
{
|
||||||
|
this( id, null, 0, cbckID, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToParcel( Parcel out, int flags ) {
|
||||||
|
out.writeInt( m_id );
|
||||||
|
out.writeInt( m_posButton );
|
||||||
|
out.writeInt( m_cbckID );
|
||||||
|
out.writeInt( m_prefsKey );
|
||||||
|
out.writeString( m_msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<DlgState> CREATOR
|
||||||
|
= new Parcelable.Creator<DlgState>() {
|
||||||
|
public DlgState createFromParcel(Parcel in) {
|
||||||
|
int id = in.readInt();
|
||||||
|
int posButton = in.readInt();
|
||||||
|
int cbckID = in.readInt();
|
||||||
|
int prefsKey = in.readInt();
|
||||||
|
String msg = in.readString();
|
||||||
|
return new DlgState( id, msg, posButton, cbckID, prefsKey );
|
||||||
|
}
|
||||||
|
|
||||||
|
public DlgState[] newArray(int size) {
|
||||||
|
return new DlgState[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -124,7 +124,7 @@ public class XWActivity extends Activity
|
||||||
|
|
||||||
protected void showOKOnlyDialog( String msg )
|
protected void showOKOnlyDialog( String msg )
|
||||||
{
|
{
|
||||||
m_delegate.showOKOnlyDialog( msg, 0 );
|
m_delegate.showOKOnlyDialog( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showDictGoneFinish()
|
protected void showDictGoneFinish()
|
||||||
|
|
|
@ -67,7 +67,6 @@ public class XWExpandableListActivity extends ExpandableListActivity
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog( final int id )
|
protected Dialog onCreateDialog( final int id )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "%s.onCreateDialog() called", getClass().getName() );
|
|
||||||
Dialog dialog = m_delegate.onCreateDialog( id );
|
Dialog dialog = m_delegate.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
dialog = super.onCreateDialog( id );
|
dialog = super.onCreateDialog( id );
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class XWListActivity extends ListActivity
|
||||||
|
|
||||||
protected void showOKOnlyDialog( String msg )
|
protected void showOKOnlyDialog( String msg )
|
||||||
{
|
{
|
||||||
m_delegate.showOKOnlyDialog( msg, 0 );
|
m_delegate.showOKOnlyDialog( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showOKOnlyDialog( int msgID )
|
protected void showOKOnlyDialog( int msgID )
|
||||||
|
|
Loading…
Reference in a new issue