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:com.atwal.wakeup.battery.util.Utilities.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRtl(Resources res) {
    return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            && (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}

From source file:android.content.res.VectorResources.java

public VectorResources(Context context, Resources res) {
    super(res.getAssets(), res.getDisplayMetrics(), res.getConfiguration());
    mContext = context;//from ww w  . ja  v a 2 s .c o m
    mBase = res;
}

From source file:com.anykey.balala.activity.BaseActivity.java

@Override
protected void onResume() {
    //?/*  w  w w.j a va  2s .  c o  m*/
    Resources resource = getResources();
    Configuration c = resource.getConfiguration();
    c.fontScale = 1.0f;
    resource.updateConfiguration(c, resource.getDisplayMetrics());
    super.onResume();
    TCAgent.onResume(this);
    MobclickAgent.onResume(this);
    AppsFlyerLib.onActivityResume(this);
}

From source file:co.edu.uniajc.vtf.content.controller.SettingsController.java

private void setLocal(String pISOLang) {
    Locale loLocale = new Locale(pISOLang);
    Resources loResource = ((Fragment) this.coView).getResources();
    DisplayMetrics loDm = loResource.getDisplayMetrics();
    Configuration loConfig = loResource.getConfiguration();
    loConfig.locale = loLocale;/*  w w  w . j  a v  a2  s.c  o m*/
    loResource.updateConfiguration(loConfig, loDm);
}

From source file:org.mariotaku.twidere.activity.DualPaneActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, false);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, false);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape ? getDualPaneLayoutRes() : getNormalLayoutRes();
        break;/*from  ww  w . ja  v a  2s . com*/
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait ? getDualPaneLayoutRes() : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    final View pane_right = findViewById(PANE_RIGHT);
    if (pane_right != null) {
        pane_right.setBackgroundResource(getPaneBackground());
    }
    getSupportFragmentManager().addOnBackStackChangedListener(this);
}

From source file:org.mariotaku.twidere.activity.DualPaneActivity.java

@Override
protected void onStart() {
    final FragmentManager fm = getSupportFragmentManager();
    if (!isDualPaneMode() && !FragmentManagerTrojan.isStateSaved(fm)) {
        final int count = fm.getBackStackEntryCount();
        for (int i = 0; i < count; i++) {
            fm.popBackStackImmediate();// w  w w .ja va2 s  . co  m
        }
    }
    super.onStart();
    final boolean dual_pane_in_portrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, false);
    final boolean dual_pane_in_landscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE,
            false);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        if (mDualPaneInLandscape != dual_pane_in_landscape) {
            restart();
        }
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        if (mDualPaneInPortrait != dual_pane_in_portrait) {
            restart();
        }
        break;
    }
}

From source file:br.com.frs.foodrestrictions.FoodMessages.java

@Override
public void onItemSelected(AdapterView<?> adapterView, View v, int i, long l) {

    /* //TODO - Find a better way of doing it
     * I don't believe that this is the best approach to handle this problem but it is
     * the only way I found to do it so far. Do you have any better idea?
     * please help me here :D/*  w w  w .  ja  va  2 s.  c  o  m*/
     */

    /* Getting the current resource  and config info */
    Resources rsc = v.getContext().getResources();
    Configuration config = new Configuration(rsc.getConfiguration());
    /* Saving the original locale before changing to the new one
     * just to show the texts
     */
    Locale orgLocale = config.locale;

    /* Changing the language to the one the user have selected based on the
     * Languages.xml file
     */
    switch (i) {
    /* English */
    case 0:
        config.locale = new Locale("en");
        break;
    /* Portuguese */
    case 1:
        config.locale = new Locale("pt");
        break;
    }

    /* Setting the new locale */
    rsc.updateConfiguration(config, rsc.getDisplayMetrics());
    refreshMessages(v);

    /* Updating the layout with the new selected language */

    /* Return to last locale to keep the app as it was before */
    config.locale = orgLocale;
    rsc.updateConfiguration(config, rsc.getDisplayMetrics());
}

From source file:com.vrem.wifianalyzer.MainActivity.java

private boolean isLargeScreen() {
    Resources resources = getResources();
    android.content.res.Configuration configuration = resources.getConfiguration();
    int screenLayoutSize = configuration.screenLayout
            & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK;
    return screenLayoutSize == android.content.res.Configuration.SCREENLAYOUT_SIZE_LARGE
            || screenLayoutSize == android.content.res.Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:com.aqnote.app.wifianalyzer.MainActivity.java

private boolean isLargeScreenLayout() {
    Resources resources = getResources();
    android.content.res.Configuration configuration = resources.getConfiguration();
    int screenLayoutSize = configuration.screenLayout
            & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK;
    return screenLayoutSize == android.content.res.Configuration.SCREENLAYOUT_SIZE_LARGE
            || screenLayoutSize == android.content.res.Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onCreate(savedInstanceState);
    final Resources res = getResources();
    final int orientation = res.getConfiguration().orientation;
    final int layout;
    final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen);
    mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen);
    mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen);
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();/*from w  ww. ja  v  a  2s.co m*/
        break;
    case Configuration.ORIENTATION_PORTRAIT:
        layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes()
                : getNormalLayoutRes();
        break;
    default:
        layout = getNormalLayoutRes();
        break;
    }
    setContentView(layout);
    if (mSlidingPane != null) {
        mSlidingPane.setRightPaneBackground(getPaneBackground());
    }
    final FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
    if (savedInstanceState != null) {
        final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT);
        final View main_view = findViewById(R.id.main);
        final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded();
        if (main_view != null) {
            final int visibility = left_pane_used ? View.GONE : View.VISIBLE;
            main_view.setVisibility(visibility);
        }
    }
}