Java Code Examples for android.content.res.Configuration#SCREENLAYOUT_SIZE_LARGE
The following examples show how to use
android.content.res.Configuration#SCREENLAYOUT_SIZE_LARGE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIUtils.java From sms-ticket with Apache License 2.0 | 6 votes |
public static String getScreenSizeAsString(Context context) { String size = null; int screenLayout = context.getResources().getConfiguration().screenLayout; if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { size = "large"; } if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { size = "xlarge"; } if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { size = "normal"; } if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { size = "small"; } if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_UNDEFINED) { size = "undefined"; } return size; }
Example 2
Source File: YoukuPlayerView.java From Dota2Helper with Apache License 2.0 | 6 votes |
public void initialize(YoukuBasePlayerManager mYoukuBaseActivity) { PackageManager pm = mYoukuBaseActivity.getBaseActivity() .getPackageManager(); String ver = "4.1"; try { ver = pm.getPackageInfo(mYoukuBaseActivity.getBaseActivity() .getPackageName(), 0).versionName; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } boolean isTablet = (this.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; String ua = (isTablet ? "Youku HD;" : "Youku;") + ver + ";Android;" + android.os.Build.VERSION.RELEASE + ";" + android.os.Build.MODEL; Logger.d(TAG, "initialize(): ua = " + ua); initialize(mYoukuBaseActivity, 10001, "4e308edfc33936d7", ver, ua, false, -7L, "631l1i1x3fv5vs2dxlj5v8x81jqfs2om"); }
Example 3
Source File: DecorUtils.java From GestureViews with Apache License 2.0 | 6 votes |
private static int getNavBarHeight(Context context) { boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasNavBar = !hasMenuKey && !hasBackKey; if (hasNavBar) { boolean isPortrait = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; String key = isPortrait ? "navigation_bar_height" : (isTablet ? "navigation_bar_height_landscape" : null); return key == null ? 0 : getDimenSize(context, key); } else { return 0; } }
Example 4
Source File: Utils.java From chips-input-layout with MIT License | 5 votes |
static int getNavBarHeight(Context c) { int result = 0; boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { // The device has a navigation bar final Resources res = c.getResources(); final Configuration config = res.getConfiguration(); int orientation = config.orientation; int resourceId; // Check if the device is a tablet if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); } else { resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android"); } if (resourceId > 0) { return res.getDimensionPixelSize(resourceId); } } return result; }
Example 5
Source File: GrblActivity.java From grblcontroller with GNU General Public License v3.0 | 4 votes |
public static boolean isTablet(Context context){ return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 6
Source File: MainActivity.java From BotLibre with Eclipse Public License 1.0 | 4 votes |
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 7
Source File: TranslationReadActivity.java From QuranAndroid with GNU General Public License v3.0 | 4 votes |
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 8
Source File: DeviceUtils.java From AndroidUtilCode with Apache License 2.0 | 4 votes |
/** * Return whether device is tablet. * * @return {@code true}: yes<br>{@code false}: no */ public static boolean isTablet() { return (Resources.getSystem().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 9
Source File: AppUtil.java From FastLib with Apache License 2.0 | 4 votes |
public static boolean isPad(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 10
Source File: MainActivity.java From BotLibre with Eclipse Public License 1.0 | 4 votes |
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 11
Source File: SettingsActivity.java From heads-up with GNU General Public License v3.0 | 4 votes |
/** * Helper method to determine if the device has an extra-large screen. For * example, 10" tablets are extra-large. */ private static boolean isXLargeTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 12
Source File: ViewHelper.java From WanAndroid with GNU General Public License v3.0 | 4 votes |
private static boolean isTablet(@NonNull Resources resources) { return (resources.getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 13
Source File: MainActivity.java From 2048-android with MIT License | 4 votes |
@SuppressLint({"SetJavaScriptEnabled", "ShowToast", "ClickableViewAccessibility"}) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Don't show an action bar or title requestWindowFeature(Window.FEATURE_NO_TITLE); // Enable hardware acceleration getWindow().setFlags(LayoutParams.FLAG_HARDWARE_ACCELERATED, LayoutParams.FLAG_HARDWARE_ACCELERATED); // Apply previous setting about showing status bar or not applyFullScreen(isFullScreen()); // Check if screen rotation is locked in settings boolean isOrientationEnabled = false; try { isOrientationEnabled = Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION) == 1; } catch (SettingNotFoundException e) { Log.d(MAIN_ACTIVITY_TAG, "Settings could not be loaded"); } // If rotation isn't locked and it's a LARGE screen then add orientation changes based on sensor int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (((screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE) || (screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE)) && isOrientationEnabled) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } setContentView(R.layout.activity_main); DialogChangeLog changeLog = DialogChangeLog.newInstance(this); if (changeLog.isFirstRun()) { changeLog.getLogDialog().show(); } // Load webview with game mWebView = findViewById(R.id.mainWebView); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setRenderPriority(RenderPriority.HIGH); settings.setDatabasePath(getFilesDir().getParentFile().getPath() + "/databases"); // If there is a previous instance restore it in the webview if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { // Load webview with current Locale language mWebView.loadUrl("file:///android_asset/2048/index.html?lang=" + Locale.getDefault().getLanguage()); } Toast.makeText(getApplication(), R.string.toggle_fullscreen, Toast.LENGTH_SHORT).show(); // Set fullscreen toggle on webview LongClick mWebView.setOnTouchListener((v, event) -> { // Implement a long touch action by comparing // time between action up and action down long currentTime = System.currentTimeMillis(); if ((event.getAction() == MotionEvent.ACTION_UP) && (Math.abs(currentTime - mLastTouch) > mTouchThreshold)) { boolean toggledFullScreen = !isFullScreen(); saveFullScreen(toggledFullScreen); applyFullScreen(toggledFullScreen); } else if (event.getAction() == MotionEvent.ACTION_DOWN) { mLastTouch = currentTime; } // return so that the event isn't consumed but used // by the webview as well return false; }); pressBackToast = Toast.makeText(getApplicationContext(), R.string.press_back_again_to_exit, Toast.LENGTH_SHORT); }
Example 14
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
static public boolean isLargeTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 15
Source File: Utilities.java From Yahala-Messenger with MIT License | 4 votes |
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 16
Source File: SuperToast.java From SuperToasts with Apache License 2.0 | 4 votes |
/** * Modify various attributes of the SuperToast before being shown. */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") protected void onPrepareShow() { final int sdkVersion = android.os.Build.VERSION.SDK_INT; // Modify various attributes of the message TextView this.mTextView.setText(this.mStyle.message); this.mTextView.setTypeface(this.mTextView.getTypeface(), this.mStyle.messageTypefaceStyle); this.mTextView.setTextColor(this.mStyle.messageTextColor); this.mTextView.setTextSize(this.mStyle.messageTextSize); if (this.mStyle.messageIconResource > 0) { if (this.mStyle.messageIconPosition == Style.ICONPOSITION_LEFT) { this.mTextView.setCompoundDrawablesWithIntrinsicBounds( this.mStyle.messageIconResource, 0, 0, 0); } else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_TOP) { this.mTextView.setCompoundDrawablesWithIntrinsicBounds( 0, this.mStyle.messageIconResource, 0, 0); } else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_RIGHT) { this.mTextView.setCompoundDrawablesWithIntrinsicBounds( 0, 0, this.mStyle.messageIconResource, 0); } else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_BOTTOM) { this.mTextView.setCompoundDrawablesWithIntrinsicBounds( 0, 0, 0, this.mStyle.messageIconResource); } } // Handle depreciated API for setting the background if (sdkVersion >= Build.VERSION_CODES.JELLY_BEAN) { this.mView.setBackground(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color)); // Give Lollipop devices a nice shadow (does not work with transparent backgrounds) if (sdkVersion >= Build.VERSION_CODES.LOLLIPOP) mView.setElevation(3f); } else this.mView.setBackgroundDrawable(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color)); // Make adjustments that are specific to Lollipop frames if (this.mStyle.frame == Style.FRAME_LOLLIPOP) { this.mTextView.setGravity(Gravity.START); // We are on a big screen device, show the SuperToast on the bottom left with padding if ((this.mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { this.mStyle.xOffset = BackgroundUtils.convertToDIP(12); this.mStyle.yOffset = BackgroundUtils.convertToDIP(12); this.mStyle.width = BackgroundUtils.convertToDIP(288); this.mStyle.gravity = Gravity.BOTTOM | Gravity.START; // Simple background shape with rounded corners final GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setCornerRadius(BackgroundUtils.convertToDIP(2)); gradientDrawable.setColor(this.mStyle.color); // Handle depreciated API for setting the background if (sdkVersion >= Build.VERSION_CODES.JELLY_BEAN) this.mView.setBackground(gradientDrawable); else this.mView.setBackgroundDrawable(gradientDrawable); // We are NOT on a big screen device, show the SuperToast on the bottom with NO padding } else { this.mStyle.yOffset = 0; this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT; } // Set the priority color of the Lollipop frame if any if (this.mStyle.priorityColor != 0) { mView.findViewById(R.id.border).setVisibility(View.VISIBLE); mView.findViewById(R.id.border).setBackgroundColor(this.mStyle.priorityColor); } } // Used for PriorityQueue comparisons this.getStyle().timestamp = System.currentTimeMillis(); }
Example 17
Source File: Utils.java From SmartFlasher with GNU General Public License v3.0 | 4 votes |
public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 18
Source File: DeviceUtils.java From Android-utils with Apache License 2.0 | 4 votes |
private static boolean isTabletInner(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
Example 19
Source File: ViewUtils.java From TheGreatAdapter with Apache License 2.0 | 4 votes |
public static boolean isLargeScreen(Context context) { return getScreenSize(context) == Configuration.SCREENLAYOUT_SIZE_LARGE || getScreenSize(context) == Configuration.SCREENLAYOUT_SIZE_XLARGE; }
Example 20
Source File: CommonUtils.java From o2oa with GNU Affero General Public License v3.0 | 2 votes |
/** * 判断是否是平板 * 这个方法是从 Google I/O App for Android 的源码里找来的,非常准确。 * @param context * @return */ public static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }