mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-12-18 00:05:10 +01:00
DroidFish: Made it possible to change background color and text foreground color. From Leo Mayer.
This commit is contained in:
parent
fa0d1a20d9
commit
705e0ffea3
|
@ -5,7 +5,8 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:background="@android:drawable/title_bar"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:tag="title" >
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/first_title_line"
|
||||
|
@ -13,7 +14,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="2dp"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="horizontal"
|
||||
android:tag="title" >
|
||||
<TextView
|
||||
android:id="@+id/white_clock"
|
||||
style="?android:attr/windowTitleStyle"
|
||||
|
@ -26,7 +28,8 @@
|
|||
android:gravity="left"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="true">
|
||||
android:singleLine="true"
|
||||
android:tag="title" >
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
|
@ -35,6 +38,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:tag="title"
|
||||
android:text="@string/app_name">
|
||||
</TextView>
|
||||
<TextView
|
||||
|
@ -49,7 +53,8 @@
|
|||
android:gravity="right"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true">
|
||||
android:singleLine="true"
|
||||
android:tag="title" >
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -58,7 +63,8 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical">
|
||||
android:layout_gravity="center_vertical"
|
||||
android:tag="title" >
|
||||
<TextView
|
||||
android:id="@+id/white_pieces"
|
||||
style="?android:attr/windowTitleStyle"
|
||||
|
@ -71,6 +77,7 @@
|
|||
android:gravity="center|center_vertical"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:singleLine="true"
|
||||
android:tag="title"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold">
|
||||
</TextView>
|
||||
|
@ -81,6 +88,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center|center_vertical"
|
||||
android:tag="title"
|
||||
android:text="">
|
||||
</TextView>
|
||||
<TextView
|
||||
|
@ -96,6 +104,7 @@
|
|||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:tag="title"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold">
|
||||
</TextView>
|
||||
|
|
|
@ -319,6 +319,8 @@ you are not actively using the program.\
|
|||
<string name="prefs_move_list">Move List</string>
|
||||
<string name="prefs_color_currentMove_title">Current Move</string>
|
||||
<string name="prefs_color_pgnComment_title">Comments</string>
|
||||
<string name="prefs_color_fontForeground_title">Font color</string>
|
||||
<string name="prefs_color_generalBackground_title">Background</string>
|
||||
<string name="prefs_other">Other</string>
|
||||
<string name="prefs_bookSettings_title">Opening Book Settings</string>
|
||||
<string name="prefs_bookSettings_summary">Settings for opening book usage</string>
|
||||
|
|
|
@ -473,6 +473,18 @@
|
|||
alphaSlider="true"
|
||||
android:defaultValue="#FFC0C000">
|
||||
</net.margaritov.preference.colorpicker.ColorPickerPreference>
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="color_fontForeground"
|
||||
android:title="@string/prefs_color_fontForeground_title"
|
||||
alphaSlider="false"
|
||||
android:defaultValue="#FFFFFFFF">
|
||||
</net.margaritov.preference.colorpicker.ColorPickerPreference>
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="color_generalBackground"
|
||||
android:title="@string/prefs_color_generalBackground_title"
|
||||
alphaSlider="false"
|
||||
android:defaultValue="#FF000000">
|
||||
</net.margaritov.preference.colorpicker.ColorPickerPreference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ColorTheme {
|
|||
private static ColorTheme inst = null;
|
||||
|
||||
/** Get singleton instance. */
|
||||
static final ColorTheme instance() {
|
||||
public static final ColorTheme instance() {
|
||||
if (inst == null)
|
||||
inst = new ColorTheme();
|
||||
return inst;
|
||||
|
@ -48,13 +48,16 @@ public class ColorTheme {
|
|||
final static int SQUARE_LABEL = 13;
|
||||
final static int DECORATION = 14;
|
||||
final static int PGN_COMMENT = 15;
|
||||
private final static int numColors = 16;
|
||||
public final static int FONT_FOREGROUND = 16;
|
||||
public final static int GENERAL_BACKGROUND = 17;
|
||||
private final static int numColors = 18;
|
||||
|
||||
private int colorTable[] = new int[numColors];
|
||||
|
||||
private static final String[] prefNames = {
|
||||
"darkSquare", "brightSquare", "selectedSquare", "cursorSquare", "darkPiece", "brightPiece", "currentMove",
|
||||
"arrow0", "arrow1", "arrow2", "arrow3", "arrow4", "arrow5", "squareLabel", "decoration", "pgnComment"
|
||||
"arrow0", "arrow1", "arrow2", "arrow3", "arrow4", "arrow5", "squareLabel", "decoration", "pgnComment",
|
||||
"fontForeground", "generalBackground"
|
||||
};
|
||||
private static final String prefPrefix = "color_";
|
||||
|
||||
|
@ -65,37 +68,37 @@ public class ColorTheme {
|
|||
{ // Original
|
||||
"#FF808080", "#FFBEBE5A", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF9F9F66", "#FFC0C000"
|
||||
"#FF9F9F66", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // XBoard
|
||||
"#FF77A26D", "#FFC8C365", "#FFFFFF00", "#FF00FF00", "#FF202020", "#FFFFFFCC", "#FF6B9262",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF808080", "#FFC0C000"
|
||||
"#FF808080", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // Blue
|
||||
"#FF83A5D2", "#FFFFFFFA", "#FF3232D1", "#FF5F5FFD", "#FF282828", "#FFF0F0F0", "#FF3333FF",
|
||||
"#A01F1FFF", "#A01FFF1F", "#501F1FFF", "#501FFF1F", "#1E1F1FFF", "#281FFF1F", "#FFFF0000",
|
||||
"#FF808080", "#FFC0C000"
|
||||
"#FF808080", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // Grey
|
||||
"#FF666666", "#FFDDDDDD", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF909090", "#FFC0C000"
|
||||
"#FF909090", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // Scid Default
|
||||
"#FF80A0A0", "#FFD0E0D0", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF808080", "#FFC0C000"
|
||||
"#FF808080", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // Scid Brown
|
||||
"#B58863", "#F0D9B5", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF808080", "#FFC0C000"
|
||||
"#FF808080", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
},
|
||||
{ // Scid Green
|
||||
"#FF769656", "#FFEEEED2", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#1E1F1FFF", "#28FF1F1F", "#FFFF0000",
|
||||
"#FF808080", "#FFC0C000"
|
||||
"#FF808080", "#FFC0C000", "#FFFFFFFF", "#FF000000"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -121,7 +124,7 @@ public class ColorTheme {
|
|||
readColors(settings);
|
||||
}
|
||||
|
||||
final int getColor(int colorType) {
|
||||
public final int getColor(int colorType) {
|
||||
return colorTable[colorType];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -535,6 +535,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
private final void initUI() {
|
||||
leftHanded = leftHandedView();
|
||||
setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
|
||||
Util.overrideFonts(findViewById(android.R.id.content));
|
||||
|
||||
// title lines need to be regenerated every time due to layout changes (rotations)
|
||||
secondTitleLine = findViewById(R.id.second_title_line);
|
||||
|
@ -888,6 +889,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
|
||||
ColorTheme.instance().readColors(settings);
|
||||
cb.setColors();
|
||||
Util.overrideFonts(findViewById(android.R.id.content));
|
||||
|
||||
gameTextListener.clear();
|
||||
setPieceNames(pgnOptions.view.pieceType);
|
||||
|
@ -2026,6 +2028,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||
gameTextListener.clear();
|
||||
ctrl.prefsChanged(false);
|
||||
dialog.dismiss();
|
||||
Util.overrideFonts(findViewById(android.R.id.content));
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
|
|
|
@ -12,7 +12,14 @@ import org.petero.droidfish.gamelogic.Position;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class Util {
|
||||
public final static String boldStart;
|
||||
|
@ -82,4 +89,29 @@ public final class Util {
|
|||
}
|
||||
a.getWindow().setAttributes(attrs);
|
||||
}
|
||||
|
||||
/** Change foreground/background color in a view. */
|
||||
public static void overrideFonts(final View v) {
|
||||
if (v == null)
|
||||
return;
|
||||
final int bg = ColorTheme.instance().getColor(ColorTheme.GENERAL_BACKGROUND);
|
||||
final boolean excludedItems = v instanceof Button ||
|
||||
v instanceof EditText ||
|
||||
v instanceof ImageButton ||
|
||||
"title".equals(v.getTag());
|
||||
if (!excludedItems)
|
||||
v.setBackgroundColor(bg);
|
||||
if (v instanceof ListView)
|
||||
((ListView) v).setCacheColorHint(bg);
|
||||
if (v instanceof ViewGroup) {
|
||||
ViewGroup vg = (ViewGroup) v;
|
||||
for (int i = 0; i < vg.getChildCount(); i++) {
|
||||
View child = vg.getChildAt(i);
|
||||
overrideFonts(child);
|
||||
}
|
||||
} else if ((v instanceof TextView) && !excludedItems) {
|
||||
int fg = ColorTheme.instance().getColor(ColorTheme.FONT_FOREGROUND);
|
||||
((TextView) v).setTextColor(fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@ public class EditBoard extends Activity {
|
|||
|
||||
private final void initUI() {
|
||||
setContentView(R.layout.editboard);
|
||||
Util.overrideFonts(findViewById(android.R.id.content));
|
||||
|
||||
cb = (ChessBoardEdit)findViewById(R.id.eb_chessboard);
|
||||
status = (TextView)findViewById(R.id.eb_status);
|
||||
okButton = (Button)findViewById(R.id.eb_ok);
|
||||
|
|
|
@ -21,7 +21,9 @@ package org.petero.droidfish.activities;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.petero.droidfish.ColorTheme;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
import org.petero.droidfish.activities.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.PGNFile.GameInfoResult;
|
||||
import org.petero.droidfish.gamelogic.Pair;
|
||||
|
@ -43,6 +45,7 @@ import android.text.TextWatcher;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
|
@ -234,7 +237,18 @@ public class EditPGN extends ListActivity {
|
|||
private final void showList() {
|
||||
progress.dismiss();
|
||||
setContentView(R.layout.select_game);
|
||||
aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile);
|
||||
Util.overrideFonts(findViewById(android.R.id.content));
|
||||
aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
if (view instanceof TextView) {
|
||||
int fg = ColorTheme.instance().getColor(ColorTheme.FONT_FOREGROUND);
|
||||
((TextView) view).setTextColor(fg);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
setListAdapter(aa);
|
||||
ListView lv = getListView();
|
||||
lv.setSelectionFromTop(defaultItem, 0);
|
||||
|
|
|
@ -21,7 +21,9 @@ package org.petero.droidfish.activities;
|
|||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.petero.droidfish.ColorTheme;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.ListActivity;
|
||||
|
@ -36,9 +38,11 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
|
@ -167,9 +171,21 @@ public class LoadScid extends ListActivity {
|
|||
|
||||
private final void showList() {
|
||||
progress.dismiss();
|
||||
final ArrayAdapter<GameInfo> aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile);
|
||||
final ArrayAdapter<GameInfo> aa =
|
||||
new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
if (view instanceof TextView) {
|
||||
int fg = ColorTheme.instance().getColor(ColorTheme.FONT_FOREGROUND);
|
||||
((TextView) view).setTextColor(fg);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
setListAdapter(aa);
|
||||
ListView lv = getListView();
|
||||
Util.overrideFonts(lv);
|
||||
lv.setSelectionFromTop(defaultItem, 0);
|
||||
lv.setFastScrollEnabled(true);
|
||||
lv.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user