DroidFish: Display PGN comments in a color different from PGN moves.

This commit is contained in:
Peter Osterlund 2012-04-07 09:15:44 +00:00
parent 34d52f62f2
commit bdd67ce315
4 changed files with 24 additions and 12 deletions

View File

@ -423,6 +423,7 @@ you are not actively using the program.\
<string name="prefs_color_decoration_title">Tablebase hints</string> <string name="prefs_color_decoration_title">Tablebase hints</string>
<string name="prefs_move_list">Move List</string> <string name="prefs_move_list">Move List</string>
<string name="prefs_color_currentMove_title">Current Move</string> <string name="prefs_color_currentMove_title">Current Move</string>
<string name="prefs_color_pgnComment_title">Comments</string>
<string name="prefs_other">Other</string> <string name="prefs_other">Other</string>
<string name="prefs_bookSettings_title">Opening Book Settings</string> <string name="prefs_bookSettings_title">Opening Book Settings</string>
<string name="prefs_bookSettings_summary">Settings for opening book usage</string> <string name="prefs_bookSettings_summary">Settings for opening book usage</string>

View File

@ -244,7 +244,12 @@
android:title="@string/prefs_color_currentMove_title" android:title="@string/prefs_color_currentMove_title"
android:defaultValue="#FF3333FF"> android:defaultValue="#FF3333FF">
</EditTextPreference> </EditTextPreference>
</PreferenceCategory> <EditTextPreference
android:key="color_pgnComment"
android:title="@string/prefs_color_pgnComment_title"
android:defaultValue="#FFC0C000">
</EditTextPreference>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory

View File

@ -47,13 +47,14 @@ public class ColorTheme {
final static int ARROW_5 = 12; final static int ARROW_5 = 12;
final static int SQUARE_LABEL = 13; final static int SQUARE_LABEL = 13;
final static int DECORATION = 14; final static int DECORATION = 14;
private final static int numColors = 15; final static int PGN_COMMENT = 15;
private final static int numColors = 16;
private int colorTable[] = new int[numColors]; private int colorTable[] = new int[numColors];
private static final String[] prefNames = { private static final String[] prefNames = {
"darkSquare", "brightSquare", "selectedSquare", "cursorSquare", "darkPiece", "brightPiece", "currentMove", "darkSquare", "brightSquare", "selectedSquare", "cursorSquare", "darkPiece", "brightPiece", "currentMove",
"arrow0", "arrow1", "arrow2", "arrow3", "arrow4", "arrow5", "squareLabel", "decoration" "arrow0", "arrow1", "arrow2", "arrow3", "arrow4", "arrow5", "squareLabel", "decoration", "pgnComment"
}; };
private static final String prefPrefix = "color_"; private static final String prefPrefix = "color_";
@ -64,37 +65,37 @@ public class ColorTheme {
{ // Original { // Original
"#FF808080", "#FFBEBE5A", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF888888", "#FF808080", "#FFBEBE5A", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF888888",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF9F9F66" "#FF9F9F66", "#FFC0C000"
}, },
{ // XBoard { // XBoard
"#FF77A26D", "#FFC8C365", "#FFFFFF00", "#FF00FF00", "#FF202020", "#FFFFFFCC", "#FF6B9262", "#FF77A26D", "#FFC8C365", "#FFFFFF00", "#FF00FF00", "#FF202020", "#FFFFFFCC", "#FF6B9262",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF808080" "#FF808080", "#FFC0C000"
}, },
{ // Blue { // Blue
"#FF83A5D2", "#FFFFFFFA", "#FF3232D1", "#FF5F5FFD", "#FF282828", "#FFF0F0F0", "#FF3333FF", "#FF83A5D2", "#FFFFFFFA", "#FF3232D1", "#FF5F5FFD", "#FF282828", "#FFF0F0F0", "#FF3333FF",
"#A01F1FFF", "#A01FFF1F", "#501F1FFF", "#501FFF1F", "#1E1F1FFF", "#281FFF1F", "#FFFF0000", "#A01F1FFF", "#A01FFF1F", "#501F1FFF", "#501FFF1F", "#1E1F1FFF", "#281FFF1F", "#FFFF0000",
"#FF808080" "#FF808080", "#FFC0C000"
}, },
{ // Grey { // Grey
"#FF666666", "#FFDDDDDD", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF888888", "#FF666666", "#FFDDDDDD", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF888888",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF909090" "#FF909090", "#FFC0C000"
}, },
{ // Scid Default { // Scid Default
"#FF80A0A0", "#FFD0E0D0", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666", "#FF80A0A0", "#FFD0E0D0", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF808080" "#FF808080", "#FFC0C000"
}, },
{ // Scid Brown { // Scid Brown
"#B58863", "#F0D9B5", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666", "#B58863", "#F0D9B5", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF808080" "#FF808080", "#FFC0C000"
}, },
{ // Scid Green { // Scid Green
"#FF769656", "#FFEEEED2", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF666666", "#FF769656", "#FFEEEED2", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF666666",
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000", "#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
"#FF808080" "#FF808080", "#FFC0C000"
} }
}; };

View File

@ -87,6 +87,7 @@ import android.text.TextPaint;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.BackgroundColorSpan; import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.LeadingMarginSpan; import android.text.style.LeadingMarginSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.TypedValue; import android.util.TypedValue;
@ -1507,8 +1508,8 @@ public class DroidFish extends Activity implements GUIInterface {
public void onClick(DialogInterface dialog, int item) { public void onClick(DialogInterface dialog, int item) {
ColorTheme.instance().setTheme(settings, item); ColorTheme.instance().setTheme(settings, item);
cb.setColors(); cb.setColors();
gameTextListener.setCurrent(gameTextListener.currNode); gameTextListener.clear();
moveListUpdated(); ctrl.prefsChanged();
dialog.dismiss(); dialog.dismiss();
} }
}); });
@ -2193,7 +2194,11 @@ public class DroidFish extends Activity implements GUIInterface {
sb.append(' '); sb.append(' ');
} }
} }
int l0 = sb.length();
sb.append(token.replaceAll("[ \t\r\n]+", " ").trim()); sb.append(token.replaceAll("[ \t\r\n]+", " ").trim());
int l1 = sb.length();
int color = ColorTheme.instance().getColor(ColorTheme.PGN_COMMENT);
sb.setSpan(new ForegroundColorSpan(color), l0, l1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
col0 = false; col0 = false;
if (nestLevel == 0) if (nestLevel == 0)
newLine(); newLine();