List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL
int SCREENLAYOUT_SIZE_SMALL
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL.
Click Source Link
From source file:Main.java
/** * Constant for screenLayout: bits that encode the size. * @param sl_size_mask "screenLayout & SCREENLAYOUT_SIZE_MASK" * @return Device type by screen size, "Handset" or "Tablet". *///from www.j a va 2 s . c o m public static String getDeviceTypeStr(int sl_size_mask) { switch (sl_size_mask) { case Configuration.SCREENLAYOUT_SIZE_SMALL://1 case Configuration.SCREENLAYOUT_SIZE_NORMAL://2 return "Handset"; case Configuration.SCREENLAYOUT_SIZE_LARGE://3 case Configuration.SCREENLAYOUT_SIZE_XLARGE://4 return "Tablet"; default: return UNKNOWN; } }
From source file:Main.java
private static boolean isEnoughSpace(Configuration configuration) { if (configuration == null) { return false; }/* www . ja v a 2 s .c o m*/ if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { return true; } int sizeMask = configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; boolean smallScreen = sizeMask == Configuration.SCREENLAYOUT_SIZE_SMALL || sizeMask == Configuration.SCREENLAYOUT_SIZE_NORMAL; return !smallScreen; }
From source file:Main.java
/** * Constant for screenLayout: bits that encode the size. * @param sl_size_mask "screenLayout & SCREENLAYOUT_SIZE_MASK" *//*from ww w. j a va 2 s . c om*/ public static String getSLSizeMaskStr(int sl_size_mask) { switch (sl_size_mask) { case Configuration.SCREENLAYOUT_SIZE_UNDEFINED://0 return "SCREENLAYOUT_SIZE_UNDEFINED"; case Configuration.SCREENLAYOUT_SIZE_SMALL://1 return "SCREENLAYOUT_SIZE_SMALL"; case Configuration.SCREENLAYOUT_SIZE_NORMAL://2 return "SCREENLAYOUT_SIZE_NORMAL"; case Configuration.SCREENLAYOUT_SIZE_LARGE://3 return "SCREENLAYOUT_SIZE_LARGE"; case Configuration.SCREENLAYOUT_SIZE_XLARGE://4 return "SCREENLAYOUT_SIZE_XLARGE"; default: return UNKNOWN; } }
From source file:Main.java
@TargetApi(13) public static int getColumnCount(Context context) { if (!API_13) { int screenSize = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (screenSize == Configuration.SCREENLAYOUT_SIZE_SMALL) return 1; int orientation = context.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) return 2; } else {/*from www . j a v a 2 s .com*/ int screenWidthDp = context.getResources().getConfiguration().screenWidthDp; // if (screenWidthDp > 820) return 4; if (screenWidthDp >= 720) return 3; if (screenWidthDp >= 480) return 2; } return 1; }
From source file:com.commonsware.android.feedfrags.FeedsTabActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_nav);// ww w . ja va 2 s. com for (final Feed feed : Feed.getFeeds()) { addNewFeed(feed); } ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayHomeAsUpEnabled(true); int screenLayout = getResources().getConfiguration().screenLayout; if (((screenLayout & Configuration.SCREENLAYOUT_SIZE_NORMAL) == Configuration.SCREENLAYOUT_SIZE_NORMAL) || ((screenLayout & Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL)) { bar.setDisplayShowHomeEnabled(false); } if (savedInstanceState != null) { cleanUpFragments(); } }
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);/*w w w . j a va2s.c om*/ 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:com.mruddy.devdataviewer.DevDataListFragment.java
@SuppressLint("InlinedApi") private static void initMaps() { DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_LOW, "LDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_MEDIUM, "MDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_HIGH, "HDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XHIGH, "XHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXHIGH, "XXHDPI"); DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXXHIGH, "XXXHDPI"); DevDataListFragment.ROTATION.append(Surface.ROTATION_0, "0"); DevDataListFragment.ROTATION.append(Surface.ROTATION_90, "90"); DevDataListFragment.ROTATION.append(Surface.ROTATION_180, "180"); DevDataListFragment.ROTATION.append(Surface.ROTATION_270, "270"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_UNDEFINED, "undefined"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_PORTRAIT, "portrait"); DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_LANDSCAPE, "landscape"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_UNDEFINED, "undefined"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_SMALL, "small"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_NORMAL, "normal"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_LARGE, "large"); DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_XLARGE, "xlarge"); }
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 va2 s . 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:com.adjust.sdk.Util.java
private static String getDeviceType(final int screenLayout) { int screenSize = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_SMALL: case Configuration.SCREENLAYOUT_SIZE_NORMAL: return "phone"; case Configuration.SCREENLAYOUT_SIZE_LARGE: case 4://from w w w . j a va 2 s . c o m return "tablet"; default: return UNKNOWN; } }
From source file:eu.inmite.apps.smsjizdenka.core.ProjectBaseActivity.java
private void printDebugInfo() { DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); DebugLog.i("Device density: " + displaymetrics.densityDpi); if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { DebugLog.i("Device size is: LARGE"); }//w ww. ja v a 2s . co m if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { DebugLog.i("Device size is: XLARGE"); } if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { DebugLog.i("Device size is: NORMAL"); } if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { DebugLog.i("Device size is: SMALL"); } DebugLog.i("Device is tablet: " + UIUtils.isHoneycombTablet(this)); }