forked from Zukero/andors-trail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved localization handling on screen turn (might fix issue Zukero…
…#125) - in some activities the code for setting the locale was missing and therefore a simple turn of the device switched to localized texts even if localized resources were disabled - for all other activities there was the problem that the locale was set only in onCreate but in some special cases the config is reset but only onResume gets called (e.g. when turning the device, hitting the home button, turning the device back and then switching to AT again). Setting it only in onResume would be too late for the regular cases. The code is almost a noop if there is no change to be done so it seems ok to call it twice. - created two baseclasses for activities to encapsulate the logic and increase the chance that a new activity will be based on that classes and the code will not be forgotten - might fix issue Zukero#125 "Localized resources showing even when disabled" - ways of working solutions for setting the locale differ from API level to API level (see https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758) - tested on android Pie and Marshmallow
- Loading branch information
Showing
20 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/AndorsTrailBaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.gpl.rpg.AndorsTrail.activity; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; | ||
|
||
public abstract class AndorsTrailBaseActivity extends Activity { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this); | ||
if (!app.isInitialized()) { | ||
return; | ||
} | ||
app.setLocale(this); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this); | ||
app.setLocale(this); | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/AndorsTrailBaseFragmentActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gpl.rpg.AndorsTrail.activity; | ||
|
||
import android.app.Activity; | ||
import android.content.res.Resources; | ||
import android.os.Bundle; | ||
import android.support.v4.app.FragmentActivity; | ||
|
||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; | ||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper; | ||
|
||
public abstract class AndorsTrailBaseFragmentActivity extends FragmentActivity { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this); | ||
if (!app.isInitialized()) { | ||
return; | ||
} | ||
app.setLocale(this); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this); | ||
app.setLocale(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters