Browse Source

Localization in api level below 18 fixes

master
preyearegmi 6 years ago
parent
commit
692ab412ed
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 6
      app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java
  3. 63
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BaseActivity.java
  4. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java
  5. 41
      app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java
  6. 16
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java
  7. 3
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java
  8. 58
      app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java
  9. 4
      app/src/main/res/values-bn-rBD/strings.xml
  10. 50
      app/src/main/res/values-ru-rRU/strings.xml
  11. 0
      app/src/main/res/values-th/strings.xml

BIN
.idea/caches/build_file_checksums.ser

6
app/src/main/java/com/gmeremit/online/gmeremittance_native/GmeApplication.java

@ -174,9 +174,9 @@ public class GmeApplication extends MultiDexApplication {
}
}
public void updateResources(Resources res) {
this.resources=res;
}
// public void updateResources(Resources res) {
// this.resources=res;
// }
}
}

63
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BaseActivity.java

@ -2,23 +2,39 @@ package com.gmeremit.online.gmeremittance_native.base;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomProgressDialog;
import java.util.Locale;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_LOCALE;
public class BaseActivity extends AppCompatActivity implements BaseContractInterface {
private CustomProgressDialog dialog;
private boolean isProgressBarShowing;
private CustomAlertDialog customAlertDialog;
@Override
protected void attachBaseContext(Context newBase) {
String lang_code = GmeApplication.getStorage().getString(USER_PREFERRED_LOCALE, "en");
Context context = changeLang(newBase, lang_code);
super.attachBaseContext(context);
}
@Override
public void showProgressBar(boolean action, String message) {
try {
@ -61,9 +77,7 @@ public class BaseActivity extends AppCompatActivity implements BaseContractInter
customAlertDialog.show(fragmentManager, "CustomerMessage" + alertType.toString());
}
catch (Exception e)
{
} catch (Exception e) {
}
@ -105,5 +119,46 @@ public class BaseActivity extends AppCompatActivity implements BaseContractInter
}
}
public static ContextWrapper changeLang(Context context, String lang_code) {
Locale sysLocale;
Resources rs = context.getResources();
Configuration config = rs.getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
sysLocale = config.getLocales().get(0);
} else {
sysLocale = config.locale;
}
if (!lang_code.equals("") && !sysLocale.getLanguage().equals(lang_code)) {
Locale locale = new Locale(lang_code);
Locale.setDefault(locale);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
config.setLocale(locale);
} else {
config.locale = locale;
}
Resources resources = context.getResources();
resources.updateConfiguration(config, context.getResources().getDisplayMetrics());
// GmeApplication.getStringExtractor().updateResources(resources);
}
return new ContextWrapper(context);
}
public void restartApp()
{
try {
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
// restart(this,500);
}
catch(NullPointerException ne)
{
showToastMessage("Please restart app manually.");
}
}
}

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java

@ -444,7 +444,7 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra
getResources().getDisplayMetrics()
);
GmeApplication.getStringExtractor().updateResources(res);
// GmeApplication.getStringExtractor().updateResources(res);
try {
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());

41
app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java

@ -1,8 +1,6 @@
package com.gmeremit.online.gmeremittance_native.settings.view;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
@ -10,24 +8,24 @@ import android.view.View;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.changepasswordV2.view.ChangePasswordV2Activity;
import com.gmeremit.online.gmeremittance_native.settings.adapter.LanguageSelectionDialogRVAdapter;
import com.gmeremit.online.gmeremittance_native.splash_screen.model.LanguageModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import butterknife.ButterKnife;
import butterknife.OnClick;
import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFERRED_LOCALE;
/**
* Created by FMI-LT-17 on 2/20/2018.
*/
public class SettingsView extends AppCompatActivity {
public class SettingsView extends BaseActivity {
@Override
@ -60,8 +58,7 @@ public class SettingsView extends AppCompatActivity {
}
private void promptLanguageSelectionDialog()
{
private void promptLanguageSelectionDialog() {
LanguageSelectionListingDialog languageSelectionDialog = new LanguageSelectionListingDialog();
languageSelectionDialog.setLanguageData(getLanguagedata());
languageSelectionDialog.setListener(new LanguageSelectionDialogRVAdapter.LanguageSelectionListener() {
@ -77,34 +74,12 @@ public class SettingsView extends AppCompatActivity {
}
private void changeLocale(String localeCode) {
Locale locale = new Locale(localeCode);
Locale.setDefault(locale);
// Create a new configuration object
Configuration config = new Configuration();
// Set the locale of the new configuration
config.locale = locale;
// Update the configuration of the Accplication context
Resources res= getResources();
res.updateConfiguration(
config,
getResources().getDisplayMetrics()
);
GmeApplication.getStringExtractor().updateResources(res);
try {
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
catch(NullPointerException ne)
{
}
GmeApplication.getStorage().edit().putString(USER_PREFERRED_LOCALE, localeCode).apply();
restartApp();
}
private List<LanguageModel> getLanguagedata()
{
private List<LanguageModel> getLanguagedata() {
List<LanguageModel> models = new ArrayList<>();
models.add(new LanguageModel("BD", "bd", "Bangladesh"));
models.add(new LanguageModel("KH", "th", "Cambodia"));

16
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenter.java

@ -36,20 +36,4 @@ public class SplashScreenPresenter extends BasePresenter implements SplashScreen
this.gateway.updatePreferredLanguageToStorage(selectedLanguage.getCountryName());
}
@Override
public void checkIfUserHasPreferredLocale() {
String preferredLocale = this.gateway.getPreferredLocale();
if (preferredLocale != null && preferredLocale.length() > 0) {
this.view.updateLocaleGlobally(preferredLocale);
//TODO Incase you want to update flag or title to selected language too.
// this.languageModels = this.gateway.getRelatedLanguageData();
// if(languageModels!=null&&languageModels.size()>0) {
// for (LanguageModel languageModel : languageModels)
// {
// if(languageModel.getLocaleCode().equalsIgnoreCase(preferredLocale))
// this.view.updateSelectedLanguage(languageModel);
// }
// }
}
}
}

3
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/presenter/SplashScreenPresenterInterface.java

@ -12,7 +12,6 @@ public interface SplashScreenPresenterInterface extends BasePresenterInterface {
void updatePreferredLanguage(LanguageModel selectedLanguage);
void checkIfUserHasPreferredLocale();
interface SplashScreenContractInterfacee extends BaseContractInterface
{
@ -20,8 +19,6 @@ public interface SplashScreenPresenterInterface extends BasePresenterInterface {
void updateLanguageData(List<LanguageModel> languageModels);
void updateLocaleGlobally(String preferredLocale);
void updateSelectedLanguage(LanguageModel languageModel);
}
}

58
app/src/main/java/com/gmeremit/online/gmeremittance_native/splash_screen/view/SplashScreen.java

@ -111,10 +111,8 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
presenter=new SplashScreenPresenter(this);
//We want to check if user has selected any locale prior to binding view.
presenter.checkIfUserHasPreferredLocale();
setContentView(R.layout.activity_splash_screen_key_1);
ButterKnife.bind(this);
init();
performDefaultAction(savedInstanceState);
@ -128,7 +126,8 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
}
private void init() {
ButterKnife.bind(this);
presenter=new SplashScreenPresenter(this);
languageViewTransitionManager = new LanguageViewTransitionManager(this);
layouts = new int[]{
R.layout.fragment_splash_one,
@ -145,9 +144,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
languageSelectionRVAdapter.setLanguageSelectionListener(this);
languageRv.setAdapter(languageSelectionRVAdapter);
// KeyboardUtils.forceCloseKeyboard(view_pager.getRootView());
}
private void addBottomDots(int currentPage) {
@ -234,33 +230,13 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
@Override
public void onLangugageSelected(LanguageModel languageModel) {
if (this.selectedLanguage == null) {
this.selectedLanguage = languageModel;
changeLocale(this.selectedLanguage.getLocaleCode());
this.presenter.updatePreferredLanguage(this.selectedLanguage);
} else {
if (!this.selectedLanguage.getCountryCode().equalsIgnoreCase(languageModel.getCountryCode())) {
if (this.selectedLanguage == null||!this.selectedLanguage.getCountryCode().equalsIgnoreCase(languageModel.getCountryCode())) {
this.selectedLanguage = languageModel;
changeLocale(this.selectedLanguage.getLocaleCode());
this.presenter.updatePreferredLanguage(this.selectedLanguage);
}
restartApp();
}
}
private void changeLocale(String localeCode) {
updateLocaleGlobally(localeCode);
try {
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
// restart(this,500);
}
catch(NullPointerException ne)
{
}
// performLogout();
}
@Override
public void proceedToDashboardScreen() {
@ -273,30 +249,6 @@ public class SplashScreen extends BaseActivity implements View.OnClickListener,
languageSelectionRVAdapter.setData(languageModels);
}
@Override
public void updateLocaleGlobally(String preferredLocale) {
Locale locale = new Locale(preferredLocale);
Locale.setDefault(locale);
// Create a new configuration object
Configuration config = new Configuration();
// Set the locale of the new configuration
config.locale = locale;
// Update the configuration of the Accplication context
Resources res= getResources();
res.updateConfiguration(
config,
getResources().getDisplayMetrics()
);
GmeApplication.getStringExtractor().updateResources(res);
}
@Override
public void updateSelectedLanguage(LanguageModel languageModel) {
this.selectedLanguage=languageModel;
}
public class ViewPagerAdapter extends PagerAdapter {
private LayoutInflater layoutInflater;

4
app/src/main/res/values-bn-rBD/strings.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GME Remit</string>
</resources>

50
app/src/main/res/values-ru-rRU/strings.xml

@ -1,50 +0,0 @@
<resources>
<string name="app_name">GME Remit</string>
<string name="title_home">Home</string>
<string name="title_invite">Invite</string>
<string name="title_sendmoney">Send Money</string>
<string name="title_agents">Agents</string>
<string name="title_profile">Profile</string>
<!--fonts-->
<string name="regular">SanFranciscoText-Regular.otf</string>
<string name="semibold">SanFranciscoText-Semibold.otf</string>
<string name="bold">SanFranciscoText-Bold.otf</string>
<string name="heavy">SanFranciscoText-Heavy.otf</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="verify_account_text">Your document is in verification process. This will not take long. Thereafter you can enjoy GME online service.</string>
<string name="emptyTextFieldIndicator">Please add the required information.</string>
<string name="exit_confirmation_text">Are you sure want to exit ?</string>
<string name="positive_confirm">Yes</string>
<string name="negative_confirm">No</string>
<string name="customer_support_description">We are there to help you \n(Available time 10:00AM - 12:00AM)</string>
<string name="cancel">Cancel</string>
<string name="support_gmeremit">support@gmeremit.com</string>
<string name="about_gme">We are licensed by Ministry of Strategy &amp; Finance to operate as the first Non-Bank Remittance Service providers in South Korea. Meeting all compliance regulations set forward by the regulators was a tough journey but today we feel proud about what we have achieved and how robust our operations are as a result of the hard work completed earlier. We are now ready with a 100% compliant and secured system that guarantees your money will arrive safely in right hands every single time.</string>
<string name="support_information">For more information call at </string>
<string name="suggestions_feedback">Suggestions/Feedback</string>
<string name="transactions_amendment_request">Остнс</string>
<string name="general_enquiry">General Enquiry</string>
<string name="subject">Subject</string>
<string name="send_description">Hassle free money transfer to your \nloved ones</string>
<string name="community_description">Connect to local community</string>
<string name="reward_description">Earn reward points and get \nsurprise gifts</string>
<string name="general_enquiry_thank_you">Thank you for contacting us.</string>
<string name="drawer_user_number">GME Wallet No. </string>
<string name="change_password">Change Password</string>
<!-- No Internet Title and Content -->
<string name="no_internet_title">Whoops!</string>
<string name="no_internet_message">No Internet connection found. \nCheck your connection</string>
<string name="transferedto">You have successfully transferred your money to</string>
<string name="secret_info">Please keep this GME control no. very secure.\nShare with concerned party only</string>
<string name="invite_description">Refer to friend and get 7000KRW per refer when \nthey send money for the first time</string>
<string name="non_verified_info">Your verification is still in progress.</string>
<string name="remaining_limit_text" translatable="true">Остающийся годовой баланс</string>
</resources>

0
app/src/main/res/values-th-rTH/strings.xml → app/src/main/res/values-th/strings.xml

Loading…
Cancel
Save