Permalink
Browse files

Translate to English public-facing methods of S and U classes.

  • Loading branch information...
1 parent d49f168 commit 5b9580f2a63eb88f6e45d60710067ef1b1a0b920 @yukuku committed Oct 3, 2012
@@ -596,11 +596,11 @@ private IntArrayList getSelectedVerses_1() {
private CharSequence referenceFromSelectedVerses(IntArrayList selectedVerses) {
if (selectedVerses.size() == 0) {
// should not be possible. So we don't do anything.
- return S.alamat(S.activeBook, this.chapter_1);
+ return S.reference(S.activeBook, this.chapter_1);
} else if (selectedVerses.size() == 1) {
- return S.alamat(S.activeBook, this.chapter_1, selectedVerses.get(0));
+ return S.reference(S.activeBook, this.chapter_1, selectedVerses.get(0));
} else {
- return S.alamat(S.activeBook, this.chapter_1, selectedVerses);
+ return S.reference(S.activeBook, this.chapter_1, selectedVerses);
}
}
@@ -724,7 +724,7 @@ public void onFakeContextMenuSelected(FakeContextMenu menu, Item item) {
final int ari = Ari.encode(S.activeBook.bookId, this.chapter_1, mainVerse_1);
- TypeBookmarkDialog dialog = new TypeBookmarkDialog(this, S.alamat(S.activeBook, this.chapter_1, mainVerse_1), ari);
+ TypeBookmarkDialog dialog = new TypeBookmarkDialog(this, S.reference(S.activeBook, this.chapter_1, mainVerse_1), ari);
dialog.setListener(new TypeBookmarkDialog.Listener() {
@Override public void onOk() {
uncheckAll();
@@ -1188,7 +1188,7 @@ int display(int chapter_1, int verse_1) {
PericopeBlock[] pericope_blocks;
int nblock;
- String[] verses = S.muatTeks(S.activeVersion, S.activeBook, chapter_1);
+ String[] verses = S.loadChapterText(S.activeVersion, S.activeBook, chapter_1);
//# max is set to 30 (one chapter has max of 30 blocks. Already almost impossible)
int max = 30;
@@ -1213,7 +1213,7 @@ int display(int chapter_1, int verse_1) {
}
}
- String title = S.alamat(S.activeBook, chapter_1);
+ String title = S.reference(S.activeBook, chapter_1);
lTitle.setText(title);
bGoto.setText(title);
@@ -84,23 +84,23 @@
if (a == 0) throw new RuntimeException(); // cuma mencegah project ambilwarna lupa dibuka
}
- private static synchronized void siapinEdisi() {
+ private static synchronized void prepareVersion() {
if (activeVersion == null) {
- activeVersion = getEdisiInternal();
+ activeVersion = getInternalVersion();
}
}
- private static Version edisiInternal;
- public static synchronized Version getEdisiInternal() {
- if (edisiInternal == null) {
+ private static Version internalVersion;
+ public static synchronized Version getInternalVersion() {
+ if (internalVersion == null) {
BuildConfig c = BuildConfig.get(App.context);
- edisiInternal = new Version(new InternalReader(App.context, c.internalPrefix, c.internalJudul, new ReaderDecoder.Ascii()));
+ internalVersion = new Version(new InternalReader(App.context, c.internalPrefix, c.internalJudul, new ReaderDecoder.Ascii()));
}
- return edisiInternal;
+ return internalVersion;
}
public static synchronized void prepareBook() {
- siapinEdisi();
+ prepareVersion();
if (activeBook != null) return;
activeBook = activeVersion.getFirstBook(); // nanti diset sama luar waktu init
@@ -156,60 +156,60 @@ private static int hitungHurufMerah(int warnaHuruf, int warnaLatar) {
}
}
- private static final String teksTakTersedia = "[?]"; //$NON-NLS-1$
+ private static final String notAvailableText = "[?]"; //$NON-NLS-1$
- private static final String[] teksTakTersediaArray = {
- teksTakTersedia,
+ private static final String[] notAvailableTextArray = {
+ notAvailableText,
};
- public static synchronized String muatSatuAyat(Version version, Book book, int pasal_1, int ayat_1) {
+ public static synchronized String loadVerseText(Version version, Book book, int pasal_1, int ayat_1) {
if (book == null) {
- return teksTakTersedia;
+ return notAvailableText;
}
- String[] xayat = muatTeks(version, book, pasal_1, false, false);
+ String[] xayat = loadChapterText(version, book, pasal_1, false, false);
if (xayat == null) {
- return teksTakTersedia;
+ return notAvailableText;
}
int ayat_0 = ayat_1 - 1;
if (ayat_0 >= xayat.length) {
- return teksTakTersedia;
+ return notAvailableText;
}
return xayat[ayat_0];
}
- public static synchronized String muatSatuAyat(Version version, int ari) {
- return muatSatuAyat(version, version.getBook(Ari.toBook(ari)), Ari.toChapter(ari), Ari.toVerse(ari));
+ public static synchronized String loadVerseText(Version version, int ari) {
+ return loadVerseText(version, version.getBook(Ari.toBook(ari)), Ari.toChapter(ari), Ari.toVerse(ari));
}
- public static synchronized String[] muatTeks(Version version, Book book, int pasal_1) {
+ public static synchronized String[] loadChapterText(Version version, Book book, int pasal_1) {
if (book == null) {
- return teksTakTersediaArray;
+ return notAvailableTextArray;
}
- String[] xayat = muatTeks(version, book, pasal_1, false, false);
+ String[] xayat = loadChapterText(version, book, pasal_1, false, false);
if (xayat == null) {
- return teksTakTersediaArray;
+ return notAvailableTextArray;
}
return xayat;
}
- public static synchronized String muatTeksJanganPisahAyatHurufKecil(Version version, Book book, int pasal_1) {
+ public static synchronized String loadChapterTextLowercasedWithoutSplit(Version version, Book book, int pasal_1) {
if (book == null) {
- return teksTakTersedia;
+ return notAvailableText;
}
- String[] xayat_denganSatuElemen = muatTeks(version, book, pasal_1, true, true);
+ String[] xayat_denganSatuElemen = loadChapterText(version, book, pasal_1, true, true);
if (xayat_denganSatuElemen == null) {
- return teksTakTersedia;
+ return notAvailableText;
}
return xayat_denganSatuElemen[0];
}
- private static String[] muatTeks(Version version, Book book, int pasal_1, boolean janganPisahAyat, boolean hurufKecil) {
+ private static String[] loadChapterText(Version version, Book book, int pasal_1, boolean janganPisahAyat, boolean hurufKecil) {
return version.reader.muatTeks(book, pasal_1, janganPisahAyat, hurufKecil);
}
@@ -233,15 +233,15 @@ public static String reference(Version version, int ari) {
return hasil.toString();
}
- public static String alamat(Book book, int pasal_1) {
+ public static String reference(Book book, int pasal_1) {
return (book == null? "[?]": book.judul) + " " + pasal_1; //$NON-NLS-1$ //$NON-NLS-2$
}
- public static String alamat(Book book, int pasal_1, int ayat_1) {
+ public static String reference(Book book, int pasal_1, int ayat_1) {
return (book == null? "[?]": book.judul) + " " + pasal_1 + ":" + ayat_1; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
- public static CharSequence alamat(Book book, int pasal_1, IntArrayList xayat_1) {
+ public static CharSequence reference(Book book, int pasal_1, IntArrayList xayat_1) {
StringBuilder sb = new StringBuilder(book == null? "[?]": book.judul); //$NON-NLS-1$
sb.append(' ').append(pasal_1);
if (xayat_1 == null || xayat_1.size() == 0) {
@@ -18,36 +18,36 @@
public class U {
/**
- * Kalo ayat ga berawalan @: ga ngapa2in
- * Sebaliknya, buang semua @ dan 1 karakter setelahnya.
+ * If verse doesn't start with @: don't do anything.
+ * Otherwise, remove all @'s and one character after that.
*
- * @param ayat
+ * @param text a verse
*/
- public static String removeSpecialCodes(String ayat) {
- if (ayat.length() == 0) return ayat;
- if (ayat.charAt(0) != '@') return ayat;
+ public static String removeSpecialCodes(String text) {
+ if (text.length() == 0) return text;
+ if (text.charAt(0) != '@') return text;
- StringBuilder sb = new StringBuilder(ayat.length());
+ StringBuilder sb = new StringBuilder(text.length());
int pos = 2;
while (true) {
- int p = ayat.indexOf('@', pos);
+ int p = text.indexOf('@', pos);
if (p == -1) {
break;
}
- sb.append(ayat, pos, p);
+ sb.append(text, pos, p);
pos = p + 2;
}
- sb.append(ayat, pos, ayat.length());
+ sb.append(text, pos, text.length());
return sb.toString();
}
- public static String enkodStabilo(int warnaRgb) {
+ public static String encodeHighlight(int colorRgb) {
StringBuilder sb = new StringBuilder(10);
sb.append('c');
- String h = Integer.toHexString(warnaRgb);
+ String h = Integer.toHexString(colorRgb);
for (int x = h.length(); x < 6; x++) {
sb.append('0');
}
@@ -56,21 +56,21 @@ public static String enkodStabilo(int warnaRgb) {
}
/**
- * @return warnaRgb (belum ada alphanya) atau -1 kalau ga bisa dekod
+ * @return colorRgb (without alpha) or -1 if can't decode
*/
- public static int dekodStabilo(String tulisan) {
- if (tulisan == null) return -1;
- if (tulisan.length() >= 7 && tulisan.charAt(0) == 'c') {
- return Integer.parseInt(tulisan.substring(1, 7), 16);
+ public static int decodeHighlight(String text) {
+ if (text == null) return -1;
+ if (text.length() >= 7 && text.charAt(0) == 'c') {
+ return Integer.parseInt(text.substring(1, 7), 16);
} else {
return -1;
}
}
- public static String enkodWarnaLatarLabel(int warnaRgb_background) {
+ public static String encodeLabelBackgroundColor(int colorRgb_background) {
StringBuilder sb = new StringBuilder(10);
sb.append('b'); // 'b': background color
- String h = Integer.toHexString(warnaRgb_background);
+ String h = Integer.toHexString(colorRgb_background);
for (int x = h.length(); x < 6; x++) {
sb.append('0');
}
@@ -79,20 +79,20 @@ public static String enkodWarnaLatarLabel(int warnaRgb_background) {
}
/**
- * @return warnaRgb (belum ada alphanya) atau -1 kalau ga bisa dekod
+ * @return colorRgb (without alpha) or -1 if can't decode
*/
- public static int dekodWarnaLatarLabel(String warnaLatar) {
- if (warnaLatar == null || warnaLatar.length() == 0) return -1;
- if (warnaLatar.length() >= 7 && warnaLatar.charAt(0) == 'b') { // 'b': background color
- return Integer.parseInt(warnaLatar.substring(1, 7), 16);
+ public static int decodeLabelBackgroundColor(String backgroundColor) {
+ if (backgroundColor == null || backgroundColor.length() == 0) return -1;
+ if (backgroundColor.length() >= 7 && backgroundColor.charAt(0) == 'b') { // 'b': background color
+ return Integer.parseInt(backgroundColor.substring(1, 7), 16);
} else {
return -1;
}
}
- public static int getWarnaDepanBerdasarWarnaLatar(int warnaRgb) {
+ public static int getLabelForegroundColorBasedOnBackgroundColor(int colorRgb) {
float[] hsl = {0.f, 0.f, 0.f};
- rgbToHsl(warnaRgb, hsl);
+ rgbToHsl(colorRgb, hsl);
//Log.d("getWarnaDepanBerdasarWarnaLatar", String.format("#%06x -> %3d %.2f %.2f", warnaRgb & 0xffffff, (int)hsl[0], hsl[1], hsl[2]));
if (hsl[2] > 0.5f) hsl[2] -= 0.44f;
@@ -166,7 +166,7 @@ public static int hslToRgb(float[] hsl) {
return r << 16 | g << 8 | b;
}
- public static String tampilException(Throwable e) {
+ public static String showException(Throwable e) {
StringWriter sw = new StringWriter(400);
sw.append('(').append(e.getClass().getName()).append("): ").append(e.getMessage()).append('\n'); //$NON-NLS-1$
e.printStackTrace(new PrintWriter(sw));
@@ -220,7 +220,7 @@ public static boolean isHolo() {
}
private static int[] colorSet;
- public static int getWarnaBerdasarkanKitabPos(int pos) {
+ public static int getColorBasedOnBookId(int pos) {
if (colorSet == null) {
colorSet = new int[3];
if (U.isHolo()) {
@@ -243,8 +243,8 @@ public static int getWarnaBerdasarkanKitabPos(int pos) {
}
}
- public static int alphaMixHighlight(int warnaRgb) {
- return 0xa0000000 | warnaRgb;
+ public static int alphaMixHighlight(int colorRgb) {
+ return 0xa0000000 | colorRgb;
}
public static int getHighlightColorByBrightness(float brightness) {
@@ -269,10 +269,10 @@ public static boolean equals(Object a, Object b) {
};
}
- public static void pasangWarnaLabel(Label label, TextView view) {
- int warnaLatarRgb = U.dekodWarnaLatarLabel(label.warnaLatar);
- if (warnaLatarRgb == -1) {
- warnaLatarRgb = 0x777777; // warna standar
+ public static void applyLabelColor(Label label, TextView view) {
+ int bgColorRgb = U.decodeLabelBackgroundColor(label.backgroundColor);
+ if (bgColorRgb == -1) {
+ bgColorRgb = 0x777777; // standard color
}
GradientDrawable grad = null;
@@ -288,8 +288,8 @@ public static void pasangWarnaLabel(Label label, TextView view) {
}
}
if (grad != null) {
- grad.setColor(0xff000000 | warnaLatarRgb);
- view.setTextColor(0xff000000 | U.getWarnaDepanBerdasarWarnaLatar(warnaLatarRgb));
+ grad.setColor(0xff000000 | bgColorRgb);
+ view.setTextColor(0xff000000 | U.getLabelForegroundColorBasedOnBackgroundColor(bgColorRgb));
}
}
}
@@ -312,14 +312,14 @@ protected void onPreExecute() {
Label labelLama = judulMap.get(label.judul);
if (labelLama != null) {
// update warna label lama
- if (tumpuk && label.warnaLatar != null && label.warnaLatar.length() > 0) {
- labelLama.warnaLatar = label.warnaLatar;
+ if (tumpuk && label.backgroundColor != null && label.backgroundColor.length() > 0) {
+ labelLama.backgroundColor = label.backgroundColor;
S.getDb().updateLabel(labelLama);
}
labelRelIdToAbsIdMap.put(labelToRelIdMap.get(label), labelLama._id);
Log.d(TAG, "label (lama) r->a : " + labelToRelIdMap.get(label) + "->" + labelLama._id); //$NON-NLS-1$ //$NON-NLS-2$
} else { // belum ada, harus bikin baru
- Label labelBaru = S.getDb().tambahLabel(label.judul, label.warnaLatar);
+ Label labelBaru = S.getDb().tambahLabel(label.judul, label.backgroundColor);
labelRelIdToAbsIdMap.put(labelToRelIdMap.get(label), labelBaru._id);
Log.d(TAG, "label (baru) r->a : " + labelToRelIdMap.get(label) + "->" + labelBaru._id); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -571,13 +571,13 @@ void writeBukmak2_LabelXml(XmlSerializer xml, int bukmak2_relId, int label_relId
return true;
}
- int warnaLatarRgb = U.dekodWarnaLatarLabel(label.warnaLatar);
+ int warnaLatarRgb = U.decodeLabelBackgroundColor(label.backgroundColor);
new AmbilWarnaDialog(BookmarkActivity.this, 0xff000000 | warnaLatarRgb, new OnAmbilWarnaListener() {
@Override public void onOk(AmbilWarnaDialog dialog, int color) {
if (color == -1) {
- label.warnaLatar = null;
+ label.backgroundColor = null;
} else {
- label.warnaLatar = U.enkodWarnaLatarLabel(0x00ffffff & color);
+ label.backgroundColor = U.encodeLabelBackgroundColor(0x00ffffff & color);
}
S.getDb().updateLabel(label);
adapter.notifyDataSetChanged();
@@ -671,7 +671,7 @@ private boolean hasLabels() {
lFilterLabel.setVisibility(View.VISIBLE);
lFilterLabel.setText(label.judul);
- U.pasangWarnaLabel(label, lFilterLabel);
+ U.applyLabelColor(label, lFilterLabel);
}
return res;
Oops, something went wrong.

0 comments on commit 5b9580f

Please sign in to comment.