Example usage for android.content.res Configuration SCREENLAYOUT_LONG_YES

List of usage examples for android.content.res Configuration SCREENLAYOUT_LONG_YES

Introduction

In this page you can find the example usage for android.content.res Configuration SCREENLAYOUT_LONG_YES.

Prototype

int SCREENLAYOUT_LONG_YES

To view the source code for android.content.res Configuration SCREENLAYOUT_LONG_YES.

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_LONG_MASK value that corresponds to the long resource qualifier.

Usage

From source file:com.adjust.sdk.Util.java

private static String getScreenFormat(final int screenLayout) {
    final int screenFormat = screenLayout & Configuration.SCREENLAYOUT_LONG_MASK;

    switch (screenFormat) {
    case Configuration.SCREENLAYOUT_LONG_YES:
        return LONG;
    case Configuration.SCREENLAYOUT_LONG_NO:
        return NORMAL;
    default://  w w  w.  j a va 2  s .co m
        return UNKNOWN;
    }
}

From source file:de.androvdr.activities.AndroVDR.java

public void initWorkspaceView(Bundle savedInstanceState) {
    if (!Preferences.alternateLayout)
        setTheme(R.style.Theme_Original);

    logger.debug("Model: {}", Build.MODEL);
    logger.debug("SDK Version: {}", Build.VERSION.SDK_INT);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    logger.debug("Width: {}", metrics.widthPixels);
    logger.debug("Height: {}", metrics.heightPixels);
    logger.debug("Density: {}", metrics.densityDpi);

    Configuration conf = getResources().getConfiguration();
    boolean screenSmall = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL);
    boolean screenNormal = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_NORMAL) == Configuration.SCREENLAYOUT_SIZE_NORMAL);
    boolean screenLong = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_LONG_YES) == Configuration.SCREENLAYOUT_LONG_YES);
    boolean screenLarge = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_LARGE) == Configuration.SCREENLAYOUT_SIZE_LARGE);
    boolean screenXLarge = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_XLARGE) == Configuration.SCREENLAYOUT_SIZE_XLARGE);

    logger.debug("Screen Small: {}", screenSmall);
    logger.debug("Screen Normal: {}", screenNormal);
    logger.debug("Screen Long: {}", screenLong);
    logger.debug("Screen Large: {}", screenLarge);
    logger.debug("Screen XLarge: {}", screenXLarge);

    if (screenSmall)
        Preferences.screenSize = Preferences.SCREENSIZE_SMALL;
    if (screenNormal)
        Preferences.screenSize = Preferences.SCREENSIZE_NORMAL;
    if (screenLong)
        Preferences.screenSize = Preferences.SCREENSIZE_LONG;
    if (screenLarge)
        Preferences.screenSize = Preferences.SCREENSIZE_LARGE;
    if (screenXLarge)
        Preferences.screenSize = Preferences.SCREENSIZE_XLARGE;
    logger.trace("Screen size: {}", Preferences.screenSize);

    // --- init default text size for buttons ---
    TextResizeButton.resetDefaultTextSize();
    TextResizeButton rb = (TextResizeButton) LayoutInflater.from(this).inflate(R.layout.reference_button, null);
    if ((Preferences.screenSize >= Preferences.SCREENSIZE_LARGE)
            && (metrics.widthPixels > metrics.heightPixels))
        rb.setTextSizeAsDefault(metrics.widthPixels / 2 / 5, 100);
    else/*from w  w  w.  j  a v a 2 s  .  com*/
        rb.setTextSizeAsDefault(Math.min(metrics.widthPixels, metrics.heightPixels) / 4, 100);
    logger.debug("Default TextSize (px): {}", rb.getTextSize());

    // --- landscape mode only on large displays ---
    if (Preferences.screenSize < Preferences.SCREENSIZE_LARGE) {
        logger.trace("setting SCREEN_ORIENTATION_PORTRAIT");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    setContentView(R.layout.remote_pager);
    mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);

    LinePageIndicator indicator = (LinePageIndicator) findViewById(R.id.titles);
    if (mPagerAdapter.getCount() > 1) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        int last = sp.getInt("remote_last_page", 0);
        if (last < mPagerAdapter.getCount())
            indicator.setViewPager(mPager, last);
        else
            indicator.setViewPager(mPager);
    } else {
        indicator.setVisibility(View.GONE);
    }

    // --- show current channel in status bar ---
    if (Preferences.screenSize < Preferences.SCREENSIZE_XLARGE)
        mDevices.addOnSensorChangeListener("VDR.channel", 1, new OnSensorChangeListener() {
            @Override
            public void onChange(String result) {
                logger.trace("Channel: {}", result);
                Message msg = Message.obtain(mSensorHandler, SENSOR_CHANNEL);
                Bundle bundle = new Bundle();
                bundle.putString(MSG_RESULT, result);
                msg.setData(bundle);
                msg.sendToTarget();
            }
        });

    mDevices.startSensorUpdater(0);
}