Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_XLARGE

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_XLARGE

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

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier.

Usage

From source file:com.haibison.android.lockpattern.LockPatternFragment.java

/**
 * Initializes UI.../*from w w w  . ja  va 2  s.co m*/
 */
private void initContentView() {
    /*
     * Save all controls' state to restore later.
     */
    CharSequence infoText = mTextInfo != null ? mTextInfo.getText() : null;
    Boolean btnOkEnabled = mBtnConfirm != null ? mBtnConfirm.isEnabled() : null;
    LockPatternView.DisplayMode lastDisplayMode = mLockPatternView != null ? mLockPatternView.getDisplayMode()
            : null;
    List<Cell> lastPattern = mLockPatternView != null ? mLockPatternView.getPattern() : null;

    fa.setContentView(R.layout.alp_42447968_lock_pattern_fragment);
    UI.adjustDialogSizeForLargeScreens(fa.getWindow());

    mTextInfo = (TextView) getView().findViewById(R.id.alp_42447968_textview_info);
    mLockPatternView = (LockPatternView) getView().findViewById(R.id.alp_42447968_view_lock_pattern);

    mFooter = getView().findViewById(R.id.alp_42447968_viewgroup_footer);
    mBtnCancel = (Button) getView().findViewById(R.id.alp_42447968_button_cancel);
    mBtnConfirm = (Button) getView().findViewById(R.id.alp_42447968_button_confirm);

    /*
     * LOCK PATTERN VIEW
     */

    switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
    case Configuration.SCREENLAYOUT_SIZE_XLARGE: {
        final int size = getResources().getDimensionPixelSize(R.dimen.alp_42447968_lockpatternview_size);
        LayoutParams lp = mLockPatternView.getLayoutParams();
        lp.width = size;
        lp.height = size;
        mLockPatternView.setLayoutParams(lp);

        break;
    } // LARGE / XLARGE
    }

    /*
     * Haptic feedback.
     */
    boolean hapticFeedbackEnabled = false;
    try {
        hapticFeedbackEnabled = android.provider.Settings.System.getInt(fa.getContentResolver(),
                android.provider.Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0;
    } catch (Throwable t) {
        /*
         * Ignore it.
         */
    }
    mLockPatternView.setTactileFeedbackEnabled(hapticFeedbackEnabled);

    mLockPatternView
            .setInStealthMode(mStealthMode && !ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction()));
    mLockPatternView.setOnPatternListener(mLockPatternViewListener);
    if (lastPattern != null && lastDisplayMode != null
            && !ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction()))
        mLockPatternView.setPattern(lastDisplayMode, lastPattern);

    /*
     * COMMAND BUTTONS
     */

    if (ACTION_CREATE_PATTERN.equals(fa.getIntent().getAction())) {
        mBtnCancel.setOnClickListener(mBtnCancelOnClickListener);
        mBtnConfirm.setOnClickListener(mBtnConfirmOnClickListener);

        mBtnCancel.setVisibility(View.VISIBLE);
        mFooter.setVisibility(View.VISIBLE);

        if (infoText != null)
            mTextInfo.setText(infoText);
        else
            mTextInfo.setText(R.string.alp_42447968_msg_draw_an_unlock_pattern);

        /*
         * BUTTON OK
         */
        if (mBtnOkCmd == null)
            mBtnOkCmd = ButtonOkCommand.CONTINUE;
        switch (mBtnOkCmd) {
        case CONTINUE:
            mBtnConfirm.setText(R.string.alp_42447968_cmd_continue);
            break;
        case DONE:
            mBtnConfirm.setText(R.string.alp_42447968_cmd_confirm);
            break;
        default:
            /*
             * Do nothing.
             */
            break;
        }
        if (btnOkEnabled != null)
            mBtnConfirm.setEnabled(btnOkEnabled);
    } // ACTION_CREATE_PATTERN
    else if (ACTION_COMPARE_PATTERN.equals(fa.getIntent().getAction())) {
        if (TextUtils.isEmpty(infoText))
            mTextInfo.setText(R.string.alp_42447968_msg_draw_pattern_to_unlock);
        else
            mTextInfo.setText(infoText);
        if (fa.getIntent().hasExtra(EXTRA_PENDING_INTENT_FORGOT_PATTERN)) {
            mBtnConfirm.setOnClickListener(mBtnConfirmOnClickListener);
            mBtnConfirm.setText(R.string.alp_42447968_cmd_forgot_pattern);
            mBtnConfirm.setEnabled(true);
            mFooter.setVisibility(View.VISIBLE);
        }
    } // ACTION_COMPARE_PATTERN
    else if (ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())) {
        mTextInfo.setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm);

        /*
         * NOTE: EXTRA_PATTERN should hold a char[] array. In getActivity() case we
         * use it as a temporary variable to hold a list of Cell.
         */

        final ArrayList<Cell> pattern;
        if (fa.getIntent().hasExtra(EXTRA_PATTERN))
            pattern = fa.getIntent().getParcelableArrayListExtra(EXTRA_PATTERN);
        else
            fa.getIntent().putParcelableArrayListExtra(EXTRA_PATTERN,
                    pattern = LockPatternUtils.genCaptchaPattern(mCaptchaWiredDots));

        mLockPatternView.setPattern(DisplayMode.Animate, pattern);
    } // ACTION_VERIFY_CAPTCHA
}

From source file:uk.co.threeonefour.android.snowball.activities.game.GameActivity.java

void dbgScreenSize() {

    // Determine screen size
    int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    switch (screenSize) {
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        Toast.makeText(this, "XLarge screen", Toast.LENGTH_LONG).show();
        break;// ww w . ja  v  a 2 s.com
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        Toast.makeText(this, "Large screen", Toast.LENGTH_LONG).show();
        break;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        Toast.makeText(this, "Normal sized screen", Toast.LENGTH_LONG).show();
        break;
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        Toast.makeText(this, "Small sized screen", Toast.LENGTH_LONG).show();
        break;
    default:
        Toast.makeText(this, "Unknown screen size", Toast.LENGTH_LONG).show();
        break;
    }
}

From source file:com.dish.browser.activity.BrowserActivity.java

private boolean isTablet() {
    return (getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private void openPanel(final PanelFeatureState st, KeyEvent event) {
    // Already open, return
    if (st.isOpen || isDestroyed()) {
        return;/*from  ww  w  .j  ava 2s  .c  o m*/
    }

    // Don't open an options panel for honeycomb apps on xlarge devices.
    // (The app should be using an action bar for menu items.)
    if (st.featureId == FEATURE_OPTIONS_PANEL) {
        Context context = mContext;
        Configuration config = context.getResources().getConfiguration();
        boolean isXLarge = (config.screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
        boolean isHoneycombApp = context
                .getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;

        if (isXLarge && isHoneycombApp) {
            return;
        }
    }

    Window.Callback cb = getWindowCallback();
    if ((cb != null) && (!cb.onMenuOpened(st.featureId, st.menu))) {
        // Callback doesn't want the menu to open, reset any state
        closePanel(st, true);
        return;
    }

    final WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    if (wm == null) {
        return;
    }

    // Prepare panel (should have been done before, but just in case)
    if (!preparePanel(st, event)) {
        return;
    }

    int width = WRAP_CONTENT;
    if (st.decorView == null || st.refreshDecorView) {
        if (st.decorView == null) {
            // Initialize the panel decor, this will populate st.decorView
            if (!initializePanelDecor(st) || (st.decorView == null))
                return;
        } else if (st.refreshDecorView && (st.decorView.getChildCount() > 0)) {
            // Decor needs refreshing, so remove its views
            st.decorView.removeAllViews();
        }

        // This will populate st.shownPanelView
        if (!initializePanelContent(st) || !st.hasPanelItems()) {
            return;
        }

        ViewGroup.LayoutParams lp = st.shownPanelView.getLayoutParams();
        if (lp == null) {
            lp = new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
        }

        int backgroundResId = st.background;
        st.decorView.setBackgroundResource(backgroundResId);

        ViewParent shownPanelParent = st.shownPanelView.getParent();
        if (shownPanelParent != null && shownPanelParent instanceof ViewGroup) {
            ((ViewGroup) shownPanelParent).removeView(st.shownPanelView);
        }
        st.decorView.addView(st.shownPanelView, lp);

        /*
         * Give focus to the view, if it or one of its children does not
         * already have it.
         */
        if (!st.shownPanelView.hasFocus()) {
            st.shownPanelView.requestFocus();
        }
    } else if (st.createdPanelView != null) {
        // If we already had a panel view, carry width=MATCH_PARENT through
        // as we did above when it was created.
        ViewGroup.LayoutParams lp = st.createdPanelView.getLayoutParams();
        if (lp != null && lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
            width = MATCH_PARENT;
        }
    }

    st.isHandled = false;

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, WRAP_CONTENT, st.x, st.y,
            WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
            PixelFormat.TRANSLUCENT);

    lp.gravity = st.gravity;
    lp.windowAnimations = st.windowAnimations;

    wm.addView(st.decorView, lp);
    st.isOpen = true;
}

From source file:org.mozilla.gecko.GeckoAppShell.java

public static boolean isTablet() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        Configuration config = GeckoApp.mAppContext.getResources().getConfiguration();
        // xlarge is defined by android as screens larger than 960dp x 720dp
        // and should include most devices ~7in and up.
        // http://developer.android.com/guide/practices/screens_support.html
        if ((config.screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE) {
            return true;
        }// w w w.  jav a2 s .  c o m
    }
    return false;
}