Merge pull request #10 from eighthave/fix-translations
Fix translations
This commit is contained in:
commit
9a786d4aca
|
@ -0,0 +1,10 @@
|
||||||
|
[main]
|
||||||
|
host = https://www.transifex.com
|
||||||
|
lang_map = af_ZA: af-rZA, am_ET: am-rET, ar_AE: ar-rAE, ar_BH: ar-rBH, ar_DZ: ar-rDZ, ar_EG: ar-rEG, ar_IQ: ar-rIQ, ar_JO: ar-rJO, ar_KW: ar-rKW, ar_LB: ar-rLB, ar_LY: ar-rLY, ar_MA: ar-rMA, ar_OM: ar-rOM, ar_QA: ar-rQA, ar_SA: ar-rSA, ar_SY: ar-rSY, ar_TN: ar-rTN, ar_YE: ar-rYE, arn_CL: arn-rCL, as_IN: as-rIN, az_AZ: az-rAZ, ba_RU: ba-rRU, be_BY: be-rBY, bg_BG: bg-rBG, bn_BD: bn-rBD, bn_IN: bn-rIN, bo_CN: bo-rCN, br_FR: br-rFR, bs_BA: bs-rBA, ca_ES: ca-rES, co_FR: co-rFR, cs_CZ: cs-rCZ, cy_GB: cy-rGB, da_DK: da-rDK, de_AT: de-rAT, de_CH: de-rCH, de_DE: de-rDE, de_LI: de-rLI, de_LU: de-rLU, dsb_DE: dsb-rDE, dv_MV: dv-rMV, el_GR: el-rGR, en_AU: en-rAU, en_BZ: en-rBZ, en_CA: en-rCA, en_GB: en-rGB, en_IE: en-rIE, en_IN: en-rIN, en_JM: en-rJM, en_MY: en-rMY, en_NZ: en-rNZ, en_PH: en-rPH, en_SG: en-rSG, en_TT: en-rTT, en_US: en-rUS, en_ZA: en-rZA, en_ZW: en-rZW, es_AR: es-rAR, es_BO: es-rBO, es_CL: es-rCL, es_CO: es-rCO, es_CR: es-rCR, es_DO: es-rDO, es_EC: es-rEC, es_ES: es-rES, es_GT: es-rGT, es_HN: es-rHN, es_MX: es-rMX, es_NI: es-rNI, es_PA: es-rPA, es_PE: es-rPE, es_PR: es-rPR, es_PY: es-rPY, es_SV: es-rSV, es_US: es-rUS, es_UY: es-rUY, es_VE: es-rVE, et_EE: et-rEE, eu_ES: eu-rES, fa_IR: fa-rIR, fi_FI: fi-rFI, fil: tl, fil_PH: tl-rPH, fo_FO: fo-rFO, fr_BE: fr-rBE, fr_CA: fr-rCA, fr_CH: fr-rCH, fr_FR: fr-rFR, fr_LU: fr-rLU, fr_MC: fr-rMC, fy_NL: fy-rNL, ga_IE: ga-rIE, gd_GB: gd-rGB, gl_ES: gl-rES, gsw_FR: gsw-rFR, gu_IN: gu-rIN, ha_NG: ha-rNG, he: iw, he_IL: iw-rIL, hi_IN: hi-rIN, hr_BA: hr-rBA, hr_HR: hr-rHR, hsb_DE: hsb-rDE, hu_HU: hu-rHU, hy_AM: hy-rAM, id: in, id_ID: in-rID, ig_NG: ig-rNG, ii_CN: ii-rCN, is_IS: is-rIS, it_CH: it-rCH, it_IT: it-rIT, iu_CA: iu-rCA, ja_JP: ja-rJP, ka_GE: ka-rGE, kk_KZ: kk-rKZ, kl_GL: kl-rGL, km_KH: km-rKH, kn_IN: kn-rIN, ko_KR: ko-rKR, kok_IN: kok-rIN, ky_KG: ky-rKG, lb_LU: lb-rLU, lo_LA: lo-rLA, lt_LT: lt-rLT, lv_LV: lv-rLV, mi_NZ: mi-rNZ, mk_MK: mk-rMK, ml_IN: ml-rIN, mn_CN: mn-rCN, mn_MN: mn-rMN, moh_CA: moh-rCA, mr_IN: mr-rIN, ms_BN: ms-rBN, ms_MY: ms-rMY, mt_MT: mt-rMT, nb_NO: nb-rNO, ne_NP: ne-rNP, nl_BE: nl-rBE, nl_NL: nl-rNL, nn_NO: nn-rNO, nso_ZA: nso-rZA, oc_FR: oc-rFR, or_IN: or-rIN, pa_IN: pa-rIN, pl_PL: pl-rPL, prs_AF: prs-rAF, ps_AF: ps-rAF, pt_BR: pt-rBR, pt_PT: pt-rPT, qut_GT: qut-rGT, quz_BO: quz-rBO, quz_EC: quz-rEC, quz_PE: quz-rPE, rm_CH: rm-rCH, ro_RO: ro-rRO, ru_RU: ru-rRU, rw_RW: rw-rRW, sa_IN: sa-rIN, sah_RU: sah-rRU, se_FI: se-rFI, se_NO: se-rNO, se_SE: se-rSE, si_LK: si-rLK, sk_SK: sk-rSK, sl_SI: sl-rSI, sma_NO: sma-rNO, sma_SE: sma-rSE, smj_NO: smj-rNO, smj_SE: smj-rSE, smn_FI: smn-rFI, sms_FI: sms-rFI, sq_AL: sq-rAL, sr: sr, sv_FI: sv-rFI, sv_SE: sv-rSE, sw_KE: sw-rKE, syr_SY: syr-rSY, ta_IN: ta-rIN, te_IN: te-rIN, tg_TJ: tg-rTJ, th_TH: th-rTH, tk_TM: tk-rTM, tn_ZA: tn-rZA, tr_TR: tr-rTR, tt_RU: tt-rRU, tzm_DZ: tzm-rDZ, ug_CN: ug-rCN, uk_UA: uk-rUA, ur_PK: ur-rPK, uz_UZ: uz-rUZ, vi_VN: vi-rVN, wo_SN: wo-rSN, xh_ZA: xh-rZA, yo_NG: yo-rNG, zh: zh-rCN, zh_HK: zh-rHK, zh_MO: zh-rMO, zh_SG: zh-rSG, zh_TW: zh-rTW, zu_ZA: zu-rZA
|
||||||
|
|
||||||
|
[orbot.stringsxml]
|
||||||
|
file_filter = res/values-<lang>/strings.xml
|
||||||
|
host = https://www.transifex.com
|
||||||
|
source_file = res/values/strings.xml
|
||||||
|
source_lang = en
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<string name="menu_browse">ब्राउज़</string>
|
|
||||||
<string name="menu_settings">सेटिंग्स</string>
|
|
||||||
<string name="menu_info">मदद</string>
|
|
||||||
<string name="button_help">मदद</string>
|
|
||||||
<string name="button_close">बंद करें </string>
|
|
||||||
<string name="btn_back">वापस</string>
|
|
||||||
<string name="btn_cancel">रद्द करें </string>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<string name="wizard_proxy_help_info">प्रोक्सी सेटींग</string>
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<string name="pref_general_group">समन्य </string>
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="wizard_transproxy_none">कोई नहीं</string>
|
|
||||||
<string name="status">स्थिति</string>
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,52 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<string name="app_name">Orbot</string>
|
|
||||||
<string name="internal_web_url">http://orbot/</string>
|
|
||||||
<string name="default_web_url">http://check.torproject.org</string>
|
|
||||||
<string name="secure_default_web_url">https://check.torproject.org</string>
|
|
||||||
<string name="tor_check_api_url">https://check.torproject.org/?TorButton=true</string>
|
|
||||||
<string name="control_permission_label">mulai dan akhiri Tor</string>
|
|
||||||
<string name="tor_proxy_service_process">torproxyservice</string>
|
|
||||||
<string name="status_starting_up">Orbot sedang dimulai…</string>
|
|
||||||
<string name="status_activated">Tersambung ke Jaringan Tor</string>
|
|
||||||
<string name="status_disabled">Orbot telah dibatalkan</string>
|
|
||||||
<string name="status_shutting_down">Orbot sedang dimatikan</string>
|
|
||||||
<string name="not_anonymous_yet">PERINGATAN: </string>
|
|
||||||
<string name="menu_home">Home</string>
|
|
||||||
<string name="menu_browse">Jelajahi</string>
|
|
||||||
<string name="menu_settings">Pengaturan</string>
|
|
||||||
<string name="menu_log">Log</string>
|
|
||||||
<string name="menu_info">Bantuan</string>
|
|
||||||
<string name="menu_about">Mengenai</string>
|
|
||||||
<string name="button_help">Bantuan</string>
|
|
||||||
<string name="button_close">Dekat</string>
|
|
||||||
<string name="button_about">Mengenai</string>
|
|
||||||
<string name="button_clear_log">Hapus Log</string>
|
|
||||||
<string name="menu_verify">Periksa</string>
|
|
||||||
<string name="menu_exit">Keluar</string>
|
|
||||||
<string name="pref_transparent_all_title">Tor Semuanya</string>
|
|
||||||
<string name="pref_transparent_port_title">Daftar Port</string>
|
|
||||||
<string name="pref_has_root">Minta Akses Dasar</string>
|
|
||||||
<string name="btn_back">Kembali</string>
|
|
||||||
<string name="btn_cancel">Batal</string>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<string name="wizard_proxy_help_info">Pengaturan Proxy</string>
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<string name="pref_general_group">Umum</string>
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<string name="wizard_warning_title">Peringatan</string>
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="wizard_transproxy_none">Tidak ada</string>
|
|
||||||
<string name="status">Status</string>
|
|
||||||
<string name="error">Kesalahan</string>
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
<string name="btn_save_settings">Simpan Pengaturan</string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<!--<string name="pref_use_whispercore">Use WhisperCore</string>
|
|
||||||
<string name="pref_use_whispercore_summary">Use the proprietary NetFilter APIs provided by WhisperSystems (required device with WhisperCore installed)</string>-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<string name="app_name">Orbot</string>
|
|
||||||
<string name="default_web_url">http://check.torproject.org</string>
|
|
||||||
<string name="secure_default_web_url">https://check.torproject.org</string>
|
|
||||||
<string name="tor_check_api_url">https://check.torproject.org/?TorButton=true</string>
|
|
||||||
<string name="menu_settings">Zvamada</string>
|
|
||||||
<string name="menu_about">Maererano</string>
|
|
||||||
<string name="button_about">Maererano</string>
|
|
||||||
<string name="menu_exit">Buda</string>
|
|
||||||
<string name="wizard_btn_tell_me_more">Maererano Orbot</string>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<string name="wizard_proxy_help_info">Proxy Zvamada</string>
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<resources>
|
|
||||||
<!--Welcome Wizard strings (DJH)-->
|
|
||||||
<!--END Welcome Wizard strings (DJH)-->
|
|
||||||
<!--New Wizard Strings-->
|
|
||||||
<!--Title Screen-->
|
|
||||||
<!--Warning screen-->
|
|
||||||
<!--Permissions screen-->
|
|
||||||
<!--TipsAndTricks screen-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--Transparent Proxy screen-->
|
|
||||||
<string name="default_bridges"></string>
|
|
||||||
</resources>
|
|
|
@ -2,42 +2,6 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string-array name="languages">
|
|
||||||
<item>Default</item>
|
|
||||||
<item>English</item>
|
|
||||||
<item>العربية</item>
|
|
||||||
<item>فارسی</item>
|
|
||||||
<item>中文(简体)</item>
|
|
||||||
<item>Deutsche</item>
|
|
||||||
<item>Español</item>
|
|
||||||
<item>Français</item>
|
|
||||||
<item>Italian</item>
|
|
||||||
<item>Nederlands</item>
|
|
||||||
<item>Magyar</item>
|
|
||||||
<item>Português</item>
|
|
||||||
<item>Português Brasileiro</item>
|
|
||||||
<item>русский язык</item>
|
|
||||||
|
|
||||||
</string-array>
|
|
||||||
<string-array name="languages_values">
|
|
||||||
<item>xx</item>
|
|
||||||
<item>en</item>
|
|
||||||
<item>ar</item>
|
|
||||||
<item>fa</item>
|
|
||||||
<item>zh</item>
|
|
||||||
<item>de</item>
|
|
||||||
<item>es</item>
|
|
||||||
<item>fr</item>
|
|
||||||
<item>it</item>
|
|
||||||
<item>nl</item>
|
|
||||||
<item>hu</item>
|
|
||||||
<item>pt</item>
|
|
||||||
<item>pt_BR</item>
|
|
||||||
<item>ru</item>
|
|
||||||
|
|
||||||
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="bridge_options">
|
<string-array name="bridge_options">
|
||||||
<item>Obfs4 (Recommended)</item>
|
<item>Obfs4 (Recommended)</item>
|
||||||
<item>Obfs3</item>
|
<item>Obfs3</item>
|
||||||
|
|
|
@ -236,7 +236,7 @@
|
||||||
|
|
||||||
<string name="notification_using_bridges">Bridges enabled!</string>
|
<string name="notification_using_bridges">Bridges enabled!</string>
|
||||||
<string name="default_bridges"/>
|
<string name="default_bridges"/>
|
||||||
<string name="set_locale_title">Set Locale</string>
|
<string name="set_locale_title">Language</string>
|
||||||
<string name="set_locale_summary">Choose the locale and language for Orbot</string>
|
<string name="set_locale_summary">Choose the locale and language for Orbot</string>
|
||||||
<string name="wizard_locale_title">Choose Language</string>
|
<string name="wizard_locale_title">Choose Language</string>
|
||||||
<string name="wizard_locale_msg">Leave default or switch the current language</string>
|
<string name="wizard_locale_msg">Leave default or switch the current language</string>
|
||||||
|
|
|
@ -25,8 +25,6 @@ android:title="@string/pref_use_expanded_notifications_title"/>
|
||||||
|
|
||||||
<ListPreference android:title="@string/set_locale_title"
|
<ListPreference android:title="@string/set_locale_title"
|
||||||
android:key="pref_default_locale"
|
android:key="pref_default_locale"
|
||||||
android:entryValues="@array/languages_values"
|
|
||||||
android:entries="@array/languages"
|
|
||||||
android:summary="@string/set_locale_summary"
|
android:summary="@string/set_locale_summary"
|
||||||
android:defaultValue="en">
|
android:defaultValue="en">
|
||||||
</ListPreference>
|
</ListPreference>
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
|
||||||
|
package info.guardianproject.util;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
public class Languages {
|
||||||
|
private static final String TAG = "Languages";
|
||||||
|
private static Languages singleton;
|
||||||
|
private static Map<String, String> tmpMap = new TreeMap<String, String>();
|
||||||
|
private static Map<String, String> nameMap;
|
||||||
|
public static final String USE_SYSTEM_DEFAULT = "";
|
||||||
|
public static final Locale TIBETAN = new Locale("bo");
|
||||||
|
static final Locale localesToTest[] = {
|
||||||
|
Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN,
|
||||||
|
Locale.ITALIAN, Locale.JAPANESE, Locale.KOREAN,
|
||||||
|
Locale.TRADITIONAL_CHINESE, Locale.SIMPLIFIED_CHINESE,
|
||||||
|
TIBETAN, new Locale("af"), new Locale("am"),
|
||||||
|
new Locale("ar"), new Locale("az"), new Locale("bg"),
|
||||||
|
new Locale("bn"), new Locale("ca"), new Locale("cs"),
|
||||||
|
new Locale("da"), new Locale("el"), new Locale("es"),
|
||||||
|
new Locale("et"), new Locale("eu"), new Locale("fa"),
|
||||||
|
new Locale("fi"), new Locale("gl"), new Locale("hi"),
|
||||||
|
new Locale("hr"), new Locale("hu"), new Locale("hy"),
|
||||||
|
new Locale("in"), new Locale("hy"), new Locale("in"),
|
||||||
|
new Locale("is"), new Locale("it"), new Locale("iw"),
|
||||||
|
new Locale("ka"), new Locale("kk"), new Locale("km"),
|
||||||
|
new Locale("kn"), new Locale("ky"), new Locale("lo"),
|
||||||
|
new Locale("lt"), new Locale("lv"), new Locale("mk"),
|
||||||
|
new Locale("ml"), new Locale("mn"), new Locale("mr"),
|
||||||
|
new Locale("ms"), new Locale("my"), new Locale("nb"),
|
||||||
|
new Locale("ne"), new Locale("nl"), new Locale("pl"),
|
||||||
|
new Locale("pt"), new Locale("rm"), new Locale("ro"),
|
||||||
|
new Locale("ru"), new Locale("si"), new Locale("sk"),
|
||||||
|
new Locale("sl"), new Locale("sn"), new Locale("sr"),
|
||||||
|
new Locale("sv"), new Locale("sw"), new Locale("ta"),
|
||||||
|
new Locale("te"), new Locale("th"), new Locale("tl"),
|
||||||
|
new Locale("tr"), new Locale("uk"), new Locale("ur"),
|
||||||
|
new Locale("uz"), new Locale("vi"), new Locale("zu"),
|
||||||
|
};
|
||||||
|
|
||||||
|
private Languages(Activity activity, int resId, String defaultString) {
|
||||||
|
AssetManager assets = activity.getAssets();
|
||||||
|
Configuration config = activity.getResources().getConfiguration();
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
Resources resources;
|
||||||
|
Set<Locale> localeSet = new LinkedHashSet<Locale>();
|
||||||
|
for (Locale locale : localesToTest) {
|
||||||
|
config.locale = locale;
|
||||||
|
resources = new Resources(assets, metrics, config);
|
||||||
|
if (!TextUtils.equals(defaultString, resources.getString(resId))
|
||||||
|
|| locale.equals(Locale.ENGLISH))
|
||||||
|
localeSet.add(locale);
|
||||||
|
}
|
||||||
|
for (Locale locale : localeSet) {
|
||||||
|
if (locale.equals(TIBETAN)) {
|
||||||
|
// include English name for devices that don't support Tibetan
|
||||||
|
// font
|
||||||
|
tmpMap.put(TIBETAN.getLanguage(), "Tibetan བོད་སྐད།"); // Tibetan
|
||||||
|
} else if (locale.equals(Locale.SIMPLIFIED_CHINESE)) {
|
||||||
|
tmpMap.put(Locale.SIMPLIFIED_CHINESE.toString(), "中文 (中国)"); // Chinese
|
||||||
|
// (China)
|
||||||
|
} else if (locale.equals(Locale.TRADITIONAL_CHINESE)) {
|
||||||
|
tmpMap.put(Locale.TRADITIONAL_CHINESE.toString(), "中文 (台灣)"); // Chinese
|
||||||
|
// (Taiwan)
|
||||||
|
} else {
|
||||||
|
tmpMap.put(locale.getLanguage(), locale.getDisplayLanguage(locale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO implement this completely, the menu item works, but doesn't work
|
||||||
|
// properly
|
||||||
|
/* USE_SYSTEM_DEFAULT is a fake one for displaying in a chooser menu. */
|
||||||
|
// localeSet.add(null);
|
||||||
|
// tmpMap.put(USE_SYSTEM_DEFAULT,
|
||||||
|
// activity.getString(R.string.use_system_default));
|
||||||
|
nameMap = Collections.unmodifiableMap(tmpMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance of {@link Languages} to work with, providing the
|
||||||
|
* {@link Activity} that is will be working as part of. This uses the
|
||||||
|
* provided string resource {@code resId} find the supported translations:
|
||||||
|
* if an included translation has a translated string that matches that
|
||||||
|
* {@code resId}, i.e. {@code R.string.menu_settings}, then that language
|
||||||
|
* will be included as a supported language.
|
||||||
|
*
|
||||||
|
* @param activity the {@link Activity} this is working as part of
|
||||||
|
* @param resId the string resource ID to test, e.g.
|
||||||
|
* {@code R.string.menu_settings}
|
||||||
|
* @param defaultString the string resource in the default language, e.g.
|
||||||
|
* {@code "Settings"}
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Languages get(Activity activity, int resId, String defaultString) {
|
||||||
|
if (singleton == null)
|
||||||
|
singleton = new Languages(activity, resId, defaultString);
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the language based on the locale.
|
||||||
|
*
|
||||||
|
* @param locale
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName(String locale) {
|
||||||
|
String ret = nameMap.get(locale);
|
||||||
|
// if no match, try to return a more general name (i.e. English for
|
||||||
|
// en_IN)
|
||||||
|
if (ret == null && locale.contains("_"))
|
||||||
|
ret = nameMap.get(locale.split("_")[0]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of the names of all the supported languages, sorted to
|
||||||
|
* match what is returned by {@link Languages#getSupportedLocales()}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] getAllNames() {
|
||||||
|
return nameMap.values().toArray(new String[nameMap.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition(Locale locale) {
|
||||||
|
String localeName = locale.getLanguage();
|
||||||
|
int i = 0;
|
||||||
|
for (String key : nameMap.keySet())
|
||||||
|
if (TextUtils.equals(key, localeName))
|
||||||
|
return i;
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get sorted list of supported locales.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] getSupportedLocales() {
|
||||||
|
Set<String> keys = nameMap.keySet();
|
||||||
|
return keys.toArray(new String[keys.size()]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,68 +1,90 @@
|
||||||
|
|
||||||
package org.torproject.android;
|
package org.torproject.android;
|
||||||
|
|
||||||
import java.util.Locale;
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import info.guardianproject.util.Languages;
|
||||||
|
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
import android.app.Application;
|
import java.util.Locale;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
public class OrbotApp extends Application implements OrbotConstants
|
public class OrbotApp extends Application implements OrbotConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private final static String DEFAULT_LOCALE = "en";
|
private SharedPreferences prefs;
|
||||||
private SharedPreferences settings;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
settings = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
setNewLocale(prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage()));
|
||||||
Configuration config = getResources().getConfiguration();
|
|
||||||
|
|
||||||
String lang = settings.getString(PREF_DEFAULT_LOCALE, DEFAULT_LOCALE);
|
|
||||||
|
|
||||||
if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
|
|
||||||
{
|
|
||||||
if (lang.equals("xx"))
|
|
||||||
{
|
|
||||||
locale = Locale.getDefault();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
locale = new Locale(lang);
|
|
||||||
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
|
|
||||||
Configuration myConfig = new Configuration(config);
|
|
||||||
myConfig.locale = locale;
|
|
||||||
|
|
||||||
getResources().updateConfiguration(myConfig, getResources().getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig)
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
{
|
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
Log.i(TAG, "onConfigurationChanged " + newConfig.locale.getLanguage());
|
||||||
|
setNewLocale(prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage()));
|
||||||
|
}
|
||||||
|
|
||||||
String lang = settings.getString(PREF_DEFAULT_LOCALE, DEFAULT_LOCALE);
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
|
public void setNewLocale(String language) {
|
||||||
|
if (TextUtils.isEmpty(language))
|
||||||
|
return;
|
||||||
|
|
||||||
if (! "".equals(lang) && ! newConfig.locale.getLanguage().equals(lang))
|
if (locale != null && TextUtils.equals(locale.getLanguage(), language))
|
||||||
{
|
return; // already configured
|
||||||
locale = new Locale(lang);
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
|
|
||||||
Configuration myConfig = new Configuration(newConfig);
|
/* handle locales with the country in it, i.e. zh_CN, zh_TW, etc */
|
||||||
myConfig.locale = locale;
|
String localeSplit[] = language.split("_");
|
||||||
|
if (localeSplit.length > 1)
|
||||||
|
locale = new Locale(localeSplit[0], localeSplit[1]);
|
||||||
|
else
|
||||||
|
locale = new Locale(language);
|
||||||
|
Configuration config = getResources().getConfiguration();
|
||||||
|
if (Build.VERSION.SDK_INT >= 17)
|
||||||
|
config.setLocale(locale);
|
||||||
|
else
|
||||||
|
config.locale = locale;
|
||||||
|
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
||||||
|
|
||||||
getResources().updateConfiguration(myConfig, getResources().getDisplayMetrics());
|
/*
|
||||||
}
|
* Set the preference after setting the locale in case something goes
|
||||||
|
* wrong. If setting the locale causes an Exception, it should be set in
|
||||||
|
* the preferences, otherwise ChatSecure will be stuck in a crash loop.
|
||||||
|
*/
|
||||||
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(this);
|
||||||
|
Editor prefEdit = prefs.edit();
|
||||||
|
prefEdit.putString(PREF_DEFAULT_LOCALE, language);
|
||||||
|
prefEdit.apply();
|
||||||
|
Log.i(TAG, "setNewLocale complete: locale: " + locale.getLanguage()
|
||||||
|
+ " Locale.getDefault: " + Locale.getDefault().getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void forceChangeLanguage(Activity activity) {
|
||||||
|
Intent intent = activity.getIntent();
|
||||||
|
if (intent == null) // when launched as LAUNCHER
|
||||||
|
intent = new Intent(activity, OrbotMainActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
activity.finish();
|
||||||
|
activity.overridePendingTransition(0, 0);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
activity.overridePendingTransition(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Languages getLanguages(Activity activity) {
|
||||||
|
return Languages.get(activity, R.string.menu_settings, "Settings");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
private MenuItem mItemOnOff = null;
|
private MenuItem mItemOnOff = null;
|
||||||
private TextView downloadText = null;
|
private TextView downloadText = null;
|
||||||
private TextView uploadText = null;
|
private TextView uploadText = null;
|
||||||
private NumberFormat mNumberFormat = null;
|
|
||||||
private TextView mTxtOrbotLog = null;
|
private TextView mTxtOrbotLog = null;
|
||||||
|
|
||||||
private Button mBtnBrowser = null;
|
private Button mBtnBrowser = null;
|
||||||
|
@ -96,6 +95,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
private final static long INIT_DELAY = 100;
|
private final static long INIT_DELAY = 100;
|
||||||
private final static int REQUEST_VPN = 8888;
|
private final static int REQUEST_VPN = 8888;
|
||||||
|
private final static int REQUEST_SETTINGS = 0x9874;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -104,8 +104,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
mPrefs.registerOnSharedPreferenceChangeListener(this);
|
mPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
setLocale();
|
|
||||||
|
|
||||||
doLayout();
|
doLayout();
|
||||||
|
|
||||||
// Register to receive messages.
|
// Register to receive messages.
|
||||||
|
@ -391,7 +389,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
if (item.getItemId() == R.id.menu_settings)
|
if (item.getItemId() == R.id.menu_settings)
|
||||||
{
|
{
|
||||||
showSettings();
|
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
|
||||||
|
startActivityForResult(intent, REQUEST_SETTINGS);
|
||||||
}
|
}
|
||||||
else if (item.getItemId() == R.id.menu_wizard)
|
else if (item.getItemId() == R.id.menu_wizard)
|
||||||
{
|
{
|
||||||
|
@ -473,10 +472,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java
|
|
||||||
* @see android.app.Activity#onPause()
|
|
||||||
*/
|
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -572,6 +567,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
// Get intent, action and MIME type
|
// Get intent, action and MIME type
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
Log.e(TAG, "handleIntents " + action);
|
||||||
|
|
||||||
String type = intent.getType();
|
String type = intent.getType();
|
||||||
|
|
||||||
if (action == null)
|
if (action == null)
|
||||||
|
@ -620,16 +617,19 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
else if (action.equals("org.torproject.android.START_TOR"))
|
else if (action.equals("org.torproject.android.START_TOR"))
|
||||||
{
|
{
|
||||||
autoStartFromIntent = true;
|
autoStartFromIntent = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Log.i(TAG, "action equals org.torproject.android.START_TOR");
|
||||||
startTor();
|
startTor();
|
||||||
|
|
||||||
Intent nResult = new Intent();
|
Intent resultIntent = new Intent(intent);
|
||||||
|
resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT);
|
||||||
//nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc
|
resultIntent.putExtra("socks_proxy_host", "127.0.0.1");
|
||||||
|
resultIntent.putExtra("socks_proxy_port", TorServiceConstants.PORT_SOCKS_DEFAULT);
|
||||||
setResult(RESULT_OK,nResult);
|
resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.PORT_HTTP);
|
||||||
|
resultIntent.putExtra("http_proxy_host", "127.0.0.1");
|
||||||
|
resultIntent.putExtra("http_proxy_port", TorServiceConstants.PORT_HTTP);
|
||||||
|
setResult(RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -808,23 +808,13 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Load the basic settings application to display torrc
|
|
||||||
*/
|
|
||||||
private void showSettings ()
|
|
||||||
{
|
|
||||||
|
|
||||||
startActivityForResult(new Intent(this, SettingsPreferences.class), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int request, int response, Intent data) {
|
protected void onActivityResult(int request, int response, Intent data) {
|
||||||
super.onActivityResult(request, response, data);
|
super.onActivityResult(request, response, data);
|
||||||
|
|
||||||
|
if (request == REQUEST_SETTINGS && response == RESULT_OK)
|
||||||
if (request == 1 && response == RESULT_OK)
|
|
||||||
{
|
{
|
||||||
|
OrbotApp.forceChangeLanguage(this);
|
||||||
if (data != null && data.getBooleanExtra("transproxywipe", false))
|
if (data != null && data.getBooleanExtra("transproxywipe", false))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1168,8 +1158,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
public void run ()
|
public void run ()
|
||||||
{
|
{
|
||||||
|
|
||||||
setLocale();
|
|
||||||
|
|
||||||
handleIntents();
|
handleIntents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1253,13 +1241,12 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (autoStartFromIntent)
|
if (autoStartFromIntent)
|
||||||
{
|
{
|
||||||
setResult(RESULT_OK);
|
autoStartFromIntent = false;
|
||||||
finish();
|
finish();
|
||||||
|
Log.e(TAG, "autoStartFromIntent finish");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (torStatus == TorServiceConstants.STATUS_CONNECTING)
|
else if (torStatus == TorServiceConstants.STATUS_CONNECTING)
|
||||||
{
|
{
|
||||||
|
@ -1430,33 +1417,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for interacting with the main interface of the service.
|
|
||||||
*/
|
|
||||||
// this is the connection that gets called back when a successfull bind occurs
|
|
||||||
// we should use this to activity monitor unbind so that we don't have to call
|
|
||||||
// bindService() a million times
|
|
||||||
|
|
||||||
private void setLocale ()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
Configuration config = getResources().getConfiguration();
|
|
||||||
String lang = mPrefs.getString(PREF_DEFAULT_LOCALE, "");
|
|
||||||
|
|
||||||
if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
|
|
||||||
{
|
|
||||||
Locale locale = new Locale(lang);
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
config.locale = locale;
|
|
||||||
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
mNumberFormat = NumberFormat.getInstance(Locale.getDefault());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -1477,30 +1437,31 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatCount(long count) {
|
private String formatCount(long count) {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
|
||||||
// Converts the supplied argument into a string.
|
// Converts the supplied argument into a string.
|
||||||
// Under 2Mb, returns "xxx.xKb"
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
// Over 2Mb, returns "xxx.xxMb"
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
|
|
||||||
//Locale.getDefault();
|
|
||||||
|
|
||||||
if (count < 1e6)
|
if (count < 1e6)
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kbps);
|
return numberFormat.format(Math.round(((float) ((int) (count * 10 / 1024)) / 10)))
|
||||||
|
+ getString(R.string.kbps);
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mbps);
|
else
|
||||||
|
return numberFormat.format(Math
|
||||||
//return count+" kB";
|
.round(((float) ((int) (count * 100 / 1024 / 1024)) / 100)))
|
||||||
|
+ getString(R.string.mbps);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatTotal(long count) {
|
private String formatTotal(long count) {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
|
||||||
// Converts the supplied argument into a string.
|
// Converts the supplied argument into a string.
|
||||||
// Under 2Mb, returns "xxx.xKb"
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
// Over 2Mb, returns "xxx.xxMb"
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
if (count < 1e6)
|
if (count < 1e6)
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kb);
|
return numberFormat.format(Math.round(((float) ((int) (count * 10 / 1024)) / 10)))
|
||||||
|
+ getString(R.string.kb);
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mb);
|
else
|
||||||
|
return numberFormat.format(Math
|
||||||
//return count+" kB";
|
.round(((float) ((int) (count * 100 / 1024 / 1024)) / 100)))
|
||||||
|
+ getString(R.string.mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,28 +3,33 @@
|
||||||
|
|
||||||
package org.torproject.android.settings;
|
package org.torproject.android.settings;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.rootcommands.RootCommands;
|
|
||||||
import org.sufficientlysecure.rootcommands.Shell;
|
|
||||||
import org.torproject.android.R;
|
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import info.guardianproject.util.Languages;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.rootcommands.RootCommands;
|
||||||
|
import org.sufficientlysecure.rootcommands.Shell;
|
||||||
|
import org.torproject.android.OrbotApp;
|
||||||
|
import org.torproject.android.R;
|
||||||
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
public class SettingsPreferences
|
public class SettingsPreferences
|
||||||
extends PreferenceActivity implements OnPreferenceClickListener {
|
extends PreferenceActivity implements OnPreferenceClickListener {
|
||||||
|
private static final String TAG = "SettingsPreferences";
|
||||||
|
|
||||||
private CheckBoxPreference prefCBTransProxy = null;
|
private CheckBoxPreference prefCBTransProxy = null;
|
||||||
private CheckBoxPreference prefcBTransProxyAll = null;
|
private CheckBoxPreference prefcBTransProxyAll = null;
|
||||||
|
@ -32,53 +37,51 @@ public class SettingsPreferences
|
||||||
|
|
||||||
private Preference prefTransProxyApps = null;
|
private Preference prefTransProxyApps = null;
|
||||||
private CheckBoxPreference prefHiddenServices = null;
|
private CheckBoxPreference prefHiddenServices = null;
|
||||||
|
private EditTextPreference prefHiddenServicesPorts;
|
||||||
|
private EditTextPreference prefHiddenServicesHostname;
|
||||||
private CheckBoxPreference prefRequestRoot = null;
|
private CheckBoxPreference prefRequestRoot = null;
|
||||||
private Preference prefLocale = null;
|
private ListPreference prefLocale = null;
|
||||||
|
|
||||||
private boolean hasRoot = false;
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
private final static int HIDDEN_SERVICE_PREF_IDX = 6;
|
|
||||||
private final static int TRANSPROXY_GROUP_IDX = 1;
|
|
||||||
private final static int DEBUG_GROUP_IDX = 8;
|
|
||||||
|
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
|
getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
|
||||||
hasRoot = prefs.getBoolean("has_root",false);
|
prefRequestRoot = (CheckBoxPreference) findPreference("has_root");
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init ()
|
|
||||||
{
|
|
||||||
int SET_LOCALE_IDX = 3;
|
|
||||||
|
|
||||||
int GENERAL_GROUP_IDX = 0;
|
|
||||||
|
|
||||||
prefRequestRoot = ((CheckBoxPreference)((PreferenceCategory)getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(0));
|
|
||||||
prefRequestRoot.setOnPreferenceClickListener(this);
|
prefRequestRoot.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
prefLocale = (((PreferenceCategory)getPreferenceScreen().getPreference(GENERAL_GROUP_IDX)).getPreference(SET_LOCALE_IDX));
|
prefLocale = (ListPreference) findPreference("pref_default_locale");
|
||||||
prefLocale.setOnPreferenceClickListener(this);
|
prefLocale.setOnPreferenceClickListener(this);
|
||||||
|
Languages languages = Languages.get(this, R.string.menu_settings, "Settings");
|
||||||
|
prefLocale.setEntries(languages.getAllNames());
|
||||||
|
prefLocale.setEntryValues(languages.getSupportedLocales());
|
||||||
|
prefLocale.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
|
||||||
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(1));
|
@Override
|
||||||
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(2);
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
String language = (String) newValue;
|
||||||
|
if (preference == prefLocale) {
|
||||||
|
SharedPreferences settings = TorServiceUtils
|
||||||
|
.getSharedPrefs(getApplicationContext());
|
||||||
|
|
||||||
prefTransProxyFlush = (Preference)((PreferenceCategory)this.getPreferenceScreen().getPreference(DEBUG_GROUP_IDX)).getPreference(8);
|
String lang = settings.getString("pref_default_locale",
|
||||||
|
Locale.getDefault().getLanguage());
|
||||||
|
OrbotApp app = (OrbotApp) getApplication();
|
||||||
|
app.setNewLocale(language);
|
||||||
|
lang = settings.getString("pref_default_locale",
|
||||||
|
Locale.getDefault().getLanguage());
|
||||||
|
OrbotApp.forceChangeLanguage(SettingsPreferences.this);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prefCBTransProxy = (CheckBoxPreference) findPreference("pref_transparent");
|
||||||
|
prefcBTransProxyAll = (CheckBoxPreference) findPreference("pref_transparent_all");
|
||||||
|
|
||||||
|
prefTransProxyFlush = (Preference) findPreference("pref_transproxy_flush");
|
||||||
prefTransProxyFlush.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
prefTransProxyFlush.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,49 +97,21 @@ public class SettingsPreferences
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(3);
|
prefTransProxyApps = findPreference("pref_transparent_app_list");
|
||||||
|
prefTransProxyApps.setOnPreferenceClickListener(this);
|
||||||
|
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked()
|
||||||
|
&& (!prefcBTransProxyAll.isChecked()));
|
||||||
|
|
||||||
prefCBTransProxy.setOnPreferenceClickListener(this);
|
prefCBTransProxy.setOnPreferenceClickListener(this);
|
||||||
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
||||||
prefTransProxyApps.setOnPreferenceClickListener(this);
|
|
||||||
|
|
||||||
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
||||||
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
|
|
||||||
|
|
||||||
|
prefHiddenServices = (CheckBoxPreference) findPreference("pref_hs_enable");
|
||||||
prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(0));
|
|
||||||
prefHiddenServices.setOnPreferenceClickListener(this);
|
prefHiddenServices.setOnPreferenceClickListener(this);
|
||||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
|
prefHiddenServicesPorts = (EditTextPreference) findPreference("pref_hs_ports");
|
||||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
|
prefHiddenServicesPorts.setEnabled(prefHiddenServices.isChecked());
|
||||||
|
prefHiddenServicesHostname = (EditTextPreference) findPreference("pref_hs_hostname");
|
||||||
|
prefHiddenServicesHostname.setEnabled(prefHiddenServices.isChecked());
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see android.app.Activity#onStop()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
@ -175,33 +150,8 @@ public class SettingsPreferences
|
||||||
}
|
}
|
||||||
else if (preference == prefHiddenServices)
|
else if (preference == prefHiddenServices)
|
||||||
{
|
{
|
||||||
|
prefHiddenServicesPorts.setEnabled(prefHiddenServices.isChecked());
|
||||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
|
prefHiddenServicesHostname.setEnabled(prefHiddenServices.isChecked());
|
||||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (preference == prefLocale)
|
|
||||||
{
|
|
||||||
SharedPreferences settings = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
|
||||||
|
|
||||||
Configuration config = getResources().getConfiguration();
|
|
||||||
|
|
||||||
String lang = settings.getString("pref_default_locale", "");
|
|
||||||
|
|
||||||
Locale locale;
|
|
||||||
|
|
||||||
if (lang.equals("xx"))
|
|
||||||
{
|
|
||||||
locale = Locale.getDefault();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
locale = new Locale(lang);
|
|
||||||
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
config.locale = locale;
|
|
||||||
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
package org.torproject.android.ui.wizard;
|
package org.torproject.android.ui.wizard;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.torproject.android.R;
|
|
||||||
import org.torproject.android.OrbotConstants;
|
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -21,39 +15,40 @@ import android.widget.Button;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import info.guardianproject.util.Languages;
|
||||||
|
|
||||||
|
import org.torproject.android.OrbotApp;
|
||||||
|
import org.torproject.android.OrbotConstants;
|
||||||
|
import org.torproject.android.R;
|
||||||
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
|
public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
|
||||||
|
|
||||||
private int flag = 0;
|
|
||||||
private ListView listLocales;
|
private ListView listLocales;
|
||||||
|
private String[] localeValues;
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
|
|
||||||
super.onStart();
|
|
||||||
setContentView(R.layout.layout_wizard_locale);
|
setContentView(R.layout.layout_wizard_locale);
|
||||||
|
|
||||||
|
|
||||||
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
|
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
|
||||||
Button next = ((Button)findViewById(R.id.btnWizard2));
|
Button next = ((Button)findViewById(R.id.btnWizard2));
|
||||||
// next.setEnabled(false);
|
// next.setEnabled(false);
|
||||||
|
|
||||||
String[] strLangs = getResources().getStringArray(R.array.languages);
|
Languages languages = OrbotApp.getLanguages(this);
|
||||||
strLangs[0] = Locale.getDefault().getDisplayName();
|
localeValues = languages.getSupportedLocales();
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, strLangs);
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||||
|
android.R.layout.simple_list_item_1, android.R.id.text1,
|
||||||
|
languages.getAllNames());
|
||||||
listLocales.setAdapter(adapter);
|
listLocales.setAdapter(adapter);
|
||||||
|
|
||||||
listLocales.setSelection(0);
|
listLocales.setSelection(0);
|
||||||
|
|
||||||
|
|
||||||
listLocales.setOnItemClickListener(new OnItemClickListener() {
|
listLocales.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> arg0, View arg1,
|
public void onItemClick(AdapterView<?> arg0, View arg1,
|
||||||
int arg2, long arg3) {
|
int arg2, long arg3) {
|
||||||
|
@ -61,7 +56,6 @@ public class ChooseLocaleWizardActivity extends Activity implements OrbotConstan
|
||||||
setLocalePref(arg2);
|
setLocalePref(arg2);
|
||||||
finish();
|
finish();
|
||||||
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
|
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,21 +68,15 @@ public class ChooseLocaleWizardActivity extends Activity implements OrbotConstan
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLocalePref(int selId)
|
private void setLocalePref(int selId)
|
||||||
{
|
{
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
|
||||||
Configuration config = getResources().getConfiguration();
|
Configuration config = getResources().getConfiguration();
|
||||||
|
|
||||||
String[] localeVals = getResources().getStringArray(R.array.languages_values);
|
String lang = localeValues[selId];
|
||||||
|
|
||||||
String lang = localeVals[selId];
|
|
||||||
|
|
||||||
Editor pEdit = prefs.edit();
|
Editor pEdit = prefs.edit();
|
||||||
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
|
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
|
||||||
|
@ -106,21 +94,6 @@ public class ChooseLocaleWizardActivity extends Activity implements OrbotConstan
|
||||||
Locale.setDefault(locale);
|
Locale.setDefault(locale);
|
||||||
config.locale = locale;
|
config.locale = locale;
|
||||||
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Code to override the back button!
|
//Code to override the back button!
|
||||||
|
|
Loading…
Reference in New Issue