Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_MASK

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_MASK

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

Click Source Link

Document

Constant for #screenLayout : bits that encode the size.

Usage

From source file:com.near.chimerarevo.fragments.AboutContainerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about_container_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*from ww w .j a v  a2s  .  c o m*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    ViewPager pager = (ViewPager) v.findViewById(R.id.view_pager);
    pager.setAdapter(new AboutPagerAdapter());

    return v;
}

From source file:whipkey.stemesteem.components.EndingListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {/*from w w  w . ja  va2s  .c om*/
        dialogClickListener = (DialogItemClickListener) activity;
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) < Configuration.SCREENLAYOUT_SIZE_LARGE) {
            i = activity.getIntent();
            b = i.getExtras();
        } // the above is skipped if we are on a large/xlarge device,
          // because we have no intent (one activity, not two).

    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + "needs to implement DialogClickListener");
    }
}

From source file:com.near.chimerarevo.fragments.WebFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.webview_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*from w w w. ja v  a  2 s.  co m*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    mWebView = (WebView) v.findViewById(R.id.webview);
    mProgressContainer = v.findViewById(R.id.progressContainer);
    mWebContainer = v.findViewById(R.id.webViewContainer);

    return v;
}

From source file:org.exoplatform.accountswitcher.AccountSwitcherActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boolean isDialog = false;
    // Detect the size of the screen and set a theme "Dialog" to display the
    // activity as a dialog
    // if the screen is LARGE or XLARGE
    // TODO find how to set the black background translucent
    int screenLayout = getResources().getConfiguration().screenLayout;
    screenLayout &= Configuration.SCREENLAYOUT_SIZE_MASK;
    if (screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE
            || screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        setTheme(R.style.Theme_eXo_Dialog);
        isDialog = true;//w ww  . ja v  a2s .co  m
    }
    Log.i(TAG, "Start account switcher in mode: " + (isDialog ? "dialog" : "activity"));

    setContentView(R.layout.account_switcher_activity);

    getSupportFragmentManager().beginTransaction().add(R.id.share_extension_fragment,
            new AccountSwitcherFragment(), AccountSwitcherFragment.FRAGMENT_TAG).commit();
}

From source file:com.iangclifton.auid.appendixc.sections.VariousDemosFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.various_demos, container, false);

    final StringBuilder sb = new StringBuilder();

    // Create a String for the device physical size
    switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        // Extra large (most 10" tablets)
        sb.append(getString(R.string.configuration_xlarge));
        break;//  w  w w . ja  va  2s.c  o  m
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        // Large (most 7" tablets)
        sb.append(getString(R.string.configuration_large));
        break;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        // Normal (most phones)
        sb.append(getString(R.string.configuration_normal));
        break;
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        // Small (very uncommon)
        sb.append(getString(R.string.configuration_small));
        break;
    default:
        sb.append(getString(R.string.configuration_unknown));
        break;
    }
    sb.append('\n');

    // Create a String for the display density
    switch (getResources().getDisplayMetrics().densityDpi) {
    case DisplayMetrics.DENSITY_XXHIGH:
        // Display is around 480 pixels per inch
        sb.append(getString(R.string.density_xxhdpi));
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        // Display is around 320 pixels per inch
        sb.append(getString(R.string.density_xhdpi));
        break;
    case DisplayMetrics.DENSITY_HIGH:
        // Display is around 240 pixels per inch
        sb.append(getString(R.string.density_hdpi));
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        // Display is around 160 pixels per inch
        sb.append(getString(R.string.density_mdpi));
        break;
    case DisplayMetrics.DENSITY_LOW:
        // Display is around 120 pixels per inch
        sb.append(getString(R.string.density_ldpi));
        break;
    case DisplayMetrics.DENSITY_TV:
        // Display is a 720p TV screen
        // Sometimes also used for 1280x720 7" tablets
        // Rarely should you ever specifically target this density
        sb.append(getString(R.string.density_tv));
        break;
    default:
        sb.append(getString(R.string.density_unknown));
        break;
    }
    sb.append('\n');

    // Create a String for the thread we're on
    // Obviously this method is always called on the main thread but this technique can be used anywhere.
    if (Utils.isUiThread()) {
        // UI Thread
        sb.append(getString(R.string.main_thread_true));
    } else {
        // Other Thread
        sb.append(getString(R.string.main_thread_false));
    }
    sb.append(" (Thread name: ").append(Thread.currentThread().getName()).append(')');

    // Set text
    final TextView tv = (TextView) rootView.findViewById(R.id.main_text);
    tv.setText(sb);

    return rootView;
}

From source file:ch.rts.cordova.is.tablet.IsTablet.java

private boolean isTabletDevice(Context applicationContext) {
    boolean device_large = ((applicationContext.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (device_large) {
        DisplayMetrics metrics = new DisplayMetrics();
        Activity activity = this.cordova.getActivity();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
                || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
                || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
                || metrics.densityDpi == DisplayMetrics.DENSITY_TV
                || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) {
            Log.d(LOG_TAG, "Is Tablet Device");
            return true;
        }/*from  w ww.ja  v  a  2 s .c  om*/
    }
    Log.d(LOG_TAG, "Is NOT Tablet Device");
    return false;
}

From source file:uk.co.workingedge.phonegap.plugin.IsTablet.java

private boolean isTabletDevice(Context applicationContext) {
    boolean device_large = ((applicationContext.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (device_large) {
        DisplayMetrics metrics = new DisplayMetrics();
        Activity activity = this.cordova.getActivity();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
                || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
                || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
                || metrics.densityDpi == DisplayMetrics.DENSITY_TV
                || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH
                || metrics.densityDpi == DisplayMetrics.DENSITY_XXHIGH) {
            Log.d(LOG_TAG, "Is Tablet Device");
            return true;
        }/*w  ww  . ja  v a  2 s  .c  o m*/
    }
    Log.d(LOG_TAG, "Is NOT Tablet Device");
    return false;
}

From source file:com.thiagorosa.robotita.ActivityMain.java

@Override
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity);/*from w  w  w.j  av a  2  s. c  o m*/

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {
            View decorView = getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(uiOptions);
        }
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.theme_secondary));
    }

    if (savedInstanceState == null) {
        if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
            FragmentManager.BackStackEntry first = getSupportFragmentManager().getBackStackEntryAt(0);
            getSupportFragmentManager().popBackStack(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
        }

        Fragment fragment = new FragmentMain();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right,
                R.anim.slide_out_right);
        transaction.replace(R.id.fragment, fragment, "fragment");
        transaction.addToBackStack("main");
        transaction.commitAllowingStateLoss();

        if (!TextUtils.isEmpty(PreferencesManager.getDeviceMAC(getApplicationContext()))) {
            Bundle args = new Bundle();
            args.putString(FragmentDeviceList.EXTRA_MAC,
                    PreferencesManager.getDeviceMAC(getApplicationContext()));

            Fragment fragmentDevice = new FragmentDeviceList();
            fragmentDevice.setArguments(args);
            FragmentTransaction transactionDevice = getSupportFragmentManager().beginTransaction();
            transactionDevice.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left,
                    R.anim.slide_in_right, R.anim.slide_out_right);
            transactionDevice.replace(R.id.fragment, fragmentDevice, "fragment");
            transactionDevice.addToBackStack("device");
            transactionDevice.commitAllowingStateLoss();
        }
    }

}

From source file:de.wikilab.android.friendica01.Max.java

public static boolean isLarge(Configuration c) {
    return (((c.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
            || ((c.screenLayout/*from w  w  w  .  ja  v  a  2s.  co m*/
                    & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE));
}

From source file:eu.alefzero.owncloud.ui.activity.FileDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity 
    Configuration conf = getResources().getConfiguration();
    mConfigurationChangedToLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (conf.screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (!mConfigurationChangedToLandscape) {
        setContentView(R.layout.file_activity_details);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        OCFile file = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
        Account account = getIntent().getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);
        FileDetailFragment mFileDetail = new FileDetailFragment(file, account);

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.fragment, mFileDetail, FileDetailFragment.FTAG);
        ft.commit();//  w  w  w .  j a  v  a  2 s  .c  om

    } else {
        backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;
    }

}