That fuck shit the fascists are using
at master 56 lines 1.6 kB view raw
1package org.tm.archive.util; 2 3import android.app.Activity; 4import android.app.Service; 5import android.content.Context; 6import android.content.res.Configuration; 7 8import org.tm.archive.keyvalue.SignalStore; 9import org.tm.archive.util.dynamiclanguage.LanguageString; 10 11import java.util.Locale; 12 13/** 14 * @deprecated Use a base activity that uses the {@link org.tm.archive.util.dynamiclanguage.DynamicLanguageContextWrapper} 15 */ 16@Deprecated 17public class DynamicLanguage { 18 19 public void onCreate(Activity activity) { 20 } 21 22 public void onResume(Activity activity) { 23 } 24 25 public void updateServiceLocale(Service service) { 26 setContextLocale(service, getSelectedLocale(service)); 27 } 28 29 public Locale getCurrentLocale() { 30 return Locale.getDefault(); 31 } 32 33 static int getLayoutDirection(Context context) { 34 Configuration configuration = context.getResources().getConfiguration(); 35 return configuration.getLayoutDirection(); 36 } 37 38 private static void setContextLocale(Context context, Locale selectedLocale) { 39 Configuration configuration = context.getResources().getConfiguration(); 40 41 if (!configuration.locale.equals(selectedLocale)) { 42 configuration.setLocale(selectedLocale); 43 context.getResources().updateConfiguration(configuration, 44 context.getResources().getDisplayMetrics()); 45 } 46 } 47 48 private static Locale getSelectedLocale(Context context) { 49 Locale locale = LanguageString.parseLocale(SignalStore.settings().getLanguage()); 50 if (locale == null) { 51 return Locale.getDefault(); 52 } else { 53 return locale; 54 } 55 } 56}