mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
don't go straight from tap on dict word to browser: add bool so that
even if there's only one lookup URL it'll be listed and user can quickly cancel.
This commit is contained in:
parent
c222f08252
commit
56fc73e78a
5 changed files with 22 additions and 8 deletions
|
@ -180,7 +180,7 @@ public class DictBrowseActivity extends XWListActivity
|
||||||
{
|
{
|
||||||
TextView text = (TextView)view;
|
TextView text = (TextView)view;
|
||||||
String[] words = { text.getText().toString() };
|
String[] words = { text.getText().toString() };
|
||||||
launchLookup( words, m_lang );
|
launchLookup( words, m_lang, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findButtonClicked()
|
private void findButtonClicked()
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class DlgDelegate {
|
||||||
private static final String POSBUTTON = "posbutton";
|
private static final String POSBUTTON = "posbutton";
|
||||||
private static final String WORDS = "words";
|
private static final String WORDS = "words";
|
||||||
private static final String LANG = "lang";
|
private static final String LANG = "lang";
|
||||||
|
private static final String FORCELIST = "forcelist";
|
||||||
|
|
||||||
// Cache a couple of callback implementations that never change:
|
// Cache a couple of callback implementations that never change:
|
||||||
private DialogInterface.OnClickListener m_cbkOnClickLstnr = null;
|
private DialogInterface.OnClickListener m_cbkOnClickLstnr = null;
|
||||||
|
@ -78,6 +79,7 @@ public class DlgDelegate {
|
||||||
private String m_dictName = null;
|
private String m_dictName = null;
|
||||||
private String[] m_words = null;
|
private String[] m_words = null;
|
||||||
private int m_wordsLang = -1;
|
private int m_wordsLang = -1;
|
||||||
|
private boolean m_forceList = false;
|
||||||
|
|
||||||
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
||||||
Bundle bundle )
|
Bundle bundle )
|
||||||
|
@ -93,6 +95,7 @@ public class DlgDelegate {
|
||||||
m_prefsKey = bundle.getInt( PREFSKEY );
|
m_prefsKey = bundle.getInt( PREFSKEY );
|
||||||
m_words = bundle.getStringArray( WORDS );
|
m_words = bundle.getStringArray( WORDS );
|
||||||
m_wordsLang = bundle.getInt( LANG );
|
m_wordsLang = bundle.getInt( LANG );
|
||||||
|
m_forceList = bundle.getBoolean( FORCELIST );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +108,7 @@ public class DlgDelegate {
|
||||||
outState.putInt( PREFSKEY, m_prefsKey );
|
outState.putInt( PREFSKEY, m_prefsKey );
|
||||||
outState.putStringArray( WORDS, m_words );
|
outState.putStringArray( WORDS, m_words );
|
||||||
outState.putInt( LANG, m_wordsLang );
|
outState.putInt( LANG, m_wordsLang );
|
||||||
|
outState.putBoolean( FORCELIST, m_forceList );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dialog onCreateDialog( int id )
|
public Dialog onCreateDialog( int id )
|
||||||
|
@ -130,12 +134,13 @@ public class DlgDelegate {
|
||||||
dialog = createDictGoneDialog();
|
dialog = createDictGoneDialog();
|
||||||
break;
|
break;
|
||||||
case DLG_LOOKUP:
|
case DLG_LOOKUP:
|
||||||
LookupView view = (LookupView)Utils.inflate( m_activity, R.layout.lookup );
|
LookupView view = (LookupView)Utils.inflate( m_activity,
|
||||||
|
R.layout.lookup );
|
||||||
dialog = new AlertDialog.Builder( m_activity )
|
dialog = new AlertDialog.Builder( m_activity )
|
||||||
.setView( view )
|
.setView( view )
|
||||||
.create();
|
.create();
|
||||||
view.setDialog( dialog, DLG_LOOKUP );
|
view.setDialog( dialog, DLG_LOOKUP );
|
||||||
view.setWords( m_words, m_wordsLang );
|
view.setWords( m_words, m_wordsLang, m_forceList );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return dialog;
|
return dialog;
|
||||||
|
@ -242,10 +247,11 @@ public class DlgDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launchLookup( String[] words, int lang )
|
public void launchLookup( String[] words, int lang, boolean forceList )
|
||||||
{
|
{
|
||||||
m_words = words;
|
m_words = words;
|
||||||
m_wordsLang = lang;
|
m_wordsLang = lang;
|
||||||
|
m_forceList = forceList;
|
||||||
m_activity.showDialog( DLG_LOOKUP );
|
m_activity.showDialog( DLG_LOOKUP );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class LookupView extends LinearLayout
|
||||||
private static int s_lang = -1;
|
private static int s_lang = -1;
|
||||||
|
|
||||||
private String[] m_words;
|
private String[] m_words;
|
||||||
|
private boolean m_forceList;
|
||||||
private static int m_lang;
|
private static int m_lang;
|
||||||
private int m_wordIndex = 0;
|
private int m_wordIndex = 0;
|
||||||
private int m_urlIndex = 0;
|
private int m_urlIndex = 0;
|
||||||
|
@ -79,9 +80,10 @@ public class LookupView extends LinearLayout
|
||||||
m_context = cx;
|
m_context = cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWords( String[] words, int lang )
|
public void setWords( String[] words, int lang, boolean forceList )
|
||||||
{
|
{
|
||||||
m_words = words;
|
m_words = words;
|
||||||
|
m_forceList = forceList;
|
||||||
setLang( lang );
|
setLang( lang );
|
||||||
|
|
||||||
m_state = STATE_DONE;
|
m_state = STATE_DONE;
|
||||||
|
@ -140,7 +142,8 @@ public class LookupView extends LinearLayout
|
||||||
if ( STATE_WORDS == m_state && 1 >= m_words.length ) {
|
if ( STATE_WORDS == m_state && 1 >= m_words.length ) {
|
||||||
m_state += incr;
|
m_state += incr;
|
||||||
}
|
}
|
||||||
if ( STATE_URLS == m_state && 1 >= s_lookupUrls.length ) {
|
if ( STATE_URLS == m_state &&
|
||||||
|
( 1 >= s_lookupUrls.length && !m_forceList ) ) {
|
||||||
m_state += incr;
|
m_state += incr;
|
||||||
}
|
}
|
||||||
if ( m_state == curState ) {
|
if ( m_state == curState ) {
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class XWActivity extends Activity
|
||||||
|
|
||||||
protected void launchLookup( String[] words, int lang )
|
protected void launchLookup( String[] words, int lang )
|
||||||
{
|
{
|
||||||
m_delegate.launchLookup( words, lang );
|
m_delegate.launchLookup( words, lang, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// DlgDelegate.DlgClickNotify interface
|
// DlgDelegate.DlgClickNotify interface
|
||||||
|
|
|
@ -155,7 +155,12 @@ public class XWListActivity extends ListActivity
|
||||||
|
|
||||||
protected void launchLookup( String[] words, int lang )
|
protected void launchLookup( String[] words, int lang )
|
||||||
{
|
{
|
||||||
m_delegate.launchLookup( words, lang );
|
m_delegate.launchLookup( words, lang, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void launchLookup( String[] words, int lang, boolean forceList )
|
||||||
|
{
|
||||||
|
m_delegate.launchLookup( words, lang, forceList );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue