DroidFish: Moved error message to strings.xml.

This commit is contained in:
Peter Osterlund
2012-01-04 21:10:26 +00:00
parent da605aa225
commit 1d0dde26d0
4 changed files with 11 additions and 7 deletions

View File

@@ -407,6 +407,7 @@ you are not actively using the program.\
<string name="engine_error">Engine error</string> <string name="engine_error">Engine error</string>
<string name="stockfish_engine">Stockfish</string> <string name="stockfish_engine">Stockfish</string>
<string name="cuckoochess_engine">CuckooChess</string> <string name="cuckoochess_engine">CuckooChess</string>
<string name="failed_to_start_engine">Failed to start engine</string>
<string name="err_too_few_spaces">Too few spaces</string> <string name="err_too_few_spaces">Too few spaces</string>
<string name="err_invalid_piece">Invalid piece</string> <string name="err_invalid_piece">Invalid piece</string>

View File

@@ -29,8 +29,13 @@ import java.nio.channels.FileChannel;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.petero.droidfish.R;
import android.content.Context;
/** Engine running as a process started from an external resource. */ /** Engine running as a process started from an external resource. */
public class ExternalEngine extends UCIEngineBase { public class ExternalEngine extends UCIEngineBase {
protected final Context context;
private File engineFileName; private File engineFileName;
protected static final String intSfPath = "/data/data/org.petero.droidfish/internal_sf"; protected static final String intSfPath = "/data/data/org.petero.droidfish/internal_sf";
private static final String exePath = "/data/data/org.petero.droidfish/engine.exe"; private static final String exePath = "/data/data/org.petero.droidfish/engine.exe";
@@ -42,7 +47,8 @@ public class ExternalEngine extends UCIEngineBase {
private List<String> inLines; private List<String> inLines;
private boolean startedOk; private boolean startedOk;
public ExternalEngine(String engine, Report report) { public ExternalEngine(Context context, String engine, Report report) {
this.context = context;
this.report = report; this.report = report;
engineFileName = new File(engine); engineFileName = new File(engine);
engineProc = null; engineProc = null;
@@ -68,7 +74,7 @@ public class ExternalEngine extends UCIEngineBase {
try { try {
engineProc.waitFor(); engineProc.waitFor();
if (!startedOk) if (!startedOk)
report.reportError("Failed to start engine"); report.reportError(context.getString(R.string.failed_to_start_engine));
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }

View File

@@ -29,12 +29,9 @@ import android.os.Build;
/** Stockfish engine running as process, started from assets resource. */ /** Stockfish engine running as process, started from assets resource. */
public class InternalStockFish extends ExternalEngine { public class InternalStockFish extends ExternalEngine {
private Context context;
public InternalStockFish(Context context, Report report) { public InternalStockFish(Context context, Report report) {
super("", report); super(context, "", report);
this.context = context;
} }
/** @inheritDoc */ /** @inheritDoc */

View File

@@ -34,7 +34,7 @@ public abstract class UCIEngineBase implements UCIEngine {
else if ("stockfish".equals(engine)) else if ("stockfish".equals(engine))
return new InternalStockFish(context, report); return new InternalStockFish(context, report);
else else
return new ExternalEngine(engine, report); return new ExternalEngine(context, engine, report);
} }
protected UCIEngineBase() { protected UCIEngineBase() {