mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
add debug menu option to enable debug features, and first such
feature, to copy xwdb file to /sdcard. Option to do opposite is stubbed out.
This commit is contained in:
parent
1fe14be9bf
commit
af2c361225
8 changed files with 115 additions and 26 deletions
|
@ -281,6 +281,23 @@
|
|||
<PreferenceScreen android:title="@string/advanced"
|
||||
android:summary="@string/advanced_summary"
|
||||
>
|
||||
<EditTextPreference android:title="@string/git_rev_title"
|
||||
android:summary="@string/git_rev"
|
||||
android:enabled="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_logging_on"
|
||||
android:title="@string/logging_on"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_enable_debug"
|
||||
android:title="Enable debug features"
|
||||
android:summary="Menuitems etc."
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_show_sms"
|
||||
android:title="Show SMS sends, receives"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<org.eehouse.android.xw4sms.XWEditTextPreference
|
||||
android:key="@string/key_relay_host"
|
||||
android:title="@string/relay_host"
|
||||
|
@ -310,17 +327,5 @@
|
|||
android:defaultValue="@string/dict_url"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference android:key="@string/key_logging_on"
|
||||
android:title="@string/logging_on"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_show_sms"
|
||||
android:title="Show SMS sends, receives"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<EditTextPreference android:title="@string/git_rev_title"
|
||||
android:summary="@string/git_rev"
|
||||
android:enabled="false"
|
||||
/>
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -32,5 +32,13 @@
|
|||
android:icon="@drawable/stat_notify_sync"
|
||||
/>
|
||||
|
||||
<!-- Debug only menuitems -->
|
||||
<item android:id="@+id/gamel_menu_storedb"
|
||||
android:title="@string/gamel_menu_storedb"
|
||||
/>
|
||||
<item android:id="@+id/gamel_menu_loaddb"
|
||||
android:title="@string/gamel_menu_loaddb"
|
||||
/>
|
||||
|
||||
<!-- ic_menu_archive.png -->
|
||||
</menu>
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
<string name="key_na_lookup">key_na_lookup</string>
|
||||
<string name="key_na_browse">key_na_browse</string>
|
||||
<string name="key_na_values">key_na_values</string>
|
||||
<string name="key_enable_debug">key_enable_debug</string>
|
||||
|
||||
<!-- Nor is my email address -->
|
||||
<string name="email_author_email">xwords@eehouse.org</string>
|
||||
|
@ -110,6 +111,8 @@
|
|||
<string name="relay_port">Relay game port</string>
|
||||
<string name="proxy_port">Relay device port</string>
|
||||
<string name="name_dict_fmt">%1$s/%2$s</string>
|
||||
<string name="gamel_menu_storedb">Write DB to SD card</string>
|
||||
<string name="gamel_menu_loaddb">Load DB from SD card</string>
|
||||
|
||||
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
||||
|
||||
|
|
|
@ -275,6 +275,19 @@
|
|||
<PreferenceScreen android:title="@string/advanced"
|
||||
android:summary="@string/advanced_summary"
|
||||
>
|
||||
<EditTextPreference android:title="@string/git_rev_title"
|
||||
android:summary="@string/git_rev"
|
||||
android:enabled="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_logging_on"
|
||||
android:title="@string/logging_on"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_enable_debug"
|
||||
android:title="Enable debug features"
|
||||
android:summary="Menuitems etc."
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<org.eehouse.android.xw4.XWEditTextPreference
|
||||
android:key="@string/key_relay_host"
|
||||
android:title="@string/relay_host"
|
||||
|
@ -303,14 +316,5 @@
|
|||
android:title="@string/dict_host"
|
||||
android:defaultValue="@string/dict_url"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference android:key="@string/key_logging_on"
|
||||
android:title="@string/logging_on"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<EditTextPreference android:title="@string/git_rev_title"
|
||||
android:summary="@string/git_rev"
|
||||
android:enabled="false"
|
||||
/>
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -71,6 +71,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
super( context, DB_NAME, null, DB_VERSION );
|
||||
}
|
||||
|
||||
public static String getDBName()
|
||||
{
|
||||
return DB_NAME;
|
||||
}
|
||||
|
||||
private void onCreateSum( SQLiteDatabase db )
|
||||
{
|
||||
db.execSQL( "CREATE TABLE " + TABLE_NAME_SUM + " ("
|
||||
|
|
|
@ -20,20 +20,26 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import java.util.StringTokenizer;
|
||||
import android.content.ContentValues;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import android.text.TextUtils;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
@ -897,6 +903,36 @@ public class DBUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void saveDB( Context context )
|
||||
{
|
||||
String name = DBHelper.getDBName();
|
||||
File srcDB = context.getDatabasePath( name );
|
||||
if ( srcDB.exists() ) {
|
||||
try {
|
||||
File destDB = new File( Environment.getExternalStorageDirectory(),
|
||||
name );
|
||||
InputStream src = new FileInputStream(srcDB);
|
||||
OutputStream dest = new FileOutputStream(destDB);
|
||||
byte[] buffer = new byte[1024];
|
||||
for ( ; ; ) {
|
||||
int nRead = src.read(buffer);
|
||||
if ( 0 > nRead ) {
|
||||
break;
|
||||
}
|
||||
dest.write( buffer, 0, nRead );
|
||||
}
|
||||
|
||||
dest.flush();
|
||||
dest.close();
|
||||
src.close();
|
||||
} catch( java.io.FileNotFoundException fnfe ) {
|
||||
DbgUtils.logf( "in saveDB: %s", fnfe.toString() );
|
||||
} catch( java.io.IOException ioe ) {
|
||||
DbgUtils.logf( "in saveDB: %s", ioe.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Chat is independent of the GameLock mechanism because it's not
|
||||
// touching the SNAPSHOT column.
|
||||
private static void saveChatHistory( Context context, long rowid,
|
||||
|
|
|
@ -71,6 +71,9 @@ public class GamesList extends XWListActivity
|
|||
private static final int DELETE_ALL_ACTION = 4;
|
||||
private static final int SYNC_MENU_ACTION = 5;
|
||||
private static final int NEW_FROM_ACTION = 6;
|
||||
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
|
||||
, R.id.gamel_menu_storedb
|
||||
};
|
||||
|
||||
private static boolean s_firstShown = false;
|
||||
|
||||
|
@ -525,13 +528,26 @@ public class GamesList extends XWListActivity
|
|||
return handleMenuItem( item.getItemId(), info.position );
|
||||
} // onContextItemSelected
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.games_list_menu, menu );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
boolean visible = XWPrefs.getDebugEnabled( this ) ;
|
||||
for ( int id : DEBUGITEMS ) {
|
||||
MenuItem item = menu.findItem( id );
|
||||
item.setVisible( visible );
|
||||
}
|
||||
return super.onPrepareOptionsMenu( menu );
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
boolean handled = true;
|
||||
|
@ -574,6 +590,13 @@ public class GamesList extends XWListActivity
|
|||
Utils.emailAuthor( this );
|
||||
break;
|
||||
|
||||
case R.id.gamel_menu_loaddb:
|
||||
Utils.notImpl(this);
|
||||
break;
|
||||
case R.id.gamel_menu_storedb:
|
||||
DBUtils.saveDB( this );
|
||||
break;
|
||||
|
||||
// case R.id.gamel_menu_view_hidden:
|
||||
// Utils.notImpl( this );
|
||||
// break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -31,6 +31,11 @@ public class XWPrefs {
|
|||
return getPrefsBoolean( context, R.string.key_enable_sms, false );
|
||||
}
|
||||
|
||||
public static boolean getDebugEnabled( Context context )
|
||||
{
|
||||
return getPrefsBoolean( context, R.string.key_enable_debug, false );
|
||||
}
|
||||
|
||||
public static boolean getPrefsBoolean( Context context, int keyID,
|
||||
boolean defaultValue )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue