Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_LARGE

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_LARGE

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

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 480x640 dp units, corresponds to the large resource qualifier.

Usage

From source file:supertoast.utils.SuperActivityToast.java

/**
 * Modify various attributes of the SuperActivityToast before being shown.
 *//*from  w ww  .j ava2s  . c  o  m*/
@Override
protected void onPrepareShow() {
    super.onPrepareShow(); // This will take care of many modifications

    final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.mStyle.width,
            this.mStyle.height);

    // Make some type specific tweaks
    switch (this.mStyle.type) {

    case Style.TYPE_STANDARD:
        break;

    case Style.TYPE_BUTTON:
        // If NOT Lollipop frame, give padding on each side
        if (this.mStyle.frame != Style.FRAME_LOLLIPOP) {
            this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT;
            this.mStyle.xOffset = BackgroundUtils.convertToDIP(24);
            this.mStyle.yOffset = BackgroundUtils.convertToDIP(24);
        }

        // On a big screen device, show the SuperActivityToast on the bottom left
        if ((this.mContext.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
            this.mStyle.width = BackgroundUtils.convertToDIP(568);
            this.mStyle.gravity = Gravity.BOTTOM | Gravity.START;
        }

        // Set up the Button attributes
        final Button button = (Button) this.mView.findViewById(R.id.button);
        button.setBackgroundResource(BackgroundUtils.getButtonBackgroundResource(this.mStyle.frame));
        button.setText(this.mStyle.buttonText != null ? this.mStyle.buttonText.toUpperCase() : "");
        button.setTypeface(button.getTypeface(), this.mStyle.buttonTypefaceStyle);
        button.setTextColor(this.mStyle.buttonTextColor);
        button.setTextSize(this.mStyle.buttonTextSize);

        if (this.mStyle.frame != Style.FRAME_LOLLIPOP) {
            this.mView.findViewById(R.id.divider).setBackgroundColor(this.mStyle.buttonDividerColor);

            // Set an icon resource if desired
            if (this.mStyle.buttonIconResource > 0) {
                button.setCompoundDrawablesWithIntrinsicBounds(
                        ResourcesCompat.getDrawable(mContext.getResources(), this.mStyle.buttonIconResource,
                                mContext.getTheme()),
                        null, null, null);
            }
        }

        if (this.mOnButtonClickListener != null) {
            button.setOnClickListener(new View.OnClickListener() {

                short clicked = 0;

                @Override
                public void onClick(View view) {
                    // Prevent button spamming
                    if (clicked > 0)
                        return;
                    clicked++;

                    mOnButtonClickListener.onClick(view, getButtonToken());
                    SuperActivityToast.this.dismiss();
                }
            });
        }
        break;

    case Style.TYPE_PROGRESS_CIRCLE:
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
        }
        break;

    case Style.TYPE_PROGRESS_BAR:
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
            this.mProgressBar.setProgressTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setProgressTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
        }
        this.mProgressBar.setProgress(this.mStyle.progress);
        this.mProgressBar.setMax(this.mStyle.progressMax);
        this.mProgressBar.setIndeterminate(this.mStyle.progressIndeterminate);
        break;
    }

    layoutParams.width = this.mStyle.width;
    layoutParams.height = this.mStyle.height;
    layoutParams.gravity = this.mStyle.gravity;
    layoutParams.bottomMargin = this.mStyle.yOffset;
    layoutParams.topMargin = this.mStyle.yOffset;
    layoutParams.leftMargin = this.mStyle.xOffset;
    layoutParams.rightMargin = this.mStyle.xOffset;

    this.mView.setLayoutParams(layoutParams);

    // Set up touch to dismiss
    if (this.mStyle.touchToDismiss) {
        mView.setOnTouchListener(new View.OnTouchListener() {

            int timesTouched;

            @Override
            public boolean onTouch(View v, MotionEvent motionEvent) {
                // Prevent repetitive touch events
                if (timesTouched == 0 && motionEvent.getAction() == MotionEvent.ACTION_DOWN)
                    dismiss();
                timesTouched++;

                return false; // Do not consume the event in case a Button listener is set
            }
        });
    } else {
        // Make sure no listener is set
        mView.setOnTouchListener(null);
    }
}

From source file:com.github.johnpersano.supertoasts.library.SuperActivityToast.java

/**
 * Modify various attributes of the SuperActivityToast before being shown.         
 *//* w  ww.  j  a  va2s  .com*/
@Override
protected void onPrepareShow() {
    super.onPrepareShow(); // This will take care of many modifications 

    final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.mStyle.width,
            this.mStyle.height);

    // Make some type specific tweaks
    switch (this.mStyle.type) {

    case Style.TYPE_STANDARD:
        break;

    case Style.TYPE_BUTTON:
        // If NOT Lollipop frame, give padding on each side
        if (this.mStyle.frame != Style.FRAME_LOLLIPOP) {
            this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT;
            this.mStyle.xOffset = BackgroundUtils.convertToDIP(24);
            this.mStyle.yOffset = BackgroundUtils.convertToDIP(24);
        }

        // On a big screen device, show the SuperActivityToast on the bottom left
        if ((this.mContext.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
            this.mStyle.width = BackgroundUtils.convertToDIP(568);
            this.mStyle.gravity = Gravity.BOTTOM | Gravity.START;
        }

        // Set up the Button attributes
        final Button button = (Button) this.mView.findViewById(R.id.button);
        button.setBackgroundResource(BackgroundUtils.getButtonBackgroundResource(this.mStyle.frame));
        button.setText(this.mStyle.buttonText != null ? this.mStyle.buttonText.toUpperCase() : "");
        button.setTypeface(button.getTypeface(), this.mStyle.buttonTypefaceStyle);
        button.setTextColor(this.mStyle.buttonTextColor);
        button.setTextSize(this.mStyle.buttonTextSize);

        if (this.mStyle.frame != Style.FRAME_LOLLIPOP) {
            this.mView.findViewById(R.id.divider).setBackgroundColor(this.mStyle.buttonDividerColor);

            // Set an icon resource if desired
            if (this.mStyle.buttonIconResource > 0) {
                button.setCompoundDrawablesWithIntrinsicBounds(
                        ResourcesCompat.getDrawable(mContext.getResources(), this.mStyle.buttonIconResource,
                                mContext.getTheme()),
                        null, null, null);
            }
        }

        if (this.mOnButtonClickListener != null) {
            button.setOnClickListener(new View.OnClickListener() {

                short clicked = 0;

                @Override
                public void onClick(View view) {
                    // Prevent button spamming
                    if (clicked > 0)
                        return;
                    clicked++;

                    mOnButtonClickListener.onClick(view, getButtonToken());
                    SuperActivityToast.this.dismiss();
                }
            });
        }
        break;

    case Style.TYPE_PROGRESS_CIRCLE:
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
        }
        break;

    case Style.TYPE_PROGRESS_BAR:
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            this.mProgressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
            this.mProgressBar.setProgressTintMode(PorterDuff.Mode.SRC_IN);
            this.mProgressBar.setProgressTintList(ColorStateList.valueOf(this.mStyle.progressBarColor));
        }
        this.mProgressBar.setProgress(this.mStyle.progress);
        this.mProgressBar.setMax(this.mStyle.progressMax);
        this.mProgressBar.setIndeterminate(this.mStyle.progressIndeterminate);
        break;
    }

    layoutParams.width = this.mStyle.width;
    layoutParams.height = this.mStyle.height;
    layoutParams.gravity = this.mStyle.gravity;
    layoutParams.bottomMargin = this.mStyle.yOffset;
    layoutParams.topMargin = this.mStyle.yOffset;
    layoutParams.leftMargin = this.mStyle.xOffset;
    layoutParams.rightMargin = this.mStyle.xOffset;

    this.mView.setLayoutParams(layoutParams);

    // Set up touch to dismiss
    if (this.mStyle.touchToDismiss) {
        mView.setOnTouchListener(new View.OnTouchListener() {

            int timesTouched;

            @Override
            public boolean onTouch(View v, MotionEvent motionEvent) {
                // Prevent repetitive touch events
                if (timesTouched == 0 && motionEvent.getAction() == MotionEvent.ACTION_DOWN)
                    dismiss();
                timesTouched++;

                return false; // Do not consume the event in case a Button listener is set
            }
        });
    } else {
        // Make sure no listener is set
        mView.setOnTouchListener(null);
    }
}

From source file:com.androidaq.AndroiDAQMain.java

@Override
public void openOptionsMenu() {

    Configuration config = getResources().getConfiguration();

    if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) > Configuration.SCREENLAYOUT_SIZE_LARGE) {

        int originalScreenLayout = config.screenLayout;
        config.screenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE;
        super.openOptionsMenu();
        config.screenLayout = originalScreenLayout;

    } else {//from   w ww  .  ja va 2 s. c om
        super.openOptionsMenu();
    }
}

From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java

public boolean navigationBarAtBottom() {
    return (getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
            && getResources().getString(R.string.screen_type).equals("tablet");
}

From source file:at.alladin.rmbt.android.main.RMBTMainMenuFragment.java

/**
 * /*from w w  w .  ja  v  a2  s.  c  om*/
 * @return
 */
public boolean onBackPressed() {
    int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    if (infoOverlay.getVisibility() == View.VISIBLE && screenSize < Configuration.SCREENLAYOUT_SIZE_LARGE) {
        infoOverlay.setVisibility(View.GONE);
        return true;
    }

    return false;
}

From source file:org.smilec.smile.student.CourseList.java

void setWebviewFontSize(WebView view) {
    WebSettings webSettings = view.getSettings();

    //Determine screen size  xlarge 720x960 dp units
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { // 480x640 dp units
        //Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show();
        webSettings.setTextSize(WebSettings.TextSize.LARGER);
    } /*//from w  ww.jav a  2s  .  c  o  m
      else if ((getResources().getConfiguration().screenLayout &      
       Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {     // 320x470 dp units mobile phone
       Toast.makeText(this, "Normal sized screen" , Toast.LENGTH_LONG).show();
              
      } 
      else if ((getResources().getConfiguration().screenLayout &      
       Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {     // 320x426 dp units
       Toast.makeText(this, "Small sized screen" , Toast.LENGTH_LONG).show();
      }
      else {
       Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show();
      }*/

}

From source file:com.skytree.epubtest.BookViewActivity.java

public boolean isTablet() {
    return (getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

public boolean isTablet() {
    return (getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}