show locally-translated strings in red

This commit is contained in:
Eric House 2014-05-14 19:04:58 -07:00
parent d00e49f843
commit 6426e41d30
3 changed files with 51 additions and 33 deletions

View file

@ -52,9 +52,9 @@ public class LocItemEditDelegate extends DelegateBase {
TextView view = (TextView)findViewById( R.id.english_view );
view.setText( key );
view = (TextView)findViewById( R.id.xlated_view_blessed );
view.setText( LocUtils.getXlation( m_activity, key, false, true ) );
view.setText( LocUtils.getBlessedXlation( m_activity, key, true ) );
m_edit = (EditText)findViewById( R.id.xlated_view_local );
m_edit.setText( LocUtils.getXlation( m_activity, key, true, true ) );
m_edit.setText( LocUtils.getLocalXlation( m_activity, key, true ) );
setLabel( R.id.english_label, R.string.loc_main_english );
setLabel( R.id.blessed_label, R.string.loc_main_yourlang );

View file

@ -20,13 +20,14 @@
package org.eehouse.android.xw4.loc;
import android.widget.LinearLayout;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.TextView;
import android.widget.EditText;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import junit.framework.Assert;
@ -37,6 +38,8 @@ import org.eehouse.android.xw4.DbgUtils;
public class LocListItem extends LinearLayout
implements View.OnClickListener {
private static final int LOCAL_COLOR = Color.argb( 0xFF, 0x7f, 0x00, 0x00 );
private LocSearcher.Pair m_pair;
private int m_position;
private TextView m_xlated;
@ -63,10 +66,21 @@ public class LocListItem extends LinearLayout
private void setXlated()
{
m_xlation = LocUtils.getXlation( getContext(), m_pair.getKey(), true );
if ( null != m_xlation ) {
m_pair.setXlation( m_xlation );
m_xlated.setText( m_xlation );
boolean local = false;
String key = m_pair.getKey();
String xlation = LocUtils.getLocalXlation( getContext(), key, true );
if ( null != xlation ) {
local = true;
} else {
xlation = LocUtils.getBlessedXlation( getContext(), key, true );
}
if ( null != xlation ) {
m_xlation = xlation;
m_pair.setXlation( xlation );
m_xlated.setText( xlation );
if ( local ) {
m_xlated.setTextColor( LOCAL_COLOR );
}
}
}

View file

@ -229,36 +229,40 @@ public class LocUtils {
s_xlationsLocal.put( key, txt );
}
protected static String getXlation( Context context, String key,
boolean canUseDB )
{
return getXlation( context, key, null, canUseDB );
}
protected static String getXlation( Context context, String key,
boolean forceLocal, boolean canUseDB )
{
return getXlation( context, key, new Boolean(forceLocal), canUseDB );
}
private static String getXlation( Context context, String key,
Boolean forceLocal, boolean canUseDB )
protected static String getLocalXlation( Context context, String key,
boolean canUseDB )
{
if ( canUseDB ) {
loadXlations( context );
}
String result = null;
if ( null == forceLocal || forceLocal ) {
if ( null != s_xlationsLocal ) {
result = s_xlationsLocal.get( key );
}
if ( null != s_xlationsLocal ) {
result = s_xlationsLocal.get( key );
}
return result;
}
if ( null == forceLocal || !forceLocal ) {
if ( null == result && null != s_xlationsBlessed ) {
result = s_xlationsBlessed.get( key );
}
protected static String getBlessedXlation( Context context, String key,
boolean canUseDB )
{
if ( canUseDB ) {
loadXlations( context );
}
String result = null;
if ( null != s_xlationsBlessed ) {
result = s_xlationsBlessed.get( key );
}
return result;
}
protected static String getXlation( Context context, String key,
boolean canUseDB )
{
String result = null;
result = getLocalXlation( context, key, canUseDB );
if ( null == result ) {
result = getBlessedXlation( context, key, canUseDB );
}
if ( UPPER_CASE && null == result ) {