mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-17 09:34:08 +01:00
(more of prev commit) generate xml layout files from res_src, and run all inflation through LocUtils that tries to substitute strings
This commit is contained in:
parent
201e808b4a
commit
d27f2d580a
26 changed files with 158 additions and 65 deletions
xwords4/android
XWords4
build.xml
res
src/org/eehouse/android/xw4
BTInviteActivity.javaBoardDelegate.javaChatActivity.javaChatDelegate.javaDelegateBase.javaDictBrowseActivity.javaDictsActivity.javaDictsDelegate.javaDlgDelegate.javaGameConfig.javaGameListGroup.javaGameListItem.javaGamesListDelegate.javaLookupAlert.javaNewGameActivity.javaSMSCheckBoxPreference.javaSMSInviteActivity.javaUtils.javaXWListItem.javaXWPrefs.java
loc
scripts
|
@ -84,6 +84,10 @@
|
||||||
failonerror="true" output="/dev/null"
|
failonerror="true" output="/dev/null"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<exec dir="." executable="../scripts/mk_xml.py"
|
||||||
|
failonerror="true" output="/dev/null"
|
||||||
|
/>
|
||||||
|
|
||||||
<exec dir="." executable="../scripts/gen_gcmid.sh"
|
<exec dir="." executable="../scripts/gen_gcmid.sh"
|
||||||
output="src/org/eehouse/android/xw4/GCMConsts.java"
|
output="src/org/eehouse/android/xw4/GCMConsts.java"
|
||||||
logError="true" failonerror="true"
|
logError="true" failonerror="true"
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
<string name="key_enable_debug">key_enable_debug</string>
|
<string name="key_enable_debug">key_enable_debug</string>
|
||||||
<string name="key_enable_dup_invite">key_enable_dup_invite</string>
|
<string name="key_enable_dup_invite">key_enable_dup_invite</string>
|
||||||
<string name="key_download_path">key_download_path</string>
|
<string name="key_download_path">key_download_path</string>
|
||||||
|
<string name="key_xlations_locale">key_xlations_locale</string>
|
||||||
|
|
||||||
<!-- Nor is my email address -->
|
<!-- Nor is my email address -->
|
||||||
<string name="email_author_email">xwords@eehouse.org</string>
|
<string name="email_author_email">xwords@eehouse.org</string>
|
||||||
|
@ -152,6 +153,7 @@
|
||||||
<string name="gamel_menu_storedb">Write DB to SD card</string>
|
<string name="gamel_menu_storedb">Write DB to SD card</string>
|
||||||
<string name="gamel_menu_loaddb">Load DB from SD card</string>
|
<string name="gamel_menu_loaddb">Load DB from SD card</string>
|
||||||
<string name="enable_dupes_title">Accept duplicate invites</string>
|
<string name="enable_dupes_title">Accept duplicate invites</string>
|
||||||
|
<string name="xlations_locale">Fake locale for translation</string>
|
||||||
<string name="enable_dupes_summary">Accept invitations more than once</string>
|
<string name="enable_dupes_summary">Accept invitations more than once</string>
|
||||||
|
|
||||||
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
|
||||||
|
|
|
@ -321,6 +321,11 @@
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<org.eehouse.android.xw4.XWEditTextPreference
|
||||||
|
android:key="@string/key_xlations_locale"
|
||||||
|
android:title="@string/xlations_locale"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- For broken devices like my Blaze 4G that report a download
|
<!-- For broken devices like my Blaze 4G that report a download
|
||||||
directory that doesn't exist, allow users to set it. Mine:
|
directory that doesn't exist, allow users to set it. Mine:
|
||||||
/sdcard/external_sd/download
|
/sdcard/external_sd/download
|
||||||
|
|
|
@ -39,6 +39,8 @@ import android.os.Handler;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class BTInviteActivity extends InviteActivity
|
public class BTInviteActivity extends InviteActivity
|
||||||
implements CompoundButton.OnCheckedChangeListener {
|
implements CompoundButton.OnCheckedChangeListener {
|
||||||
|
|
||||||
|
@ -158,7 +160,7 @@ public class BTInviteActivity extends InviteActivity
|
||||||
public View getView( final int position, View convertView,
|
public View getView( final int position, View convertView,
|
||||||
ViewGroup parent ) {
|
ViewGroup parent ) {
|
||||||
CheckBox box = (CheckBox)
|
CheckBox box = (CheckBox)
|
||||||
Utils.inflate( BTInviteActivity.this, R.layout.btinviter_item );
|
LocUtils.inflate( BTInviteActivity.this, R.layout.btinviter_item );
|
||||||
box.setText( m_devs[position] );
|
box.setText( m_devs[position] );
|
||||||
box.setOnCheckedChangeListener( BTInviteActivity.this );
|
box.setOnCheckedChangeListener( BTInviteActivity.this );
|
||||||
return box;
|
return box;
|
||||||
|
|
|
@ -2255,8 +2255,8 @@ public class BoardDelegate extends DelegateBase
|
||||||
m_dlgTitleStr =
|
m_dlgTitleStr =
|
||||||
LocUtils.getString( m_activity, R.string.msg_ask_password_fmt,
|
LocUtils.getString( m_activity, R.string.msg_ask_password_fmt,
|
||||||
m_pwdName );
|
m_pwdName );
|
||||||
m_passwdLyt = (LinearLayout)Utils.inflate( m_activity,
|
m_passwdLyt = (LinearLayout)LocUtils.inflate( m_activity,
|
||||||
R.layout.passwd_view );
|
R.layout.passwd_view );
|
||||||
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
|
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import android.os.Bundle;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
|
@ -26,13 +26,14 @@ import android.os.Bundle;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class ChatDelegate extends DelegateBase
|
public class ChatDelegate extends DelegateBase
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
|
|
||||||
|
@ -56,14 +57,12 @@ public class ChatDelegate extends DelegateBase
|
||||||
if ( null != pairs ) {
|
if ( null != pairs ) {
|
||||||
LinearLayout layout = (LinearLayout)
|
LinearLayout layout = (LinearLayout)
|
||||||
m_activity.findViewById( R.id.chat_history );
|
m_activity.findViewById( R.id.chat_history );
|
||||||
LayoutInflater factory = LayoutInflater.from( m_activity );
|
|
||||||
|
|
||||||
for ( DBUtils.HistoryPair pair : pairs ) {
|
for ( DBUtils.HistoryPair pair : pairs ) {
|
||||||
TextView view = (TextView)factory
|
TextView view = (TextView)
|
||||||
.inflate( pair.sourceLocal
|
LocUtils.inflate( m_activity, pair.sourceLocal
|
||||||
? R.layout.chat_history_local
|
? R.layout.chat_history_local
|
||||||
: R.layout.chat_history_remote,
|
: R.layout.chat_history_remote );
|
||||||
null );
|
|
||||||
view.setText( pair.msg );
|
view.setText( pair.msg );
|
||||||
layout.addView( view );
|
layout.addView( view );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
@ -55,6 +56,13 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify,
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setContentView( int resID )
|
||||||
|
{
|
||||||
|
m_activity.setContentView( resID );
|
||||||
|
View view = Utils.getContentView( m_activity );
|
||||||
|
LocUtils.xlateView( m_activity, view );
|
||||||
|
}
|
||||||
|
|
||||||
protected void showDialog( DlgID dlgID )
|
protected void showDialog( DlgID dlgID )
|
||||||
{
|
{
|
||||||
m_delegate.showDialog( dlgID );
|
m_delegate.showDialog( dlgID );
|
||||||
|
|
|
@ -45,6 +45,7 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class DictBrowseActivity extends XWListActivity
|
public class DictBrowseActivity extends XWListActivity
|
||||||
implements View.OnClickListener, OnItemSelectedListener {
|
implements View.OnClickListener, OnItemSelectedListener {
|
||||||
|
@ -103,9 +104,9 @@ public class DictBrowseActivity extends XWListActivity
|
||||||
|
|
||||||
public Object getItem( int position )
|
public Object getItem( int position )
|
||||||
{
|
{
|
||||||
TextView text =
|
TextView text = (TextView)
|
||||||
(TextView)Utils.inflate( DictBrowseActivity.this,
|
LocUtils.inflate( DictBrowseActivity.this,
|
||||||
android.R.layout.simple_list_item_1 );
|
android.R.layout.simple_list_item_1 );
|
||||||
String str = XwJNI.dict_iter_nthWord( m_dictClosure, position );
|
String str = XwJNI.dict_iter_nthWord( m_dictClosure, position );
|
||||||
if ( null != str ) {
|
if ( null != str ) {
|
||||||
text.setText( str );
|
text.setText( str );
|
||||||
|
|
|
@ -35,7 +35,6 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
|
@ -35,7 +35,6 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -61,6 +60,7 @@ import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
|
||||||
import org.eehouse.android.xw4.jni.GameSummary;
|
import org.eehouse.android.xw4.jni.GameSummary;
|
||||||
import org.eehouse.android.xw4.DictUtils.DictLoc;
|
import org.eehouse.android.xw4.DictUtils.DictLoc;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class DictsDelegate extends DelegateBase
|
public class DictsDelegate extends DelegateBase
|
||||||
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
|
implements View.OnClickListener, AdapterView.OnItemLongClickListener,
|
||||||
|
@ -86,8 +86,6 @@ public class DictsDelegate extends DelegateBase
|
||||||
|
|
||||||
private boolean m_launchedForMissing = false;
|
private boolean m_launchedForMissing = false;
|
||||||
|
|
||||||
private LayoutInflater m_factory;
|
|
||||||
|
|
||||||
private class DictListAdapter implements ExpandableListAdapter {
|
private class DictListAdapter implements ExpandableListAdapter {
|
||||||
private Context m_context;
|
private Context m_context;
|
||||||
private XWListItem[][] m_cache;
|
private XWListItem[][] m_cache;
|
||||||
|
@ -188,9 +186,8 @@ public class DictsDelegate extends DelegateBase
|
||||||
public View getGroupView( int groupPosition, boolean isExpanded,
|
public View getGroupView( int groupPosition, boolean isExpanded,
|
||||||
View convertView, ViewGroup parent )
|
View convertView, ViewGroup parent )
|
||||||
{
|
{
|
||||||
View row =
|
View row = LocUtils.inflate( m_activity, android.R.layout
|
||||||
Utils.inflate( m_activity,
|
.simple_expandable_list_item_1 );
|
||||||
android.R.layout.simple_expandable_list_item_1 );
|
|
||||||
TextView view = (TextView)row.findViewById( android.R.id.text1 );
|
TextView view = (TextView)row.findViewById( android.R.id.text1 );
|
||||||
view.setText( m_langs[groupPosition] );
|
view.setText( m_langs[groupPosition] );
|
||||||
return view;
|
return view;
|
||||||
|
@ -383,8 +380,6 @@ public class DictsDelegate extends DelegateBase
|
||||||
Resources res = m_activity.getResources();
|
Resources res = m_activity.getResources();
|
||||||
m_locNames = res.getStringArray( R.array.loc_names );
|
m_locNames = res.getStringArray( R.array.loc_names );
|
||||||
|
|
||||||
m_factory = LayoutInflater.from( m_activity );
|
|
||||||
|
|
||||||
m_downloadStr = m_activity.getString( R.string.download_dicts );
|
m_downloadStr = m_activity.getString( R.string.download_dicts );
|
||||||
|
|
||||||
m_activity.setContentView( R.layout.dict_browse );
|
m_activity.setContentView( R.layout.dict_browse );
|
||||||
|
|
|
@ -37,6 +37,8 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class DlgDelegate {
|
public class DlgDelegate {
|
||||||
|
|
||||||
public static enum Action {
|
public static enum Action {
|
||||||
|
@ -401,7 +403,7 @@ public class DlgDelegate {
|
||||||
|
|
||||||
private Dialog createAboutDialog()
|
private Dialog createAboutDialog()
|
||||||
{
|
{
|
||||||
final View view = Utils.inflate( m_activity, R.layout.about_dlg );
|
final View view = LocUtils.inflate( m_activity, R.layout.about_dlg );
|
||||||
TextView vers = (TextView)view.findViewById( R.id.version_string );
|
TextView vers = (TextView)view.findViewById( R.id.version_string );
|
||||||
vers.setText( String.format( m_activity.getString(R.string.about_vers_fmt),
|
vers.setText( String.format( m_activity.getString(R.string.about_vers_fmt),
|
||||||
m_activity.getString(R.string.app_version),
|
m_activity.getString(R.string.app_version),
|
||||||
|
|
|
@ -38,7 +38,6 @@ import android.widget.Button;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
@ -58,6 +57,7 @@ import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.jni.*;
|
import org.eehouse.android.xw4.jni.*;
|
||||||
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class GameConfig extends XWActivity
|
public class GameConfig extends XWActivity
|
||||||
implements View.OnClickListener
|
implements View.OnClickListener
|
||||||
|
@ -153,15 +153,14 @@ public class GameConfig extends XWActivity
|
||||||
{
|
{
|
||||||
Dialog dialog = super.onCreateDialog( id );
|
Dialog dialog = super.onCreateDialog( id );
|
||||||
if ( null == dialog ) {
|
if ( null == dialog ) {
|
||||||
LayoutInflater factory;
|
|
||||||
DialogInterface.OnClickListener dlpos;
|
DialogInterface.OnClickListener dlpos;
|
||||||
AlertDialog.Builder ab;
|
AlertDialog.Builder ab;
|
||||||
|
|
||||||
final DlgID dlgID = DlgID.values()[id];
|
final DlgID dlgID = DlgID.values()[id];
|
||||||
switch (dlgID) {
|
switch (dlgID) {
|
||||||
case PLAYER_EDIT:
|
case PLAYER_EDIT:
|
||||||
View playerEditView
|
View playerEditView =
|
||||||
= Utils.inflate( this, R.layout.player_edit );
|
LocUtils.inflate( this, R.layout.player_edit );
|
||||||
|
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
.setTitle(R.string.player_edit_title)
|
.setTitle(R.string.player_edit_title)
|
||||||
|
@ -205,7 +204,7 @@ public class GameConfig extends XWActivity
|
||||||
};
|
};
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
.setTitle( R.string.force_title )
|
.setTitle( R.string.force_title )
|
||||||
.setView( Utils.inflate( this, layoutForDlg(dlgID) ) )
|
.setView( LocUtils.inflate( this, layoutForDlg(dlgID) ) )
|
||||||
.setPositiveButton( R.string.button_ok, dlpos )
|
.setPositiveButton( R.string.button_ok, dlpos )
|
||||||
.create();
|
.create();
|
||||||
DialogInterface.OnDismissListener dismiss =
|
DialogInterface.OnDismissListener dismiss =
|
||||||
|
@ -686,7 +685,6 @@ public class GameConfig extends XWActivity
|
||||||
// only enable delete if one will remain (or two if networked)
|
// only enable delete if one will remain (or two if networked)
|
||||||
boolean canDelete = names.length > 2
|
boolean canDelete = names.length > 2
|
||||||
|| (localOnlyGame() && names.length > 1);
|
|| (localOnlyGame() && names.length > 1);
|
||||||
LayoutInflater factory = LayoutInflater.from(this);
|
|
||||||
View.OnClickListener lstnr = new View.OnClickListener() {
|
View.OnClickListener lstnr = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View view ) {
|
public void onClick( View view ) {
|
||||||
|
@ -710,7 +708,7 @@ public class GameConfig extends XWActivity
|
||||||
view.setOnClickListener( lstnr );
|
view.setOnClickListener( lstnr );
|
||||||
m_playerLayout.addView( view );
|
m_playerLayout.addView( view );
|
||||||
|
|
||||||
View divider = factory.inflate( R.layout.divider_view, null );
|
View divider = LocUtils.inflate( this, R.layout.divider_view );
|
||||||
m_playerLayout.addView( divider );
|
m_playerLayout.addView( divider );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
|
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class GameListGroup extends ExpiringLinearLayout
|
public class GameListGroup extends ExpiringLinearLayout
|
||||||
implements SelectableItem.LongClickHandler,
|
implements SelectableItem.LongClickHandler,
|
||||||
|
@ -59,8 +60,8 @@ public class GameListGroup extends ExpiringLinearLayout
|
||||||
SelectableItem cb,
|
SelectableItem cb,
|
||||||
GroupStateListener gcb )
|
GroupStateListener gcb )
|
||||||
{
|
{
|
||||||
GameListGroup result =
|
GameListGroup result = (GameListGroup)
|
||||||
(GameListGroup)Utils.inflate( context, R.layout.game_list_group );
|
LocUtils.inflate( context, R.layout.game_list_group );
|
||||||
result.m_cb = cb;
|
result.m_cb = cb;
|
||||||
result.m_gcb = gcb;
|
result.m_gcb = gcb;
|
||||||
result.m_groupPosition = groupPosition;
|
result.m_groupPosition = groupPosition;
|
||||||
|
|
|
@ -266,7 +266,7 @@ public class GameListItem extends LinearLayout
|
||||||
boolean[] isLocal = new boolean[1];
|
boolean[] isLocal = new boolean[1];
|
||||||
for ( int ii = 0; ii < summary.nPlayers; ++ii ) {
|
for ( int ii = 0; ii < summary.nPlayers; ++ii ) {
|
||||||
ExpiringLinearLayout tmp = (ExpiringLinearLayout)
|
ExpiringLinearLayout tmp = (ExpiringLinearLayout)
|
||||||
Utils.inflate( m_context, R.layout.player_list_elem );
|
LocUtils.inflate( m_context, R.layout.player_list_elem );
|
||||||
tview = (TextView)tmp.findViewById( R.id.item_name );
|
tview = (TextView)tmp.findViewById( R.id.item_name );
|
||||||
tview.setText( summary.summarizePlayer( ii ) );
|
tview.setText( summary.summarizePlayer( ii ) );
|
||||||
tview = (TextView)tmp.findViewById( R.id.item_score );
|
tview = (TextView)tmp.findViewById( R.id.item_score );
|
||||||
|
@ -377,7 +377,7 @@ public class GameListItem extends LinearLayout
|
||||||
SelectableItem cb )
|
SelectableItem cb )
|
||||||
{
|
{
|
||||||
GameListItem result =
|
GameListItem result =
|
||||||
(GameListItem)Utils.inflate( context, R.layout.game_list_item );
|
(GameListItem)LocUtils.inflate( context, R.layout.game_list_item );
|
||||||
result.init( handler, rowid, groupPosition, fieldID, cb );
|
result.init( handler, rowid, groupPosition, fieldID, cb );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ public class GamesListDelegate extends DelegateBase
|
||||||
|
|
||||||
case GET_NAME:
|
case GET_NAME:
|
||||||
layout =
|
layout =
|
||||||
(LinearLayout)Utils.inflate( m_activity, R.layout.dflt_name );
|
(LinearLayout)LocUtils.inflate( m_activity, R.layout.dflt_name );
|
||||||
final EditText etext =
|
final EditText etext =
|
||||||
(EditText)layout.findViewById( R.id.name_edit );
|
(EditText)layout.findViewById( R.id.name_edit );
|
||||||
etext.setText( CommonPrefs.getDefaultPlayerName( m_activity,
|
etext.setText( CommonPrefs.getDefaultPlayerName( m_activity,
|
||||||
|
@ -357,7 +357,7 @@ public class GamesListDelegate extends DelegateBase
|
||||||
m_selGroupIDs = new HashSet<Long>();
|
m_selGroupIDs = new HashSet<Long>();
|
||||||
getBundledData( savedInstanceState );
|
getBundledData( savedInstanceState );
|
||||||
|
|
||||||
m_activity.setContentView( R.layout.game_list );
|
setContentView( R.layout.game_list );
|
||||||
ListView listview = m_activity.getListView();
|
ListView listview = m_activity.getListView();
|
||||||
DBUtils.setDBChangeListener( this );
|
DBUtils.setDBChangeListener( this );
|
||||||
|
|
||||||
|
@ -1159,7 +1159,8 @@ public class GamesListDelegate extends DelegateBase
|
||||||
DialogInterface.OnClickListener lstnr,
|
DialogInterface.OnClickListener lstnr,
|
||||||
DlgID dlgID )
|
DlgID dlgID )
|
||||||
{
|
{
|
||||||
m_namer = (GameNamer)Utils.inflate( m_activity, R.layout.rename_game );
|
m_namer = (GameNamer)
|
||||||
|
LocUtils.inflate( m_activity, R.layout.rename_game );
|
||||||
m_namer.setName( curname );
|
m_namer.setName( curname );
|
||||||
m_namer.setLabel( labelID );
|
m_namer.setLabel( labelID );
|
||||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||||
|
|
|
@ -48,6 +48,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class LookupAlert extends LinearLayout
|
public class LookupAlert extends LinearLayout
|
||||||
implements View.OnClickListener, Dialog.OnKeyListener,
|
implements View.OnClickListener, Dialog.OnKeyListener,
|
||||||
AdapterView.OnItemClickListener {
|
AdapterView.OnItemClickListener {
|
||||||
|
@ -353,7 +355,8 @@ public class LookupAlert extends LinearLayout
|
||||||
|
|
||||||
public static Dialog createDialog( Activity parent, Bundle bundle )
|
public static Dialog createDialog( Activity parent, Bundle bundle )
|
||||||
{
|
{
|
||||||
LookupAlert view = (LookupAlert)Utils.inflate( parent, R.layout.lookup );
|
LookupAlert view = (LookupAlert)
|
||||||
|
LocUtils.inflate( parent, R.layout.lookup );
|
||||||
view.init( parent, bundle );
|
view.init( parent, bundle );
|
||||||
|
|
||||||
Dialog result = new AlertDialog.Builder( parent )
|
Dialog result = new AlertDialog.Builder( parent )
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class NewGameActivity extends XWActivity {
|
public class NewGameActivity extends XWActivity {
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
m_groupID = getIntent().getLongExtra( GROUPID_EXTRA, -1 );
|
m_groupID = getIntent().getLongExtra( GROUPID_EXTRA, -1 );
|
||||||
|
|
||||||
setContentView( R.layout.new_game );
|
setContentView( R.layout.new_game );
|
||||||
|
LocUtils.xlateView( this, Utils.getContentView( this ) );
|
||||||
|
|
||||||
TextView desc = (TextView)findViewById( R.id.newgame_local_desc );
|
TextView desc = (TextView)findViewById( R.id.newgame_local_desc );
|
||||||
m_dict = CommonPrefs.getDefaultHumanDict( this );
|
m_dict = CommonPrefs.getDefaultHumanDict( this );
|
||||||
|
@ -213,7 +214,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
switch( dlgID ) {
|
switch( dlgID ) {
|
||||||
case NAME_GAME:
|
case NAME_GAME:
|
||||||
final GameNamer namerView =
|
final GameNamer namerView =
|
||||||
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
(GameNamer)LocUtils.inflate( this, R.layout.rename_game );
|
||||||
namerView.setLabel( m_nameForBT ? R.string.btname_label
|
namerView.setLabel( m_nameForBT ? R.string.btname_label
|
||||||
: R.string.smsname_label );
|
: R.string.smsname_label );
|
||||||
namerView.setName( m_gameName );
|
namerView.setName( m_gameName );
|
||||||
|
|
|
@ -30,6 +30,8 @@ import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class SMSCheckBoxPreference extends CheckBoxPreference {
|
public class SMSCheckBoxPreference extends CheckBoxPreference {
|
||||||
|
|
||||||
private Context m_context;
|
private Context m_context;
|
||||||
|
@ -72,7 +74,7 @@ public class SMSCheckBoxPreference extends CheckBoxPreference {
|
||||||
|
|
||||||
public static Dialog onCreateDialog( final Activity activity, final int id )
|
public static Dialog onCreateDialog( final Activity activity, final int id )
|
||||||
{
|
{
|
||||||
final View layout = Utils.inflate( activity, R.layout.confirm_sms );
|
final View layout = LocUtils.inflate( activity, R.layout.confirm_sms );
|
||||||
|
|
||||||
DialogInterface.OnClickListener lstnr =
|
DialogInterface.OnClickListener lstnr =
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class SMSInviteActivity extends InviteActivity {
|
public class SMSInviteActivity extends InviteActivity {
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
switch( dlgID ) {
|
switch( dlgID ) {
|
||||||
case GET_NUMBER:
|
case GET_NUMBER:
|
||||||
final GameNamer namerView =
|
final GameNamer namerView =
|
||||||
(GameNamer)Utils.inflate( this, R.layout.rename_game );
|
(GameNamer)LocUtils.inflate( this, R.layout.rename_game );
|
||||||
namerView.setLabel( R.string.get_sms_number );
|
namerView.setLabel( R.string.get_sms_number );
|
||||||
namerView.setKeyListener(DialerKeyListener.getInstance());
|
namerView.setKeyListener(DialerKeyListener.getInstance());
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
|
@ -383,8 +384,8 @@ public class SMSInviteActivity extends InviteActivity {
|
||||||
// for by-index access.)
|
// for by-index access.)
|
||||||
|
|
||||||
SMSListItem item =
|
SMSListItem item =
|
||||||
(SMSListItem)Utils.inflate( SMSInviteActivity.this,
|
(SMSListItem)LocUtils.inflate( SMSInviteActivity.this,
|
||||||
R.layout.smsinviter_item );
|
R.layout.smsinviter_item );
|
||||||
item.setChecked( m_phoneRecs.get(position).m_checked );
|
item.setChecked( m_phoneRecs.get(position).m_checked );
|
||||||
|
|
||||||
CompoundButton.OnCheckedChangeListener lstnr =
|
CompoundButton.OnCheckedChangeListener lstnr =
|
||||||
|
|
|
@ -38,7 +38,6 @@ import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.ContactsContract.PhoneLookup;
|
import android.provider.ContactsContract.PhoneLookup;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -253,12 +252,6 @@ public class Utils {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static View inflate( Context context, int layoutId )
|
|
||||||
{
|
|
||||||
LayoutInflater factory = LayoutInflater.from( context );
|
|
||||||
return factory.inflate( layoutId, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setChecked( Activity activity, int id, boolean value )
|
public static void setChecked( Activity activity, int id, boolean value )
|
||||||
{
|
{
|
||||||
CheckBox cbx = (CheckBox)activity.findViewById( id );
|
CheckBox cbx = (CheckBox)activity.findViewById( id );
|
||||||
|
|
|
@ -31,6 +31,8 @@ import android.widget.CheckBox;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class XWListItem extends LinearLayout
|
public class XWListItem extends LinearLayout
|
||||||
implements SelectableItem.LongClickHandler, View.OnClickListener {
|
implements SelectableItem.LongClickHandler, View.OnClickListener {
|
||||||
private int m_position;
|
private int m_position;
|
||||||
|
@ -162,7 +164,8 @@ public class XWListItem extends LinearLayout
|
||||||
|
|
||||||
public static XWListItem inflate( Context context, SelectableItem selCB )
|
public static XWListItem inflate( Context context, SelectableItem selCB )
|
||||||
{
|
{
|
||||||
XWListItem item = (XWListItem)Utils.inflate( context, R.layout.list_item );
|
XWListItem item = (XWListItem)
|
||||||
|
LocUtils.inflate( context, R.layout.list_item );
|
||||||
item.setSelCB( selCB );
|
item.setSelCB( selCB );
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,4 +429,9 @@ public class XWPrefs {
|
||||||
{
|
{
|
||||||
setPrefsString( context, keyID, TextUtils.join( "\n", value ) );
|
setPrefsString( context, keyID, TextUtils.join( "\n", value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLocale( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsString( context, R.string.key_xlations_locale );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class LocListItem extends LinearLayout implements OnFocusChangeListener {
|
||||||
int position )
|
int position )
|
||||||
{
|
{
|
||||||
LocListItem result =
|
LocListItem result =
|
||||||
(LocListItem)Utils.inflate( context, R.layout.loc_list_item );
|
(LocListItem)LocUtils.inflate( context, R.layout.loc_list_item );
|
||||||
result.m_pair = pair;
|
result.m_pair = pair;
|
||||||
result.m_position = position;
|
result.m_position = position;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,14 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem.OnMenuItemClickListener;
|
import android.view.MenuItem.OnMenuItemClickListener;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -36,6 +41,7 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.R;
|
import org.eehouse.android.xw4.R;
|
||||||
import org.eehouse.android.xw4.DbgUtils;
|
import org.eehouse.android.xw4.DbgUtils;
|
||||||
import org.eehouse.android.xw4.DBUtils;
|
import org.eehouse.android.xw4.DBUtils;
|
||||||
|
import org.eehouse.android.xw4.XWPrefs;
|
||||||
|
|
||||||
public class LocUtils {
|
public class LocUtils {
|
||||||
// Keep this in sync with gen_loc_ids.py and what's used in the menu.xml
|
// Keep this in sync with gen_loc_ids.py and what's used in the menu.xml
|
||||||
|
@ -43,6 +49,7 @@ public class LocUtils {
|
||||||
private static final String LOC_PREFIX = "loc:";
|
private static final String LOC_PREFIX = "loc:";
|
||||||
private static HashMap<String, String>s_xlations = null;
|
private static HashMap<String, String>s_xlations = null;
|
||||||
private static HashMap<Integer, String> s_idsToKeys = null;
|
private static HashMap<Integer, String> s_idsToKeys = null;
|
||||||
|
private static Boolean s_enabled = null;
|
||||||
|
|
||||||
public interface LocIface {
|
public interface LocIface {
|
||||||
void setText( CharSequence text );
|
void setText( CharSequence text );
|
||||||
|
@ -64,6 +71,37 @@ public class LocUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static View inflate( Context context, int resID )
|
||||||
|
{
|
||||||
|
LayoutInflater factory = LayoutInflater.from( context );
|
||||||
|
View view = factory.inflate( resID, null );
|
||||||
|
xlateView( context, view );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void xlateView( Context context, View view )
|
||||||
|
{
|
||||||
|
if ( view instanceof ViewGroup ) {
|
||||||
|
ViewGroup asGroup = (ViewGroup)view;
|
||||||
|
int count = asGroup.getChildCount();
|
||||||
|
for ( int ii = 0; ii < count; ++ii ) {
|
||||||
|
View child = asGroup.getChildAt( ii );
|
||||||
|
xlateView( context, child );
|
||||||
|
}
|
||||||
|
} else if ( view instanceof Button ) {
|
||||||
|
Button button = (Button)view;
|
||||||
|
String str = button.getText().toString();
|
||||||
|
str = xlateString( context, str );
|
||||||
|
button.setText( str );
|
||||||
|
} else if ( view instanceof TextView ) {
|
||||||
|
TextView tv = (TextView)view;
|
||||||
|
String str = tv.getText().toString();
|
||||||
|
str = xlateString( context, str );
|
||||||
|
tv.setText( str );
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void xlateMenu( Activity activity, Menu menu )
|
public static void xlateMenu( Activity activity, Menu menu )
|
||||||
{
|
{
|
||||||
xlateMenu( activity, menu, 0 );
|
xlateMenu( activity, menu, 0 );
|
||||||
|
@ -217,4 +255,13 @@ public class LocUtils {
|
||||||
|
|
||||||
return s_idsToKeys.get( id );
|
return s_idsToKeys.get( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isEnabled( Context context )
|
||||||
|
{
|
||||||
|
if ( null == s_enabled ) {
|
||||||
|
String locale = XWPrefs.getLocale( context );
|
||||||
|
s_enabled = new Boolean( null != locale && 0 < locale.length() );
|
||||||
|
}
|
||||||
|
return s_enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,50 @@
|
||||||
import glob, sys, re, os
|
import glob, sys, re, os
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
pairs = {}
|
# sys.exit(0)
|
||||||
|
|
||||||
|
g_xmlTypes = [
|
||||||
|
{ 'elemName': 'item',
|
||||||
|
'attrType' : '{http://schemas.android.com/apk/res/android}title'
|
||||||
|
},
|
||||||
|
{ 'elemName': 'Button',
|
||||||
|
'attrType' : '{http://schemas.android.com/apk/res/android}text'
|
||||||
|
},
|
||||||
|
{ 'elemName': 'TextView',
|
||||||
|
'attrType' : '{http://schemas.android.com/apk/res/android}text'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
g_pairs = {}
|
||||||
|
|
||||||
STR_REF = re.compile('@string/(.*)$')
|
STR_REF = re.compile('@string/(.*)$')
|
||||||
|
|
||||||
def xform(src, dest):
|
def xform(src, dest):
|
||||||
|
print "looking at file", src
|
||||||
doc = etree.parse(src)
|
doc = etree.parse(src)
|
||||||
for item in doc.findall('item'):
|
root = doc.getroot();
|
||||||
title = item.get('{http://schemas.android.com/apk/res/android}title')
|
for child in root.iter():
|
||||||
if title:
|
for elem in g_xmlTypes:
|
||||||
match = STR_REF.match(title)
|
if child.tag == elem['elemName']:
|
||||||
if match:
|
value = child.get(elem['attrType'])
|
||||||
key = match.group(1)
|
match = value and STR_REF.match(value)
|
||||||
if key in pairs:
|
if match:
|
||||||
print key, "loc:" + key
|
key = match.group(1)
|
||||||
item.set('{http://schemas.android.com/apk/res/android}title', "loc:" + key)
|
if key in g_pairs:
|
||||||
|
print child.tag, key, "loc:" + key
|
||||||
|
child.set(elem['attrType'], "loc:" + key)
|
||||||
|
|
||||||
|
# create directory if needed, then write file
|
||||||
|
dir = os.path.dirname( dest )
|
||||||
|
if not os.path.exists(dir): os.makedirs(dir)
|
||||||
doc.write( dest, pretty_print=True )
|
doc.write( dest, pretty_print=True )
|
||||||
|
|
||||||
# Gather all localizable strings
|
# Gather all localizable strings
|
||||||
for path in glob.iglob( "res/values/strings.xml" ):
|
for path in glob.iglob( "res/values/strings.xml" ):
|
||||||
for action, elem in etree.iterparse(path):
|
for action, elem in etree.iterparse(path):
|
||||||
if "end" == action and 'string' == elem.tag:
|
if "end" == action and 'string' == elem.tag:
|
||||||
pairs[elem.get('name')] = True
|
g_pairs[elem.get('name')] = True
|
||||||
|
|
||||||
for subdir, dirs, files in os.walk('res_src'):
|
for subdir, dirs, files in os.walk('res_src'):
|
||||||
for file in files:
|
for file in files:
|
||||||
|
|
Loading…
Add table
Reference in a new issue