Permalink
Browse files

Merge branch 'feature-configurableredtext'

Conflicts:
	Alkitab/src/yuku/alkitab/base/S.java
  • Loading branch information...
yukuku committed Oct 3, 2012
2 parents f6ea4f3 + 81f1cbc commit 74b88b0eae2417a49e01f2aae3a43d029ef860f6
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -4,9 +4,10 @@
<string name="pref_bahasa_language">Language</string>
<string name="pref_atur_warna_teks_latar_belakang_dan">Set colors of text, background, and verse numbers according to a theme.</string>
<string name="pref_tema_warna">Color Theme</string>
- <string name="pref_warna_teks_alkitab">Bible Text Color</string>
- <string name="pref_warna_latar_belakang">Background Color</string>
- <string name="pref_warna_nomor_ayat">Verse Number Color</string>
+ <string name="pref_warna_teks_alkitab">Bible Text</string>
+ <string name="pref_warna_latar_belakang">Background</string>
+ <string name="pref_warna_nomor_ayat">Verse Number</string>
+ <string name="pref_redTextColor_title">Words of Jesus</string>
<string name="pref_pakai_huruf_yang_dicetak_tebal_bold">Use bold fonts.</string>
<string name="pref_tebalkan_huruf">Bold Text</string>
<string name="pref_ganti_bentuk_huruf_teks_alkitab">Modify the appearance of the Bible text.</string>
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
- <!-- warna teks, warna latar, warna ayat -->
+ <!-- text color, bg color, verse number color, red text color -->
<string-array name="pref_temaWarna_value" tools:ignore="MissingTranslation">
<!-- kertas -->
- <item>ff000000 ffeeeeee ff6666ff</item>
+ <item>ff000000 ffeeeeee ff6666ff ffed130e</item>
<!-- papan -->
- <item>fff0f0f0 ff000000 ff9090ff</item>
+ <item>fff0f0f0 ff000000 ff9090ff ffff9090</item>
<!-- hutan -->
- <item>ff1c5009 ffd2f9d0 ff543703</item>
+ <item>ff1c5009 ffd2f9d0 ff543703 fff26f05</item>
<!-- danau -->
- <item>ff274720 ffd7e9e7 ff1916ec</item>
+ <item>ff274720 ffd7e9e7 ff1916ec ffe02c2c</item>
<!-- abu -->
- <item>ff2f3540 fff2ede4 ff8c8681</item>
+ <item>ff2f3540 fff2ede4 ff8c8681 ffdc48c5</item>
<!-- jeruk -->
- <item>ff3f5765 fffffcde ffe86a1c</item>
+ <item>ff3f5765 fffffcde ff25a81e fff65608</item>
<!-- padang -->
- <item>ff562707 ffeddca9 ffe44908</item>
+ <item>ff562707 ffeddca9 ffe36b09 ffbc641d</item>
<!-- coklat -->
- <item>fffaac5f ff362b2a ffac8674</item>
+ <item>fffaac5f ff362b2a ffd8d7d7 ffede36f</item>
<!-- jambu -->
- <item>ffe7a697 ff262a33 ffad8d8d</item>
+ <item>ffffc0af ff262a33 ffad8d8d ffff9090</item>
<!-- malam -->
- <item>ffe1e6fa ff122641 ffb1790f</item>
+ <item>ffe1e6fa ff122641 ffb1790f ffff9090</item>
<!-- malam bintang -->
- <item>ffffe985 ff122641 ffe3f5ff</item>
+ <item>ffffe985 ff122641 ffe3f5ff ffff9090</item>
</string-array>
</resources>
@@ -22,7 +22,10 @@
<integer name="pref_warnaLatar_int_default">0xff000000</integer>
<string name="pref_warnaNomerAyat_int_key">warnaNomerAyat</string>
- <integer name="pref_warnaNomerAyat_int_default">0xff8080ff</integer>
+ <integer name="pref_warnaNomerAyat_int_default">0xff9090ff</integer>
+
+ <string name="pref_redTextColor_key">redTextColor</string>
+ <integer name="pref_redTextColor_default">0xffff9090</integer>
<string name="pref_boldHuruf_key">boldHuruf</string>
@@ -42,16 +42,20 @@
/>
<yuku.ambilwarna.widget.AmbilWarnaPreference
android:key="@string/pref_warnaHuruf_int_key"
- android:defaultValue="0xfff0f0f0"
+ android:defaultValue="@integer/pref_warnaHuruf_int_default"
android:title="@string/pref_warna_teks_alkitab" />
<yuku.ambilwarna.widget.AmbilWarnaPreference
android:key="@string/pref_warnaLatar_int_key"
- android:defaultValue="0xff000000"
+ android:defaultValue="@integer/pref_warnaLatar_int_default"
android:title="@string/pref_warna_latar_belakang" />
<yuku.ambilwarna.widget.AmbilWarnaPreference
android:key="@string/pref_warnaNomerAyat_int_key"
- android:defaultValue="0xff9090ff"
+ android:defaultValue="@integer/pref_warnaNomerAyat_int_default"
android:title="@string/pref_warna_nomor_ayat" />
+ <yuku.ambilwarna.widget.AmbilWarnaPreference
+ android:key="@string/pref_redTextColor_key"
+ android:defaultValue="@integer/pref_redTextColor_default"
+ android:title="@string/pref_redTextColor_title" />
</PreferenceScreen>
</PreferenceCategory>
@@ -124,7 +124,7 @@ public static void calculateAppliedValuesBasedOnPreferences() {
applied.fontColor = Preferences.getInt(App.context.getString(R.string.pref_warnaHuruf_int_key), App.context.getResources().getInteger(R.integer.pref_warnaHuruf_int_default));
applied.backgroundColor = Preferences.getInt(App.context.getString(R.string.pref_warnaLatar_int_key), App.context.getResources().getInteger(R.integer.pref_warnaLatar_int_default));
applied.verseNumberColor = Preferences.getInt(App.context.getString(R.string.pref_warnaNomerAyat_int_key), App.context.getResources().getInteger(R.integer.pref_warnaNomerAyat_int_default));
- applied.fontRedColor = hitungHurufMerah(S.applied.fontColor, S.applied.backgroundColor);
+ applied.fontRedColor = Preferences.getInt(App.context.getString(R.string.pref_redTextColor_key), App.context.getResources().getInteger(R.integer.pref_redTextColor_default));
// calculation of backgroundColor brightness. Used somewhere else.
{
@@ -144,18 +144,6 @@ public static void calculateAppliedValuesBasedOnPreferences() {
applied.indentSpacingExtra = (int) (skalaBerdasarUkuranHuruf * res.getDimensionPixelOffset(R.dimen.menjorokExtra) + 0.5f);
}
- private static int hitungHurufMerah(int warnaHuruf, int warnaLatar) {
- // berdasar warna latar saja deh untuk kali ini
- int brt = Color.red(warnaLatar) * 30 + Color.green(warnaLatar) * 59 + Color.blue(warnaLatar) * 11;
- if (brt < 30 * 100) {
- return 0xffff9090;
- } else if (brt < 86 * 100) {
- return 0xffff5050;
- } else {
- return 0xffff0000;
- }
- }
-
private static final String notAvailableText = "[?]"; //$NON-NLS-1$
private static final String[] notAvailableTextArray = {
@@ -21,10 +21,10 @@
public class ColorThemePreference extends ListPreference {
private static final String TAG = ColorThemePreference.class.getSimpleName();
-
+
int mClickedDialogEntryIndex;
String mValue;
-
+
public ColorThemePreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -33,8 +33,7 @@ public ColorThemePreference(Context context) {
this(context, null);
}
- @Override
- protected void onPrepareDialogBuilder(Builder builder) {
+ @Override protected void onPrepareDialogBuilder(Builder builder) {
final CharSequence[] entryValues = getEntryValues();
final CharSequence[] entries = getEntries();
@@ -45,8 +44,7 @@ protected void onPrepareDialogBuilder(Builder builder) {
mClickedDialogEntryIndex = getValueIndex();
builder.setAdapter(new BaseAdapter() {
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
+ @Override public View getView(int position, View convertView, ViewGroup parent) {
CheckedTextView res = (CheckedTextView) convertView;
if (convertView == null) {
res = (CheckedTextView) LayoutInflater.from(getContext()).inflate(android.R.layout.select_dialog_singlechoice, null);
@@ -75,18 +73,15 @@ public View getView(int position, View convertView, ViewGroup parent) {
return res;
}
- @Override
- public long getItemId(int position) {
+ @Override public long getItemId(int position) {
return position;
}
- @Override
- public Object getItem(int position) {
+ @Override public Object getItem(int position) {
return null;
}
- @Override
- public int getCount() {
+ @Override public int getCount() {
return entryValues.length;
}
}, new DialogInterface.OnClickListener() {
@@ -101,7 +96,7 @@ public int getCount() {
dialog.dismiss();
}
});
-
+
/*
* The typical interaction for list-based dialogs is to have
* click-on-an-item dismiss the dialog instead of the user having to
@@ -110,8 +105,7 @@ public int getCount() {
builder.setPositiveButton(null, null);
}
- @Override
- protected void onDialogClosed(boolean positiveResult) {
+ @Override protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
final CharSequence[] entryValues = getEntryValues();
@@ -125,52 +119,51 @@ protected void onDialogClosed(boolean positiveResult) {
}
}
- @Override
- public String getValue() {
+ @Override public String getValue() {
Log.d(TAG, "getValue "); //$NON-NLS-1$
-
+
SharedPreferences pref = getPreferenceManager().getSharedPreferences();
String w1 = String.format("%08x", pref.getInt(getContext().getString(R.string.pref_warnaHuruf_int_key), 0xff000000)); //$NON-NLS-1$
String w2 = String.format("%08x", pref.getInt(getContext().getString(R.string.pref_warnaLatar_int_key), 0xff000000)); //$NON-NLS-1$
String w3 = String.format("%08x", pref.getInt(getContext().getString(R.string.pref_warnaNomerAyat_int_key), 0xff000000)); //$NON-NLS-1$
- return gabungWarna(w1, w2, w3);
+ String w4 = String.format("%08x", pref.getInt(getContext().getString(R.string.pref_redTextColor_key), 0xff000000)); //$NON-NLS-1$
+ return gabungWarna(w1, w2, w3, w4);
}
private int getValueIndex() {
return findIndexOfValue(getValue());
}
- @Override
- protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
+ @Override protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
Log.d(TAG, "onSetInitialValue " + restoreValue + " " + defaultValue); //$NON-NLS-1$ //$NON-NLS-2$
setValue(restoreValue ? getPersistedString(mValue) : (String) defaultValue);
}
- @Override
- public void setValue(String value) {
+ @Override public void setValue(String value) {
Log.d(TAG, "setValue " + value); //$NON-NLS-1$
-
+
mValue = value;
int[] w = pisahWarna(value);
-
- int[] xresId = {R.string.pref_warnaHuruf_int_key, R.string.pref_warnaLatar_int_key, R.string.pref_warnaNomerAyat_int_key};
+
+ int[] xresId = { R.string.pref_warnaHuruf_int_key, R.string.pref_warnaLatar_int_key, R.string.pref_warnaNomerAyat_int_key, R.string.pref_redTextColor_key };
for (int i = 0; i < xresId.length; i++) {
AmbilWarnaPreference p = (AmbilWarnaPreference) findPreferenceInHierarchy(getContext().getString(xresId[i]));
p.forceSetValue(w[i]);
}
}
-
+
static int[] pisahWarna(CharSequence value) {
- int[] w = new int[3];
+ int[] w = new int[4];
w[0] = (int) Long.parseLong(value.subSequence(0, 8).toString(), 16);
w[1] = (int) Long.parseLong(value.subSequence(9, 17).toString(), 16);
w[2] = (int) Long.parseLong(value.subSequence(18, 26).toString(), 16);
+ w[3] = (int) Long.parseLong(value.subSequence(27, 35).toString(), 16);
return w;
}
- private static String gabungWarna(String w1, String w2, String w3) {
- return w1 + " " + w2 + " " + w3; //$NON-NLS-1$ //$NON-NLS-2$
+ private static String gabungWarna(String w1, String w2, String w3, String w4) {
+ return w1 + ' ' + w2 + ' ' + w3 + ' ' + w4;
}
}

0 comments on commit 74b88b0

Please sign in to comment.