Skip to content

Commit

Permalink
Merge branch 'hotfix/4.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yukuku committed Oct 26, 2015
2 parents 60872af + afe6ccc commit 0b08bd0
Show file tree
Hide file tree
Showing 25 changed files with 1,566 additions and 1,453 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Alkitab/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId 'yuku.alkitab.debug'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14000251
versionName '4.3.1'
versionCode 14000252
versionName '4.3.2'
multiDexEnabled true
}
buildTypes {
Expand Down
38 changes: 14 additions & 24 deletions Alkitab/src/main/java/yuku/alkitab/base/U.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.UUID;

public class U {
static final String TAG = U.class.getSimpleName();

/**
* If text is null, this returns null.
* If verse doesn't start with @: don't do anything.
Expand Down Expand Up @@ -254,34 +252,14 @@ public static int applyLabelColor(Label label, TextView view) {
}

public static String inputStreamUtf8ToString(InputStream input) throws IOException {
return inputStreamToString(input, "utf-8");
}

public static String utf8BytesToString(final byte[] bytes) {
try {
return new String(bytes, "utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

public static byte[] stringToUtf8Bytes(final String s) {
try {
return s.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

public static String inputStreamToString(final InputStream input, final String encoding) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buf = new byte[1024];
while (true) {
final int read = input.read(buf);
if (read < 0) break;
baos.write(buf, 0, read);
}
return new String(baos.toByteArray(), encoding);
return new String(baos.toByteArray(), Charset.forName("utf-8"));
}

/**
Expand Down Expand Up @@ -341,4 +319,16 @@ public static String getInstallationInfoJson() {
obj.last_commit_hash = App.context.getString(R.string.last_commit_hash);
return App.getDefaultGson().toJson(obj);
}

public interface ThrowEverythingRunnable {
void run() throws Exception;
}

public static void wontThrow(ThrowEverythingRunnable r) {
try {
r.run();
} catch (Exception e) {
throw new RuntimeException("ThrowEverythingRunnable is passed but caused exception: " + r.toString(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.io.File;

import static yuku.alkitab.base.util.Literals.Array;

public class InternalDbHelper extends SQLiteOpenHelper {
public static final String TAG = InternalDbHelper.class.getSimpleName();

Expand Down Expand Up @@ -78,11 +80,9 @@ public void onOpen(SQLiteDatabase db) {
}

if (oldVersion <= 69) { // 70: 2.0.0
// new tables Label and Marker_Label
// new table Label
createTableLabel(db);
createIndexLabel(db);
createTableMarker_Label(db);
createIndexMarker_Label(db);
}

if (oldVersion > 50 && oldVersion <= 102) { // 103: 2.7.1
Expand Down Expand Up @@ -126,7 +126,7 @@ public void onOpen(SQLiteDatabase db) {
}

if (oldVersion < 14000163) { // last version that doesn't use Marker table
addGidColumnToLabel(db);
addGidColumnToLabelIfNeeded(db);

createTableMarker(db);
createIndexMarker(db);
Expand Down Expand Up @@ -432,8 +432,18 @@ private void addShortNameColumnAndIndexToEdisi(SQLiteDatabase db) {
db.execSQL("alter table Edisi add column shortName text");
}

private void addGidColumnToLabel(SQLiteDatabase db) {
db.execSQL("alter table " + Db.TABLE_Label + " add column " + Db.Label.gid + " text");
private void addGidColumnToLabelIfNeeded(SQLiteDatabase db) {
boolean gidColumnExists = false;
try (Cursor c = db.rawQuery("pragma table_info(" + Db.TABLE_Label + ")", null)) {
while (c.moveToNext()) {
if ("gid".equals(c.getString(1 /* "name" column */))) {
gidColumnExists = true;
}
}
}
if (!gidColumnExists) {
db.execSQL("alter table " + Db.TABLE_Label + " add column " + Db.Label.gid + " text");
}

// make sure this one matches the one in createIndexLabel()
db.execSQL("create index if not exists index_402 on " + Db.TABLE_Label + " (" + Db.Label.gid + ")");
Expand Down Expand Up @@ -510,7 +520,17 @@ class Bookmark2_Label {
c.close();
}

{ // Bookmark2_Label -> Marker_Label
// Only if the upgrade old version is >= 2.0.0, where we have Bukmak2_Label table.
// In case that Bukmak2_Label table is not available, it means the onUpgrade old version is < 2.0.0,
// so we don't need to care about migrating labels.
boolean hasBookmark2_Label = false;
try (Cursor c = db.rawQuery("select tbl_name from sqlite_master where tbl_name=?", Array(TABLE_Bookmark2_Label))) {
if (c.moveToNext() && TABLE_Bookmark2_Label.equals(c.getString(0))) {
hasBookmark2_Label = true;
}
}

if (hasBookmark2_Label) { // Bookmark2_Label -> Marker_Label
final Cursor c = db.query(TABLE_Bookmark2_Label,
new String[] {"_id", Bookmark2_Label.bookmark2_id, Bookmark2_Label.label_id},
null, null, null, null, "_id asc"
Expand Down
17 changes: 14 additions & 3 deletions Alkitab/src/main/java/yuku/alkitab/base/sync/Sync_History.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
import yuku.alkitab.base.util.History;
import yuku.alkitab.base.util.Literals;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -66,16 +73,20 @@ private static Sync.Entity<Content> findEntity(final List<Sync.Entity<Content>>
}

private static List<Sync.Entity<Content>> entitiesFromShadow(@NonNull final SyncShadow ss) {
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(U.utf8BytesToString(ss.data), new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(ss.data), Charset.forName("utf-8")));
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(reader, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
return data.entities;
}

@NonNull public static SyncShadow shadowFromEntities(@NonNull final List<Sync.Entity<Content>> entities, final int revno) {
final Sync.SyncShadowDataJson<Content> data = new Sync.SyncShadowDataJson<>();
data.entities = entities;
final String s = App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final BufferedWriter w = new BufferedWriter(new OutputStreamWriter(baos, Charset.forName("utf-8")));
App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType(), w);
U.wontThrow(() -> w.flush());
final SyncShadow res = new SyncShadow();
res.data = U.stringToUtf8Bytes(s);
res.data = baos.toByteArray();
res.syncSetName = SyncShadow.SYNC_SET_HISTORY;
res.revno = revno;
return res;
Expand Down
17 changes: 14 additions & 3 deletions Alkitab/src/main/java/yuku/alkitab/base/sync/Sync_Mabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
import yuku.alkitab.model.Marker;
import yuku.alkitab.model.Marker_Label;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -66,16 +73,20 @@ private static Sync.Entity<Content> findEntity(final List<Sync.Entity<Content>>
}

private static List<Sync.Entity<Content>> entitiesFromShadow(@NonNull final SyncShadow ss) {
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(U.utf8BytesToString(ss.data), new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(ss.data), Charset.forName("utf-8")));
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(reader, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
return data.entities;
}

@NonNull public static SyncShadow shadowFromEntities(@NonNull final List<Sync.Entity<Content>> entities, final int revno) {
final Sync.SyncShadowDataJson<Content> data = new Sync.SyncShadowDataJson<>();
data.entities = entities;
final String s = App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final BufferedWriter w = new BufferedWriter(new OutputStreamWriter(baos, Charset.forName("utf-8")));
App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType(), w);
U.wontThrow(() -> w.flush());
final SyncShadow res = new SyncShadow();
res.data = U.stringToUtf8Bytes(s);
res.data = baos.toByteArray();
res.syncSetName = SyncShadow.SYNC_SET_MABEL;
res.revno = revno;
return res;
Expand Down
17 changes: 14 additions & 3 deletions Alkitab/src/main/java/yuku/alkitab/base/sync/Sync_Pins.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
import yuku.alkitab.base.widget.AttributeView;
import yuku.alkitab.model.ProgressMark;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -75,16 +82,20 @@ private static Sync.Entity<Content> findEntity(final List<Sync.Entity<Content>>
}

private static List<Sync.Entity<Content>> entitiesFromShadow(@NonNull final SyncShadow ss) {
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(U.utf8BytesToString(ss.data), new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(ss.data), Charset.forName("utf-8")));
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(reader, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
return data.entities;
}

@NonNull public static SyncShadow shadowFromEntities(@NonNull final List<Sync.Entity<Content>> entities, final int revno) {
final Sync.SyncShadowDataJson<Content> data = new Sync.SyncShadowDataJson<>();
data.entities = entities;
final String s = App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final BufferedWriter w = new BufferedWriter(new OutputStreamWriter(baos, Charset.forName("utf-8")));
App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType(), w);
U.wontThrow(() -> w.flush());
final SyncShadow res = new SyncShadow();
res.data = U.stringToUtf8Bytes(s);
res.data = baos.toByteArray();
res.syncSetName = SyncShadow.SYNC_SET_PINS;
res.revno = revno;
return res;
Expand Down
17 changes: 14 additions & 3 deletions Alkitab/src/main/java/yuku/alkitab/base/sync/Sync_Rp.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
import yuku.alkitab.base.model.SyncShadow;
import yuku.alkitab.base.util.Literals;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -74,16 +81,20 @@ private static Sync.Entity<Content> findEntity(final List<Sync.Entity<Content>>
}

private static List<Sync.Entity<Content>> entitiesFromShadow(@NonNull final SyncShadow ss) {
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(U.utf8BytesToString(ss.data), new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(ss.data), Charset.forName("utf-8")));
final Sync.SyncShadowDataJson<Content> data = App.getDefaultGson().fromJson(reader, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
return data.entities;
}

@NonNull public static SyncShadow shadowFromEntities(@NonNull final List<Sync.Entity<Content>> entities, final int revno) {
final Sync.SyncShadowDataJson<Content> data = new Sync.SyncShadowDataJson<>();
data.entities = entities;
final String s = App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final BufferedWriter w = new BufferedWriter(new OutputStreamWriter(baos, Charset.forName("utf-8")));
App.getDefaultGson().toJson(data, new TypeToken<Sync.SyncShadowDataJson<Content>>() {}.getType(), w);
U.wontThrow(() -> w.flush());
final SyncShadow res = new SyncShadow();
res.data = U.stringToUtf8Bytes(s);
res.data = baos.toByteArray();
res.syncSetName = SyncShadow.SYNC_SET_RP;
res.revno = revno;
return res;
Expand Down
4 changes: 4 additions & 0 deletions Alkitab/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@
<string name="verse_select_multiple_verse_selected">%s verse gekies</string>
<string name="google_play_store_not_installed">Google Play Store is nie geïnstalleer nie.</string>
<string name="pref_language_label_default">Verstek</string>
<string name="market_short_desc">Vinnig, betroubaar en eienskap ryk aflyn Bybel.</string>
<string name="goto_tab_dialer_label">Skakelaar</string>
<string name="goto_tab_direct_label">Direk</string>
<string name="goto_tab_grid_label">Ruit</string>
<string name="menuAskForVerse">Vra vir vers nommer</string>
<string name="fm_activity_title">Skrif Bestuurder</string>
<string name="fm_need_to_log_in_to_wifi">U moet eers op U netwerk (Wi-Fi) inskakel.</string>
<string name="fm_do_you_want_to_delete">Vee lettertipe uit %s?</string>
Expand Down Expand Up @@ -470,6 +472,8 @@
<string name="about_translators">Vertalers</string>
<string name="about_user_guide">Gebruikers Gids</string>
<string name="about_beta_feedback">Beta Weergawe Terugvoer</string>
<string name="about_enable_beta">Probeer Beta Weergawe</string>
<string name="about_enable_beta_confirmation">Teken aan by Google en klik op die \"BECOME A TESTER\" knoppie, om die Beta weergawe met die nuutste funksies en verbeteringe te toets!</string>
<string name="about_version_name">weergawe %s</string>
<string name="about_material_sources">Materiaal Bronne</string>
<string name="about_credits">Krediete</string>
Expand Down
2 changes: 2 additions & 0 deletions Alkitab/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@
<string name="verse_select_multiple_verse_selected">%s Verse ausgewählt</string>
<string name="google_play_store_not_installed">Der Google Play Store ist nicht installiert.</string>
<string name="pref_language_label_default">Systemvorgabe</string>
<string name="market_short_desc">Schnelle, zuverlässige und leistungsfähige Offline-Bibel.</string>
<string name="goto_tab_dialer_label">Wähler</string>
<string name="goto_tab_direct_label">Direkt</string>
<string name="goto_tab_grid_label">Tabelle</string>
<string name="menuAskForVerse">Nach Versnummer fragen</string>
<string name="fm_activity_title">Schriftart-Manager</string>
<string name="fm_need_to_log_in_to_wifi">Sie müssen sich zuerst mit Ihrem (WLAN-)Netzwerk verbinden.</string>
<string name="fm_do_you_want_to_delete">Schriftart %s löschen?</string>
Expand Down
5 changes: 5 additions & 0 deletions Alkitab/src/main/res/values-fr/pref_labels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
<string name="pref_biarkan_layar_menyala">L\'écran reste allumé</string>
<string name="pref_penampilan_layar">Écran</string>
<string name="pref_volumeButtonNavigation_title">Navigation avec les boutons du volume</string>
<string name="pref_copyWithVerseNumbers_title">Numéros des versets</string>
<string name="pref_copyWithVerseNumbers_summary">Commencez chaque verset avec son numéro</string>
<string name="pref_copyWithVersionName_title">Abréviations de la version</string>
<string name="pref_copyWithVersionName_summary">Mentionnez les versions initiales de la Bible</string>
<string name="pref_copyWithShareUrl_title">Partager le lien</string>
<string name="pref_copyWithShareUrl_summary">Ajouter le lien de la page partagée à la fin du texte copié ou partagé</string>
<string name="pref_autoDictionaryAnalyze_title">Recherche automatique dans le dictionnaire</string>
<string name="pref_autoDictionaryAnalyze_summary">Chercher les mots sélectionnés dans le dictionnaire</string>
<string name="pref_tapToEditNote_title">Appuyez pour modifier la note</string>
<string name="pref_tapToEditNote_summary">Décochez cette case pour éviter toute modification accidentelle lors de l\'affichage des notes existantes</string>
<string name="pref_showHiddenVersion_title">Autoriser des versions éventuellement limitées</string>
<string name="pref_selectedVerseBgColor_title">L\'arriere plan pour le verset sélectionné</string>
</resources>
5 changes: 5 additions & 0 deletions Alkitab/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@
<string name="verse_select_multiple_verse_selected">%s versets sélectionnés</string>
<string name="google_play_store_not_installed">Google Play Store n\'est pas installé.</string>
<string name="pref_language_label_default">Défaut</string>
<string name="market_short_desc">Une Bible rapide, fiable et riche en fonctionnalités, qui fonctionne sans connexion Internet.</string>
<string name="goto_tab_dialer_label">Appeler</string>
<string name="goto_tab_direct_label">Direct</string>
<string name="goto_tab_grid_label">Réseau</string>
<string name="menuAskForVerse">Demandez le numéro du verset</string>
<string name="fm_activity_title">Gestion des Fontes</string>
<string name="fm_need_to_log_in_to_wifi">Vous devez d\'abord vous connecter à votre réseau WiFi.</string>
<string name="fm_do_you_want_to_delete">Supprimer la font %s ?</string>
Expand Down Expand Up @@ -321,6 +323,7 @@
<string name="rp_menuDelete">Suppression</string>
<string name="rp_headingProgress">Progression</string>
<string name="rp_gotoToday">Aller à aujourd\'hui</string>
<string name="rp_setStartDate">Définir la date de début</string>
<string name="rp_showDetails">Afficher les détails</string>
<string name="rp_hideDetails">Masquer les détails</string>
<string name="rp_aboutPlan">Au sujet du plan</string>
Expand Down Expand Up @@ -467,6 +470,8 @@
<string name="about_translators">Traducteurs</string>
<string name="about_user_guide">Guide de l\'utilisateur</string>
<string name="about_beta_feedback">Commentaires de la Version beta</string>
<string name="about_enable_beta">Essayer la version Beta</string>
<string name="about_enable_beta_confirmation">Connectez-vous sur votre compte Google et appuyez sur le bouton DEVENIR TESTEUR pour essayer la version bêta avec les nouvelles fonctionnalités et améliorations!</string>
<string name="about_version_name">version %s</string>
<string name="about_material_sources">Sources matérielles</string>
<string name="about_credits">Remerciements</string>
Expand Down
Loading

0 comments on commit 0b08bd0

Please sign in to comment.