make changes dialog launchable from About dialog (so reachable other

than immediately after upgrade)
This commit is contained in:
Andy2 2010-08-10 20:33:33 -07:00
parent e720fe79ab
commit fc603645d1
4 changed files with 33 additions and 15 deletions

View file

@ -362,5 +362,6 @@
<string name="git_rev_title">Source version id</string>
<string name="changes_title">Recent changes</string>
<string name="changes_button">Recent changes</string>
</resources>

View file

@ -39,25 +39,32 @@ public class FirstRunDialog {
private static final String HIDDEN_PREFS = "xwprefs_hidden";
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
static void show( Context context )
static void show( Context context, boolean skipCheck )
{
int thisVersion = 0;
try {
thisVersion = context.getPackageManager()
.getPackageInfo(context.getPackageName(), 0)
.versionCode;
Utils.logf( "versionCode: %d", thisVersion );
} catch ( Exception e ) {
int shownVersion = 0;
if ( !skipCheck ) {
try {
thisVersion = context.getPackageManager()
.getPackageInfo(context.getPackageName(), 0)
.versionCode;
Utils.logf( "versionCode: %d", thisVersion );
} catch ( Exception e ) {
}
}
SharedPreferences prefs = null;
if ( thisVersion > 0 ) {
SharedPreferences prefs =
context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
int shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 );
if ( shownVersion < thisVersion ) {
showDialog( context );
prefs = context.getSharedPreferences( HIDDEN_PREFS,
Context.MODE_PRIVATE );
shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 );
}
if ( skipCheck || shownVersion < thisVersion ) {
showDialog( context );
if ( !skipCheck ) {
Editor editor = prefs.edit();
editor.putInt( SHOWN_VERSION_KEY, thisVersion );
editor.commit();

View file

@ -128,7 +128,7 @@ public class GamesList extends ListActivity {
m_adapter = new GameListAdapter( this );
setListAdapter( m_adapter );
FirstRunDialog.show( this );
FirstRunDialog.show( this, false );
}
@Override

View file

@ -25,6 +25,7 @@ import java.lang.Thread;
import android.widget.Toast;
import android.content.Context;
import android.content.Intent;
import android.content.DialogInterface;
import android.widget.CheckBox;
import android.app.Activity;
import android.app.Dialog;
@ -71,7 +72,7 @@ public class Utils {
Toast.makeText( context, text, Toast.LENGTH_SHORT).show();
}
static Dialog onCreateDialog( Context context, int id )
static Dialog onCreateDialog( final Context context, int id )
{
Assert.assertTrue( DIALOG_ABOUT == id );
LayoutInflater factory = LayoutInflater.from( context );
@ -93,6 +94,15 @@ public class Utils {
.setIcon( R.drawable.icon48x48 )
.setTitle( R.string.app_name )
.setView( view )
.setPositiveButton( R.string.changes_button,
new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dlg,
int which )
{
FirstRunDialog.show( context, true );
}
} )
.create();
}