mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
make dict storage location a default set in preference rather than
something queried each time.
This commit is contained in:
parent
6ba5d4f7c8
commit
ca561f225c
6 changed files with 30 additions and 44 deletions
|
@ -59,6 +59,7 @@
|
|||
<string name="key_hide_intro">key_hide_intro</string>
|
||||
<string name="key_keep_screenon">key_keep_screenon</string>
|
||||
<string name="key_summary_field">key_summary_field</string>
|
||||
<string name="key_default_loc">key_default_loc</string>
|
||||
|
||||
<!-- database keys whose entries aren't visible prefs -->
|
||||
<string name="key_closed_langs">key_closed_langs</string>
|
||||
|
|
|
@ -266,18 +266,6 @@
|
|||
is using it, but there is another %s wordlist installed that can
|
||||
replace it.</string>
|
||||
|
||||
<!-- Text of dialog brought up when user taps the download_dicts
|
||||
button -->
|
||||
<string name="storeWhereMsg">Store downloaded wordlists using
|
||||
internal or external (SD card) memory? (You can always move them
|
||||
later.)</string>
|
||||
<!-- title of above -->
|
||||
<string name="storeWhereTitle">Wordlist storage</string>
|
||||
<!-- One of the buttons in the above dialog -->
|
||||
<string name="button_internal">Internal</string>
|
||||
<!-- The other button in the above dialog -->
|
||||
<string name="button_sd">External</string>
|
||||
|
||||
<!--
|
||||
############################################################
|
||||
# :Dialogs:
|
||||
|
@ -2141,4 +2129,8 @@
|
|||
<string name="downloadingf">Downloading %s...</string>
|
||||
<string name="download_done">Download finished</string>
|
||||
<string name="download_failed">Download unsuccessful</string>
|
||||
|
||||
<string name="default_loc">Store wordlists internally</string>
|
||||
<string name="default_loc_summary">(Not in external/sdcard memory)</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -227,6 +227,11 @@
|
|||
android:summary="@string/skip_confirm_turn_summary"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_default_loc"
|
||||
android:title="@string/default_loc"
|
||||
android:summary="@string/default_loc_summary"
|
||||
android:defaultValue="true"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_sort_tiles"
|
||||
android:title="@string/title_sort_tiles"
|
||||
android:summary="@string/summary_sort_tiles"
|
||||
|
|
|
@ -76,10 +76,9 @@ public class DictsActivity extends ExpandableListActivity
|
|||
// For new callback alternative
|
||||
private static final int DELETE_DICT_ACTION = 1;
|
||||
|
||||
private static final int PICK_STORAGE = DlgDelegate.DIALOG_LAST + 1;
|
||||
private static final int MOVE_DICT = DlgDelegate.DIALOG_LAST + 2;
|
||||
private static final int SET_DEFAULT = DlgDelegate.DIALOG_LAST + 3;
|
||||
private static final int DICT_OR_DECLINE = DlgDelegate.DIALOG_LAST + 4;
|
||||
private static final int MOVE_DICT = DlgDelegate.DIALOG_LAST + 1;
|
||||
private static final int SET_DEFAULT = DlgDelegate.DIALOG_LAST + 2;
|
||||
private static final int DICT_OR_DECLINE = DlgDelegate.DIALOG_LAST + 3;
|
||||
private int m_lang = 0;
|
||||
private String[] m_langs;
|
||||
private String m_name = null;
|
||||
|
@ -259,21 +258,6 @@ public class DictsActivity extends ExpandableListActivity
|
|||
boolean doRemove = true;
|
||||
|
||||
switch( id ) {
|
||||
case PICK_STORAGE:
|
||||
lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
startDownload( m_lang, m_name, item !=
|
||||
DialogInterface.BUTTON_POSITIVE );
|
||||
}
|
||||
};
|
||||
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
.setTitle( R.string.storeWhereTitle )
|
||||
.setMessage( R.string.storeWhereMsg )
|
||||
.setPositiveButton( R.string.button_internal, lstnr )
|
||||
.setNegativeButton( R.string.button_sd, lstnr )
|
||||
.create();
|
||||
break;
|
||||
case MOVE_DICT:
|
||||
message = Utils.format( this, R.string.move_dictf,
|
||||
m_adapter.getSelChildView().getText() );
|
||||
|
@ -447,7 +431,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
if ( downloadNow ) {
|
||||
int lang = intent.getIntExtra( DICT_LANG_EXTRA, 0 );
|
||||
String name = intent.getStringExtra( DICT_NAME_EXTRA );
|
||||
askStartDownload( lang, name );
|
||||
startDownload( lang, name );
|
||||
}
|
||||
|
||||
downloadNewDict( intent );
|
||||
|
@ -504,7 +488,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
public void onClick( View view )
|
||||
{
|
||||
if ( view instanceof Button ) {
|
||||
askStartDownload( 0, null );
|
||||
startDownload( 0, null );
|
||||
} else {
|
||||
XWListItem item = (XWListItem)view;
|
||||
DictBrowseActivity.launch( this, item.getText(),
|
||||
|
@ -690,15 +674,11 @@ public class DictsActivity extends ExpandableListActivity
|
|||
expandGroups();
|
||||
}
|
||||
|
||||
private void askStartDownload( int lang, String name )
|
||||
private void startDownload( int lang, String name )
|
||||
{
|
||||
if ( DictUtils.haveWriteableSD() ) {
|
||||
m_lang = lang;
|
||||
m_name = name;
|
||||
showDialog( PICK_STORAGE );
|
||||
} else {
|
||||
startDownload( lang, name, false );
|
||||
}
|
||||
boolean toSD =
|
||||
DictUtils.DictLoc.EXTERNAL == XWPrefs.getDefaultLoc( this );
|
||||
startDownload( lang, name, toSD );
|
||||
}
|
||||
|
||||
private void startDownload( String url, boolean toSD )
|
||||
|
|
|
@ -278,9 +278,8 @@ public class NetUtils {
|
|||
final int lang, final String name,
|
||||
final DownloadFinishedListener lstnr )
|
||||
{
|
||||
launchAndDownload( context, lang, name,
|
||||
DictUtils.DictLoc.INTERNAL,
|
||||
lstnr );
|
||||
DictUtils.DictLoc loc = XWPrefs.getDefaultLoc( context );
|
||||
launchAndDownload( context, lang, name, loc, lstnr );
|
||||
}
|
||||
|
||||
static void launchAndDownload( final Context context,
|
||||
|
|
|
@ -184,6 +184,15 @@ public class XWPrefs {
|
|||
return id;
|
||||
}
|
||||
|
||||
public static DictUtils.DictLoc getDefaultLoc( Context context )
|
||||
{
|
||||
boolean value = getPrefsBoolean( context, R.string.key_default_loc,
|
||||
true );
|
||||
DictUtils.DictLoc result = value ? DictUtils.DictLoc.INTERNAL
|
||||
: DictUtils.DictLoc.EXTERNAL;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static String getPrefsString( Context context, int keyID )
|
||||
{
|
||||
String key = context.getString( keyID );
|
||||
|
|
Loading…
Reference in a new issue