Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
87722d94
Commit
87722d94
authored
May 14, 2019
by
Hussein El Feky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored code
parent
0cd0d777
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
35 deletions
+28
-35
SettingsFragment.kt
.../java/chat/rocket/android/settings/ui/SettingsFragment.kt
+28
-35
No files found.
app/src/main/java/chat/rocket/android/settings/ui/SettingsFragment.kt
View file @
87722d94
...
...
@@ -31,6 +31,24 @@ import timber.log.Timber
import
javax.inject.Inject
internal
const
val
TAG_SETTINGS_FRAGMENT
=
"SettingsFragment"
private
val
LOCALES
=
arrayOf
(
"en"
,
"ar"
,
"de"
,
"es"
,
"fa"
,
"fr"
,
"hi,IN"
,
"it"
,
"ja"
,
"pt,BR"
,
"pt,PT"
,
"ru,RU"
,
"tr"
,
"uk"
,
"zh,CN"
,
"zh,TW"
)
fun
newInstance
():
Fragment
=
SettingsFragment
()
...
...
@@ -165,37 +183,12 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
private
fun
changeLanguage
()
{
context
?.
let
{
// Add [String] for locales without specified countries, and
// add [Pair] for locales with specified countries.
val
locales
=
arrayOf
(
"en"
,
"ar"
,
"de"
,
"es"
,
"fa"
,
"fr"
,
Pair
(
"hi"
,
"IN"
),
"it"
,
"ja"
,
Pair
(
"pt"
,
"BR"
),
Pair
(
"pt"
,
"PT"
),
Pair
(
"ru"
,
"RU"
),
"tr"
,
"uk"
,
Pair
(
"zh"
,
"CN"
),
Pair
(
"zh"
,
"TW"
)
)
val
selectedLocale
=
presenter
.
getCurrentLocale
(
it
)
var
localeIndex
=
-
1
locales
.
forEachIndexed
{
index
,
locale
->
var
language
:
String
?
=
null
var
country
=
""
if
(
locale
is
String
)
{
language
=
locale
}
else
if
(
locale
is
Pair
<*,
*>)
{
language
=
locale
.
first
as
String
country
=
locale
.
second
as
String
}
LOCALES
.
forEachIndexed
{
index
,
locale
->
val
array
=
locale
.
split
(
","
)
val
language
=
array
[
0
]
val
country
=
if
(
array
.
size
>
1
)
array
[
1
]
else
""
// If language and country are specified, return the respective locale, else return
// the first locale found if the language is as specified regardless of the country.
if
(
language
==
selectedLocale
.
language
)
{
...
...
@@ -212,11 +205,11 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
.
setSingleChoiceItems
(
resources
.
getStringArray
(
R
.
array
.
languages
),
localeIndex
)
{
dialog
,
option
->
if
(
locales
[
option
]
is
String
)
{
updateLanguage
(
locales
[
option
]
as
String
)
}
else
if
(
locales
[
option
]
is
Pair
<*,
*>)
{
updateLanguage
((
locales
[
option
]
as
Pair
<*,
*>).
first
as
String
,
(
locales
[
option
]
as
Pair
<*,
*>).
second
as
String
)
val
array
=
LOCALES
[
option
].
split
(
","
)
if
(
array
.
size
>
1
)
{
updateLanguage
(
array
[
0
],
array
[
1
])
}
else
{
updateLanguage
(
array
[
0
]
)
}
dialog
.
dismiss
()
}
...
...
@@ -263,4 +256,4 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
.
show
()
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment