Remove string-array and add map with countryPhoneCodes
This commit is contained in:
parent
fa09df5fc7
commit
6cd6f12299
3 changed files with 84 additions and 293 deletions
|
@ -1,257 +1,4 @@
|
|||
<resources>
|
||||
<string-array name="DialingCountryCode" >
|
||||
<item>AB,+7840,+7940,+99544</item>
|
||||
<item>AF,+93</item>
|
||||
<item>AX,+35818</item>
|
||||
<item>AL,+355</item>
|
||||
<item>DZ,+213</item>
|
||||
<item>AS,+1684</item>
|
||||
<item>AD,+376</item>
|
||||
<item>AO,+244</item>
|
||||
<item>AI,+1264</item>
|
||||
<item>AG,+1268</item>
|
||||
<item>AR,+54</item>
|
||||
<item>AM,+374</item>
|
||||
<item>AW,+297</item>
|
||||
<item>SH,+247</item>
|
||||
<item>AU,+61</item>
|
||||
<item>AU,+672</item>
|
||||
<item>AT,+43</item>
|
||||
<item>AZ,+994</item>
|
||||
<item>BS,+1242</item>
|
||||
<item>BH,+973</item>
|
||||
<item>BD,+880</item>
|
||||
<item>BB,+1246</item>
|
||||
<item>AG,+1268</item>
|
||||
<item>BY,+375</item>
|
||||
<item>BE,+32</item>
|
||||
<item>BZ,+501</item>
|
||||
<item>BJ,+229</item>
|
||||
<item>BM,+1441</item>
|
||||
<item>BT,+975</item>
|
||||
<item>BO,+591</item>
|
||||
<item>BQ,+5997</item>
|
||||
<item>BA,+387</item>
|
||||
<item>BW,+267</item>
|
||||
<item>BR,+55</item>
|
||||
<item>IO,+246</item>
|
||||
<item>VG,+1284</item>
|
||||
<item>BN,+673</item>
|
||||
<item>BG,+359</item>
|
||||
<item>BF,+226</item>
|
||||
<item>MY,+95</item>
|
||||
<item>BI,+257</item>
|
||||
<item>KH,+855</item>
|
||||
<item>CM,+237</item>
|
||||
<item>CA,+1</item>
|
||||
<item>CV,+238</item>
|
||||
<item>KY,+1345</item>
|
||||
<item>CF,+236</item>
|
||||
<item>TD,+235</item>
|
||||
<item>CL,+56</item>
|
||||
<item>CN,+86</item>
|
||||
<item>CX,+61</item>
|
||||
<item>CC,+61</item>
|
||||
<item>CO,+57</item>
|
||||
<item>KM,+269</item>
|
||||
<item>CG,+242</item>
|
||||
<item>CD,+243</item>
|
||||
<item>CK,+682</item>
|
||||
<item>CR,+506</item>
|
||||
<item>CI,+225</item>
|
||||
<item>HR,+385</item>
|
||||
<item>CU,+53</item>
|
||||
<item>CW,+5999</item>
|
||||
<item>CY,+357</item>
|
||||
<item>CZ,+420</item>
|
||||
<item>DK,+45</item>
|
||||
<item>DG,+246</item>
|
||||
<item>DJ,+253</item>
|
||||
<item>DM,+1767</item>
|
||||
<item>DO,+1809,+1829,+1849</item>
|
||||
<item>TL,+670</item>
|
||||
<item>EC,+593</item>
|
||||
<item>EG,+20</item>
|
||||
<item>SV,+503</item>
|
||||
<item>GQ,+240</item>
|
||||
<item>ER,+291</item>
|
||||
<item>EE,+372</item>
|
||||
<item>ET,+251</item>
|
||||
<item>FK,+500</item>
|
||||
<item>FO,+298</item>
|
||||
<item>FJ,+679</item>
|
||||
<item>FI,+358</item>
|
||||
<item>FR,+33</item>
|
||||
<item>GF,+594</item>
|
||||
<item>PF,+689</item>
|
||||
<item>GA,+241</item>
|
||||
<item>GM,+220</item>
|
||||
<item>GE,+995</item>
|
||||
<item>DE,+49</item>
|
||||
<item>GH,+233</item>
|
||||
<item>GI,+350</item>
|
||||
<item>GR,+30</item>
|
||||
<item>GL,+299</item>
|
||||
<item>GD,+1473</item>
|
||||
<item>GP,+590</item>
|
||||
<item>GU,+1671</item>
|
||||
<item>GT,+502</item>
|
||||
<item>GG,+44</item>
|
||||
<item>GN,+224</item>
|
||||
<item>GW,+245</item>
|
||||
<item>GY,+592</item>
|
||||
<item>HT,+509</item>
|
||||
<item>HN,+504</item>
|
||||
<item>HK,+852</item>
|
||||
<item>HU,+36</item>
|
||||
<item>IS,+354</item>
|
||||
<item>IN,+91</item>
|
||||
<item>ID,+62</item>
|
||||
<item>IR,+98</item>
|
||||
<item>IQ,+964</item>
|
||||
<item>IE,+353</item>
|
||||
<item>IL,+972</item>
|
||||
<item>IT,+39</item>
|
||||
<item>JM,+1876</item>
|
||||
<item>SJ,+4779</item>
|
||||
<item>JP,+81</item>
|
||||
<item>JE,+44</item>
|
||||
<item>JO,+962</item>
|
||||
<item>KZ,+76,+77</item>
|
||||
<item>KE,+254</item>
|
||||
<item>KI,+686</item>
|
||||
<item>KP,+850</item>
|
||||
<item>KR,+82</item>
|
||||
<item>KW,+965</item>
|
||||
<item>KG,+996</item>
|
||||
<item>LA,+856</item>
|
||||
<item>LV,+371</item>
|
||||
<item>LB,+961</item>
|
||||
<item>LS,+266</item>
|
||||
<item>LR,+231</item>
|
||||
<item>LY,+218</item>
|
||||
<item>LI,+423</item>
|
||||
<item>LT,+370</item>
|
||||
<item>LU,+352</item>
|
||||
<item>MO,+853</item>
|
||||
<item>MK,+389</item>
|
||||
<item>MG,+261</item>
|
||||
<item>MW,+265</item>
|
||||
<item>MY,+60</item>
|
||||
<item>MV,+960</item>
|
||||
<item>ML,+223</item>
|
||||
<item>MT,+356</item>
|
||||
<item>MH,+692</item>
|
||||
<item>MQ,+596</item>
|
||||
<item>MR,+222</item>
|
||||
<item>MU,+230</item>
|
||||
<item>YT,+262</item>
|
||||
<item>MX,+52</item>
|
||||
<item>FM,+691</item>
|
||||
<item>MD,+373</item>
|
||||
<item>MC,+377</item>
|
||||
<item>MN,+976</item>
|
||||
<item>ME,+382</item>
|
||||
<item>MS,+1664</item>
|
||||
<item>MA,+212</item>
|
||||
<item>MZ,+258</item>
|
||||
<item>NA,+264</item>
|
||||
<item>NR,+674</item>
|
||||
<item>NP,+977</item>
|
||||
<item>NL,+31</item>
|
||||
<item>NC,+687</item>
|
||||
<item>NZ,+64</item>
|
||||
<item>NI,+505</item>
|
||||
<item>NE,+227</item>
|
||||
<item>NG,+234</item>
|
||||
<item>NU,+683</item>
|
||||
<item>NF,+672</item>
|
||||
<item>MP,+1670</item>
|
||||
<item>NO,+47</item>
|
||||
<item>OM,+968</item>
|
||||
<item>PK,+92</item>
|
||||
<item>PW,+680</item>
|
||||
<item>PS,+970</item>
|
||||
<item>PA,+507</item>
|
||||
<item>PG,+675</item>
|
||||
<item>PY,+595</item>
|
||||
<item>PE,+51</item>
|
||||
<item>PH,+63</item>
|
||||
<item>PN,+64</item>
|
||||
<item>PL,+48</item>
|
||||
<item>PT,+351</item>
|
||||
<item>PR,+1787,+1939</item>
|
||||
<item>QA,+974</item>
|
||||
<item>RE,+262</item>
|
||||
<item>RO,+40</item>
|
||||
<item>RU,+7</item>
|
||||
<item>RW,+250</item>
|
||||
<item>BL,+590</item>
|
||||
<item>SH,+290</item>
|
||||
<item>KN,+1869</item>
|
||||
<item>LC,+1758</item>
|
||||
<item>MF,+590</item>
|
||||
<item>PM,+508</item>
|
||||
<item>VC,+1784</item>
|
||||
<item>WS,+685</item>
|
||||
<item>SM,+378</item>
|
||||
<item>ST,+239</item>
|
||||
<item>SA,+966</item>
|
||||
<item>SN,+221</item>
|
||||
<item>RS,+381</item>
|
||||
<item>SC,+248</item>
|
||||
<item>SL,+232</item>
|
||||
<item>SG,+65</item>
|
||||
<item>BQ,+5993</item>
|
||||
<item>SX,+1721</item>
|
||||
<item>SK,+421</item>
|
||||
<item>SI,+386</item>
|
||||
<item>SB,+677</item>
|
||||
<item>SO,+252</item>
|
||||
<item>ZA,+27</item>
|
||||
<item>GS,+500</item>
|
||||
<item>!1,+99534</item>
|
||||
<item>SS,+211</item>
|
||||
<item>ES,+34</item>
|
||||
<item>LK,+94</item>
|
||||
<item>SD,+249</item>
|
||||
<item>SR,+597</item>
|
||||
<item>SJ,+4779</item>
|
||||
<item>SZ,+268</item>
|
||||
<item>SE,+46</item>
|
||||
<item>CH,+41</item>
|
||||
<item>SY,+963</item>
|
||||
<item>TW,+886</item>
|
||||
<item>TJ,+992</item>
|
||||
<item>TZ,+255</item>
|
||||
<item>TH,+66</item>
|
||||
<item>TG,+228</item>
|
||||
<item>TK,+690</item>
|
||||
<item>TO,+676</item>
|
||||
<item>TT,+1868</item>
|
||||
<item>TN,+216</item>
|
||||
<item>TR,+90</item>
|
||||
<item>TM,+993</item>
|
||||
<item>TC,+1649</item>
|
||||
<item>TV,+688</item>
|
||||
<item>UG,+256</item>
|
||||
<item>UA,+380</item>
|
||||
<item>AE,+971</item>
|
||||
<item>UK,+44</item>
|
||||
<item>US,+1</item>
|
||||
<item>UY,+598</item>
|
||||
<item>VI,+1340</item>
|
||||
<item>UZ,+998</item>
|
||||
<item>VU,+678</item>
|
||||
<item>VE,+58</item>
|
||||
<item>VA,+3906698,+379</item>
|
||||
<item>VN,+84</item>
|
||||
<item>WF,+681</item>
|
||||
<item>YE,+967</item>
|
||||
<item>ZM,+260</item>
|
||||
<item>!1,+255</item>
|
||||
<item>ZW,+263</item>
|
||||
</string-array>
|
||||
<string name="shared_string_telegram">Telegram</string>
|
||||
<string name="privacy_policy_use_telegram">We use a Telegram (messaging app) to connect people and make it easier for you to communicate with them.</string>
|
||||
<string name="privacy_policy_telegram_client">Telegram open platform and OsmAnd Tracker is one of the customers. Your contacts can use any other Telegram client.</string>
|
||||
|
|
|
@ -26,7 +26,6 @@ import android.widget.ImageView
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import net.osmand.PlatformUtil
|
||||
import net.osmand.data.LatLon
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.utils.AndroidNetworkUtils
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
|
@ -56,6 +55,71 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
|
||||
private var softKeyboardShown: Boolean = false
|
||||
|
||||
private var countryPhoneCodes = mapOf(
|
||||
Pair("AB", "+7840,+7940,+99544"), Pair("AF", "+93"), Pair("AX", "+35818"), Pair("AL", "+355"),
|
||||
Pair("DZ", "+213"), Pair("AS", "+1684"), Pair("AD", "+376"), Pair("AO", "+244"),
|
||||
Pair("AI", "+1264"), Pair("AG", "+1268"), Pair("AR", "+54"), Pair("AM", "+374"),
|
||||
Pair("AW", "+297"), Pair("SH", "+247"), Pair("AU", "+61"), Pair("AU", "+672"),
|
||||
Pair("AT", "+43"), Pair("AZ", "+994"), Pair("BS", "+1242"), Pair("BH", "+973"),
|
||||
Pair("BD", "+880"), Pair("BB", "+1246"), Pair("AG", "+1268"), Pair("BY", "+375"),
|
||||
Pair("BE", "+32"), Pair("BZ", "+501"), Pair("BJ", "+229"), Pair("BM", "+1441"),
|
||||
Pair("BT", "+975"), Pair("BO", "+591"), Pair("BQ", "+5997"), Pair("BA", "+387"),
|
||||
Pair("BW", "+267"), Pair("BR", "+55"), Pair("IO", "+246"), Pair("VG", "+1284"),
|
||||
Pair("BN", "+673"), Pair("BG", "+359"), Pair("BF", "+226"), Pair("MY", "+95"),
|
||||
Pair("BI", "+257"), Pair("KH", "+855"), Pair("CM", "+237"), Pair("CA", "+1"),
|
||||
Pair("CV", "+238"), Pair("KY", "+1345"), Pair("CF", "+236"), Pair("TD", "+235"),
|
||||
Pair("CL", "+56"), Pair("CN", "+86"), Pair("CX", "+61"), Pair("CC", "+61"),
|
||||
Pair("CO", "+57"), Pair("KM", "+269"), Pair("CG", "+242"), Pair("CD", "+243"),
|
||||
Pair("CK", "+682"), Pair("CR", "+506"), Pair("CI", "+225"), Pair("HR", "+385"),
|
||||
Pair("CU", "+53"), Pair("CW", "+5999"), Pair("CY", "+357"), Pair("CZ", "+420"),
|
||||
Pair("DK", "+45"), Pair("DG", "+246"), Pair("DJ", "+253"), Pair("DM", "+1767"),
|
||||
Pair("DO", "+1809,+1829,+1849"), Pair("TL", "+670"), Pair("EC", "+593"),
|
||||
Pair("EG", "+20"), Pair("SV", "+503"), Pair("GQ", "+240"), Pair("ER", "+291"),
|
||||
Pair("EE", "+372"), Pair("ET", "+251"), Pair("FK", "+500"), Pair("FO", "+298"),
|
||||
Pair("FJ", "+679"), Pair("FI", "+358"), Pair("FR", "+33"), Pair("GF", "+594"),
|
||||
Pair("PF", "+689"), Pair("GA", "+241"), Pair("GM", "+220"), Pair("GE", "+995"),
|
||||
Pair("DE", "+49"), Pair("GH", "+233"), Pair("GI", "+350"), Pair("GR", "+30"),
|
||||
Pair("GL", "+299"), Pair("GD", "+1473"), Pair("GP", "+590"), Pair("GU", "+1671"),
|
||||
Pair("GT", "+502"), Pair("GG", "+44"), Pair("GN", "+224"), Pair("GW", "+245"),
|
||||
Pair("GY", "+592"), Pair("HT", "+509"), Pair("HN", "+504"), Pair("HK", "+852"),
|
||||
Pair("HU", "+36"), Pair("IS", "+354"), Pair("IN", "+91"), Pair("ID", "+62"),
|
||||
Pair("IR", "+98"), Pair("IQ", "+964"), Pair("IE", "+353"), Pair("IL", "+972"),
|
||||
Pair("IT", "+39"), Pair("JM", "+1876"), Pair("SJ", "+4779"), Pair("JP", "+81"),
|
||||
Pair("JE", "+44"), Pair("JO", "+962"), Pair("KZ", "+76,+77"), Pair("KE", "+254"),
|
||||
Pair("KI", "+686"), Pair("KP", "+850"), Pair("KR", "+82"), Pair("KW", "+965"),
|
||||
Pair("KG", "+996"), Pair("LA", "+856"), Pair("LV", "+371"), Pair("LB", "+961"),
|
||||
Pair("LS", "+266"), Pair("LR", "+231"), Pair("LY", "+218"), Pair("LI", "+423"),
|
||||
Pair("LT", "+370"), Pair("LU", "+352"), Pair("MO", "+853"), Pair("MK", "+389"),
|
||||
Pair("MG", "+261"), Pair("MW", "+265"), Pair("MY", "+60"), Pair("MV", "+960"),
|
||||
Pair("ML", "+223"), Pair("MT", "+356"), Pair("MH", "+692"), Pair("MQ", "+596"),
|
||||
Pair("MR", "+222"), Pair("MU", "+230"), Pair("YT", "+262"), Pair("MX", "+52"),
|
||||
Pair("FM", "+691"), Pair("MD", "+373"), Pair("MC", "+377"), Pair("MN", "+976"),
|
||||
Pair("ME", "+382"), Pair("MS", "+1664"), Pair("MA", "+212"), Pair("MZ", "+258"),
|
||||
Pair("NA", "+264"), Pair("NR", "+674"), Pair("NP", "+977"), Pair("NL", "+31"),
|
||||
Pair("NC", "+687"), Pair("NZ", "+64"), Pair("NI", "+505"), Pair("NE", "+227"),
|
||||
Pair("NG", "+234"), Pair("NU", "+683"), Pair("NF", "+672"), Pair("MP", "+1670"),
|
||||
Pair("NO", "+47"), Pair("OM", "+968"), Pair("PK", "+92"), Pair("PW", "+680"),
|
||||
Pair("PS", "+970"), Pair("PA", "+507"), Pair("PG", "+675"), Pair("PY", "+595"),
|
||||
Pair("PE", "+51"), Pair("PH", "+63"), Pair("PN", "+64"), Pair("PL", "+48"),
|
||||
Pair("PT", "+351"), Pair("PR", "+1787,+1939"), Pair("QA", "+974"), Pair("RE", "+262"),
|
||||
Pair("RO", "+40"), Pair("RU", "+7"), Pair("RW", "+250"), Pair("BL", "+590"),
|
||||
Pair("SH", "+290"), Pair("KN", "+1869"), Pair("LC", "+1758"), Pair("MF", "+590"),
|
||||
Pair("PM", "+508"), Pair("VC", "+1784"), Pair("WS", "+685"), Pair("SM", "+378"),
|
||||
Pair("ST", "+239"), Pair("SA", "+966"), Pair("SN", "+221"), Pair("RS", "+381"),
|
||||
Pair("SC", "+248"), Pair("SL", "+232"), Pair("SG", "+65"), Pair("BQ", "+5993"),
|
||||
Pair("SX", "+1721"), Pair("SK", "+421"), Pair("SI", "+386"), Pair("SB", "+677"),
|
||||
Pair("SO", "+252"), Pair("ZA", "+27"), Pair("GS", "+500"), Pair("!1", "+99534"),
|
||||
Pair("SS", "+211"), Pair("ES", "+34"), Pair("LK", "+94"), Pair("SD", "+249"),
|
||||
Pair("SR", "+597"), Pair("SJ", "+4779"), Pair("SZ", "+268"), Pair("SE", "+46"),
|
||||
Pair("CH", "+41"), Pair("SY", "+963"), Pair("TW", "+886"), Pair("TJ", "+992"),
|
||||
Pair("TZ", "+255"), Pair("TH", "+66"), Pair("TG", "+228"), Pair("TK", "+690"),
|
||||
Pair("TO", "+676"), Pair("TT", "+1868"), Pair("TN", "+216"), Pair("TR", "+90"),
|
||||
Pair("TM", "+993"), Pair("TC", "+1649"), Pair("TV", "+688"), Pair("UG", "+256"),
|
||||
Pair("UA", "+380"), Pair("AE", "+971"), Pair("UK", "+44"), Pair("US", "+1"),
|
||||
Pair("UY", "+598"), Pair("VI", "+1340"), Pair("UZ", "+998"), Pair("VU", "+678"),
|
||||
Pair("VE", "+58"), Pair("VA", "+3906698,+379"), Pair("VN", "+84"), Pair("WF", "+681"),
|
||||
Pair("YE", "+967"), Pair("ZM", "+260"), Pair("ZW", "+263"))
|
||||
|
||||
private var countryPhoneCode: String = "+"
|
||||
|
||||
fun showWelcomeDialog(fragmentManager: FragmentManager) {
|
||||
|
@ -172,7 +236,7 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
val width = if (expanded) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
params.apply {
|
||||
val horizontalMargin = app.resources.getDimensionPixelSize(if (acceptMode) R.dimen.dialog_welcome_padding_horizontal else R.dimen.content_padding_half)
|
||||
setMargins(horizontalMargin, topMargin, horizontalMargin, AndroidUtils.dpToPx(context!!, bottomMargin))
|
||||
setMargins(horizontalMargin, topMargin, horizontalMargin, AndroidUtils.dpToPx(app, bottomMargin))
|
||||
this.width = width
|
||||
}
|
||||
continueButton.requestLayout()
|
||||
|
@ -270,14 +334,15 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
AndroidUtils.softKeyboardDelayed(editText)
|
||||
focusRequested = true
|
||||
}
|
||||
val passTextLength = if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) countryPhoneCode.length else 0
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
changeContinueButtonEnabled(s.length > countryPhoneCode.length)
|
||||
changeContinueButtonEnabled(s.length > passTextLength)
|
||||
}
|
||||
})
|
||||
changeContinueButtonEnabled(editText.text.length > countryPhoneCode.length)
|
||||
changeContinueButtonEnabled(editText.text.length > passTextLength)
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16F)
|
||||
}
|
||||
|
||||
|
@ -289,8 +354,9 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
|
||||
noTelegramViewContainer?.setOnClickListener {
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
val mainActivity = activity
|
||||
if (focusedView != null && mainActivity != null) {
|
||||
AndroidUtils.hideSoftKeyboard(mainActivity, focusedView)
|
||||
}
|
||||
updateDialog(LoginDialogType.GET_TELEGRAM, false)
|
||||
}
|
||||
|
@ -406,7 +472,7 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
|
||||
val text = editText?.text.toString()
|
||||
if (!TextUtils.isEmpty(text) && text.length > 1) {
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
||||
continueButton.setTextColor(ContextCompat.getColor(app, R.color.secondary_text_light))
|
||||
applyAuthParam(t, text)
|
||||
}
|
||||
}
|
||||
|
@ -421,8 +487,9 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
LoginDialogType.ENTER_PHONE_NUMBER -> {
|
||||
showWelcomeDialog = true
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
val mainActivity = activity
|
||||
if (focusedView != null && mainActivity != null) {
|
||||
AndroidUtils.hideSoftKeyboard(mainActivity, focusedView)
|
||||
}
|
||||
buildDialog(view)
|
||||
}
|
||||
|
@ -449,19 +516,10 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
if (result != null) {
|
||||
try {
|
||||
val obj = JSONObject(result)
|
||||
val latitude = obj.getDouble("latitude")
|
||||
val longitude = obj.getDouble("longitude")
|
||||
val countryId = obj.getString("country_code")
|
||||
if (latitude == 0.0 && longitude == 0.0) {
|
||||
log.debug("Empty location")
|
||||
} else {
|
||||
val location = LatLon(latitude, longitude)
|
||||
log.debug("$location")
|
||||
countryPhoneCode = getCountryDialCode(countryId)
|
||||
log.debug(countryPhoneCode)
|
||||
}
|
||||
countryPhoneCode = countryPhoneCodes[countryId]?.split(",")?.firstOrNull() ?: "+"
|
||||
} catch (e: Exception) {
|
||||
log.debug("JSON parsing error: ", e)
|
||||
log.error("JSON parsing error: ", e)
|
||||
}
|
||||
} else {
|
||||
log.debug("Empty response")
|
||||
|
@ -470,19 +528,6 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
})
|
||||
}
|
||||
|
||||
fun getCountryDialCode(countryId: String): String {
|
||||
var countryDialCode = ""
|
||||
val arrCountryCode = this.resources.getStringArray(R.array.DialingCountryCode)
|
||||
arrCountryCode.forEach {
|
||||
val arrDial = it.split(",")
|
||||
if (arrDial[0].trim() == (countryId)) {
|
||||
countryDialCode = arrDial[1]
|
||||
return countryDialCode
|
||||
}
|
||||
}
|
||||
return countryDialCode
|
||||
}
|
||||
|
||||
private fun applyAuthParam(t: LoginDialogType, value: String) {
|
||||
getMainActivity()?.applyAuthParam(this, t, value)
|
||||
}
|
||||
|
@ -522,7 +567,7 @@ class LoginDialogFragment : BaseDialogFragment() {
|
|||
private fun changeContinueButtonEnabled(enabled: Boolean) {
|
||||
if (enabled != continueButton.isEnabled) {
|
||||
val color = if (enabled) R.color.white else R.color.secondary_text_light
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, color))
|
||||
continueButton.setTextColor(ContextCompat.getColor(app, color))
|
||||
continueButton.isEnabled = enabled
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,14 +164,14 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
}
|
||||
AndroidUtils.addStatusBarPadding19v(context!!, this)
|
||||
AndroidUtils.addStatusBarPadding19v(app, this)
|
||||
title = findViewById(R.id.title)
|
||||
description = findViewById(R.id.description)
|
||||
}
|
||||
|
||||
searchBoxBg = GradientDrawable().apply {
|
||||
shape = GradientDrawable.RECTANGLE
|
||||
setColor(ContextCompat.getColor(context!!, R.color.screen_bg_light))
|
||||
setColor(ContextCompat.getColor(app, R.color.screen_bg_light))
|
||||
cornerRadius = (searchBoxHeight / 2).toFloat()
|
||||
}
|
||||
|
||||
|
@ -662,8 +662,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
|
||||
val duration = shareInfo?.userSetLivePeriod
|
||||
if (duration != null && duration > 0) {
|
||||
holder.descriptionDuration?.text =
|
||||
OsmandFormatter.getFormattedDuration(context!!, duration)
|
||||
holder.descriptionDuration?.text = OsmandFormatter.getFormattedDuration(app, duration)
|
||||
holder.description?.apply {
|
||||
visibility = View.VISIBLE
|
||||
text = "${getText(R.string.sharing_time)}:"
|
||||
|
@ -676,7 +675,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
val time =
|
||||
shareInfo?.additionalActiveTime ?: ADDITIONAL_ACTIVE_TIME_VALUES_SEC[0]
|
||||
visibility = View.VISIBLE
|
||||
text = "+ ${OsmandFormatter.getFormattedDuration(context!!, time)}"
|
||||
text = "+ ${OsmandFormatter.getFormattedDuration(app, time)}"
|
||||
setOnClickListener {
|
||||
val expireTime = shareInfo?.getChatLiveMessageExpireTime() ?: 0
|
||||
val newLivePeriod = expireTime + (shareInfo?.additionalActiveTime
|
||||
|
@ -711,7 +710,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
description.setSpan(CustomTypefaceSpan(typeface), start, description.length, 0)
|
||||
}
|
||||
description.setSpan(ForegroundColorSpan(ContextCompat.getColor(app, R.color.primary_text_light)), start, description.length, 0)
|
||||
description.append((getString(R.string.in_time, OsmandFormatter.getFormattedDuration(context!!, expiresIn, true))))
|
||||
description.append((getString(R.string.in_time, OsmandFormatter.getFormattedDuration(app, expiresIn, true))))
|
||||
text = description
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue