Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_NORMAL

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_NORMAL

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

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier.

Usage

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.ja v  a 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;
    }// w  w w  . j ava 2 s  .co  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  w ww.j  av  a 2s. 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:com.commonsware.android.feedfrags.FeedsTabActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_nav);//w w  w .ja  v  a2 s.  co  m

    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.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;/*from  ww  w  .j a  va 2s .  com*/
    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.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: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");
    }/*from   w ww . j a  v a  2  s. c  o  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));
}

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:/*  ww w.j a  v  a  2s.  c om*/
        return "tablet";
    default:
        return UNKNOWN;
    }
}

From source file:gr.scify.newsum.ui.Facebook.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL
            & (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }/*from w  w  w .j  a va 2s.c o m*/

    SharedPreferences userlang = getSharedPreferences("lang", 0);
    String newlang = userlang.getString("lang", Locale.getDefault().getLanguage());
    // Changed getApplicationContext() to "this"
    Setlanguage.updateLanguage(this, newlang);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
        pendingAction = PendingAction.valueOf(name);
    }

    setContentView(R.layout.facebook);

    Bundle extras = getIntent().getExtras();
    summaryF = extras.getString("summaryF");

    loginButton = (LoginButton) findViewById(R.id.login_button);
    loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
        @Override
        public void onUserInfoFetched(GraphUser user) {
            Facebook.this.user = user;
            updateUI();
            // It's possible that we were waiting for this.user to be populated in order to post a
            // status update.
            handlePendingAction();
        }
    });

    profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
    greeting = (TextView) findViewById(R.id.greeting);

    postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton);
    postStatusUpdateButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onClickPostStatusUpdate();
        }
    });

    controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container);

    final FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);
    if (fragment != null) {
        // If we're being re-created and have a fragment, we need to a) hide the main UI controls and
        // b) hook up its listeners again.
        controlsContainer.setVisibility(View.GONE);
    }

    // Listen for changes in the back stack so we know if a fragment got popped off because the user
    // clicked the back button.
    fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
        @Override
        public void onBackStackChanged() {
            if (fm.getBackStackEntryCount() == 0) {
                // We need to re-show our UI.
                controlsContainer.setVisibility(View.VISIBLE);
            }
        }
    });
}

From source file:com.raja.knowme.FragmentSpecialization.java

private AppTextView addItem(final SpecializationDetailsObject data) {
    final AppTextView mTextView = new AppTextView(getActivity());

    /*                 Multiple Screen Size Condition             */

    // Small Size

    if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        //   Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(14);//from  ww  w  . j  a  v a 2 s  . c o m
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        //   Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(16);
        mTextView.setPadding(3, 15, 0, 0);
    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //X-large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        //  Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(24);
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Undefined Size

    else {
        //Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    /*try {
      mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0);
    } catch (Exception e) {
      Log.w(this.getClass().getName(), "Drawable not found for : " + name);
    }*/
    if (data.getSpecializationLink().length() > 0) {
        mTextView.setBackgroundResource(R.drawable.button_config);
        mTextView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (data.getSpecializationLink().trim().length() > 0)
                    openWebPage(data.getSpecializationLink(), mTextView);
                else {
                    mTextView.startAnimation(shake);
                    Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    return mTextView;
}