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
9bcc0f5c
Commit
9bcc0f5c
authored
Apr 27, 2019
by
Hussein El Feky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Showed the selected locale in Language setter
parent
521f0a8b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
26 deletions
+45
-26
SharedPrefsCurrentLanguageRepository.kt
...er/infrastructure/SharedPrefsCurrentLanguageRepository.kt
+3
-2
SettingsPresenter.kt
...rocket/android/settings/presentation/SettingsPresenter.kt
+3
-3
SettingsFragment.kt
.../java/chat/rocket/android/settings/ui/SettingsFragment.kt
+39
-21
No files found.
app/src/main/java/chat/rocket/android/server/infrastructure/SharedPrefsCurrentLanguageRepository.kt
View file @
9bcc0f5c
package
chat.rocket.android.server.infrastructure
package
chat.rocket.android.server.infrastructure
import
android.content.SharedPreferences
import
android.content.SharedPreferences
import
java.util.*
private
const
val
CURRENT_LANGUAGE
=
"current_language"
private
const
val
CURRENT_LANGUAGE
=
"current_language"
private
const
val
CURRENT_LANGUAGE_COUNTRY
=
"current_language_country"
private
const
val
CURRENT_LANGUAGE_COUNTRY
=
"current_language_country"
...
@@ -16,10 +17,10 @@ class SharedPrefsCurrentLanguageRepository(private val preferences: SharedPrefer
...
@@ -16,10 +17,10 @@ class SharedPrefsCurrentLanguageRepository(private val preferences: SharedPrefer
}
}
override
fun
getLanguage
():
String
?
{
override
fun
getLanguage
():
String
?
{
return
preferences
.
getString
(
CURRENT_LANGUAGE
,
""
)
return
preferences
.
getString
(
CURRENT_LANGUAGE
,
Locale
.
getDefault
().
language
)
}
}
override
fun
getCountry
():
String
?
{
override
fun
getCountry
():
String
?
{
return
preferences
.
getString
(
CURRENT_LANGUAGE_COUNTRY
,
""
)
return
preferences
.
getString
(
CURRENT_LANGUAGE_COUNTRY
,
Locale
.
getDefault
().
country
)
}
}
}
}
app/src/main/java/chat/rocket/android/settings/presentation/SettingsPresenter.kt
View file @
9bcc0f5c
...
@@ -40,11 +40,12 @@ class SettingsPresenter @Inject constructor(
...
@@ -40,11 +40,12 @@ class SettingsPresenter @Inject constructor(
private
val
tokenRepository
:
TokenRepository
,
private
val
tokenRepository
:
TokenRepository
,
private
val
permissions
:
PermissionsInteractor
,
private
val
permissions
:
PermissionsInteractor
,
private
val
rocketChatClientFactory
:
RocketChatClientFactory
,
private
val
rocketChatClientFactory
:
RocketChatClientFactory
,
private
val
saveLanguageInteractor
:
SaveCurrentLanguageInteractor
,
val
getCurrentLanguageInteractor
:
GetCurrentLanguageInteractor
,
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
removeAccountInteractor
:
RemoveAccountInteractor
,
removeAccountInteractor
:
RemoveAccountInteractor
,
databaseManagerFactory
:
DatabaseManagerFactory
,
databaseManagerFactory
:
DatabaseManagerFactory
,
connectionManagerFactory
:
ConnectionManagerFactory
,
connectionManagerFactory
:
ConnectionManagerFactory
private
val
saveLanguageInteractor
:
SaveCurrentLanguageInteractor
)
:
CheckServerPresenter
(
)
:
CheckServerPresenter
(
strategy
=
strategy
,
strategy
=
strategy
,
factory
=
rocketChatClientFactory
,
factory
=
rocketChatClientFactory
,
...
@@ -92,7 +93,6 @@ class SettingsPresenter @Inject constructor(
...
@@ -92,7 +93,6 @@ class SettingsPresenter @Inject constructor(
fun
enableAnalyticsTracking
(
isEnabled
:
Boolean
)
{
fun
enableAnalyticsTracking
(
isEnabled
:
Boolean
)
{
analyticsTrackingInteractor
.
save
(
isEnabled
)
analyticsTrackingInteractor
.
save
(
isEnabled
)
}
}
fun
logout
()
{
fun
logout
()
{
...
...
app/src/main/java/chat/rocket/android/settings/ui/SettingsFragment.kt
View file @
9bcc0f5c
...
@@ -35,8 +35,10 @@ internal const val TAG_SETTINGS_FRAGMENT = "SettingsFragment"
...
@@ -35,8 +35,10 @@ internal const val TAG_SETTINGS_FRAGMENT = "SettingsFragment"
fun
newInstance
():
Fragment
=
SettingsFragment
()
fun
newInstance
():
Fragment
=
SettingsFragment
()
class
SettingsFragment
:
Fragment
(),
SettingsView
,
AppLanguageView
{
class
SettingsFragment
:
Fragment
(),
SettingsView
,
AppLanguageView
{
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
@Inject
lateinit
var
presenter
:
SettingsPresenter
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
presenter
:
SettingsPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -163,29 +165,45 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
...
@@ -163,29 +165,45 @@ class SettingsFragment : Fragment(), SettingsView, AppLanguageView {
private
fun
changeLanguage
()
{
private
fun
changeLanguage
()
{
context
?.
let
{
context
?.
let
{
val
locales
=
ArrayList
<
Pair
<
String
,
String
>>()
with
(
locales
)
{
add
(
Pair
(
"en"
,
""
))
add
(
Pair
(
"ar"
,
""
))
add
(
Pair
(
"de"
,
""
))
add
(
Pair
(
"es"
,
""
))
add
(
Pair
(
"fa"
,
""
))
add
(
Pair
(
"fr"
,
""
))
add
(
Pair
(
"hi"
,
"IN"
))
add
(
Pair
(
"it"
,
""
))
add
(
Pair
(
"ja"
,
""
))
add
(
Pair
(
"pt"
,
"BR"
))
add
(
Pair
(
"pt"
,
"PT"
))
add
(
Pair
(
"ru"
,
"RU"
))
add
(
Pair
(
"tr"
,
""
))
add
(
Pair
(
"uk"
,
""
))
add
(
Pair
(
"zh"
,
"CN"
))
add
(
Pair
(
"zh"
,
"TW"
))
}
val
selectedLanguage
=
presenter
.
getCurrentLanguageInteractor
.
getLanguage
()
val
selectedCountry
=
presenter
.
getCurrentLanguageInteractor
.
getCountry
()
var
localeIndex
=
-
1
locales
.
forEachIndexed
{
index
,
locale
->
// If country is specified, then return the respective locale, else return the
// first locale found if the language is as specified regardless of the country.
if
(
locale
.
first
==
selectedLanguage
&&
(
localeIndex
==
-
1
||
locale
.
second
==
selectedCountry
))
{
localeIndex
=
index
if
(
locale
.
second
==
selectedCountry
)
return
@forEachIndexed
}
}
// This is needed if none of the device locales is implemented in the app.
// By default, set locale will be English
if
(
localeIndex
==
-
1
)
localeIndex
=
0
AlertDialog
.
Builder
(
it
)
AlertDialog
.
Builder
(
it
)
.
setTitle
(
R
.
string
.
title_choose_language
)
.
setTitle
(
R
.
string
.
title_choose_language
)
.
setSingleChoiceItems
(
.
setSingleChoiceItems
(
resources
.
getStringArray
(
R
.
array
.
languages
),
-
1
resources
.
getStringArray
(
R
.
array
.
languages
),
localeIndex
)
{
dialog
,
option
->
)
{
dialog
,
option
->
when
(
option
)
{
updateLanguage
(
locales
[
option
].
first
,
locales
[
option
].
second
)
0
->
updateLanguage
(
"en"
)
1
->
updateLanguage
(
"ar"
)
2
->
updateLanguage
(
"de"
)
3
->
updateLanguage
(
"es"
)
4
->
updateLanguage
(
"fa"
)
5
->
updateLanguage
(
"fr"
)
6
->
updateLanguage
(
"hi"
,
"IN"
)
7
->
updateLanguage
(
"it"
)
8
->
updateLanguage
(
"ja"
)
9
->
updateLanguage
(
"pt"
,
"BR"
)
10
->
updateLanguage
(
"pt"
,
"PT"
)
11
->
updateLanguage
(
"ru"
,
"RU"
)
12
->
updateLanguage
(
"tr"
)
13
->
updateLanguage
(
"uk"
)
14
->
updateLanguage
(
"zh"
,
"CN"
)
15
->
updateLanguage
(
"zh"
,
"TW"
)
}
dialog
.
dismiss
()
dialog
.
dismiss
()
}
}
.
create
()
.
create
()
...
...
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