mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Display player names in the title bar when the clocks are not running.
This commit is contained in:
@@ -1,29 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical">
|
android:layout_gravity="center_vertical">
|
||||||
<TextView
|
<TextView
|
||||||
style="?android:attr/windowTitleStyle"
|
style="?android:attr/windowTitleStyle"
|
||||||
android:id="@+id/white_clock"
|
android:id="@+id/white_clock"
|
||||||
android:layout_width="wrap_content"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:layout_alignParentLeft="true">
|
android:gravity="left"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
</TextView>
|
</TextView>
|
||||||
<TextView
|
<TextView
|
||||||
style="?android:attr/windowTitleStyle"
|
style="?android:attr/windowTitleStyle"
|
||||||
android:id="@+id/title_text"
|
android:id="@+id/title_text"
|
||||||
|
android:layout_weight="1"
|
||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:gravity="center"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_height="wrap_content">
|
||||||
</TextView>
|
</TextView>
|
||||||
<TextView
|
<TextView
|
||||||
style="?android:attr/windowTitleStyle"
|
style="?android:attr/windowTitleStyle"
|
||||||
android:id="@+id/black_clock"
|
android:id="@+id/black_clock"
|
||||||
android:layout_width="wrap_content"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:layout_alignParentRight="true">
|
android:gravity="right"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
</TextView>
|
</TextView>
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
private ImageButton custom1Button, custom2Button, custom3Button;
|
private ImageButton custom1Button, custom2Button, custom3Button;
|
||||||
private ImageButton modeButton, undoButton, redoButton;
|
private ImageButton modeButton, undoButton, redoButton;
|
||||||
private ButtonActions custom1ButtonActions, custom2ButtonActions, custom3ButtonActions;
|
private ButtonActions custom1ButtonActions, custom2ButtonActions, custom3ButtonActions;
|
||||||
private TextView whiteClock, blackClock, titleText;
|
private TextView whiteTitleText, blackTitleText, engineTitleText;
|
||||||
|
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
|
|
||||||
@@ -469,9 +469,9 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
|
setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
|
||||||
if (initTitle) {
|
if (initTitle) {
|
||||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
|
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
|
||||||
whiteClock = (TextView)findViewById(R.id.white_clock);
|
whiteTitleText = (TextView)findViewById(R.id.white_clock);
|
||||||
blackClock = (TextView)findViewById(R.id.black_clock);
|
blackTitleText = (TextView)findViewById(R.id.black_clock);
|
||||||
titleText = (TextView)findViewById(R.id.title_text);
|
engineTitleText = (TextView)findViewById(R.id.title_text);
|
||||||
}
|
}
|
||||||
status = (TextView)findViewById(R.id.status);
|
status = (TextView)findViewById(R.id.status);
|
||||||
moveListScroll = (ScrollView)findViewById(R.id.scrollView);
|
moveListScroll = (ScrollView)findViewById(R.id.scrollView);
|
||||||
@@ -866,15 +866,15 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
if (engine.contains("/")) {
|
if (engine.contains("/")) {
|
||||||
int idx = engine.lastIndexOf('/');
|
int idx = engine.lastIndexOf('/');
|
||||||
String eName = engine.substring(idx + 1);
|
String eName = engine.substring(idx + 1);
|
||||||
titleText.setText(eName);
|
engineTitleText.setText(eName);
|
||||||
} else {
|
} else {
|
||||||
String eName = getString(engine.equals("cuckoochess") ?
|
String eName = getString(engine.equals("cuckoochess") ?
|
||||||
R.string.cuckoochess_engine :
|
R.string.cuckoochess_engine :
|
||||||
R.string.stockfish_engine);
|
R.string.stockfish_engine);
|
||||||
if (strength < 1000) {
|
if (strength < 1000) {
|
||||||
titleText.setText(String.format("%s: %d%%", eName, strength / 10));
|
engineTitleText.setText(String.format("%s: %d%%", eName, strength / 10));
|
||||||
} else {
|
} else {
|
||||||
titleText.setText(eName);
|
engineTitleText.setText(eName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2395,8 +2395,15 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemainingTime(long wTime, long bTime, long nextUpdate) {
|
public void setRemainingTime(long wTime, long bTime, long nextUpdate) {
|
||||||
whiteClock.setText(getString(R.string.header_white) + " " + timeToString(wTime));
|
if (ctrl.getGameMode().clocksActive()) {
|
||||||
blackClock.setText(getString(R.string.header_black) + " " + timeToString(bTime));
|
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);
|
handlerTimer.removeCallbacks(r);
|
||||||
if (nextUpdate > 0) {
|
if (nextUpdate > 0) {
|
||||||
handlerTimer.postDelayed(r, nextUpdate);
|
handlerTimer.postDelayed(r, nextUpdate);
|
||||||
|
|||||||
Reference in New Issue
Block a user