mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
Merge branch 'android_branch' into android_bt
Conflicts: xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java
This commit is contained in:
commit
459ddf6e96
4 changed files with 69 additions and 50 deletions
|
@ -330,7 +330,7 @@ public class DlgDelegate {
|
|||
public void onClick( DialogInterface dlg,
|
||||
int which )
|
||||
{
|
||||
FirstRunDialog.show( m_activity, true );
|
||||
FirstRunDialog.show( m_activity );
|
||||
}
|
||||
} )
|
||||
.create();
|
||||
|
|
|
@ -20,11 +20,8 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.webkit.WebView;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -36,45 +33,7 @@ import java.io.Reader;
|
|||
*/
|
||||
|
||||
public class FirstRunDialog {
|
||||
private static final String HIDDEN_PREFS = "xwprefs_hidden";
|
||||
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
|
||||
|
||||
static boolean show( Context context, boolean skipCheck )
|
||||
{
|
||||
int thisVersion = 0;
|
||||
int shownVersion = 0;
|
||||
|
||||
if ( !skipCheck ) {
|
||||
try {
|
||||
thisVersion = context.getPackageManager()
|
||||
.getPackageInfo(context.getPackageName(), 0)
|
||||
.versionCode;
|
||||
DbgUtils.logf( "versionCode: %d", thisVersion );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences prefs = null;
|
||||
if ( thisVersion > 0 ) {
|
||||
prefs = context.getSharedPreferences( HIDDEN_PREFS,
|
||||
Context.MODE_PRIVATE );
|
||||
shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 );
|
||||
}
|
||||
|
||||
boolean isUpgrade = shownVersion < thisVersion;
|
||||
if ( skipCheck || isUpgrade ) {
|
||||
showDialog( context );
|
||||
|
||||
if ( !skipCheck ) {
|
||||
Editor editor = prefs.edit();
|
||||
editor.putInt( SHOWN_VERSION_KEY, thisVersion );
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
return isUpgrade;
|
||||
}
|
||||
|
||||
private static void showDialog( Context context )
|
||||
public static void show( Context context )
|
||||
{
|
||||
String page = null;
|
||||
InputStream inputStream = null;
|
||||
|
|
|
@ -71,6 +71,8 @@ public class GamesList extends XWListActivity
|
|||
private static final int SYNC_MENU_ACTION = 5;
|
||||
private static final int NEW_FROM_ACTION = 6;
|
||||
|
||||
private static boolean s_firstShown = false;
|
||||
|
||||
private GameListAdapter m_adapter;
|
||||
private String m_missingDict;
|
||||
private String[] m_missingDictNames;
|
||||
|
@ -241,7 +243,11 @@ public class GamesList extends XWListActivity
|
|||
registerForContextMenu( getListView() );
|
||||
DBUtils.setDBChangeListener( this );
|
||||
|
||||
boolean isUpgrade = FirstRunDialog.show( this, false );
|
||||
boolean isUpgrade = Utils.firstBootThisVersion( this );
|
||||
if ( isUpgrade && !s_firstShown ) {
|
||||
FirstRunDialog.show( this );
|
||||
s_firstShown = true;
|
||||
}
|
||||
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, isUpgrade );
|
||||
|
||||
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
|
||||
|
|
|
@ -27,23 +27,46 @@ import android.app.NotificationManager;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Toast;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.*;
|
||||
|
||||
public class Utils {
|
||||
static final String DB_PATH = "XW_GAMES";
|
||||
private static final String DB_PATH = "XW_GAMES";
|
||||
private static final String HIDDEN_PREFS = "xwprefs_hidden";
|
||||
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
|
||||
|
||||
private static Boolean s_isFirstBootThisVersion = null;
|
||||
private static Boolean s_isFirstBootEver = null;
|
||||
|
||||
private Utils() {}
|
||||
|
||||
public static boolean firstBootEver( Context context )
|
||||
{
|
||||
if ( null == s_isFirstBootEver ) {
|
||||
setFirstBootStatics( context );
|
||||
}
|
||||
return s_isFirstBootEver;
|
||||
}
|
||||
|
||||
public static boolean firstBootThisVersion( Context context )
|
||||
{
|
||||
if ( null == s_isFirstBootThisVersion ) {
|
||||
setFirstBootStatics( context );
|
||||
}
|
||||
return s_isFirstBootThisVersion;
|
||||
}
|
||||
|
||||
public static void notImpl( Context context )
|
||||
{
|
||||
CharSequence text = "Feature coming soon";
|
||||
|
@ -211,4 +234,35 @@ public class Utils {
|
|||
String fmt = context.getString( id );
|
||||
return String.format( fmt, args );
|
||||
}
|
||||
|
||||
private static void setFirstBootStatics( Context context )
|
||||
{
|
||||
int thisVersion = 0;
|
||||
int prevVersion = 0;
|
||||
|
||||
try {
|
||||
thisVersion = context.getPackageManager()
|
||||
.getPackageInfo(context.getPackageName(), 0)
|
||||
.versionCode;
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
|
||||
SharedPreferences prefs = null;
|
||||
if ( 0 < thisVersion ) {
|
||||
prefs = context.getSharedPreferences( HIDDEN_PREFS,
|
||||
Context.MODE_PRIVATE );
|
||||
prevVersion = prefs.getInt( SHOWN_VERSION_KEY, -1 );
|
||||
}
|
||||
boolean newVersion = prevVersion != thisVersion;
|
||||
|
||||
s_isFirstBootThisVersion = new Boolean( newVersion );
|
||||
s_isFirstBootEver = new Boolean( -1 == prevVersion );
|
||||
|
||||
if ( newVersion ) {
|
||||
Editor editor = prefs.edit();
|
||||
editor.putInt( SHOWN_VERSION_KEY, thisVersion );
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue