in order that non-English versions not go long after installation

without translations, try immediately after any install or upgrade to
get translations from server.  (Triggered from the Application rather
than an Activity, so initializing the preferences DB had to be moved
there too.) Should probably post a notification after installing
localizations, ideally with a message in the language, offering to
restart with all new strings.
This commit is contained in:
Eric House 2014-05-04 15:41:02 -07:00
parent 6d60e45eb9
commit edcd29c88d
4 changed files with 39 additions and 3 deletions

View file

@ -33,7 +33,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@ -365,7 +364,6 @@ public class GamesListDelegate extends DelegateBase
FirstRunDialog.show( m_activity );
s_firstShown = true;
}
PreferenceManager.setDefaultValues( m_activity, R.xml.xwprefs, isUpgrade );
m_adapter = makeNewAdapter();
listview.setOnItemLongClickListener( this );

View file

@ -318,6 +318,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
{
if ( null != json ) {
makeNotificationsIf( json );
XWPrefs.setHaveCheckedUpgrades( m_context, true );
}
}

View file

@ -24,6 +24,7 @@ import android.app.Application;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.preference.PreferenceManager;
import java.util.UUID;
@ -62,6 +63,17 @@ public class XWApp extends Application {
ConnStatusHandler.loadState( this );
RelayReceiver.RestartTimer( this );
boolean mustCheck = Utils.firstBootThisVersion( this );
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, mustCheck );
if ( mustCheck ) {
XWPrefs.setHaveCheckedUpgrades( this, false );
} else {
mustCheck = ! XWPrefs.getHaveCheckedUpgrades( this );
}
if ( mustCheck ) {
UpdateCheckReceiver.checkVersions( this, false );
}
UpdateCheckReceiver.restartTimer( this );
BTService.startService( this );

View file

@ -31,6 +31,9 @@ import junit.framework.Assert;
public class XWPrefs {
// No reason to put this in xml if they're private to this file!
private static final String key_checked_upgrades = "key_checked_upgrades";
public static boolean getSMSEnabled( Context context )
{
return getPrefsBoolean( context, R.string.key_enable_sms, false );
@ -141,6 +144,12 @@ public class XWPrefs {
boolean defaultValue )
{
String key = context.getString( keyID );
return getPrefsBoolean( context, key, defaultValue );
}
private static boolean getPrefsBoolean( Context context, String key,
boolean defaultValue )
{
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences( context );
return sp.getBoolean( key, defaultValue );
@ -148,11 +157,17 @@ public class XWPrefs {
public static void setPrefsBoolean( Context context, int keyID,
boolean newValue )
{
String key = context.getString( keyID );
setPrefsBoolean( context, key, newValue );
}
private static void setPrefsBoolean( Context context, String key,
boolean newValue )
{
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences( context );
SharedPreferences.Editor editor = sp.edit();
String key = context.getString( keyID );
editor.putBoolean( key, newValue );
editor.commit();
}
@ -439,4 +454,14 @@ public class XWPrefs {
{
return getPrefsBoolean( context, R.string.key_xlations_enabled, false );
}
public static void setHaveCheckedUpgrades( Context context, boolean haveChecked )
{
setPrefsBoolean( context, key_checked_upgrades, haveChecked );
}
public static boolean getHaveCheckedUpgrades( Context context )
{
return getPrefsBoolean( context, key_checked_upgrades, false );
}
}