Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved localization handling on screen turn (might fix issue #125) #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ public void setWindowParameters(Activity activity) {
} else {
activity.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setLocale(activity);
}

//Get default locale at startup, as somehow it seems that changing the app's
//configured locale impacts the value returned by Locale.getDefault() nowadays.
private final Locale defaultLocale = Locale.getDefault();

@SuppressLint("NewApi")
public boolean setLocale(Activity context) {
Resources res = context.getResources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.gpl.rpg.AndorsTrail.R;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class AboutActivity extends Activity implements ImageGetter {
public final class AboutActivity extends AndorsTrailBaseActivity implements ImageGetter {

/** Called when the activity is first created. */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.gpl.rpg.AndorsTrail.view.AbilityModifierInfoView;
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView_OnUse;

public final class ActorConditionInfoActivity extends Activity {
public final class ActorConditionInfoActivity extends AndorsTrailBaseActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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);
app.setLocale(this);
}

@Override
protected void onResume() {
super.onResume();
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
app.setLocale(this);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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);
app.setLocale(this);
}

@Override
protected void onResume() {
super.onResume();
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
app.setLocale(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author ejwessel
* Creates the BulkSelectionInterface dialog that allows for buy/drop/selling
*/
public final class BulkSelectionInterface extends Activity implements TextWatcher {
public final class BulkSelectionInterface extends AndorsTrailBaseActivity implements TextWatcher {

// class variables
public static enum BulkInterfaceType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class ConversationActivity
extends Activity
extends AndorsTrailBaseActivity
implements OnKeyListener
, ConversationController.ConversationStatemachine.ConversationStateListener {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gpl.rpg.AndorsTrail.activity;

import java.io.File;

import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.R;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
Expand All @@ -24,7 +24,7 @@
import android.widget.Button;
import android.widget.Toast;

public final class DisplayWorldMapActivity extends Activity {
public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
private WorldContext world;

private WebView displayworldmap_webview;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gpl.rpg.AndorsTrail.activity;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
Expand All @@ -18,7 +19,7 @@
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class HeroinfoActivity extends FragmentActivity {
public final class HeroinfoActivity extends AndorsTrailBaseFragmentActivity {
private WorldContext world;

private FragmentTabHost tabHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;

public final class ItemInfoActivity extends Activity {
public final class ItemInfoActivity extends AndorsTrailBaseActivity {

public static enum ItemInfoAction {
none, use, equip, unequip, buy, sell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class LevelUpActivity extends Activity {
public final class LevelUpActivity extends AndorsTrailBaseActivity {
private WorldContext world;
private ControllerContext controllers;
private Player player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;

public final class LoadSaveActivity extends Activity implements OnClickListener {
public final class LoadSaveActivity extends AndorsTrailBaseActivity implements OnClickListener {
private boolean isLoading = true;
private static final int SLOT_NUMBER_CREATE_NEW_SLOT = -1;
private static final int SLOT_NUMBER_FIRST_SLOT = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
import com.gpl.rpg.AndorsTrail.view.CustomDialogFactory;

public final class LoadingActivity extends Activity implements OnResourcesLoadedListener, OnSceneLoadedListener {
public final class LoadingActivity extends AndorsTrailBaseActivity implements OnResourcesLoadedListener, OnSceneLoadedListener {

private WorldSetup setup;
private Dialog progressDialog;
private CloudsAnimatorView clouds_back, clouds_mid, clouds_front;
boolean loaded = false;

private Object semaphore = new Object();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import com.gpl.rpg.AndorsTrail.view.VirtualDpadView;

public final class MainActivity
extends Activity
extends AndorsTrailBaseActivity
implements
PlayerMovementListener
, CombatActionListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class MonsterEncounterActivity extends Activity {
public final class MonsterEncounterActivity extends AndorsTrailBaseActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.gpl.rpg.AndorsTrail.view.RangeBar;
import com.gpl.rpg.AndorsTrail.view.TraitsInfoView;

public final class MonsterInfoActivity extends Activity {
public final class MonsterInfoActivity extends AndorsTrailBaseActivity {

private WorldContext world;
private ControllerContext controllers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ protected void onCreate(Bundle savedInstanceState) {
setTheme(ThemeHelper.getBaseTheme());
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
if (AndorsTrailApplication.getApplicationFromActivity(this).getPreferences().fullscreen) {
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
if (app.getPreferences().fullscreen) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

app.setLocale(this);
addPreferencesFromResource(R.xml.preferences);
}

@Override
protected void onResume() {
super.onResume();
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
app.setLocale(this);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.gpl.rpg.AndorsTrail.activity.fragment.ShopActivity_Sell;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class ShopActivity extends FragmentActivity {
public final class ShopActivity extends AndorsTrailBaseFragmentActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;

public final class SkillInfoActivity extends Activity {
public final class SkillInfoActivity extends AndorsTrailBaseActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import android.widget.TextView;
import android.widget.Toast;

public final class StartScreenActivity extends FragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
public final class StartScreenActivity extends AndorsTrailBaseFragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {

private TextView tv;
private TextView development_version;
Expand Down