mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
display English text on left side of table
This commit is contained in:
parent
2494f7b8d4
commit
663f4293a9
10 changed files with 218 additions and 24 deletions
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
<target name="-pre-compile">
|
<target name="-pre-compile">
|
||||||
<exec dir="." executable="../scripts/gen_loc_ids.py"
|
<exec dir="." executable="../scripts/gen_loc_ids.py"
|
||||||
output="src/org/eehouse/android/xw4/loc/LocIDs.java"
|
output="src/org/eehouse/android/xw4/loc/LocIDsData.java"
|
||||||
failonerror="true"
|
failonerror="true"
|
||||||
>
|
>
|
||||||
</exec>
|
</exec>
|
||||||
|
|
18
xwords4/android/XWords4/res/layout/loc_list_item.xml
Normal file
18
xwords4/android/XWords4/res/layout/loc_list_item.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<org.eehouse.android.xw4.loc.LocListItem
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:custom="http://schemas.android.com/apk/res/org.eehouse.android.xw4"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/english_view"
|
||||||
|
style="@style/spaced_buttons"
|
||||||
|
/>
|
||||||
|
<EditText android:id="@+id/xlated_view"
|
||||||
|
style="@style/spaced_buttons"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</org.eehouse.android.xw4.loc.LocListItem>
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
<!-- Search field -->
|
<!-- Search field -->
|
||||||
<LinearLayout android:orientation="horizontal"
|
<LinearLayout android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
|
|
||||||
<EditText android:id="@+id/loc_search_field"
|
<EditText android:id="@+id/loc_search_field"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageButton android:id="@+id/loc_search_button"
|
<ImageButton android:id="@+id/loc_search_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/search__gen"
|
android:src="@drawable/search__gen"
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
|
@ -33,18 +33,18 @@
|
||||||
|
|
||||||
<!-- table header -->
|
<!-- table header -->
|
||||||
<LinearLayout android:orientation="horizontal"
|
<LinearLayout android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
<TextView android:layout_width="wrap_content"
|
<TextView android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:text="@string/loc_main_english"
|
android:text="@string/loc_main_english"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<org.eehouse.android.xw4.loc.LocTextView
|
<org.eehouse.android.xw4.loc.LocTextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
custom:strid="@string/loc_main_yourlang"
|
custom:strid="@string/loc_main_yourlang"
|
||||||
/>
|
/>
|
||||||
|
@ -53,8 +53,10 @@
|
||||||
|
|
||||||
<!-- main list (of pairs loaded dynamically) -->
|
<!-- main list (of pairs loaded dynamically) -->
|
||||||
<ListView android:id="@id/android:list"
|
<ListView android:id="@id/android:list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawSelectorOnTop="false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class XWListAdapter extends BaseAdapter
|
||||||
implements ListAdapter {
|
implements ListAdapter {
|
||||||
private int m_count;
|
private int m_count;
|
||||||
|
|
||||||
public XWListAdapter( ) {
|
public XWListAdapter() {
|
||||||
this( 0 );
|
this( 0 );
|
||||||
}
|
}
|
||||||
public XWListAdapter( int count ) {
|
public XWListAdapter( int count ) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/LocIDs.java
|
/LocIDsData.java
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.eehouse.android.xw4.loc;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DelegateBase;
|
import org.eehouse.android.xw4.DelegateBase;
|
||||||
import org.eehouse.android.xw4.R;
|
import org.eehouse.android.xw4.R;
|
||||||
|
@ -29,6 +30,7 @@ import org.eehouse.android.xw4.R;
|
||||||
public class LocDelegate extends DelegateBase {
|
public class LocDelegate extends DelegateBase {
|
||||||
|
|
||||||
private ListActivity m_activity;
|
private ListActivity m_activity;
|
||||||
|
private LocListAdapter m_adapter;
|
||||||
|
|
||||||
protected LocDelegate( ListActivity activity, Bundle savedInstanceState )
|
protected LocDelegate( ListActivity activity, Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
@ -40,6 +42,10 @@ public class LocDelegate extends DelegateBase {
|
||||||
private void init( Bundle savedInstanceState )
|
private void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
m_activity.setContentView( R.layout.loc_main );
|
m_activity.setContentView( R.layout.loc_main );
|
||||||
|
|
||||||
|
ListView listview = m_activity.getListView();
|
||||||
|
m_adapter = new LocListAdapter( m_activity, listview );
|
||||||
|
m_activity.setListAdapter( m_adapter );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* -*- 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 java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class LocIDs extends LocIDsData {
|
||||||
|
private static String[] s_keys;
|
||||||
|
|
||||||
|
protected static String getNthKey( int indx )
|
||||||
|
{
|
||||||
|
if ( null == s_keys ) {
|
||||||
|
HashMap<String, Integer> map = LocIDsData.s_map;
|
||||||
|
s_keys = new String[map.size()];
|
||||||
|
Iterator<String> iter = map.keySet().iterator();
|
||||||
|
for ( int ii = 0; iter.hasNext(); ++ii ) {
|
||||||
|
s_keys[ii] = iter.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_keys[indx];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static int getID( String key )
|
||||||
|
{
|
||||||
|
return LocIDsData.s_map.get( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static int size()
|
||||||
|
{
|
||||||
|
return LocIDsData.s_map.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static int get( String key )
|
||||||
|
{
|
||||||
|
return LocIDsData.s_map.get( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
|
/*
|
||||||
|
* Copyright 2009 - 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.content.Context;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.XWListAdapter;
|
||||||
|
import org.eehouse.android.xw4.DbgUtils;
|
||||||
|
|
||||||
|
public class LocListAdapter extends XWListAdapter {
|
||||||
|
|
||||||
|
private Context m_context;
|
||||||
|
private ListView m_listView;
|
||||||
|
|
||||||
|
protected LocListAdapter( Context context, ListView listView )
|
||||||
|
{
|
||||||
|
m_context = context;
|
||||||
|
m_listView = listView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount()
|
||||||
|
{
|
||||||
|
int count = LocIDs.size();
|
||||||
|
DbgUtils.logf(" LocListAdapter.getCount() => %d", count );
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView( int position, View convertView, ViewGroup parent )
|
||||||
|
{
|
||||||
|
DbgUtils.logf( "LocListAdapter.getView(position=%d)", position );
|
||||||
|
String key = LocIDs.getNthKey( position );
|
||||||
|
return LocListItem.create( m_context, key, position );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* -*- 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.widget.LinearLayout;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.R;
|
||||||
|
import org.eehouse.android.xw4.Utils;
|
||||||
|
import org.eehouse.android.xw4.DbgUtils;
|
||||||
|
|
||||||
|
public class LocListItem extends LinearLayout {
|
||||||
|
|
||||||
|
private Context m_context;
|
||||||
|
private String m_key;
|
||||||
|
private int m_position;
|
||||||
|
|
||||||
|
public LocListItem( Context cx, AttributeSet as )
|
||||||
|
{
|
||||||
|
super( cx, as );
|
||||||
|
m_context = cx;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEnglish()
|
||||||
|
{
|
||||||
|
int id = LocIDs.get( m_key );
|
||||||
|
String str = m_context.getString( id );
|
||||||
|
TextView tv = (TextView)findViewById( R.id.english_view );
|
||||||
|
tv.setText( str );
|
||||||
|
DbgUtils.logf( "setEnglish: set to %s", str );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static LocListItem create( Context context, String key,
|
||||||
|
int position )
|
||||||
|
{
|
||||||
|
LocListItem result =
|
||||||
|
(LocListItem)Utils.inflate( context, R.layout.loc_list_item );
|
||||||
|
result.m_key = key;
|
||||||
|
result.m_position = position;
|
||||||
|
result.setEnglish();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,7 +70,7 @@ import java.util.HashMap;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.R;
|
import org.eehouse.android.xw4.R;
|
||||||
|
|
||||||
public class LocIDs {
|
public class LocIDsData {
|
||||||
public static final int NOT_FOUND = -1;
|
public static final int NOT_FOUND = -1;
|
||||||
protected static HashMap<String,Integer> s_map;
|
protected static HashMap<String,Integer> s_map;
|
||||||
static {
|
static {
|
||||||
|
@ -83,15 +83,6 @@ for key in pairs.keys():
|
||||||
# Now the end of the class
|
# Now the end of the class
|
||||||
print """
|
print """
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int getID( String key )
|
|
||||||
{
|
|
||||||
int result = NOT_FOUND;
|
|
||||||
if ( s_map.containsKey( key ) ) {
|
|
||||||
result = s_map.get( key );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* end generated file */
|
/* end generated file */
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue