diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8990656018..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: android - -# Work in progress. Repo should be used for initial checkout https://github.com/osmandapp/OsmAnd-manifest/blob/master/android_build.xml - -android: - components: - - tools - - platform-tools - - # The BuildTools version used by your project - - build-tools-27.0.3 - - android-27 - -script: ./gradlew test diff --git a/OsmAnd-java/build.gradle b/OsmAnd-java/build.gradle index 42b45a78f0..0b57c98947 100644 --- a/OsmAnd-java/build.gradle +++ b/OsmAnd-java/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'java' - +apply plugin: 'maven-publish' configurations { android @@ -77,6 +77,14 @@ artifacts { android androidJar } +publishing { + publications { + maven(MavenPublication) { + artifactId "osmand-base" + from components.java + } + } +} dependencies { testImplementation 'junit:junit:4.12' diff --git a/OsmAnd-telegram/res/drawable-hdpi/ic_action_additional_option.png b/OsmAnd-telegram/res/drawable-hdpi/ic_action_additional_option.png new file mode 100644 index 0000000000..c825caeeb3 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-hdpi/ic_action_additional_option.png differ diff --git a/OsmAnd-telegram/res/drawable-mdpi/ic_action_additional_option.png b/OsmAnd-telegram/res/drawable-mdpi/ic_action_additional_option.png new file mode 100644 index 0000000000..d7df7ace35 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-mdpi/ic_action_additional_option.png differ diff --git a/OsmAnd-telegram/res/drawable-xhdpi/ic_action_additional_option.png b/OsmAnd-telegram/res/drawable-xhdpi/ic_action_additional_option.png new file mode 100644 index 0000000000..ba244c0a10 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-xhdpi/ic_action_additional_option.png differ diff --git a/OsmAnd-telegram/res/drawable-xxhdpi/ic_action_additional_option.png b/OsmAnd-telegram/res/drawable-xxhdpi/ic_action_additional_option.png new file mode 100644 index 0000000000..0043a874e8 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-xxhdpi/ic_action_additional_option.png differ diff --git a/OsmAnd-telegram/res/drawable-xxxhdpi/ic_action_additional_option.png b/OsmAnd-telegram/res/drawable-xxxhdpi/ic_action_additional_option.png new file mode 100644 index 0000000000..9b7c6fa3f4 Binary files /dev/null and b/OsmAnd-telegram/res/drawable-xxxhdpi/ic_action_additional_option.png differ diff --git a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml index e063c5ee3d..a3a9f4a177 100644 --- a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml +++ b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml @@ -5,6 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:fitsSystemWindows="true" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd-telegram/res/layout/fragment_search_dialog.xml b/OsmAnd-telegram/res/layout/fragment_search_dialog.xml index 54f9bd41dc..322bfbf14e 100644 --- a/OsmAnd-telegram/res/layout/fragment_search_dialog.xml +++ b/OsmAnd-telegram/res/layout/fragment_search_dialog.xml @@ -2,6 +2,7 @@ + + Шукаць ва ўсіх вашых групах і кантактах. Увядзіце назву групы альбо кантакта Пошук + Накірунак + Дакладнасць + Вышыня над узроўнем мора + Ключ + Пароль + Імя карыстальніка + Пасведчанні + Порт + Сервер + Злучэнне + Уключыць + Тып проксі + Злучана + Адлучана + Налады проксі + Проксі + Прыватнасць + Накірунак \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-ca/strings.xml b/OsmAnd-telegram/res/values-ca/strings.xml index a2399368b0..8573e5317e 100644 --- a/OsmAnd-telegram/res/values-ca/strings.xml +++ b/OsmAnd-telegram/res/values-ca/strings.xml @@ -221,4 +221,18 @@ Precisió Altitud Trajectòria + Clau + Contrasenya + Nom d\'usuari + Credencials + Port + Servidor + Connexió + Activa + Tipus de servidor intermediari + Connectat + Desconnectat + Configuració del servidor intermediari + Servidor intermediari + Privacitat \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-da/strings.xml b/OsmAnd-telegram/res/values-da/strings.xml index ca4b742713..53deaa098f 100644 --- a/OsmAnd-telegram/res/values-da/strings.xml +++ b/OsmAnd-telegram/res/values-da/strings.xml @@ -19,7 +19,7 @@ Tilføj enhed Del placering som Kontakter og grupper som der deles placering med. - "Bekræft logge ud af OsmAnd Tracker, så kan der ikke deles placering eller se placeringen af andre\?" + "Bekræft log af OsmAnd Tracker, der kan ikke deles placering eller se placering af andre\?" Log ud af OsmAnd Telegram\? Navn Efter afstand @@ -38,7 +38,7 @@ Gruppe Opret forbindelse til Internettet for at logge ud af Telegram. Luk - "Sådan tilbagekaldes adgang til placeringsdeling. Åbn Telegram, gå til Settings - Privacy and Security - Sessions og afslut OsmAnd Telegram session. " + Sådan tilbagekaldes adgang til placeringsdeling. Åbn Telegram, gå til Settings - Privacy and Security - Sessions og afslut OsmAnd Telegram session. Sådan afbrydes OsmAnd Tracker fra Telegram Sådan afbrydes OsmAnd Tracker fra Telegram Tilsluttet konto @@ -220,4 +220,19 @@ Retning Højde Kurs + Nøgle + Adgangskode + Brugernavn + Legitimationsoplysninger + Port + Server + Forbindelse + Aktiver + Proxytype + Forbundet + Afbrudt + Proxy-indstillinger + Proxy + Privatliv + Præcision \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-de/strings.xml b/OsmAnd-telegram/res/values-de/strings.xml index 82bcd0b557..bc919c5996 100644 --- a/OsmAnd-telegram/res/values-de/strings.xml +++ b/OsmAnd-telegram/res/values-de/strings.xml @@ -145,7 +145,7 @@ Standortfreigabe ausschalten Bot Für alle sichtbare Zeit einstellen - Zeit einstellen, zu der Ihren Kontakten und Gruppen Ihr Standorts in Echtzeit angezeigt wird. + Stellen Sie die Zeit ein, zu der Ihren ausgewählten Kontakten und Gruppen Ihr Standort in Echtzeit angezeigt wird. Kontakte und Gruppen wählen, denen Sie Ihren Standort freigeben möchten. Standort freigeben Wählen Sie einen der Standortanbieter aus, um Ihren Standort freizugeben. @@ -221,4 +221,18 @@ Genauigkeit Höhe Peilung + Schlüssel + Passwort + Benutzername + Anmeldeinformationen + Port + Server + Verbindung + Aktivieren + Proxy-Typ + Verbunden + Getrennt + Proxy-Einstellungen + Proxy + Datenschutz \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-es-rUS/strings.xml b/OsmAnd-telegram/res/values-es-rUS/strings.xml index 1f382cf468..25bbb46249 100644 --- a/OsmAnd-telegram/res/values-es-rUS/strings.xml +++ b/OsmAnd-telegram/res/values-es-rUS/strings.xml @@ -220,4 +220,18 @@ Precisión Altitud Rumbo + Clave + Contraseña + Nombre de usuario + Credenciales + Puerto + Servidor + Conexión + Activar + Tipo de proxy + Conectado + Desconectado + Ajustes del proxy + Proxy + Privacidad \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-eu/strings.xml b/OsmAnd-telegram/res/values-eu/strings.xml new file mode 100644 index 0000000000..68942a11d2 --- /dev/null +++ b/OsmAnd-telegram/res/values-eu/strings.xml @@ -0,0 +1,141 @@ + + + Norabidea + Zehaztasuna + Altitudea + Orientazioa + Bilatu kontaktuak + Idatzi kontaktu edo talde izena + Bilatu + ADOS + Desgaitu kontrola + Kokapen grabaketa gaituta + Gaitu kontrola zure kokapen guztiak historian gordetzeko. + Online Aztarnaria + OsmAnd Aztarnaria + Telegram + Telegram (mezularitza aplikazioa) jendearekin konektatzeko eta komunikatzeko erabiltzen da. + Onartu + Telegram Pribatutasun Politika + OsmAnd Pribatutasun Politika + Zelan dabil + Itxura + Erakutsi GPS puntuak + Eguneratu + Data + GPs puntuak + Bidalita + Erakutsi OsmAnd-en + Bukaera data + Hasiera data + Mapa + Testua + Mapa eta testua + Azken eguneraketa Telegram-etik + Gehitu + Ezin izan da gailu berri bat gehitu + Gailuaren izena luzeegia + Gailuaren izena ezin da hutsik egon + Gailuaren izena + Ezkutatu + Kokapena bidaltzen + Abiarazten + Kokalekua… + Internetera konektatzen + Ezarpenetara joan + Gero + Birbidali kokapena + Egoera + GPS konexiorik ez + Internet konexiorik ez + Desgaitu + Gorde + Gehitu gailua + Partekatu kokapena honela + Izena + Ordenatu + Ordenatu honen arabera + Aukeratu erabili nahi duzun OsmAnd bertsioa + Desgaitu partekatze guztiak + Desaktibatu guztia + Irten + lehenago + Taldea + Itxi + Konektatutako kontua + Kontua + Kokapen historia + Bidali nire kokapena + Posizioa + Ireki OsmAnd + Zuzenean + Bot + Mesedez instalatu Telegram eta konfiguratu kontu bat. + Guztia + Sartu telefono zenbakia + Instalatu + Partekatu + Atzera + Partekatu kokapena + Erakutsi mapan + OsmAnd Telegram + Telefono zenbakia + Telefono zenbakia formatu internazionalean + Pasahitza + Sartu kodea + Authentication kodea + Sartu pasahitza + Telegram pasahitza + Saioa hasi + Saioa itxi + Abiarazten + Saioa ixten + Ixten + Aktibatu \"Kokapena\"\? + Ez duzu saioa hasi + Jarraitu + Utzi + Ezarpenak + Mesedez aktibatu \"Kokapena\" sistemaren ezarpenetan + Atzeko plano modua + Distantzia + Partekatu kokapena + Partekatzen kokapena + OsmAnd Telegram zebitzua + OsmAnd logoa + OsmAnd doako edo ordainpeko bertsioa instalatu behar duzu lehenik + Instalatu OsmAnd + Erakutsi erabiltzaileak mapan + Aktibatu txata + Baimena + Ongi etorri + yd + oin + mi + km + m + nmi + min/m + min/km + nmi/h + m/s + km/h + mph + Kilometro orduko + Milia orduko + Metro segunduko + Minutu kilometroko + Minutu miliaro + Milia nautikoa orduro (knot) + Miliak/Oin + Miliak/yardak + Kilometroak/metroak + Milia nautikoak + Miliak/metroak + o + min + seg + Nire kokapena + Zuzenean orain + Denbora-eskala + \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-he/strings.xml b/OsmAnd-telegram/res/values-he/strings.xml index 2f0a092be0..113303b6a5 100644 --- a/OsmAnd-telegram/res/values-he/strings.xml +++ b/OsmAnd-telegram/res/values-he/strings.xml @@ -220,4 +220,18 @@ דיוק גובה תכווין + מפתח + ססמה + שם משתמש + פרטי גישה + פתחה + שרת + חיבור + הפעלה + סוג מתווך + מחובר + מנותק + הגדרות מתווך + מתווך + פרטיות \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-nb/strings.xml b/OsmAnd-telegram/res/values-nb/strings.xml index 8c05b8cdf7..80c7dd64b1 100644 --- a/OsmAnd-telegram/res/values-nb/strings.xml +++ b/OsmAnd-telegram/res/values-nb/strings.xml @@ -187,7 +187,7 @@ Startdato Tidslinje Telegram - OsmAnd-sporeren er én av kundene som bruker Telegram. Dine kontakter kan bruke enhver annen Telegram-klient. + OsmAnd-sporeren er én av klientene som bruker Telegram. Dine kontakter kan bruke enhver annen Telegram-klient. Ved å klikke \"Fortsett\" samtykker du til vilkårene i Telegram-personvernspraksisen, og OsmAnd-personvernspraksisen. Godta Telegram-personvernspraksis @@ -221,4 +221,18 @@ Nøyaktighet Høyde Kurs + Nøkkel + Passord + Brukernavn + Identitetsdetaljer + Port + Tjener + Forbindelse + Skru på + Mellomtjenertype + Tilkoblet + Frakoblet + Mellomtjener-innstillinger + Mellomtjener + Personvern \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-pl/strings.xml b/OsmAnd-telegram/res/values-pl/strings.xml index 1742317041..ac76ae2ca1 100644 --- a/OsmAnd-telegram/res/values-pl/strings.xml +++ b/OsmAnd-telegram/res/values-pl/strings.xml @@ -222,4 +222,19 @@ Kierunek Precyzja Wysokość + Klucz + Hasło + Nazwa użytkownika + Poświadczenia + Port + Serwer + Połączenia + Włącz + Typ serwera proxy + Podłączony + Odłączony + Ustawienia proxy + Serwer proxy + Prywatność + Kierunek \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-pt-rBR/strings.xml b/OsmAnd-telegram/res/values-pt-rBR/strings.xml index d1b3c20a6b..a9e4e34f68 100644 --- a/OsmAnd-telegram/res/values-pt-rBR/strings.xml +++ b/OsmAnd-telegram/res/values-pt-rBR/strings.xml @@ -217,4 +217,22 @@ Pesquise em todos os seus grupos e contatos. Digite o nome do contato ou do grupo Pesquisar + Direção + Precisão + Altitude + Rolamento + Chave + Senha + Nome de usuário + Credenciais + Port + Servidor + Conexão + Ativar + Tipo de proxy + Conectado + Desconectado + Configurações de proxy + Proxy + Privacidade \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-sc/strings.xml b/OsmAnd-telegram/res/values-sc/strings.xml index 3d10e54872..cbe2ef47a2 100644 --- a/OsmAnd-telegram/res/values-sc/strings.xml +++ b/OsmAnd-telegram/res/values-sc/strings.xml @@ -218,4 +218,20 @@ Chirca Pretzisione Artària + Diretzione + Crae servidore + Crae de intrada + Nùmene impreadore + Credentziales + Ghenna + Servidore + Connessione + Abìlita + Casta de servidore intermediàriu + Connessu + Disconnessu + Impostatziones de su servidore intermediàriu + Servidore intermediàriu (proxy) + Privadesa + Andamentu \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-zh-rTW/strings.xml b/OsmAnd-telegram/res/values-zh-rTW/strings.xml index eb8fd80bb6..a02096a7df 100644 --- a/OsmAnd-telegram/res/values-zh-rTW/strings.xml +++ b/OsmAnd-telegram/res/values-zh-rTW/strings.xml @@ -222,4 +222,18 @@ 精確 高度 方位 + 金鑰 + 密碼 + 使用者名稱 + 憑證 + 連接埠 + 伺服器 + 連線 + 啟用 + 代理伺服器類型 + 已連線 + 已斷線 + 代理伺服器設定 + 代理伺服器 + 隱私 \ No newline at end of file diff --git a/OsmAnd-telegram/res/values/dimens.xml b/OsmAnd-telegram/res/values/dimens.xml index 29448998fb..97f34a64b3 100644 --- a/OsmAnd-telegram/res/values/dimens.xml +++ b/OsmAnd-telegram/res/values/dimens.xml @@ -44,6 +44,7 @@ 28dp 52dp + 140dp 6dp @@ -73,6 +74,8 @@ 300dp + 60dp + 22sp diff --git a/OsmAnd-telegram/res/values/strings.xml b/OsmAnd-telegram/res/values/strings.xml index 3712668b0a..59a0e6d26a 100644 --- a/OsmAnd-telegram/res/values/strings.xml +++ b/OsmAnd-telegram/res/values/strings.xml @@ -1,5 +1,19 @@ + Key + Password + Username + Credentials + Port + Server + Connection + Enable + Proxy type + Connected + Disconnected + Proxy Settings + Proxy + Privacy Direction Precision Altitude diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index bbe431bbf8..34bbd5bda3 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -85,6 +85,9 @@ private const val MONITORING_ENABLED = "monitoring_enabled" private const val SHOW_GPS_POINTS = "show_gps_points" +private const val PROXY_ENABLED = "proxy_enabled" +private const val PROXY_PREFERENCES_KEY = "proxy_preferences" + private const val SHARING_INITIALIZATION_TIME = 60 * 2L // 2 minutes private const val WAITING_TDLIB_TIME = 30 // 2 seconds @@ -103,6 +106,9 @@ class TelegramSettings(private val app: TelegramApplication) { var currentSharingMode = "" private set + var currentProxyPref: ProxyPref = ProxySOCKS5Pref(-1, "", -1, "", "") + private set + var metricsConstants = MetricsConstants.KILOMETERS_AND_METERS var speedConstants = SpeedConstants.KILOMETERS_PER_HOUR @@ -124,9 +130,12 @@ class TelegramSettings(private val app: TelegramApplication) { var showGpsPoints = false + var proxyEnabled = false + init { updatePrefs() read() + applyProxyPref() } fun hasAnyChatToShareLocation() = shareChatsInfo.isNotEmpty() @@ -202,6 +211,30 @@ class TelegramSettings(private val app: TelegramApplication) { currentSharingMode = sharingMode } + fun updateCurrentProxyPref(proxyPref: ProxyPref, proxyEnabled: Boolean) { + this.proxyEnabled = proxyEnabled + currentProxyPref = proxyPref + applyProxyPref() + } + + fun updateProxySetting(enable: Boolean) { + this.proxyEnabled = enable + if (enable) { + app.telegramHelper.enableProxy(currentProxyPref.id) + } else { + app.telegramHelper.disableProxy() + } + } + + fun applyProxyPref() { + val proxyId = currentProxyPref.id + if (proxyId != -1) { + app.telegramHelper.editProxyPref(currentProxyPref, proxyEnabled) + } else { + app.telegramHelper.addProxyPref(currentProxyPref, proxyEnabled) + } + } + fun prepareForSharingNewMessages() { shareChatsInfo.forEach { (_, shareInfo) -> prepareForSharingNewMessages(shareInfo) @@ -536,6 +569,8 @@ class TelegramSettings(private val app: TelegramApplication) { edit.putBoolean(SHOW_GPS_POINTS, showGpsPoints) + edit.putBoolean(PROXY_ENABLED, proxyEnabled) + val jArray = convertShareChatsInfoToJson() if (jArray != null) { edit.putString(SHARE_CHATS_INFO_KEY, jArray.toString()) @@ -546,6 +581,11 @@ class TelegramSettings(private val app: TelegramApplication) { edit.putString(SHARE_DEVICES_KEY, jsonObject.toString()) } + val jsonObjectProxy = convertProxyPrefToJson() + if (jsonObjectProxy != null) { + edit.putString(PROXY_PREFERENCES_KEY, jsonObjectProxy.toString()) + } + edit.apply() } @@ -597,7 +637,14 @@ class TelegramSettings(private val app: TelegramApplication) { monitoringEnabled = prefs.getBoolean(MONITORING_ENABLED,false) - showGpsPoints = prefs.getBoolean(SHOW_GPS_POINTS,false) + showGpsPoints = prefs.getBoolean(SHOW_GPS_POINTS, false) + + proxyEnabled = prefs.getBoolean(PROXY_ENABLED, false) + try { + parseProxyPreferences(JSONObject(prefs.getString(PROXY_PREFERENCES_KEY, ""))) + } catch (e: JSONException) { + e.printStackTrace() + } } private fun convertShareDevicesToJson():JSONObject?{ @@ -621,6 +668,27 @@ class TelegramSettings(private val app: TelegramApplication) { } } + private fun convertProxyPrefToJson(): JSONObject? { + return try { + val proxyPref = currentProxyPref + JSONObject().apply { + put(ProxyPref.PROXY_ID, proxyPref.id) + put(ProxyPref.TYPE_ID, proxyPref.type) + put(ProxyPref.SERVER_ID, proxyPref.server) + put(ProxyPref.PORT_ID, proxyPref.port) + if (proxyPref is ProxyMTProtoPref) { + put(ProxyMTProtoPref.KEY_ID, proxyPref.key) + } else if (proxyPref is ProxySOCKS5Pref) { + put(ProxySOCKS5Pref.LOGIN_ID, proxyPref.login) + put(ProxySOCKS5Pref.PASSWORD_ID, proxyPref.password) + } + } + } catch (e: JSONException) { + e.printStackTrace() + null + } + } + private fun convertShareChatsInfoToJson(): JSONArray? { return try { val jArray = JSONArray() @@ -678,6 +746,28 @@ class TelegramSettings(private val app: TelegramApplication) { } } + private fun parseProxyPreferences(jsonObject: JSONObject) { + val proxyId = jsonObject.optInt(ProxyPref.PROXY_ID) + val typeString = jsonObject.optString(ProxyPref.TYPE_ID) + val server = jsonObject.optString(ProxyPref.SERVER_ID) + val port = jsonObject.optInt(ProxyPref.PORT_ID) + val proxyPref = when { + ProxyType.valueOf(typeString) == ProxyType.MTPROTO -> { + val key = jsonObject.optString(ProxyMTProtoPref.KEY_ID) + ProxyMTProtoPref(proxyId, server, port, key) + } + ProxyType.valueOf(typeString) == ProxyType.SOCKS5 -> { + val login = jsonObject.optString(ProxySOCKS5Pref.LOGIN_ID) + val password = jsonObject.optString(ProxySOCKS5Pref.PASSWORD_ID) + ProxySOCKS5Pref(proxyId, server, port, login, password) + } + else -> null + } + if (proxyPref != null) { + currentProxyPref = proxyPref + } + } + private fun parseShareDevices(json: String) { shareDevices = OsmandApiUtils.parseJsonContents(json).toHashSet() } @@ -926,6 +1016,45 @@ class TelegramSettings(private val app: TelegramApplication) { } } + enum class ProxyType { + MTPROTO, SOCKS5 + } + + abstract class ProxyPref( + var id: Int, + var type: ProxyType, + open var server: String, + open var port: Int + ) { + companion object { + internal const val PROXY_ID = "proxyId" + internal const val TYPE_ID = "type" + internal const val SERVER_ID = "serverId" + internal const val PORT_ID = "portId" + } + } + + class ProxyMTProtoPref(id: Int, server: String, port: Int, var key: String) : + ProxyPref(id, ProxyType.MTPROTO, server, port) { + companion object { + internal const val KEY_ID = "key" + } + } + + class ProxySOCKS5Pref( + id: Int, + server: String, + port: Int, + var login: String, + var password: String + ) : + ProxyPref(id, ProxyType.SOCKS5, server, port) { + companion object { + internal const val LOGIN_ID = "login" + internal const val PASSWORD_ID = "password" + } + } + class SharingStatus { var title: String = "" diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt index 8b5a47f399..63659c5c56 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt @@ -683,6 +683,80 @@ class TelegramHelper private constructor() { } } + fun disableProxy() { + client?.send(TdApi.DisableProxy()) { obj -> + when (obj.constructor) { + TdApi.Error.CONSTRUCTOR -> { + val error = obj as TdApi.Error + if (error.code != IGNORED_ERROR_CODE) { + listener?.onTelegramError(error.code, error.message) + } + } + TdApi.Ok.CONSTRUCTOR -> { + } + } + } + } + + fun enableProxy(proxyId: Int) { + client?.send(TdApi.EnableProxy(proxyId)) { obj -> + when (obj.constructor) { + TdApi.Error.CONSTRUCTOR -> { + val error = obj as TdApi.Error + if (error.code != IGNORED_ERROR_CODE) { + listener?.onTelegramError(error.code, error.message) + } + } + TdApi.Ok.CONSTRUCTOR -> { + } + } + } + } + + fun addProxyPref(proxyPref: TelegramSettings.ProxyPref, enable: Boolean) { + val proxyType: TdApi.ProxyType? = when (proxyPref) { + is TelegramSettings.ProxyMTProtoPref -> TdApi.ProxyTypeMtproto(proxyPref.key) + is TelegramSettings.ProxySOCKS5Pref -> TdApi.ProxyTypeSocks5(proxyPref.login, proxyPref.password) + else -> null + } + client?.send(TdApi.AddProxy(proxyPref.server, proxyPref.port, enable, proxyType)) { obj -> + when (obj.constructor) { + TdApi.Error.CONSTRUCTOR -> { + val error = obj as TdApi.Error + if (error.code != IGNORED_ERROR_CODE) { + listener?.onTelegramError(error.code, error.message) + } + } + TdApi.Proxy.CONSTRUCTOR -> { + val proxy = (obj as TdApi.Proxy) + proxyPref.id = proxy.id + } + } + } + } + + fun editProxyPref(proxyPref: TelegramSettings.ProxyPref, enable: Boolean) { + val proxyType: TdApi.ProxyType? = when (proxyPref) { + is TelegramSettings.ProxyMTProtoPref -> TdApi.ProxyTypeMtproto(proxyPref.key) + is TelegramSettings.ProxySOCKS5Pref -> TdApi.ProxyTypeSocks5(proxyPref.login, proxyPref.password) + else -> null + } + client?.send(TdApi.EditProxy(proxyPref.id, proxyPref.server, proxyPref.port, enable, proxyType)) { obj -> + when (obj.constructor) { + TdApi.Error.CONSTRUCTOR -> { + val error = obj as TdApi.Error + if (error.code != IGNORED_ERROR_CODE) { + listener?.onTelegramError(error.code, error.message) + } + } + TdApi.Proxy.CONSTRUCTOR -> { + val proxy = (obj as TdApi.Proxy) + proxyPref.id = proxy.id + } + } + } + } + fun createPrivateChatWithUser( userId: Int, shareInfo: TelegramSettings.ShareChatInfo, diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt index d0a28d1d48..f5de2e8e2e 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt @@ -217,17 +217,23 @@ class LoginDialogFragment : BaseDialogFragment() { welcomeImage?.visibility = View.GONE } - val continueButton = view?.findViewById