diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index c514c9fed..17d438762 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -187,6 +187,9 @@ + diff --git a/xwords4/android/XWords4/img_src/search.svg b/xwords4/android/XWords4/img_src/search.svg index fde727e7b..0f2befb5f 100644 --- a/xwords4/android/XWords4/img_src/search.svg +++ b/xwords4/android/XWords4/img_src/search.svg @@ -1,9 +1,15 @@ - - - -core + + + + + + + + + + + diff --git a/xwords4/android/XWords4/res/layout/loc_main.xml b/xwords4/android/XWords4/res/layout/loc_main.xml new file mode 100644 index 000000000..3720870f0 --- /dev/null +++ b/xwords4/android/XWords4/res/layout/loc_main.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 8079ce379..45cadf416 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -114,6 +114,7 @@ xwords@eehouse.org + English eehouse.org diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index f3a40fd04..7a44a46cb 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2231,4 +2231,6 @@ Unselect all Selected: %1$d + Your language + Translate diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java new file mode 100644 index 000000000..5dc789d69 --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java @@ -0,0 +1,36 @@ +/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ +/* + * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4.loc; + +import android.app.ListActivity; +import android.os.Bundle; + +public class LocActivity extends ListActivity { + + private LocDelegate m_dlgt; + + @Override + protected void onCreate( Bundle savedInstanceState ) + { + super.onCreate( savedInstanceState ); + m_dlgt = new LocDelegate( this, savedInstanceState ); + } // onCreate + +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java new file mode 100644 index 000000000..038c3ba0d --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocDelegate.java @@ -0,0 +1,45 @@ +/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ +/* + * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4.loc; + +import android.app.ListActivity; +import android.os.Bundle; + +import org.eehouse.android.xw4.DelegateBase; +import org.eehouse.android.xw4.R; + + +public class LocDelegate extends DelegateBase { + + private ListActivity m_activity; + + protected LocDelegate( ListActivity activity, Bundle savedInstanceState ) + { + super( activity, savedInstanceState ); + m_activity = activity; + init( savedInstanceState ); + } + + private void init( Bundle savedInstanceState ) + { + m_activity.setContentView( R.layout.loc_main ); + } + +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java index e566aa7b7..9fc693298 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocUtils.java @@ -19,9 +19,12 @@ package org.eehouse.android.xw4.loc; +import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.util.AttributeSet; import android.view.Menu; +import android.view.MenuItem.OnMenuItemClickListener; import android.view.MenuItem; import junit.framework.Assert; @@ -54,32 +57,9 @@ public class LocUtils { } } - public static void xlateMenu( Context context, Menu menu ) + public static void xlateMenu( Activity activity, Menu menu ) { - int count = menu.size(); - DbgUtils.logf( "xlateMenu: menu has %d items", count ); - for ( int ii = 0; ii < count; ++ii ) { - MenuItem item = menu.getItem( ii ); - CharSequence ts = item.getTitle(); - if ( null != ts ) { - String title = ts.toString(); - DbgUtils.logf( "xlateMenu: %d; %s", ii, title ); - if ( title.startsWith( LOC_PREFIX ) ) { - String asKey = title.substring( LOC_PREFIX.length() ); - int id = LocIDs.getID( asKey ); - if ( LocIDs.NOT_FOUND != id ) { - asKey = getString( context, id ); - } else { - DbgUtils.logf( "nothing for %s", asKey ); - } - item.setTitle( asKey ); - } - } - - if ( item.hasSubMenu() ) { - xlateMenu( context, item.getSubMenu() ); - } - } + xlateMenu( activity, menu, 0 ); } public static String xlateString( Context context, String str ) @@ -118,4 +98,48 @@ public class LocUtils { str = String.format( str, params ); return str.toUpperCase(); } + + private static void xlateMenu( final Activity activity, Menu menu, + int depth ) + { + int count = menu.size(); + DbgUtils.logf( "xlateMenu: menu has %d items", count ); + for ( int ii = 0; ii < count; ++ii ) { + MenuItem item = menu.getItem( ii ); + CharSequence ts = item.getTitle(); + if ( null != ts ) { + String title = ts.toString(); + DbgUtils.logf( "xlateMenu: %d; %s", ii, title ); + if ( title.startsWith( LOC_PREFIX ) ) { + String asKey = title.substring( LOC_PREFIX.length() ); + int id = LocIDs.getID( asKey ); + if ( LocIDs.NOT_FOUND != id ) { + asKey = getString( activity, id ); + } else { + DbgUtils.logf( "nothing for %s", asKey ); + } + item.setTitle( asKey ); + } + } + + if ( item.hasSubMenu() ) { + xlateMenu( activity, item.getSubMenu(), 1 + depth ); + } + } + + // The caller is loc-aware, so add our menu -- at the top level! + if ( 0 == depth ) { + String title = getString( activity, R.string.loc_menu_xlate ); + menu.add( title ) + .setOnMenuItemClickListener( new OnMenuItemClickListener() { + public boolean onMenuItemClick( MenuItem item ) { + Intent intent = + new Intent( activity, LocActivity.class ); + activity.startActivity( intent ); + return true; + } + }); + } + } + }