confirm before downloading wordlist, and only check-and-offer once.

This commit is contained in:
Eric House 2015-03-30 08:04:37 -07:00
parent 427b652c27
commit e1f0c176d5
6 changed files with 141 additions and 106 deletions

View file

@ -55,21 +55,21 @@ public final class R {
public static final int in_arrow=0x7f020012;
public static final int in_arrow_active=0x7f020013;
public static final int multigame__gen=0x7f020014;
public static final int multigame_new__gen=0x7f020015;
public static final int new_group__gen=0x7f020016;
public static final int next_hint=0x7f020017;
public static final int origin=0x7f020018;
public static final int out_arrow=0x7f020019;
public static final int out_arrow_active=0x7f02001a;
public static final int prefs__gen=0x7f02001b;
public static final int prev_hint=0x7f02001c;
public static final int refresh=0x7f02001d;
public static final int relabel__gen=0x7f02001e;
public static final int reset__gen=0x7f02001f;
public static final int rightarrow=0x7f020020;
public static final int save__gen=0x7f020021;
public static final int search__gen=0x7f020022;
public static final int select_all__gen=0x7f020023;
public static final int new_group__gen=0x7f020015;
public static final int next_hint=0x7f020016;
public static final int origin=0x7f020017;
public static final int out_arrow=0x7f020018;
public static final int out_arrow_active=0x7f020019;
public static final int prefs__gen=0x7f02001a;
public static final int prev_hint=0x7f02001b;
public static final int refresh=0x7f02001c;
public static final int relabel__gen=0x7f02001d;
public static final int reset__gen=0x7f02001e;
public static final int rightarrow=0x7f02001f;
public static final int save__gen=0x7f020020;
public static final int search__gen=0x7f020021;
public static final int select_all__gen=0x7f020022;
public static final int send__gen=0x7f020023;
public static final int shuffle=0x7f020024;
public static final int sologame__gen=0x7f020025;
public static final int stat_notify_chat=0x7f020026;
@ -1039,7 +1039,7 @@ XLATE-ME
/** EXPLAIN ME
EXPLAIN ME
*/
public static final int bt_disabled=0x7f0502f8;
public static final int bt_disabled=0x7f0502f9;
/**
<string name="bt_fail_fmt">Bluetooth sends to %1$s have failed too many
@ -1056,7 +1056,7 @@ XLATE-ME
/** EXPLAIN ME
EXPLAIN ME
*/
public static final int bt_networked_desc=0x7f0502f9;
public static final int bt_networked_desc=0x7f0502fa;
/** <string name="bt_no_devs">You currently have no paired Bluetooth
devices. Would you like to open the Android Settings Panel to add
one or more?\n\n(You may also need to open it on the device you
@ -1079,7 +1079,7 @@ XLATE-ME
/**
*/
public static final int bt_pick_rescan_button=0x7f050305;
public static final int bt_pick_rescan_button=0x7f050306;
/**
<string name="bt_resend_fmt">Bluetooth send to %1$s failed; retry %3$d in
@ -1093,7 +1093,7 @@ XLATE-ME
/**
*/
public static final int btname_label=0x7f050308;
public static final int btname_label=0x7f050309;
/** text of button for adding new player to game
text of button for adding new player to game
<string name="button_add_player">Add player</string>
@ -1231,7 +1231,7 @@ XLATE-ME
*/
public static final int button_enable_sms=0x7f050224;
public static final int button_go_settings=0x7f05025b;
public static final int button_html=0x7f0502fc;
public static final int button_html=0x7f0502fd;
/**
<string name="button_invite">Invite checked</string>
@ -1355,7 +1355,7 @@ XLATE-ME
/** <string name="button_newgroup">New group</string>
*/
public static final int button_newgroup=0x7f0501cc;
public static final int button_nfc=0x7f05031d;
public static final int button_nfc=0x7f05031e;
/** <string name="button_no">No</string>
*/
public static final int button_no=0x7f050194;
@ -1538,7 +1538,7 @@ XLATE-ME
plaintext and html formatting. These two strings are shown in the
two buttons in the dialog.
*/
public static final int button_text=0x7f0502fb;
public static final int button_text=0x7f0502fc;
/** <string name="button_trade_cancel">Cancel trade</string>
*/
public static final int button_trade_cancel=0x7f0500d6;
@ -1793,7 +1793,7 @@ XLATE-ME
wordlist is substituted for %1$s. Sometimes one of the two
strings below is appended.
*/
public static final int confirm_delete_dict_fmt=0x7f05031b;
public static final int confirm_delete_dict_fmt=0x7f05031c;
/** Additional text appended to text confirm_delete_dictf in the
wordlist delete confiration dialog in the case where the
wordlist to be deleted is the last in its language. The name
@ -1810,13 +1810,13 @@ XLATE-ME
wordlist to be deleted is NOT the last in its language. The
name of the language is substituted for %1$s.
*/
public static final int confirm_deletemore_dict_fmt=0x7f0502f4;
public static final int confirm_deletemore_dict_fmt=0x7f0502f5;
/** Additional text appended to text confirm_delete_dictf in the
wordlist delete confiration dialog in the case where the
wordlist to be deleted is the last in its language. The name
of the language is substituted for %1$s.
*/
public static final int confirm_deleteonly_dict_fmt=0x7f05031a;
public static final int confirm_deleteonly_dict_fmt=0x7f05031b;
/** Additional text appended to text confirm_delete_dictf in the
wordlist delete confiration dialog in the case where the
wordlist to be deleted is the last in its language. The name
@ -1827,10 +1827,11 @@ XLATE-ME
of the language is substituted for %1$s.
*/
public static final int confirm_deleteonly_dicts_fmt=0x7f0500a0;
public static final int confirm_get_locdict_fmt=0x7f0502f0;
/** Text of confirmation dialog posted when list_item_reset menu
is selected
*/
public static final int confirm_reset_fmt=0x7f050312;
public static final int confirm_reset_fmt=0x7f050313;
/** Text of confirmation dialog for above
Text of confirmation dialog for above
<string name="confirm_revert_all">Are you sure you want to restore
@ -1867,7 +1868,7 @@ XLATE-ME
title of above confirmation dialog
*/
public static final int confirm_save_title=0x7f0500c9;
public static final int confirm_seldeletes_fmt=0x7f050313;
public static final int confirm_seldeletes_fmt=0x7f050314;
/**
<string name="confirm_sms_expl">Warning: This feature is meant for
@ -1915,7 +1916,7 @@ XLATE-ME
*/
public static final int confirm_sms_willpay=0x7f050221;
public static final int confirm_studylist_clear_fmt=0x7f050321;
public static final int confirm_studylist_clear_fmt=0x7f050322;
/** text of dialog shown when the menu item board_menu_undo_last
is chosen.
text of dialog shown when the menu item board_menu_undo_last
@ -1992,7 +1993,7 @@ XLATE-ME
/** text of separator marking out the connection area of the dialog
text of separator marking out the connection area of the dialog
*/
public static final int connect_label_relay=0x7f0502f6;
public static final int connect_label_relay=0x7f0502f7;
/**
<string name="connect_label_sms">Connection (via SMS/text)</string>
@ -2027,7 +2028,7 @@ XLATE-ME
/**
*/
public static final int connstat_bt=0x7f050310;
public static final int connstat_bt=0x7f050311;
/**
<string name="connstat_lastother_succ_fmt">(Last failure was %1$s)</string>
@ -2262,7 +2263,7 @@ XLATE-ME
/**
*/
public static final int dft_name_fmt=0x7f05030b;
public static final int dft_name_fmt=0x7f05030c;
/**
<string name="sms_disabled">Playing via SMS is currently disabled.
You can enable it in Settings->Network game settings.</string>
@ -2283,10 +2284,10 @@ XLATE-ME
public static final int dict_browse_nowords_fmt=0x7f0501d3;
/**
*/
public static final int dict_browse_title1_fmt=0x7f05032a;
public static final int dict_browse_title1_fmt=0x7f05032b;
/**
*/
public static final int dict_browse_title_fmt=0x7f05032b;
public static final int dict_browse_title_fmt=0x7f05032c;
/** XLATE-ME
<string name="dict_host">Wordlist download URL</string>
*/
@ -2576,10 +2577,10 @@ XLATE-ME
These four strings are displayed as step-by-step
instructions
*/
public static final int explain_b1=0x7f0502fe;
public static final int explain_b2=0x7f0502ff;
public static final int explain_b3=0x7f050300;
public static final int explain_b4=0x7f050301;
public static final int explain_b1=0x7f0502ff;
public static final int explain_b2=0x7f050300;
public static final int explain_b3=0x7f050301;
public static final int explain_b4=0x7f050302;
/** if this preference is checked, a dialog will be posted every
time a robot makes a move or a move is received from a remote
player.
@ -2789,7 +2790,7 @@ XLATE-ME
/**
*/
public static final int game_smsname_title=0x7f05030a;
public static final int game_smsname_title=0x7f05030b;
/** Put nothing in the summary space, so it just reads "Game 2"
Put nothing in the summary space, so it just reads "Game 2"
<string name="game_summary_field_empty">\u003CNothing\u003E</string>
@ -2925,12 +2926,12 @@ XLATE-ME
/** <string name="group_cur_games">My games</string>
*/
public static final int group_cur_games=0x7f050245;
public static final int group_name_fmt=0x7f050325;
public static final int group_name_fmt=0x7f050326;
/** <string name="group_new_games">New games</string>
*/
public static final int group_new_games=0x7f050246;
public static final int groups_confirm_del_fmt=0x7f050327;
public static final int groups_confirm_del_games_fmt=0x7f050326;
public static final int groups_confirm_del_fmt=0x7f050328;
public static final int groups_confirm_del_games_fmt=0x7f050327;
/** Used as the default name for remote players displayed within
the Game configure screen
Used as the default name for remote players displayed within
@ -3135,7 +3136,7 @@ XLATE-ME
public static final int initial_player_minutes=0x7f050123;
/**
*/
public static final int invite_bt_desc_fmt=0x7f050329;
public static final int invite_bt_desc_fmt=0x7f05032a;
public static final int invite_choice_bt=0x7f050167;
public static final int invite_choice_email=0x7f050166;
public static final int invite_choice_nfc=0x7f050168;
@ -3245,7 +3246,7 @@ XLATE-ME
invititation while trying to warn him not to send duplicates.
The number of players missing is substituted for "%1$d".
*/
public static final int invite_msg_fmt=0x7f050319;
public static final int invite_msg_fmt=0x7f05031a;
/** XLATE-ME
<string name="invite_multi_summary">Invite more than one player per remote device</string>
*/
@ -3283,7 +3284,7 @@ XLATE-ME
/**
*/
public static final int invite_progress=0x7f050307;
public static final int invite_progress=0x7f050308;
/** <string name="invite_progress_fmt">Sending invitation to Crosswords on %1$s</string>
*/
public static final int invite_progress_fmt=0x7f0501e2;
@ -3294,7 +3295,7 @@ XLATE-ME
public static final int invite_progress_title=0x7f0501e1;
/**
*/
public static final int invite_sms_desc_fmt=0x7f050328;
public static final int invite_sms_desc_fmt=0x7f050329;
/** XLATE-ME
<string name="invite_stays">(This dialog will stay up until all
remote players have connected. You can close the game if you
@ -3331,7 +3332,7 @@ XLATE-ME
/**
*/
public static final int invite_success=0x7f05030f;
public static final int invite_success=0x7f050310;
/** This is the body of the text version of the invitation. A URL
is created with parameters describing the game and
substituted for "%1$s".
@ -4027,7 +4028,7 @@ XLATE-ME
registered with the relay in this game. This should be seen
only once per game.
*/
public static final int msg_relay_waiting_fmt=0x7f050317;
public static final int msg_relay_waiting_fmt=0x7f050318;
/** (I believe this can no longer occur)
(I believe this can no longer occur)
<string name="msg_too_many">You are providing more players than
@ -4223,7 +4224,7 @@ XLATE-ME
/**
*/
public static final int new_smsmove_title=0x7f05030e;
public static final int new_smsmove_title=0x7f05030f;
/**
###########################################################
# :Dialogs:
@ -4289,7 +4290,7 @@ XLATE-ME
<string name="newgame_configure_first">Configure first</string>
*/
public static final int newgame_configure_first=0x7f050160;
public static final int newgame_enable_bt=0x7f050304;
public static final int newgame_enable_bt=0x7f050305;
/** Text of first of two buttons for new networked games. Tap
this and a game will be created, but you probably won't see
it immediately because an email or messaging app will be
@ -4445,8 +4446,8 @@ XLATE-ME
game is open.</string>
*/
public static final int nfc_just_tap=0x7f0502c0;
public static final int nfc_or_email=0x7f05031f;
public static final int nfc_or_sms_or_email=0x7f05031e;
public static final int nfc_or_email=0x7f050320;
public static final int nfc_or_sms_or_email=0x7f05031f;
/** XLATE-ME
<string name="nfc_to_self">Send via NFC to self?</string>
*/
@ -4577,7 +4578,7 @@ XLATE-ME
find and launch an app that's registered to handle http
downloads a Toast is posted with this message.
*/
public static final int no_download_warning=0x7f0502f3;
public static final int no_download_warning=0x7f0502f4;
/** If you click on the Play button without having entered a room
name you get an alert with this error message.
If you click on the Play button without having entered a room
@ -4600,11 +4601,11 @@ XLATE-ME
you get this error message
*/
public static final int no_games_to_refresh=0x7f05008c;
public static final int no_hide_titlebar=0x7f050324;
public static final int no_hide_titlebar=0x7f050325;
/** <string name="no_market">Google Play app not found</string>
*/
public static final int no_market=0x7f05025f;
public static final int no_move_onegroup=0x7f050311;
public static final int no_move_onegroup=0x7f050312;
/** displayed when you long-tap a scoreboard entry and there's no
most recent score to show
displayed when you long-tap a scoreboard entry and there's no
@ -4812,7 +4813,7 @@ XLATE-ME
in Settings.</string>
*/
public static final int not_again_enablepublic=0x7f0502c6;
public static final int not_again_firefox=0x7f050322;
public static final int not_again_firefox=0x7f050323;
/** Shown when you tap the flip button on the toolbar of the main
Board screen
Shown when you tap the flip button on the toolbar of the main
@ -4921,7 +4922,7 @@ XLATE-ME
\"Actionbar.\"</string>
*/
public static final int not_again_newselect=0x7f050251;
public static final int not_again_sms_ready=0x7f050323;
public static final int not_again_sms_ready=0x7f050324;
/** <string name="not_again_studycopy">The selected words will be
copied to the system clipboard. You can then paste them into any
app that supports pasting text, e.g. an email app.</string>
@ -5048,7 +5049,7 @@ XLATE-ME
/** <string name="note_none">(None)</string>
*/
public static final int note_none=0x7f05029c;
public static final int notify_body_fmt=0x7f050303;
public static final int notify_body_fmt=0x7f050304;
/** This text is displayed as the "summary" for both of the
notify choices above, as extra information. (There could be
different strings if it makes more sense in your language.)
@ -5088,7 +5089,7 @@ XLATE-ME
device, and the body that appears when you pull the notifications
down.
*/
public static final int notify_title=0x7f050302;
public static final int notify_title=0x7f050303;
/** When a move is fetched from the relay a Notification is
posted. These are its title, which appears in the top bar of the
device, and the body that appears when you pull the notifications
@ -5139,7 +5140,7 @@ XLATE-ME
games as well.
*/
public static final int password_label=0x7f0500d4;
public static final int paste_done_fmt=0x7f050320;
public static final int paste_done_fmt=0x7f050321;
/** <string name="not_again_sms_ready">You have NFC enabled. That
means that any time a board that\'s missing a player is open, you
can tap a nearby person\'s device to invite him/her to
@ -5347,7 +5348,7 @@ XLATE-ME
/** Toast shown when players are missing, same time as above
but more subtle.
*/
public static final int players_miss_fmt=0x7f050318;
public static final int players_miss_fmt=0x7f050319;
/** Label for the first "human player" name preference
Label for the first "human player" name preference
<string name="pref_human_name">Human player</string>
@ -5627,7 +5628,7 @@ XLATE-ME
/** Text of dialog asking user to confirm a move that exchanges
tiles (instead of forming a new word to earn points)
*/
public static final int query_trade_fmt=0x7f05031c;
public static final int query_trade_fmt=0x7f05031d;
/** XLATE-ME
<string name="radio_name_cdma">CDMA</string>
*/
@ -5735,7 +5736,7 @@ XLATE-ME
This is the heading above the list of steps. The default
language is substituted for %1$s.
*/
public static final int relay_game_explain_fmt=0x7f0502fd;
public static final int relay_game_explain_fmt=0x7f0502fe;
/** XLATE-ME
<string name="relay_host">Relay host</string>
*/
@ -5805,7 +5806,7 @@ XLATE-ME
(on this device only) to:</string>
*/
public static final int rename_label_caveat=0x7f050099;
public static final int resend_finished_fmt=0x7f050314;
public static final int resend_finished_fmt=0x7f050315;
/** if this preference is checked, the hardware volume keys will
work to zoom the board in and out (and will not control
volume) This only applies when the Board screen is
@ -5882,7 +5883,7 @@ XLATE-ME
/**
*/
public static final int scan_progress=0x7f050306;
public static final int scan_progress=0x7f050307;
/** <string name="sel_games_fmt">Games: %1$d</string>
*/
public static final int sel_games_fmt=0x7f050253;
@ -5997,7 +5998,7 @@ XLATE-ME
/**
*/
public static final int sms_disabled=0x7f05030d;
public static final int sms_disabled=0x7f05030e;
/** Title of phone number picker during invitation to a game via SMS
Title of phone number picker during invitation to a game via SMS
<string name="sms_invite_title">SMS Invitation</string>
@ -6006,7 +6007,7 @@ XLATE-ME
/**
*/
public static final int sms_networked_desc=0x7f05030c;
public static final int sms_networked_desc=0x7f05030d;
/** The invitation process begins with this query. The choice is
between html and plaintext formatting but I also provide some
explanation/guidance.
@ -6014,14 +6015,14 @@ XLATE-ME
between html and plaintext formatting but I also provide some
explanation/guidance.
*/
public static final int sms_or_email=0x7f0502fa;
public static final int sms_or_email=0x7f0502fb;
/** <string name="sms_ready_text">Tap the receiving device now</string>
*/
public static final int sms_ready_text=0x7f05025c;
/**
*/
public static final int smsname_label=0x7f050309;
public static final int smsname_label=0x7f05030a;
/** <string name="square_tiles">Square rack tiles</string>
*/
public static final int square_tiles=0x7f05024c;
@ -6106,7 +6107,7 @@ XLATE-ME
skipped a turn because of an attempted illegal move/play of a
phony
*/
public static final int str_lostturn=0x7f0502f1;
public static final int str_lostturn=0x7f0502f2;
/** Displayed when you try to commit a turn that is illegal
because there is empty space between some of the tiles
placed, i.e. they do not form a single word.
@ -6182,7 +6183,7 @@ XLATE-ME
user skipped his turn, or made a move involving 0 tiles for 0
points
*/
public static final int str_passed=0x7f0502f0;
public static final int str_passed=0x7f0502f1;
/** Used to alert user to loss of turn when a move is made and
phonies is set to lose turn when word used not in wordlist
@ -6368,11 +6369,11 @@ XLATE-ME
public static final int strd_remaining_tiles_add_fmt=0x7f0500f9;
/** Intro to the paragraph lisiting all of the tiles remaining
*/
public static final int strd_remains_expl_fmt=0x7f050315;
public static final int strd_remains_expl_fmt=0x7f050316;
/** First line in the remaining tiles dialog (reached by tapping
the number at left end of the scoreboard)
*/
public static final int strd_remains_header_fmt=0x7f050316;
public static final int strd_remains_header_fmt=0x7f050317;
/** I don't know how this is used. :-)
I don't know how this is used. :-)
<string name="strd_time_penalty_sub_fmt"> - %1$d [time]</string>
@ -6384,7 +6385,7 @@ XLATE-ME
Used in formatting reports of trades (exchanges of tiles).
Number of tiles traded is substituted for %1$d
*/
public static final int strd_traded_fmt=0x7f0502f7;
public static final int strd_traded_fmt=0x7f0502f8;
/** Used in formatting moves and history. The total score for
one turn is substituted for %1$d.
Used in formatting moves and history. The total score for
@ -6439,7 +6440,7 @@ string name="str_robot_moved">Robot uskutočnil tento ťah:</string
/** formats tiles and score together, and probably doesn't need
translation unless the colon ':' needs to be replaced
*/
public static final int strsd_summaryscored_fmt=0x7f0502f2;
public static final int strsd_summaryscored_fmt=0x7f0502f3;
/** Used in formatting exchange move summaries
Used in formatting exchange move summaries
<string name="strss_traded_for_fmt">Exchanged %1$s for %2$s.</string>
@ -6736,7 +6737,7 @@ string name="str_robot_moved">Robot uskutočnil tento ťah:</string
/**
*/
public static final int title_gamebt_config_fmt=0x7f0502f5;
public static final int title_gamebt_config_fmt=0x7f0502f6;
/** alternate window title used when game is networked
alternate window title used when game is networked
<string name="title_gamenet_config_fmt">%1$s settings (networked)</string>

View file

@ -2449,4 +2449,8 @@
<string name="got_langdict_title">Fetch default wordlist for language</string>
<string name="got_langdict_summary">Don\'t try a second time</string>
<string name="confirm_get_locdict_fmt">Your device is set up for
%1$s. Would you like to download a wordlist so you can play
Crosswords in %1$s?</string>
</resources>

View file

@ -70,6 +70,7 @@ import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.jni.GameSummary;
import org.eehouse.android.xw4.loc.LocUtils;
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
public class DictsDelegate extends ListDelegateBase
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
@ -990,7 +991,7 @@ public class DictsDelegate extends ListDelegateBase
}
public static void downloadDefaultDict( Context context, String lc,
DownloadFinishedListener lstnr )
OnGotLcDictListener lstnr )
{
new GetDefaultDictTask( context, lc, lstnr ).execute();
}
@ -1092,24 +1093,27 @@ public class DictsDelegate extends ListDelegateBase
return result;
}
private static class GetDefaultDictTask extends AsyncTask<Void, Void, Void> {
private static class GetDefaultDictTask extends AsyncTask<Void, Void, String> {
private Context m_context;
private String m_lc;
private DownloadFinishedListener m_lstnr;
private String m_langName;
private OnGotLcDictListener m_lstnr;
public GetDefaultDictTask( Context context, String lc,
DownloadFinishedListener lnr ) {
OnGotLcDictListener lnr ) {
m_context = context;
m_lc = lc;
m_lstnr = lnr;
}
@Override
public Void doInBackground( Void... unused )
public String doInBackground( Void... unused )
{
// FIXME: this should pass up the language code to retrieve and
// parse less data
HttpPost post = UpdateCheckReceiver.makePost( m_context, "listDicts" );
String name = null;
String proc = String.format( "listDicts?lc=%s", m_lc );
HttpPost post = UpdateCheckReceiver.makePost( m_context, proc );
if ( null != post ) {
JSONObject theOne = null;
String langName = null;
@ -1126,7 +1130,7 @@ public class DictsDelegate extends ListDelegateBase
}
// we have our language; look for one marked default;
// otherwise take the largest.
langName = langObj.getString( "lang" );
m_langName = langObj.getString( "lang" );
JSONArray dicts = langObj.getJSONArray( "dicts" );
int nDicts = dicts.length();
int theOneNWords = 0;
@ -1150,14 +1154,16 @@ public class DictsDelegate extends ListDelegateBase
}
if ( null != theOne ) {
String name = theOne.optString( "xwd" );
if ( null != name ) {
DwnldDelegate.downloadDictInBack( m_context, langName,
name, m_lstnr );
}
name = theOne.optString( "xwd" );
}
}
return null;
return name;
}
@Override
protected void onPostExecute( String name )
{
m_lstnr.gotDictInfo( null != name, m_langName, name );
}
}

View file

@ -61,6 +61,7 @@ public class DlgDelegate {
NEW_NET_GAME,
NEW_GAME_PRESSED,
SET_HIDE_NEWGAME_BUTTONS,
DWNLD_LOC_DICT,
// BoardDelegate
UNDO_LAST_ACTION,

View file

@ -65,6 +65,11 @@ public class DwnldDelegate extends ListDelegateBase {
void downloadFinished( String lang, String name, boolean success );
}
public interface OnGotLcDictListener {
void gotDictInfo( boolean success, String lc, String name );
}
public DwnldDelegate( ListDelegator delegator, Bundle savedInstanceState )
{
super( delegator, savedInstanceState, R.layout.import_dict );

View file

@ -65,6 +65,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.loc.LocUtils;
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
public class GamesListDelegate extends ListDelegateBase
implements OnItemLongClickListener,
@ -1198,6 +1199,22 @@ public class GamesListDelegate extends ListDelegateBase
XWPrefs.setHideNewgameButtons( m_activity, true );
setupButtons();
break;
case DWNLD_LOC_DICT:
String lang = (String)params[0];
String name = (String)params[1];
DownloadFinishedListener lstnr = new DownloadFinishedListener() {
public void downloadFinished( String lang, String name, boolean success )
{
if ( success ) {
XWPrefs.setPrefsBoolean( m_activity,
R.string.key_got_langdict,
true );
// TODO: set language and dict pref to match
}
}
};
DwnldDelegate.downloadDictInBack( m_activity, lang, name, lstnr );
break;
default:
Assert.fail();
}
@ -1871,25 +1888,26 @@ public class GamesListDelegate extends ListDelegateBase
private void getDictForLangIf()
{
String lc = Locale.getDefault().getLanguage();
if ( !lc.equals("en") ) {
int code = LocUtils.codeForLangCode( m_activity, lc );
String[] names = DictLangCache.getHaveLang( m_activity, code );
if ( 0 == names.length ) {
DownloadFinishedListener lstnr = new DownloadFinishedListener() {
public void downloadFinished( final String lang,
String name,
boolean success ) {
if ( success ) {
runOnUiThread( new Runnable() {
public void run() {
showGotDictForLang( lang );
}
} );
if ( ! XWPrefs.getPrefsBoolean( m_activity, R.string.key_got_langdict,
false ) ) {
String lc = "it";//Locale.getDefault().getLanguage();
if ( !lc.equals("en") ) {
int code = LocUtils.codeForLangCode( m_activity, lc );
String[] names = DictLangCache.getHaveLang( m_activity, code );
if ( 0 == names.length ) {
OnGotLcDictListener lstnr = new OnGotLcDictListener() {
public void gotDictInfo( boolean success, String lang,
String name ) {
if ( success ) {
String msg = getString( R.string.confirm_get_locdict_fmt, lang );
showConfirmThen( msg, R.string.button_download,
Action.DWNLD_LOC_DICT, lang,
name );
}
}
}
};
DictsDelegate.downloadDefaultDict( m_activity, lc, lstnr );
};
DictsDelegate.downloadDefaultDict( m_activity, lc, lstnr );
}
}
}
}