Example usage for android.content.res Resources getConfiguration

List of usage examples for android.content.res Resources getConfiguration

Introduction

In this page you can find the example usage for android.content.res Resources getConfiguration.

Prototype

public Configuration getConfiguration() 

Source Link

Document

Return the current configuration that is in effect for this resource object.

Usage

From source file:Main.java

public static boolean isPortrait(Resources res) {
    return res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}

From source file:Main.java

public static boolean isNightMode(Resources resources) {
    return ((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) > 0);
}

From source file:Main.java

public static Locale getAppLanguage(Resources resources) {
    Configuration config = resources.getConfiguration();
    return config.locale;
}

From source file:Main.java

public static void normalFontSize(Resources resource) {
    Configuration configuration = resource.getConfiguration();
    configuration.fontScale = 1f;//  ww  w  . jav  a2  s.com
    resource.updateConfiguration(configuration, resource.getDisplayMetrics());
}

From source file:Main.java

static private void resetLocale(Resources res) {
    Configuration conf = new Configuration(res.getConfiguration());
    conf.locale = mCurLocale;//from   w  w  w .j av  a2 s .c om
    new Resources(res.getAssets(), res.getDisplayMetrics(), conf);
}

From source file:Main.java

public static boolean inPortarit(Resources res) {
    return (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
}

From source file:Main.java

public static void changeAppLanguage(Resources resources, String lanAtr) {
    Configuration config = resources.getConfiguration();
    DisplayMetrics dm = resources.getDisplayMetrics();
    if (lanAtr.equals("zh-cn")) {
        config.locale = Locale.SIMPLIFIED_CHINESE;
    } else {//from   w w w  . j  av a  2  s.c  o  m
        config.locale = Locale.getDefault();
    }
    resources.updateConfiguration(config, dm);
}

From source file:Main.java

public static void updateApplicationResourceLocale(Context context, Locale locale) {
    Resources resources = context.getResources();
    Configuration configuration = resources.getConfiguration();
    if (!configuration.locale.equals(locale)) {
        android.util.DisplayMetrics displaymetrics = resources.getDisplayMetrics();
        configuration.locale = locale;//w w  w.  j  ava2  s  . c  o  m
        resources.updateConfiguration(configuration, displaymetrics);
        Resources.getSystem().updateConfiguration(configuration, displaymetrics);
    }
}

From source file:Main.java

public static void updateResources(Context context, String language) {
    //set the language of the app
    Locale locale = new Locale(language);
    Locale.setDefault(locale);//from   w  w w.j a  va2 s.c om

    Resources resources = context.getResources();

    Configuration configuration = resources.getConfiguration();
    configuration.locale = locale;

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

From source file:Main.java

private static void updateResources(Context context, String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);/*from   www  .j  a  v a  2 s.  c  o m*/

    Resources resources = context.getResources();

    Configuration configuration = resources.getConfiguration();
    configuration.locale = locale;

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}