mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
implement menus, including adding crappy placeholder icons
This commit is contained in:
parent
aa6fbf8605
commit
fd817a98da
6 changed files with 121 additions and 26 deletions
19
xwords4/android/XWords4/img_src/clear_all.svg
Normal file
19
xwords4/android/XWords4/img_src/clear_all.svg
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg id="svg7384" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<metadata id="metadata90">
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title>Gnome Symbolic Icon Theme</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<title id="title9167">Gnome Symbolic Icon Theme</title>
|
||||
<g id="layer12" transform="translate(-201 -767)">
|
||||
<path id="path36048" style="block-progression:tb;text-indent:0;color:#000000;enable-background:new;text-transform:none;fill:#bebebe" d="m211.88 767.06a1.0001 1.0001 0 0 0 -0.6875 0.5l-3.3125 5.625a1.0078 1.0078 0 1 0 1.75 1l3.3125-5.625a1.0001 1.0001 0 0 0 -1.0625 -1.5z"/>
|
||||
<path id="path36050" style="color:#000000;enable-background:new;fill:#bebebe" d="m206.53 771.72 4.9474 3.0538c0.60355 0.31472 0.68739 0.89216 0.20883 1.5087l-0.625 0.8125-6.5938-3.875 0.55118-1.0614c0.28883-0.58524 0.75466-0.81586 1.5113-0.43864z"/>
|
||||
<path id="path36052" style="color:#000000;enable-background:new;fill:#bebebe" d="m204.56 774.58s-2.8547 3.0362-1.3326 4.6991c1.6875 1.8438 4.758 1.7674 5.8628 1.7232h4.0087c-1.875-0.375-3.8371-1.8156-2.9027-3.2446z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
17
xwords4/android/XWords4/img_src/select_all.svg
Normal file
17
xwords4/android/XWords4/img_src/select_all.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg id="svg7384" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<metadata id="metadata90">
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title>Gnome Symbolic Icon Theme</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<title id="title9167">Gnome Symbolic Icon Theme</title>
|
||||
<g id="layer12" transform="translate(-241 -647)">
|
||||
<path id="path4387-5" style="color:#bebebe;fill:#bebebe" d="m243.93 648c-0.50766 0.0395-0.94152 0.51729-0.93263 1.0269v12.945c-0.008 0.5398 0.48663 1.0348 1.0259 1.0269h9.948c0.53926 0.008 1.0337-0.48711 1.0259-1.0269v-9.958c-0.004-0.26704-0.1184-0.53079-0.31088-0.71573l-2.9844-2.9874c-0.18475-0.19267-0.44824-0.30734-0.71501-0.31119h-6.9636c-0.0311-0.00099-0.0622-0.00099-0.0933 0zm1.0881 2.0539h5.9688v1.9916h-5.9688zm0 3.9832h7.9584v1.9916h-7.9584zm0 3.9832h7.9584v1.9916h-7.9584z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -1,22 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/select_all"
|
||||
<item android:id="@+id/slmenu_select_all"
|
||||
android:title="@string/slmenu_select_all"
|
||||
android:icon="@drawable/select_all__gen"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/deselect_all"
|
||||
<item android:id="@+id/slmenu_deselect_all"
|
||||
android:title="@string/slmenu_deselect_all"
|
||||
android:icon="@drawable/clear_all__gen"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/copy_all"
|
||||
android:title="@string/slmenu_copy_all"
|
||||
<item android:id="@+id/slmenu_copy_sel"
|
||||
android:title="@string/slmenu_copy_sel"
|
||||
android:icon="@drawable/content_copy__gen"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/clear_all"
|
||||
android:title="@string/slmenu_clear_all"
|
||||
<item android:id="@+id/slmenu_clear_sel"
|
||||
android:title="@string/slmenu_clear_sel"
|
||||
android:icon="@drawable/content_discard__gen"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
|
|
|
@ -2207,10 +2207,10 @@
|
|||
of words to remember</string>
|
||||
<string name="gamel_menu_study">Studylist…</string>
|
||||
|
||||
<string name="slmenu_copy_all">Copy to clipboard</string>
|
||||
<string name="slmenu_clear_all">Delete</string>
|
||||
<string name="slmenu_copy_sel">Copy to clipboard</string>
|
||||
<string name="slmenu_clear_sel">Delete</string>
|
||||
<string name="confirm_studylist_clear">Are you sure you want to
|
||||
delete this list?\n\n(This action cannot be undone.)</string>
|
||||
delete the selected words?\n\n(This action cannot be undone.)</string>
|
||||
<string name="paste_donef">%d word[s] copied</string>
|
||||
<string name="add_donef">%s added to list</string>
|
||||
<string name="studylist_titlef">Studylist for %s</string>
|
||||
|
@ -2222,7 +2222,7 @@
|
|||
<string name="study_no_lists">You have not yet saved any words
|
||||
into a studylist.</string>
|
||||
|
||||
<string name="not_again_studycopy">The words in this list will be
|
||||
<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>
|
||||
|
||||
|
|
|
@ -1665,9 +1665,18 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void studyListClear( Context context, int lang )
|
||||
public static void studyListClear( Context context, int lang, String[] words )
|
||||
{
|
||||
String selection = String.format( "%s = %d", DBHelper.LANGUAGE, lang );
|
||||
if ( null != words ) {
|
||||
String[] inQuotes = new String[words.length];
|
||||
for ( int ii = 0; ii < inQuotes.length; ++ii ) {
|
||||
inQuotes[ii] = String.format( "'%s'", words[ii] );
|
||||
}
|
||||
String wordsTest = String.format( " AND %s in (%s)", DBHelper.WORD,
|
||||
TextUtils.join(",", inQuotes) );
|
||||
selection += wordsTest;
|
||||
}
|
||||
|
||||
initDB( context );
|
||||
synchronized( s_dbHelper ) {
|
||||
|
@ -1677,6 +1686,11 @@ public class DBUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void studyListClear( Context context, int lang )
|
||||
{
|
||||
studyListClear( context, lang, null );
|
||||
}
|
||||
|
||||
private static void copyGameDB( Context context, boolean toSDCard )
|
||||
{
|
||||
String name = DBHelper.getDBName();
|
||||
|
|
|
@ -37,6 +37,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.Spinner;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
@ -74,6 +75,15 @@ public class StudyList extends XWListActivity
|
|||
initOrFinish( getIntent() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ( 0 == m_checkeds.size() ) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
clearSels();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
|
@ -81,37 +91,40 @@ public class StudyList extends XWListActivity
|
|||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onPrepareOptionsMenu( Menu menu )
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
int nSel = m_checkeds.size();
|
||||
Utils.setItemVisible( menu, R.id.slmenu_copy_sel, 0 < nSel );
|
||||
Utils.setItemVisible( menu, R.id.slmenu_clear_sel, 0 < nSel );
|
||||
Utils.setItemVisible( menu, R.id.slmenu_select_all, m_words.length > nSel );
|
||||
Utils.setItemVisible( menu, R.id.slmenu_deselect_all, 0 < nSel );
|
||||
return super.onPrepareOptionsMenu( menu );
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
boolean handled = true;
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.copy_all:
|
||||
case R.id.slmenu_copy_sel:
|
||||
showNotAgainDlgThen( R.string.not_again_studycopy,
|
||||
R.string.key_na_studycopy,
|
||||
Action.SL_COPY_ACTION );
|
||||
break;
|
||||
case R.id.clear_all:
|
||||
case R.id.slmenu_clear_sel:
|
||||
showConfirmThen( R.string.confirm_studylist_clear,
|
||||
Action.SL_CLEAR_ACTION );
|
||||
break;
|
||||
|
||||
case R.id.select_all:
|
||||
case R.id.slmenu_select_all:
|
||||
for ( int ii = 0; ii < m_words.length; ++ii ) {
|
||||
m_checkeds.add( ii );
|
||||
}
|
||||
makeAdapter();
|
||||
setTitleBar();
|
||||
break;
|
||||
case R.id.deselect_all:
|
||||
m_checkeds.clear();
|
||||
makeAdapter();
|
||||
setTitleBar();
|
||||
case R.id.slmenu_deselect_all:
|
||||
clearSels();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -129,15 +142,20 @@ public class StudyList extends XWListActivity
|
|||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
switch ( action ) {
|
||||
case SL_CLEAR_ACTION:
|
||||
DBUtils.studyListClear( this, m_langCodes[m_langPosition] );
|
||||
String[] selWords = getSelWords();
|
||||
if ( selWords.length == m_words.length ) {
|
||||
selWords = null; // all: easier on DB :-)
|
||||
}
|
||||
DBUtils.studyListClear( this, m_langCodes[m_langPosition], selWords );
|
||||
initOrFinish( null );
|
||||
break;
|
||||
case SL_COPY_ACTION:
|
||||
selWords = getSelWords();
|
||||
ClipboardManager clipboard = (ClipboardManager)
|
||||
getSystemService( Context.CLIPBOARD_SERVICE );
|
||||
clipboard.setText( TextUtils.join( "\n", m_words ) );
|
||||
clipboard.setText( TextUtils.join( "\n", selWords ) );
|
||||
|
||||
String msg = getString( R.string.paste_donef, m_words.length );
|
||||
String msg = getString( R.string.paste_donef, selWords.length );
|
||||
Utils.showToast( this, msg );
|
||||
break;
|
||||
default:
|
||||
|
@ -269,6 +287,29 @@ public class StudyList extends XWListActivity
|
|||
setTitle( newTitle );
|
||||
}
|
||||
|
||||
private String[] getSelWords()
|
||||
{
|
||||
String[] result;
|
||||
int nSels = m_checkeds.size();
|
||||
if ( nSels == m_words.length ) {
|
||||
result = m_words;
|
||||
} else {
|
||||
result = new String[nSels];
|
||||
Iterator<Integer> iter = m_checkeds.iterator();
|
||||
for ( int ii = 0; iter.hasNext(); ++ii ) {
|
||||
result[ii] = m_words[iter.next()];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void clearSels()
|
||||
{
|
||||
m_checkeds.clear();
|
||||
makeAdapter();
|
||||
setTitleBar();
|
||||
}
|
||||
|
||||
public static void launchOrAlert( Context context, int lang,
|
||||
DlgDelegate.HasDlgDelegate dlg )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue