DroidFish: Display player names in the title bar when the clocks are not running.

This commit is contained in:
Peter Osterlund 2012-07-16 08:45:57 +00:00
parent fca2f69711
commit 352b54254a
2 changed files with 31 additions and 21 deletions

View File

@ -1,29 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/white_clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true">
android:layout_weight="1"
android:layout_width="fill_parent"
android:gravity="left"
android:layout_height="wrap_content">
</TextView>
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/title_text"
android:layout_weight="1"
android:text="@string/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
android:layout_width="fill_parent"
android:gravity="center"
android:layout_height="wrap_content">
</TextView>
<TextView
style="?android:attr/windowTitleStyle"
android:id="@+id/black_clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
android:layout_weight="1"
android:layout_width="fill_parent"
android:gravity="right"
android:layout_height="wrap_content">
</TextView>
</RelativeLayout>
</LinearLayout>

View File

@ -173,7 +173,7 @@ public class DroidFish extends Activity implements GUIInterface {
private ImageButton custom1Button, custom2Button, custom3Button;
private ImageButton modeButton, undoButton, redoButton;
private ButtonActions custom1ButtonActions, custom2ButtonActions, custom3ButtonActions;
private TextView whiteClock, blackClock, titleText;
private TextView whiteTitleText, blackTitleText, engineTitleText;
SharedPreferences settings;
@ -469,9 +469,9 @@ public class DroidFish extends Activity implements GUIInterface {
setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
if (initTitle) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
whiteClock = (TextView)findViewById(R.id.white_clock);
blackClock = (TextView)findViewById(R.id.black_clock);
titleText = (TextView)findViewById(R.id.title_text);
whiteTitleText = (TextView)findViewById(R.id.white_clock);
blackTitleText = (TextView)findViewById(R.id.black_clock);
engineTitleText = (TextView)findViewById(R.id.title_text);
}
status = (TextView)findViewById(R.id.status);
moveListScroll = (ScrollView)findViewById(R.id.scrollView);
@ -866,15 +866,15 @@ public class DroidFish extends Activity implements GUIInterface {
if (engine.contains("/")) {
int idx = engine.lastIndexOf('/');
String eName = engine.substring(idx + 1);
titleText.setText(eName);
engineTitleText.setText(eName);
} else {
String eName = getString(engine.equals("cuckoochess") ?
R.string.cuckoochess_engine :
R.string.stockfish_engine);
if (strength < 1000) {
titleText.setText(String.format("%s: %d%%", eName, strength / 10));
engineTitleText.setText(String.format("%s: %d%%", eName, strength / 10));
} else {
titleText.setText(eName);
engineTitleText.setText(eName);
}
}
}
@ -2395,8 +2395,15 @@ public class DroidFish extends Activity implements GUIInterface {
@Override
public void setRemainingTime(long wTime, long bTime, long nextUpdate) {
whiteClock.setText(getString(R.string.header_white) + " " + timeToString(wTime));
blackClock.setText(getString(R.string.header_black) + " " + timeToString(bTime));
if (ctrl.getGameMode().clocksActive()) {
whiteTitleText.setText(getString(R.string.header_white) + " " + timeToString(wTime));
blackTitleText.setText(getString(R.string.header_black) + " " + timeToString(bTime));
} else {
TreeMap<String,String> headers = new TreeMap<String,String>();
ctrl.getHeaders(headers);
whiteTitleText.setText(headers.get("White"));
blackTitleText.setText(headers.get("Black"));
}
handlerTimer.removeCallbacks(r);
if (nextUpdate > 0) {
handlerTimer.postDelayed(r, nextUpdate);