/**
 * Copyright (C) 2021 SIL International. All rights reserved.
 */

package com.tavultesoft.kmea;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.LocaleList;

import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;

import com.tavultesoft.kmea.util.ContextUtils;

import java.util.Locale;

public class BaseActivity extends AppCompatActivity {

  @Override
  protected void attachBaseContext(Context newBase) {
    // Override the app locale using the BCP 47 tag from shared preferences
    // Using PreferenceManager because this is before onCreate()
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(newBase);
    String languageTag  = prefs.getString(DisplayLanguages.displayLanguageKey, DisplayLanguages.unspecifiedLocale);
    Locale localeToSwitchTo;
    if (languageTag == null || languageTag.equals(DisplayLanguages.unspecifiedLocale)) {
      // If display language not specified, use the default locale
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        super.attachBaseContext(newBase);
        return;
      }
      localeToSwitchTo = LocaleList.getDefault().get(0);
    } else {
      localeToSwitchTo = Locale.forLanguageTag(languageTag);
    }
    ContextWrapper localeUpdatedContext = ContextUtils.updateLocale(newBase, localeToSwitchTo);
    super.attachBaseContext(localeUpdatedContext);
  }

}

@@ -263,16 +263,46 @@
 leList;%0A
+import android.widget.Toast;%0A%0A
 %0Aimport 
@@ -517,16 +517,705 @@
 tivity %7B
+%0A  static ContextWrapper localeUpdatedContext;%0A%0A  /**%0A   * Some classes aren't an AppCompatActivity and need this helper to localize Toast notifications%0A   * in the updated locale.%0A   * @param defaultContext - the context to fallback if localeUpdatedContext is null%0A   * @param resID - resource ID of the string%0A   * @param duration - length of the Toast notification (Toast.LENGTH_LONG or Toast.LENGTH_SHORT)%0A   */%0A  public static void makeToast(Context defaultContext, int resID, int duration) %7B%0A    Context context = (localeUpdatedContext != null) ? localeUpdatedContext : defaultContext;%0A    String msg = context.getString(resID);%0A    Toast.makeText(context, msg, duration).show();%0A  %7D
 %0A%0A  @Ove
@@ -2068,31 +2068,21 @@
   %7D%0A    
-ContextWrapper 
+this.
 localeUp

Add help method to localize Toast notifications