Merge branch 'master' into bookmarks

# Conflicts:
#	android/src/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java
This commit is contained in:
Elad Keyshawn 2016-07-03 16:54:08 +03:00
commit 5abd99909a
6 changed files with 13 additions and 26 deletions

View File

@ -5,6 +5,7 @@ NEW: Kiwix search home screen widget
FIXED: Opening problem with ZIM filenames with special characters FIXED: Opening problem with ZIM filenames with special characters
FIXED: Useless "w820dp" language FIXED: Useless "w820dp" language
FIXED: Failing he, id, yi locales FIXED: Failing he, id, yi locales
FIXED: Non-localised setting language list sorting
1.99 1.99
FIXED: ZIM load error on ICS FIXED: ZIM load error on ICS

2
README
View File

@ -110,7 +110,7 @@ To make an APK which embeds a ZIM file:
* In the json file, add: * In the json file, add:
"embed_zim": true, "embed_zim": true,
* You might need to set up following env. variable: * You might need to set up following env. variable:
_JAVA_OPTIONS="\"-Xmx4096m\" \"-Xms4096m\" \"-XX:MaxPermSize=4096m\"" _JAVA_OPTIONS="\"-Xmx4096m\" \"-Xms4096m\""
********************************************************************* *********************************************************************
*************************** CONTACT ********************************* *************************** CONTACT *********************************

View File

@ -34,7 +34,7 @@ import shutil
import logging import logging
from io import StringIO from io import StringIO
import tempfile import tempfile
import urllib.request as urllib2 import urllib2
from collections import OrderedDict from collections import OrderedDict
from subprocess import call from subprocess import call
PY3 = sys.version_info.major >= 3 PY3 = sys.version_info.major >= 3

2
gradlew vendored
View File

@ -7,7 +7,7 @@
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="\"-Xmx4096m\" \"-Xms4096m\" \"-XX:MaxPermSize=4096m\"" DEFAULT_JVM_OPTS="\"-Xmx4096m\" \"-Xms4096m\""
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`

View File

@ -98,14 +98,7 @@ public class KiwixSettingsActivity extends AppCompatActivity {
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (toolbar != null) { toolbar.setNavigationOnClickListener(v -> onBackPressed());
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
} }
public static class PrefsFragment extends PreferenceFragment implements public static class PrefsFragment extends PreferenceFragment implements

View File

@ -40,33 +40,24 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.text.Collator;
import org.kiwix.kiwixmobile.utils.files.FileWriter; import org.kiwix.kiwixmobile.utils.files.FileWriter;
public class LanguageUtils { public class LanguageUtils {
public static final String TAG_KIWIX = "kiwix"; public static final String TAG_KIWIX = "kiwix";
private static HashMap<String, Locale> mLocaleMap; private static HashMap<String, Locale> mLocaleMap;
private List<LanguageContainer> mLanguageList; private List<LanguageContainer> mLanguageList;
private List<String> mLocaleLanguageCodes; private List<String> mLocaleLanguageCodes;
private Context mContext; private Context mContext;
public LanguageUtils(Context context) { public LanguageUtils(Context context) {
mContext = context; mContext = context;
mLanguageList = new ArrayList<LanguageContainer>(); mLanguageList = new ArrayList<LanguageContainer>();
mLocaleLanguageCodes = new ArrayList<String>(); mLocaleLanguageCodes = new ArrayList<String>();
getLanguageCodesFromAssets(); getLanguageCodesFromAssets();
setupLanguageList(); setupLanguageList();
sortLanguageList(context.getResources().getConfiguration().locale);
sortLanguageList();
} }
public static void handleLocaleChange(Context context) { public static void handleLocaleChange(Context context) {
@ -134,12 +125,15 @@ public class LanguageUtils {
} }
// Sort the language list by the language name // Sort the language list by the language name
private void sortLanguageList() { private void sortLanguageList(Locale locale) {
Collator localeCollator = Collator.getInstance(locale);
localeCollator.setStrength(Collator.SECONDARY);
Collections.sort(mLanguageList, new Comparator<LanguageContainer>() { Collections.sort(mLanguageList, new Comparator<LanguageContainer>() {
@Override @Override
public int compare(LanguageContainer a, LanguageContainer b) { public int compare(LanguageContainer a, LanguageContainer b) {
return a.getLanguageName().compareToIgnoreCase(b.getLanguageName()); return localeCollator.compare(a.getLanguageName(), b.getLanguageName());
} }
}); });
} }
@ -150,7 +144,6 @@ public class LanguageUtils {
for (Locale s : Locale.getAvailableLocales()) { for (Locale s : Locale.getAvailableLocales()) {
if (s.getLanguage().equals(Locale.getDefault().toString())) { if (s.getLanguage().equals(Locale.getDefault().toString())) {
return false; return false;
} }
@ -281,7 +274,7 @@ public class LanguageUtils {
exceptions.put("gu", "fonts/Lohit-Gujarati.ttf"); exceptions.put("gu", "fonts/Lohit-Gujarati.ttf");
exceptions.put("my", "fonts/Parabaik.ttf"); exceptions.put("my", "fonts/Parabaik.ttf");
exceptions.put("or", "fonts/Lohit-Odia.ttf"); exceptions.put("or", "fonts/Lohit-Odia.ttf");
// These scripts could be supported via more Lohit fonts if DevaVu doesn't // These scripts could be supported via more Lohit fonts if DejaVu doesn't
// support them. That is untested now as they aren't even in the language // support them. That is untested now as they aren't even in the language
// menu: // menu:
// * (no ISO code?) (Devanagari/Nagari) -- at 0% in translatewiki // * (no ISO code?) (Devanagari/Nagari) -- at 0% in translatewiki