mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
add menu and implement copy-to-clipboard
This commit is contained in:
parent
42f35cb3d9
commit
2520fb4c05
3 changed files with 57 additions and 6 deletions
11
xwords4/android/XWords4/res/menu/studylist.xml
Normal file
11
xwords4/android/XWords4/res/menu/studylist.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/copy_all"
|
||||||
|
android:title="@string/slmenu_copy_all"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<item android:id="@+id/clear_all"
|
||||||
|
android:title="@string/slmenu_clear_all"
|
||||||
|
/>
|
||||||
|
</menu>
|
|
@ -2210,4 +2210,8 @@
|
||||||
of words to remember</string>
|
of words to remember</string>
|
||||||
<string name="gamel_menu_study">Study list…</string>
|
<string name="gamel_menu_study">Study list…</string>
|
||||||
<string name="pick_language_prompt">Choose list language</string>
|
<string name="pick_language_prompt">Choose list language</string>
|
||||||
|
|
||||||
|
<string name="slmenu_copy_all">Copy to clipboard</string>
|
||||||
|
<string name="slmenu_clear_all">Clear all</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -19,20 +19,26 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Spinner;
|
import android.text.ClipboardManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.text.TextUtils;
|
||||||
import android.widget.AdapterView;
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
public class StudyList extends XWListActivity
|
public class StudyList extends XWListActivity
|
||||||
implements OnItemSelectedListener {
|
implements OnItemSelectedListener {
|
||||||
|
|
||||||
private Spinner m_spinner;
|
private Spinner m_spinner;
|
||||||
private int[] m_langCodes;
|
private int[] m_langCodes;
|
||||||
|
private String[] m_words;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
|
@ -66,6 +72,36 @@ public class StudyList extends XWListActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu( Menu menu )
|
||||||
|
{
|
||||||
|
getMenuInflater().inflate( R.menu.studylist, menu );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean onPrepareOptionsMenu( Menu menu )
|
||||||
|
// {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected( MenuItem item )
|
||||||
|
{
|
||||||
|
boolean handled = true;
|
||||||
|
switch ( item.getItemId() ) {
|
||||||
|
case R.id.copy_all:
|
||||||
|
ClipboardManager clipboard = (ClipboardManager)
|
||||||
|
getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setText( TextUtils.join( "\n", m_words ) );
|
||||||
|
break;
|
||||||
|
case R.id.clear_all:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
handled = false;
|
||||||
|
}
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// AdapterView.OnItemSelectedListener interface
|
// AdapterView.OnItemSelectedListener interface
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
@ -82,10 +118,10 @@ public class StudyList extends XWListActivity
|
||||||
|
|
||||||
private void loadList( int lang )
|
private void loadList( int lang )
|
||||||
{
|
{
|
||||||
String[] words = DBUtils.studyListWords( this, lang );
|
m_words = DBUtils.studyListWords( this, lang );
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>
|
||||||
( this, android.R.layout.simple_list_item_1 );
|
( this, android.R.layout.simple_list_item_1 );
|
||||||
for ( String word : words ) {
|
for ( String word : m_words ) {
|
||||||
adapter.add( word );
|
adapter.add( word );
|
||||||
}
|
}
|
||||||
// adapter.sort();
|
// adapter.sort();
|
||||||
|
|
Loading…
Add table
Reference in a new issue