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

fix #1009: New instance of home created only if language is changed #1016

Merged
Merged
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 @@ -2,26 +2,37 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;

import org.mifos.mobilebanking.R;
import org.mifos.mobilebanking.ui.activities.base.BaseActivity;
import org.mifos.mobilebanking.ui.fragments.SettingsFragment;
import org.mifos.mobilebanking.utils.Constants;

public class SettingsActivity extends BaseActivity {

private boolean hasSettingsChanged;
rahul-jha98 marked this conversation as resolved.
Show resolved Hide resolved

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
setToolbarTitle(getString(R.string.settings));
showBackButton();
replaceFragment(SettingsFragment.newInstance(), false, R.id.container);
if (getIntent().hasExtra(Constants.HAS_SETTINGS_CHANGED)) {
hasSettingsChanged = getIntent().getBooleanExtra(Constants.HAS_SETTINGS_CHANGED,
false);
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
Intent i = new Intent(this, HomeActivity.class);
startActivity(i);
if (hasSettingsChanged) {
ActivityCompat.finishAffinity(this);
rahul-jha98 marked this conversation as resolved.
Show resolved Hide resolved
Intent i = new Intent(this, HomeActivity.class);
startActivity(i);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.mifos.mobilebanking.R;
import org.mifos.mobilebanking.utils.ConfigurationPreference;
import org.mifos.mobilebanking.utils.ConfigurationDialogFragmentCompat;
import org.mifos.mobilebanking.utils.Constants;
import org.mifos.mobilebanking.utils.LanguageHelper;

/**
Expand Down Expand Up @@ -68,7 +69,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
LanguageHelper.setLocale(getContext(), listPreference.getValue());
startActivity(new Intent(getActivity(), getActivity().getClass()));
Intent intent = new Intent(getActivity(), getActivity().getClass());
intent.putExtra(Constants.HAS_SETTINGS_CHANGED, true);
startActivity(intent);
getActivity().finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ public class Constants {
public static final String INDEX = "index";

public static final String DATE_PICKER_TYPE = "datePickerType";

public static final String HAS_SETTINGS_CHANGED = "hasSettingsChanged";
}