DroidFish: Don't change background color for the overlay view. Removed

unnecessary preference change listener.
This commit is contained in:
Peter Osterlund 2016-01-13 20:50:44 +01:00
parent 43228ba081
commit f4622e620a
10 changed files with 19 additions and 23 deletions

View File

@ -3,8 +3,8 @@
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">

View File

@ -4,6 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">

View File

@ -3,8 +3,8 @@
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">

View File

@ -90,7 +90,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
@ -428,12 +427,6 @@ public class DroidFish extends Activity
PreferenceManager.setDefaultValues(this, R.xml.preferences, false); PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
settings = PreferenceManager.getDefaultSharedPreferences(this); settings = PreferenceManager.getDefaultSharedPreferences(this);
settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
handlePrefsChange();
}
});
setWakeLock(false); setWakeLock(false);
@ -792,7 +785,7 @@ public class DroidFish extends Activity
private final void initUI() { private final void initUI() {
leftHanded = leftHandedView(); leftHanded = leftHandedView();
setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main); setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
Util.overrideFonts(findViewById(android.R.id.content)); overrideViewAttribs();
// title lines need to be regenerated every time due to layout changes (rotations) // title lines need to be regenerated every time due to layout changes (rotations)
firstTitleLine = findViewById(R.id.first_title_line); firstTitleLine = findViewById(R.id.first_title_line);
@ -1241,7 +1234,7 @@ public class DroidFish extends Activity
ColorTheme.instance().readColors(settings); ColorTheme.instance().readColors(settings);
cb.setColors(); cb.setColors();
Util.overrideFonts(findViewById(android.R.id.content)); overrideViewAttribs();
gameTextListener.clear(); gameTextListener.clear();
setPieceNames(pgnOptions.view.pieceType); setPieceNames(pgnOptions.view.pieceType);
@ -1254,6 +1247,10 @@ public class DroidFish extends Activity
secondTitleLine.setVisibility(showMaterialDiff ? View.VISIBLE : View.GONE); secondTitleLine.setVisibility(showMaterialDiff ? View.VISIBLE : View.GONE);
} }
private void overrideViewAttribs() {
Util.overrideViewAttribs(findViewById(R.id.main));
}
/** /**
* Change the Pieces into figurine or regular (i.e. letters) display * Change the Pieces into figurine or regular (i.e. letters) display
*/ */
@ -2619,7 +2616,7 @@ public class DroidFish extends Activity
gameTextListener.clear(); gameTextListener.clear();
ctrl.prefsChanged(false); ctrl.prefsChanged(false);
dialog.dismiss(); dialog.dismiss();
Util.overrideFonts(findViewById(android.R.id.content)); overrideViewAttribs();
} }
}); });
return builder.create(); return builder.create();

View File

@ -116,7 +116,7 @@ public final class Util {
} }
/** Change foreground/background color in a view. */ /** Change foreground/background color in a view. */
public static void overrideFonts(final View v) { public static void overrideViewAttribs(final View v) {
if (v == null) if (v == null)
return; return;
final int bg = ColorTheme.instance().getColor(ColorTheme.GENERAL_BACKGROUND); final int bg = ColorTheme.instance().getColor(ColorTheme.GENERAL_BACKGROUND);
@ -126,8 +126,6 @@ public final class Util {
v instanceof ImageButton || v instanceof ImageButton ||
"title".equals(tag); "title".equals(tag);
if (!excludedItems) { if (!excludedItems) {
if ("drawer".equals(tag))
return;
int c = bg; int c = bg;
if ("thinking".equals(tag)) { if ("thinking".equals(tag)) {
float[] hsv = new float[3]; float[] hsv = new float[3];
@ -143,7 +141,7 @@ public final class Util {
ViewGroup vg = (ViewGroup) v; ViewGroup vg = (ViewGroup) v;
for (int i = 0; i < vg.getChildCount(); i++) { for (int i = 0; i < vg.getChildCount(); i++) {
View child = vg.getChildAt(i); View child = vg.getChildAt(i);
overrideFonts(child); overrideViewAttribs(child);
} }
} else if (!excludedItems && (v instanceof TextView)) { } else if (!excludedItems && (v instanceof TextView)) {
int fg = ColorTheme.instance().getColor(ColorTheme.FONT_FOREGROUND); int fg = ColorTheme.instance().getColor(ColorTheme.FONT_FOREGROUND);

View File

@ -137,7 +137,7 @@ public class EditBoard extends Activity {
private final void initUI() { private final void initUI() {
setContentView(R.layout.editboard); setContentView(R.layout.editboard);
Util.overrideFonts(findViewById(android.R.id.content)); Util.overrideViewAttribs(findViewById(android.R.id.content));
View firstTitleLine = findViewById(R.id.first_title_line); View firstTitleLine = findViewById(R.id.first_title_line);
View secondTitleLine = findViewById(R.id.second_title_line); View secondTitleLine = findViewById(R.id.second_title_line);

View File

@ -209,7 +209,7 @@ public class EditOptions extends Activity {
} }
setContentView(view); setContentView(view);
Util.overrideFonts(findViewById(android.R.id.content)); Util.overrideViewAttribs(findViewById(android.R.id.content));
Button okButton = (Button)findViewById(R.id.eo_ok); Button okButton = (Button)findViewById(R.id.eo_ok);
Button cancelButton = (Button)findViewById(R.id.eo_cancel); Button cancelButton = (Button)findViewById(R.id.eo_cancel);
Button resetButton = (Button)findViewById(R.id.eo_reset); Button resetButton = (Button)findViewById(R.id.eo_reset);

View File

@ -240,7 +240,7 @@ public class EditPGN extends ListActivity {
progress = null; progress = null;
removeDialog(PROGRESS_DIALOG); removeDialog(PROGRESS_DIALOG);
setContentView(R.layout.select_game); setContentView(R.layout.select_game);
Util.overrideFonts(findViewById(android.R.id.content)); Util.overrideViewAttribs(findViewById(android.R.id.content));
aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile) { aa = new ArrayAdapter<GameInfo>(this, R.layout.select_game_list_item, gamesInFile) {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {

View File

@ -215,7 +215,7 @@ public class LoadFEN extends ListActivity {
} }
}); });
Util.overrideFonts(findViewById(android.R.id.content)); Util.overrideViewAttribs(findViewById(android.R.id.content));
aa = new ArrayAdapter<FenInfo>(this, R.layout.select_game_list_item, fensInFile) { aa = new ArrayAdapter<FenInfo>(this, R.layout.select_game_list_item, fensInFile) {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {

View File

@ -243,7 +243,7 @@ public class LoadScid extends ListActivity {
}; };
setListAdapter(aa); setListAdapter(aa);
ListView lv = getListView(); ListView lv = getListView();
Util.overrideFonts(lv); Util.overrideViewAttribs(lv);
lv.setSelectionFromTop(defaultItem, 0); lv.setSelectionFromTop(defaultItem, 0);
lv.setFastScrollEnabled(true); lv.setFastScrollEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() { lv.setOnItemClickListener(new OnItemClickListener() {