Skip to content

Commit

Permalink
Fix change locale not working after migratio to androidx bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Rkareko authored and ndegwamartin committed Nov 25, 2020
1 parent 99a954e commit bf4b926
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion opensrp-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ dependencies {
implementation 'net.zetetic:android-database-sqlcipher:4.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.codehaus.jackson:jackson-core-asl:1.9.13'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "org.apache.httpcomponents:httpmime:4.5.6"
implementation group: 'commons-codec', name: 'commons-codec', version: '1.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ protected void attachBaseContext(android.content.Context base) {
super.attachBaseContext(LangUtils.setAppLocale(base, lang));
}

//solution borrowed from
// https://stackoverflow.com/questions/55265834/change-locale-not-work-after-migrate-to-androidx/61420643#61420643
@Override
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
// add this to fix androidx.appcompat:appcompat 1.1.0 bug
// which happens on Android 6.x ~ 7.x
getResources();
}
super.applyOverrideConfiguration(overrideConfiguration);
}

}

0 comments on commit bf4b926

Please sign in to comment.