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:watch.oms.omswatch.application.OMSApplication.java

/**
 * Checks if the device is a tablet or a phone
 * //from   w  w w  .  j  av  a 2  s.  c  om
 * @param
 *
 * @return Returns true if the device is a Tablet
 */
public boolean isTabletDevice() {
    // Verifies if the Generalized Size of the device is XLARGE to be
    // considered a Tablet
    boolean xlarge = ((activity.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);

    // If XLarge, checks if the Generalized Density is at least MDPI
    // (160dpi)
    if (xlarge) {
        DisplayMetrics metrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160,
        // DENSITY_TV=213, DENSITY_XHIGH=320
        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) {

            // Yes, this is a tablet!
            return true;
        }
    }
    return false;
}

From source file:com.money.manager.ex.core.Core.java

/**
 * Function that determines if the application is running on tablet
 * @return true if running on the tablet, otherwise false
 *///from w  w w .ja v  a2s  . c o  m
public boolean isTablet() {
    int layout = getContext().getResources().getConfiguration().screenLayout;
    return ((layout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
            || ((layout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
}

From source file:com.miz.functions.MizLib.java

/**
 * Determines if the application is running on a tablet
 * @param c - Context of the application
 * @return True if running on a tablet, false if on a smartphone
 *//*from  w  w w .  j  a v  a  2  s. c  om*/
public static boolean isTablet(Context c) {
    return (c.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

From source file:com.oliversride.wordryo.Utils.java

public static boolean hasSmallScreen(Context context) {
    if (null == s_hasSmallScreen) {
        int screenLayout = context.getResources().getConfiguration().screenLayout;
        boolean hasSmallScreen = (screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL;
        s_hasSmallScreen = new Boolean(hasSmallScreen);
    }//from  ww  w  .ja v  a 2 s . co m
    return s_hasSmallScreen;
}

From source file:com.miz.functions.MizLib.java

/**
 * Determines if the application is running on a xlarge tablet
 * @param c - Context of the application
 * @return True if running on a xlarge tablet, false if on a smaller device
 *///  w  w  w. j a v a  2s  . c  om
public static boolean isXlargeTablet(Context c) {
    return (c.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:uni.oulu.mentor.TeacherVisionActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //DO NOT USE THIS SERVICE YET, DOES NOT WORK
    //Intent intent = new Intent(this, TeacherVisionService.class);
    //startService(intent);
    /*Idea from http://stackoverflow.com/questions/2902640/android-get-the-screen-resolution-pixels-as-integer-values */
    @SuppressWarnings("deprecation")
    int screenWidthPix = getWindowManager().getDefaultDisplay().getWidth();
    @SuppressWarnings("deprecation")
    int screenHeightPix = getWindowManager().getDefaultDisplay().getHeight();
    /*Idea from http://stackoverflow.com/questions/5015094/determine-device-screen-category-small-normal-large-xlarge-using-code*/
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
        screenType = 3;/*www.jav a2  s .c o  m*/
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE)
        screenType = 4;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL)
        screenType = 1;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL)
        screenType = 2;
    //screen density is investigated here
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int density = metrics.densityDpi;
    if (density == DisplayMetrics.DENSITY_HIGH) {
        //400 dpi is 600px
        if (screenType == 1)
            translationX = 240; //240 / 1.5 = 160
        else if (screenType == 2)
            translationX = 315; //315 / 1.5 = 210 in dpi, screen 800 pix wide screen, needs about 1024/400 = 800/x => 312,5, 2.56
        else if (screenType == 3)
            translationX = 540; //540 / 1.5 = 360 in dpi
        else if (screenType == 4)
            translationX = 600; //600 / 1.5 = 400 in dpi   
    } else if (density == DisplayMetrics.DENSITY_MEDIUM) {
        //400 dpi is 400px
        if (screenType == 1)
            translationX = 160; //160 / 1 = 160 in dpi
        else if (screenType == 2)
            translationX = 210; //210 / 1 = 210 in dpi
        else if (screenType == 3)
            translationX = 360; //360 / 1 = 360 in dpi
        else if (screenType == 4)
            translationX = 400; //400 / 1 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_LOW) {
        //400 dpi is 300px
        if (screenType == 1)
            translationX = 120; //120 / 0.75 = 160 in dpi
        else if (screenType == 2)
            translationX = 158; //158 / 0.75 = 210 in dpi
        else if (screenType == 3)
            translationX = 270; //270 / 0.75 = 360 in dpi
        else if (screenType == 4)
            translationX = 300; //300 / 0.75 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_XHIGH || density == DisplayMetrics.DENSITY_XXHIGH) {
        //400 dpi is 800px
        if (screenType == 1)
            translationX = 320; //320 / 2 = 160 in dpi
        else if (screenType == 2)
            translationX = 420; // 420 / 2 = 210 in dpi
        else if (screenType == 3)
            translationX = 720; // 720 / 2 = 360 in dpi
        else if (screenType == 4)
            translationX = 800; // 800 / 2 = 400 in dpi         
    } else {
        //not supported
    }
    int offsetX = ((int) screenWidthPix / 20);
    int offsetY = ((int) screenHeightPix / 10);
    maxPosOpenX = screenWidthPix;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel open touch
    minPosOpenX = screenWidthPix - offsetX;
    //boundary for maximum amount of width on x-axis, where the touch is seen as panel close touch
    maxPosCloseX = screenWidthPix - translationX + offsetX;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel close touch
    minPosCloseX = screenWidthPix - translationX - offsetX;
    //boundary for maximum amount of height on y-axis, where the touch is seen as panel open or close touch
    maxPosY = (screenHeightPix / 2) + offsetY;
    //boundary for minimum amount of height on y-axis, where the touch is seen as panel open or close touch
    minPosY = (screenHeightPix / 2) - offsetY;
    //instantiation of lists
    onlineStudentsList = new ArrayList<Student>();
    feedbacksList = new ArrayList<Feedback>();
    questionsList = new ArrayList<Question>();
    answersList = new ArrayList<Answer>();
    ownQuestionsList = new ArrayList<Question>();
    //data stored for this user is fetched here, from the previous activity, and stored into the teacher instance
    Intent intent2 = getIntent();
    teacher = (Teacher) intent2.getParcelableExtra("teacherObj");
    ipStr = getResources().getString(R.string.IP);
    usersUrl = "http://" + ipStr + "/mentor/users";
    coursesUrl = "http://" + ipStr + "/mentor/courses";
    //default preferences are fetched, and listener is set to listen for preference changes
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sp.registerOnSharedPreferenceChangeListener(this);
    //SharedPreferences.Editor editor = sp.edit();
    //editor.putString("flaretimePref", "5");
    //editor.clear();
    //editor.commit();
    // In case of notifications are added later
    /*String ns = Context.NOTIFICATION_SERVICE;
    mNotificationManager = (NotificationManager) getSystemService(ns);
    icon = R.drawable.mlogo2;*/
    //AndAR preview
    renderer = new CustomRenderer();//optional, may be set to null
    super.setNonARRenderer(renderer);//or might be omitted
    try {
        //register an object for each marker type
        artoolkit = super.getArtoolkit();
        oneObject = new CustomObject("onePatt", "onePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter, customColor
        twoObject = new CustomObject("twoPatt", "twoPatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        threeObject = new CustomObject("threePatt", "threePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        artoolkit.registerARObject(oneObject);
        artoolkit.registerARObject(twoObject);
        artoolkit.registerARObject(threeObject);
    } catch (AndARException ex) {
        Log.e("AndARException ", ex.getMessage());
    }
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View vv = inflater.inflate(R.layout.activity_teacher_vision, null);
    //screen width and height in pixels
    screenWidth = (float) this.getApplicationContext().getResources().getDisplayMetrics().widthPixels;
    screenHeight = (float) this.getApplicationContext().getResources().getDisplayMetrics().heightPixels;
    inflater.inflate(R.layout.fragment_teacher_vision, null);
    //UI elements are added on top of AndAR by calling this addContentView-method instead of setContentView
    super.addContentView(vv, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //create a layout for settings button. add it over video frames
    LinearLayout lil = new LinearLayout(this);
    Button settingsButton = new Button(this);
    settingsButton.setText("Settings");
    settingsButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    settingsButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment())
                    .addToBackStack("settings").commit();
        }
    });
    lil.addView(settingsButton);
    super.addContentView(lil, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //starts the AndAR
    startPreview();
    //mDetector is instantiated here for detecting gestures
    mDetector = new GestureDetectorCompat(this, new SwipeGestureListener());
    //view pager instantiation, also mAdapter instantiated and set as adapter for view pager
    mPager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new TabAdapter(getFragmentManager(), mPager);
    mPager.setAdapter(mAdapter);
    //begin to poll online users
    pollUsersCancelled = false;
    pollUsersTask = new PollUsersTask(this);
    pollUsersTask.execute();
    //begin to poll feedbacks
    pollFeedbacksCancelled = false;
    pollFeedbacksTask = new PollFeedbacksTask(this);
    pollFeedbacksTask.execute();
    //begin to poll questions
    pollQuestionsCancelled = false;
    pollQuestionsTask = new PollQuestionsTask(this);
    pollQuestionsTask.execute();
    //begin to poll answers
    pollAnswersCancelled = false;
    pollAnswersTask = new PollAnswersTask(this);
    pollAnswersTask.execute();
    //initialize tab buttons
    button = (Button) findViewById(R.id.goto_first);
    //first one is not enabled at the beginning, because the user is in first tab at first 
    button.setEnabled(false);
    button2 = (Button) findViewById(R.id.goto_second);
    button3 = (Button) findViewById(R.id.goto_last);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(0);
            button.setEnabled(false);
            button2.setEnabled(true);
            button3.setEnabled(true);
        }
    });
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(1);
            button.setEnabled(true);
            button2.setEnabled(false);
            button3.setEnabled(true);
        }
    });
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(2);
            button.setEnabled(true);
            button2.setEnabled(true);
            button3.setEnabled(false);
        }
    });
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static float getTextSize(Context context) {
    float textSize = 12f;
    int screentLayoutSize = context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (screentLayoutSize == Configuration.SCREENLAYOUT_SIZE_LARGE
            || screentLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE)
        textSize = 15f;/*w w  w  .  j  a  v  a  2 s.  co  m*/
    return textSize;
}

From source file:com.taobao.weex.utils.WXUtils.java

public static boolean isTabletDevice() {
    try {/*from  w ww .j  a va  2  s . c  om*/
        return (WXEnvironment.getApplication().getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    } catch (Exception e) {
        WXLogUtils.e("[WXUtils] isTabletDevice:", e);
    }
    return false;
}

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

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    Resources res = getResources(); //get resources
    language_list = res.getStringArray(R.array.language_list);
    category_arr = res.getStringArray(R.array.category_list);

    // First Extract the bundle from intent
    Bundle bundle = getIntent().getExtras();
    // Next extract the values using the key as
    curusertype = 1; // fixed (student)

    curusername = bundle.getString("USERNAME");
    cururi = bundle.getString("URI");
    curlanguage = bundle.getString("CHOSEN_LANGUAGE");
    String manufacturer = android.os.Build.MANUFACTURER;
    //showToast(manufacturer);

    resultSize1 = returnPixels(16.0f);//from w w  w  .j  a  va 2s  . c  om
    resultSize2 = returnPixels(18.0f);

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { // 480x640 dp units
        draw_piechart = new piechart(this, returnPixels(200.0f));
        titleSize1 = "<big>";
        titleSize2 = "</big>";
        resultSize1 = returnPixels(24.0f);
        resultSize2 = returnPixels(26.0f);
    } else if (manufacturer != null && manufacturer.toLowerCase().equals("samsung")) {
        draw_piechart = new piechart(this, returnPixels(150.0f));
        draw_piechart.setFontSize(returnPixels(12.0f));
    } else
        draw_piechart = new piechart(this, returnPixels(150.0f)); // to draw the piechart

    draw_piechart.onStart(100, 0);

    add_pic_g = new AndroidCustomGallery(this); // on 3/19/2012s

    answer_arr = new Vector<Integer>();
    rating_arr = new Vector<Integer>();
    my_score = new Vector<Integer>();
    right_answer = new Vector<Integer>();

    score_winner_name = new Vector<String>();
    rating_winner_name = new Vector<String>();
    final_avg_ratings = new Vector<String>();
    r_answer_percents = new Vector<String>();

    // connection_created = false;
    _act = this;

    chkimg = 0; // no image
    image_qa = null;

    student = null; // student communicator is created by make_connection()

    // Adding quick action menu
    image_quickaction();

    MY_IP = get_IP();

    getStoredFileURL();
    create_connection();
    show_todo_view();

    // student.send_initial_message();
    uploadErrorLog(cururi);
}

From source file:de.Maxr1998.xposed.maxlock.ui.LockFragment.java

private void setupPatternLayout() {
    // Pattern View
    lockPatternView = (LockPatternView) rootView.findViewById(R.id.pattern_view);
    // Pattern Listener
    patternListener = new LockPatternView.OnPatternListener() {
        @Override//w w w .  j  a  v  a  2  s.com
        public void onPatternStart() {
            lockPatternView.removeCallbacks(mLockPatternViewReloader);
        }

        @Override
        public void onPatternCleared() {
            lockPatternView.removeCallbacks(mLockPatternViewReloader);
            lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
        }

        @Override
        public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {

        }

        @Override
        public void onPatternDetected(List<LockPatternView.Cell> pattern) {
            key.setLength(0);
            key.append(pattern);
            if (!checkInput()) {
                lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
                lockPatternView.postDelayed(mLockPatternViewReloader, DateUtils.SECOND_IN_MILLIS);
            }
        }
    };
    // Layout
    switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
    case Configuration.SCREENLAYOUT_SIZE_XLARGE: {
        final int size = getResources().getDimensionPixelSize(
                com.haibison.android.lockpattern.R.dimen.alp_42447968_lockpatternview_size);
        ViewGroup.LayoutParams lp = lockPatternView.getLayoutParams();
        lp.width = size;
        lp.height = size;
        lockPatternView.setLayoutParams(lp);
        break;
    }
    }
    lockPatternView.setOnPatternListener(patternListener);
    lockPatternView.setInStealthMode(!prefs.getBoolean(Common.PATTERN_SHOW_PATH, true));
    lockPatternView.setTactileFeedbackEnabled(prefs.getBoolean(Common.PATTERN_FEEDBACK, true));
}