mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
make changes dialog launchable from About dialog (so reachable other
than immediately after upgrade)
This commit is contained in:
parent
e720fe79ab
commit
fc603645d1
4 changed files with 33 additions and 15 deletions
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue