mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add first helptext dialog, with do-not-show-again button, attached to
the sync menuitem. The plan's that a bunch of these will make the game easier for newbies to use.
This commit is contained in:
parent
0d4f77fb0a
commit
5c9cf0ebc8
5 changed files with 93 additions and 22 deletions
|
@ -37,6 +37,9 @@
|
|||
<string name="key_default_phonies">key_default_phonies2</string>
|
||||
<string name="key_default_timerenabled">key_default_timerenabled</string>
|
||||
<string name="key_connect_frequency">key_connect_frequency</string>
|
||||
|
||||
<string name="key_notagain_sync">key_notagain_sync</string>
|
||||
|
||||
<string name="relayids_extra">org.eehouse.android.xw4.relayids_extra</string>
|
||||
|
||||
<!-- other -->
|
||||
|
|
|
@ -392,4 +392,12 @@
|
|||
<string name="msgs_progress">Checking meetup server for moves
|
||||
etc...</string>
|
||||
|
||||
<string name="button_notagain">Do not show again</string>
|
||||
|
||||
<string name="not_again_sync">This action connects to the relay
|
||||
server on behalf of any connected games to see if there are any
|
||||
moves or other messages pending from other devices in the game.
|
||||
If so the games will be redrawn with a sync icon on the
|
||||
left.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -243,6 +243,15 @@ public class GamesList extends XWListActivity
|
|||
return true;
|
||||
}
|
||||
|
||||
private void doSyncMenuitem()
|
||||
{
|
||||
if ( null == DBUtils.getRelayIDNoMsgs( this ) ) {
|
||||
showOKOnlyDialog( R.string.no_games_to_refresh );
|
||||
} else {
|
||||
new RefreshMsgsTask( this, this ).execute();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
boolean handled = true;
|
||||
|
@ -262,14 +271,13 @@ public class GamesList extends XWListActivity
|
|||
break;
|
||||
|
||||
case R.id.gamel_menu_checkmoves:
|
||||
if ( null == DBUtils.getRelayIDNoMsgs( this ) ) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt( "msgID", R.string.no_games_to_refresh );
|
||||
setDialogBundle( bundle );
|
||||
showDialog( XWActivity.DIALOG_OKONLY );
|
||||
} else {
|
||||
new RefreshMsgsTask( this, this ).execute();
|
||||
}
|
||||
showNotAgainDlgThen( R.string.not_again_sync,
|
||||
R.string.key_notagain_sync,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
doSyncMenuitem();
|
||||
}
|
||||
} );
|
||||
break;
|
||||
|
||||
case R.id.gamel_menu_prefs:
|
||||
|
|
|
@ -32,6 +32,8 @@ import android.widget.TextView;
|
|||
import android.app.AlertDialog;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
public class XWActivity extends Activity {
|
||||
|
||||
public static final int DIALOG_ABOUT = 1;
|
||||
|
@ -39,7 +41,9 @@ public class XWActivity extends Activity {
|
|||
public static final int DIALOG_NOTAGAIN = 3;
|
||||
public static final int DIALOG_LAST = DIALOG_NOTAGAIN;
|
||||
|
||||
public static Bundle s_dialogBundle = null;
|
||||
private static int s_msgID;
|
||||
private static Runnable s_dialogRunnable = null;
|
||||
private static int s_prefsKey;
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
|
@ -74,6 +78,7 @@ public class XWActivity extends Activity {
|
|||
dialog = doOKDialog( context );
|
||||
break;
|
||||
case DIALOG_NOTAGAIN:
|
||||
dialog = doNotAgainDialog( context );
|
||||
break;
|
||||
}
|
||||
return dialog;
|
||||
|
@ -114,19 +119,51 @@ public class XWActivity extends Activity {
|
|||
|
||||
private static Dialog doOKDialog( final Context context )
|
||||
{
|
||||
Bundle bundle = s_dialogBundle;
|
||||
Assert.assertTrue( null != bundle );
|
||||
int msgID = bundle.getInt( "msgID" );
|
||||
return new AlertDialog.Builder( context )
|
||||
.setTitle( R.string.info_title )
|
||||
.setMessage( msgID )
|
||||
.setMessage( s_msgID )
|
||||
.setPositiveButton( R.string.button_ok, null )
|
||||
.create();
|
||||
}
|
||||
|
||||
public static void setDialogBundle( Bundle bundle )
|
||||
private static Dialog doNotAgainDialog( final Context context )
|
||||
{
|
||||
s_dialogBundle = bundle;
|
||||
DialogInterface.OnClickListener lstnr_p =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
s_dialogRunnable.run();
|
||||
}
|
||||
};
|
||||
|
||||
DialogInterface.OnClickListener lstnr_n =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
CommonPrefs.setPrefsBoolean( context, s_prefsKey, true );
|
||||
s_dialogRunnable.run();
|
||||
}
|
||||
};
|
||||
|
||||
return new AlertDialog.Builder( context )
|
||||
.setTitle( R.string.info_title )
|
||||
.setMessage( s_msgID )
|
||||
.setPositiveButton( R.string.button_ok, lstnr_p )
|
||||
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
||||
.create();
|
||||
}
|
||||
|
||||
public static void setDialogMsgID( int msgID )
|
||||
{
|
||||
s_msgID = msgID;
|
||||
}
|
||||
|
||||
public static void setDialogRunnable( Runnable runnable )
|
||||
{
|
||||
s_dialogRunnable = runnable;
|
||||
}
|
||||
|
||||
public static void setDialogPrefsKey( int prefsKey )
|
||||
{
|
||||
s_prefsKey = prefsKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ import android.app.ListActivity;
|
|||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class XWListActivity extends ListActivity {
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
private static int DLG_SOMETIMES = 100;
|
||||
public class XWListActivity extends ListActivity {
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
|
@ -36,6 +36,26 @@ public class XWListActivity extends ListActivity {
|
|||
DispatchNotify.SetRunning( this );
|
||||
}
|
||||
|
||||
protected void showOKOnlyDialog( int msgID )
|
||||
{
|
||||
XWActivity.setDialogMsgID( msgID );
|
||||
showDialog( XWActivity.DIALOG_OKONLY );
|
||||
}
|
||||
|
||||
protected void showNotAgainDlgThen( int msgID, int prefsKey,
|
||||
Runnable proc )
|
||||
{
|
||||
boolean set = CommonPrefs.getPrefsBoolean( this, prefsKey, false );
|
||||
if ( set ) {
|
||||
proc.run();
|
||||
} else {
|
||||
XWActivity.setDialogMsgID( msgID );
|
||||
XWActivity.setDialogRunnable( proc );
|
||||
XWActivity.setDialogPrefsKey( prefsKey );
|
||||
showDialog( XWActivity.DIALOG_NOTAGAIN );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
@ -53,9 +73,4 @@ public class XWListActivity extends ListActivity {
|
|||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
protected void setDialogBundle( Bundle bundle )
|
||||
{
|
||||
XWActivity.setDialogBundle( bundle );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue