Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
9743255c
There was a problem fetching the pipeline metadata.
Verified
Commit
9743255c
authored
6 years ago
by
Julian Dehm
Browse files
Options
Downloads
Patches
Plain Diff
immutable version
parent
fc99dedb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/main/java/org/briarproject/briar/android/Localizer.java
+23
-13
23 additions, 13 deletions
...c/main/java/org/briarproject/briar/android/Localizer.java
with
23 additions
and
13 deletions
briar-android/src/main/java/org/briarproject/briar/android/Localizer.java
+
23
−
13
View file @
9743255c
...
...
@@ -21,21 +21,32 @@ public class Localizer {
@Nullable
private
static
Localizer
INSTANCE
;
private
final
Locale
systemLocale
;
// Locking: this
@Nullable
private
Locale
l
ocale
;
private
final
Locale
userL
ocale
;
private
Localizer
(
SharedPreferences
sharedPreferences
)
{
systemLocale
=
Locale
.
getDefault
();
l
ocale
=
getLocaleFromTag
(
userL
ocale
=
getLocaleFromTag
(
sharedPreferences
.
getString
(
LANGUAGE
,
"default"
));
}
private
Localizer
(
Locale
systemLocale
,
@Nullable
Locale
userLocale
)
{
this
.
systemLocale
=
systemLocale
;
this
.
userLocale
=
userLocale
;
}
// Instantiate the Localizer.
public
static
synchronized
void
initialize
(
SharedPreferences
prefs
)
{
if
(
INSTANCE
==
null
)
INSTANCE
=
new
Localizer
(
prefs
);
}
// Reinstantiate the Localizer with the system locale
private
static
synchronized
void
reinitialize
(
Locale
systemLocale
)
{
INSTANCE
=
new
Localizer
(
systemLocale
,
null
);
}
// Get the current instance.
public
static
synchronized
Localizer
getInstance
()
{
if
(
INSTANCE
==
null
)
throw
new
IllegalStateException
(
"Localizer not initialized"
);
...
...
@@ -44,7 +55,7 @@ public class Localizer {
// Reset to the system locale
public
synchronized
void
reset
()
{
locale
=
systemLocale
;
reinitialize
(
systemLocale
)
;
}
// Get Locale from BCP-47 tag
...
...
@@ -66,19 +77,18 @@ public class Localizer {
public
Context
setLocale
(
Context
context
)
{
Resources
res
=
context
.
getResources
();
Configuration
conf
=
res
.
getConfiguration
();
Locale
currentLocale
;
Locale
locale
,
currentLocale
;
if
(
SDK_INT
>=
24
)
{
currentLocale
=
conf
.
getLocales
().
get
(
0
);
}
else
currentLocale
=
conf
.
locale
;
synchronized
(
this
)
{
if
(
locale
==
null
)
{
// Detect if the user changed the system language
if
(
systemLocale
.
equals
(
currentLocale
))
return
context
;
locale
=
systemLocale
;
}
}
if
(
userLocale
==
null
)
{
// Detect if the user changed the system language
if
(
systemLocale
.
equals
(
currentLocale
))
return
context
;
locale
=
systemLocale
;
}
else
locale
=
userLocale
;
if
(
locale
.
equals
(
currentLocale
))
return
context
;
Locale
.
setDefault
(
locale
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment