From c30dd905a29d7d88f615e7ebd3afe3e9a2eafd8e Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 31 Mar 2011 18:11:36 -0700 Subject: [PATCH] move getting user strings into impl so available in background. Fixes bug where trades were not reported when received from relay via proxy. --- .../eehouse/android/xw4/BoardActivity.java | 94 +----------------- .../org/eehouse/android/xw4/GameUtils.java | 1 + .../eehouse/android/xw4/jni/UtilCtxtImpl.java | 99 ++++++++++++++++++- 3 files changed, 103 insertions(+), 91 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 4c286ef4e..a02af1838 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -695,6 +695,11 @@ public class BoardActivity extends XWActivity private class BoardUtilCtxt extends UtilCtxtImpl { + public BoardUtilCtxt() + { + super( BoardActivity.this ); + } + public void requestTime() { m_handler.post( new Runnable() { @@ -831,95 +836,6 @@ public class BoardActivity extends XWActivity } ); } - public String getUserString( int stringCode ) - { - int id = 0; - switch( stringCode ) { - case UtilCtxt.STRD_ROBOT_TRADED: - id = R.string.strd_robot_traded; - break; - case UtilCtxt.STR_ROBOT_MOVED: - id = R.string.str_robot_moved; - break; - case UtilCtxt.STRS_VALUES_HEADER: - id = R.string.strs_values_header; - break; - case UtilCtxt.STRD_REMAINING_TILES_ADD: - id = R.string.strd_remaining_tiles_add; - break; - case UtilCtxt.STRD_UNUSED_TILES_SUB: - id = R.string.strd_unused_tiles_sub; - break; - case UtilCtxt.STR_REMOTE_MOVED: - id = R.string.str_remote_moved; - break; - case UtilCtxt.STRD_TIME_PENALTY_SUB: - id = R.string.strd_time_penalty_sub; - break; - case UtilCtxt.STR_PASS: - id = R.string.str_pass; - break; - case UtilCtxt.STRS_MOVE_ACROSS: - id = R.string.strs_move_across; - break; - case UtilCtxt.STRS_MOVE_DOWN: - id = R.string.strs_move_down; - break; - case UtilCtxt.STRS_TRAY_AT_START: - id = R.string.strs_tray_at_start; - break; - case UtilCtxt.STRSS_TRADED_FOR: - id = R.string.strss_traded_for; - break; - case UtilCtxt.STR_PHONY_REJECTED: - id = R.string.str_phony_rejected; - break; - case UtilCtxt.STRD_CUMULATIVE_SCORE: - id = R.string.strd_cumulative_score; - break; - case UtilCtxt.STRS_NEW_TILES: - id = R.string.strs_new_tiles; - break; - case UtilCtxt.STR_PASSED: - id = R.string.str_passed; - break; - case UtilCtxt.STRSD_SUMMARYSCORED: - id = R.string.strsd_summaryscored; - break; - case UtilCtxt.STRD_TRADED: - id = R.string.strd_traded; - break; - case UtilCtxt.STR_LOSTTURN: - id = R.string.str_lostturn; - break; - case UtilCtxt.STR_COMMIT_CONFIRM: - id = R.string.str_commit_confirm; - break; - case UtilCtxt.STR_LOCAL_NAME: - id = R.string.str_local_name; - break; - case UtilCtxt.STR_NONLOCAL_NAME: - id = R.string.str_nonlocal_name; - break; - case UtilCtxt.STR_BONUS_ALL: - id = R.string.str_bonus_all; - break; - case UtilCtxt.STRD_TURN_SCORE: - id = R.string.strd_turn_score; - break; - default: - Utils.logf( "no such stringCode: " + stringCode ); - } - - String result; - if ( 0 == id ) { - result = ""; - } else { - result = getString( id ); - } - return result; - } - public boolean userQuery( int id, String query ) { boolean result; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 38ae18cf2..e9a0156b2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -547,6 +547,7 @@ public class GameUtils { public FeedUtilsImpl( Context context, String path ) { + super( context ); m_context = context; m_path = path; m_gotMsg = false; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java index 7a004f1ba..bd4391143 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java @@ -20,9 +20,21 @@ package org.eehouse.android.xw4.jni; +import android.content.Context; + import org.eehouse.android.xw4.Utils; +import org.eehouse.android.xw4.R; public class UtilCtxtImpl implements UtilCtxt { + private Context m_context; + + private UtilCtxtImpl() {} // force subclasses to pass context + + public UtilCtxtImpl( Context context ) + { + super(); + m_context = context; + } public void requestTime() { subclassOverride( "requestTime" ); @@ -83,8 +95,91 @@ public class UtilCtxtImpl implements UtilCtxt { public String getUserString( int stringCode ) { - subclassOverride( "getUserString" ); - return ""; + int id = 0; + switch( stringCode ) { + case UtilCtxt.STRD_ROBOT_TRADED: + id = R.string.strd_robot_traded; + break; + case UtilCtxt.STR_ROBOT_MOVED: + id = R.string.str_robot_moved; + break; + case UtilCtxt.STRS_VALUES_HEADER: + id = R.string.strs_values_header; + break; + case UtilCtxt.STRD_REMAINING_TILES_ADD: + id = R.string.strd_remaining_tiles_add; + break; + case UtilCtxt.STRD_UNUSED_TILES_SUB: + id = R.string.strd_unused_tiles_sub; + break; + case UtilCtxt.STR_REMOTE_MOVED: + id = R.string.str_remote_moved; + break; + case UtilCtxt.STRD_TIME_PENALTY_SUB: + id = R.string.strd_time_penalty_sub; + break; + case UtilCtxt.STR_PASS: + id = R.string.str_pass; + break; + case UtilCtxt.STRS_MOVE_ACROSS: + id = R.string.strs_move_across; + break; + case UtilCtxt.STRS_MOVE_DOWN: + id = R.string.strs_move_down; + break; + case UtilCtxt.STRS_TRAY_AT_START: + id = R.string.strs_tray_at_start; + break; + case UtilCtxt.STRSS_TRADED_FOR: + id = R.string.strss_traded_for; + break; + case UtilCtxt.STR_PHONY_REJECTED: + id = R.string.str_phony_rejected; + break; + case UtilCtxt.STRD_CUMULATIVE_SCORE: + id = R.string.strd_cumulative_score; + break; + case UtilCtxt.STRS_NEW_TILES: + id = R.string.strs_new_tiles; + break; + case UtilCtxt.STR_PASSED: + id = R.string.str_passed; + break; + case UtilCtxt.STRSD_SUMMARYSCORED: + id = R.string.strsd_summaryscored; + break; + case UtilCtxt.STRD_TRADED: + id = R.string.strd_traded; + break; + case UtilCtxt.STR_LOSTTURN: + id = R.string.str_lostturn; + break; + case UtilCtxt.STR_COMMIT_CONFIRM: + id = R.string.str_commit_confirm; + break; + case UtilCtxt.STR_LOCAL_NAME: + id = R.string.str_local_name; + break; + case UtilCtxt.STR_NONLOCAL_NAME: + id = R.string.str_nonlocal_name; + break; + case UtilCtxt.STR_BONUS_ALL: + id = R.string.str_bonus_all; + break; + case UtilCtxt.STRD_TURN_SCORE: + id = R.string.strd_turn_score; + break; + default: + Utils.logf( "no such stringCode: " + stringCode ); + } + + String result; + if ( 0 == id ) { + result = ""; + } else { + result = m_context.getString( id ); + } + return result; } public boolean userQuery( int id, String query )