mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
From game config's download-more spinner items, launch DictsActivity
rather than a separate download. This uses DictsActivity's query for where the downloaded item should be stored.
This commit is contained in:
parent
7cf412dd50
commit
d11ef3c390
2 changed files with 43 additions and 13 deletions
|
@ -29,6 +29,8 @@ import android.widget.TextView;
|
|||
import android.widget.AdapterView;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ContextMenu;
|
||||
|
@ -37,7 +39,6 @@ import android.view.ContextMenu.ContextMenuInfo;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.content.SharedPreferences;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.XwJNI;
|
||||
|
@ -46,8 +47,13 @@ import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
|||
public class DictsActivity extends XWListActivity
|
||||
implements View.OnClickListener,
|
||||
XWListItem.DeleteCallback {
|
||||
|
||||
public static final String DICT_DOLAUNCH = "do_launch";
|
||||
public static final String DICT_LANG_EXTRA = "use_lang";
|
||||
|
||||
private String[] m_dicts;
|
||||
private static final int PICK_STORAGE = DlgDelegate.DIALOG_LAST + 1;
|
||||
private int m_lang = 0;
|
||||
|
||||
private class DictListAdapter extends XWListAdapter {
|
||||
private Context m_context;
|
||||
|
@ -88,7 +94,8 @@ public class DictsActivity extends XWListActivity
|
|||
|
||||
lstnrSD = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
startDownload( item != DialogInterface.BUTTON_POSITIVE );
|
||||
startDownload( m_lang, item !=
|
||||
DialogInterface.BUTTON_POSITIVE );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -117,6 +124,15 @@ public class DictsActivity extends XWListActivity
|
|||
|
||||
showNotAgainDlg( R.string.not_again_dicts,
|
||||
R.string.key_notagain_dicts );
|
||||
|
||||
Intent intent = getIntent();
|
||||
if ( null != intent ) {
|
||||
boolean downloadNow = intent.getBooleanExtra( DICT_DOLAUNCH, false );
|
||||
if ( downloadNow ) {
|
||||
int lang = intent.getIntExtra( DICT_LANG_EXTRA, 0 );
|
||||
askStartDownload( lang );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,11 +144,7 @@ public class DictsActivity extends XWListActivity
|
|||
|
||||
public void onClick( View v )
|
||||
{
|
||||
if ( GameUtils.haveWriteableSD() ) {
|
||||
showDialog( PICK_STORAGE );
|
||||
} else {
|
||||
startDownload( false );
|
||||
}
|
||||
askStartDownload( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -223,10 +235,20 @@ public class DictsActivity extends XWListActivity
|
|||
mkListAdapter();
|
||||
}
|
||||
|
||||
private void startDownload( boolean toSD )
|
||||
private void askStartDownload( int lang )
|
||||
{
|
||||
if ( GameUtils.haveWriteableSD() ) {
|
||||
m_lang = lang;
|
||||
showDialog( PICK_STORAGE );
|
||||
} else {
|
||||
startDownload( lang, false );
|
||||
}
|
||||
}
|
||||
|
||||
private void startDownload( int lang, boolean toSD )
|
||||
{
|
||||
DictImportActivity.setUseSD( toSD );
|
||||
startActivity( Utils.mkDownloadActivity( this ) );
|
||||
startActivity( Utils.mkDownloadActivity( this, lang ) );
|
||||
}
|
||||
|
||||
private void mkListAdapter()
|
||||
|
|
|
@ -662,11 +662,9 @@ public class GameConfig extends XWActivity
|
|||
(String)parentView.getItemAtPosition( position );
|
||||
|
||||
if ( chosen.equals( m_browseText ) ) {
|
||||
startActivity( Utils.mkDownloadActivity(GameConfig.this,
|
||||
m_gi.dictLang ) );
|
||||
launchDictBrowser( m_gi.dictLang );
|
||||
} else {
|
||||
lp.dictName = chosen;
|
||||
Utils.logf( "set lp.dictName: %s", lp.dictName );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,7 +689,7 @@ public class GameConfig extends XWActivity
|
|||
String chosen =
|
||||
(String)parentView.getItemAtPosition( position );
|
||||
if ( chosen.equals( m_browseText ) ) {
|
||||
startActivity( Utils.mkDownloadActivity(GameConfig.this) );
|
||||
launchDictBrowser( 0 );
|
||||
} else {
|
||||
m_gi.setLang( DictLangCache.
|
||||
getLangLangCode( GameConfig.this,
|
||||
|
@ -978,4 +976,14 @@ public class GameConfig extends XWActivity
|
|||
m_gi.nPlayers, m_roomChoose ).execute();
|
||||
}
|
||||
|
||||
private void launchDictBrowser( int lang )
|
||||
{
|
||||
Intent intent = new Intent( this, DictsActivity.class );
|
||||
intent.putExtra( DictsActivity.DICT_DOLAUNCH, true );
|
||||
if ( lang > 0 ) {
|
||||
intent.putExtra( DictsActivity.DICT_LANG_EXTRA, lang );
|
||||
}
|
||||
startActivity( intent );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue