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:uk.co.workingedge.phonegap.plugin.IsTablet.java

private boolean isTabletDevice(Context applicationContext) {
    boolean device_large = ((applicationContext.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (device_large) {
        DisplayMetrics metrics = new DisplayMetrics();
        Activity activity = this.cordova.getActivity();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        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
                || metrics.densityDpi == DisplayMetrics.DENSITY_XXHIGH) {
            Log.d(LOG_TAG, "Is Tablet Device");
            return true;
        }/*ww  w  .j ava2s  .c  o  m*/
    }
    Log.d(LOG_TAG, "Is NOT Tablet Device");
    return false;
}

From source file:de.wikilab.android.friendica01.Max.java

public static boolean isLarge(Configuration c) {
    return (((c.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
            || ((c.screenLayout//from  w  ww .  j a v  a 2 s. com
                    & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE));
}

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 w w w.  j a v a2s  .c  o  m*/
    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:eu.alefzero.owncloud.ui.activity.FileDetailActivity.java

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

    // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity 
    Configuration conf = getResources().getConfiguration();
    mConfigurationChangedToLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (conf.screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (!mConfigurationChangedToLandscape) {
        setContentView(R.layout.file_activity_details);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        OCFile file = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
        Account account = getIntent().getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);
        FileDetailFragment mFileDetail = new FileDetailFragment(file, account);

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.fragment, mFileDetail, FileDetailFragment.FTAG);
        ft.commit();/*from ww  w .  j  a va  2 s .  c om*/

    } else {
        backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;
    }

}

From source file:com.near.chimerarevo.fragments.FavoritesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.recyclerview_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*from ww w  .  j a va2s  .c om*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    mListView = (RecyclerView) v.findViewById(R.id.cardList);

    mProgressContainer = v.findViewById(R.id.progressContainer);
    mListContainer = v.findViewById(R.id.listContainer);
    mEmptyText = v.findViewById(android.R.id.empty);

    ((TextView) v.findViewById(android.R.id.empty)).setText(R.string.text_nofavorites);

    return v;
}

From source file:org.flexlabs.widgets.dualbattery.app.SettingsActivity.java

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

    fragments = new Fragment[4];
    fragments[0] = new SettingsFragment();
    fragments[1] = new FeedbackFragment();
    fragments[2] = new DonateFragment();
    fragments[3] = new AboutFragment();
    titles = new String[4];
    titles[0] = getString(R.string.settings);
    titles[1] = getString(R.string.propHeader_Feedback);
    titles[2] = getString(R.string.propHeader_Donate);
    titles[3] = getString(R.string.propHeader_About);

    int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
            && screenLayout > Configuration.SCREENLAYOUT_SIZE_LARGE) {
        setContentView(R.layout.preference_list_large);

        ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1,
                titles);//from   ww  w.  j a  v a  2 s .  co m

        mList = (ListView) findViewById(android.R.id.list);
        mList.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
        mList.setOnItemClickListener(this);
        mList.setAdapter(adapter);
        mList.setItemChecked(0, true);
        mList.performClick();
        getSupportFragmentManager().beginTransaction().replace(R.id.prefs, fragments[0]).commit();
    } else {
        setContentView(R.layout.widgetsettings);
        PagerTabAdapter mPagerAdapter = new PagerTabAdapter(getSupportFragmentManager());
        ViewPager mPager = (ViewPager) findViewById(R.id.pager);
        mPager.setAdapter(mPagerAdapter);

        PageIndicator mIndicator = (TabPageIndicator) findViewById(R.id.indicator);
        mIndicator.setViewPager(mPager);
    }
}

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");
    }// ww  w. jav a2  s  .  co 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:net.kevxu.muzei.interfacelift.InterfaceliftMacdropsClient.java

/**
 * Get suitable photo size based on the screen size of phone.
 *
 * @return Dimension Dimension of suitable photo size.
 *//* ww w.j  a  va  2 s.co  m*/
protected Dimension getSuitablePhotoDimension() {
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    final int width = size.x;
    final int height = size.y;

    int screenLayout = mContext.getResources().getConfiguration().screenLayout;
    boolean isXlarge = ((screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
    boolean isLarge = ((screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
    final boolean isTablet = isXlarge || isLarge;

    Dimension dimen;

    if (!isTablet) {
        // Wallpaper for phone needs at least [width x 2] x height
        dimen = new Dimension(width * 2, height);
    } else {
        // Wallpaper for tablet needs at least [long edge] x [long edge]
        int longEdge = width > height ? width : height;
        dimen = new Dimension(longEdge, longEdge);
    }

    return dimen;
}

From source file:com.example.administrator.mynews.view.AdMobBannerSizesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_admob_banner_sizes, container, false);

    mSizesSpinner = (Spinner) rootView.findViewById(R.id.bannersizes_spn_size);
    mLoadButton = (Button) rootView.findViewById(R.id.bannersizes_btn_loadad);
    mAdFrameLayout = (FrameLayout) rootView.findViewById(R.id.bannersizes_fl_adframe);

    String[] sizesArray;/*  w w w.j  a v a 2  s .com*/

    // It is a Mobile Ads SDK policy that only the banner, large banner, and smart banner ad
    // sizes are shown on phones, and that the full banner, leaderboard, and medium rectangle
    // sizes are reserved for use on tablets.  The conditional below checks the screen size
    // and retrieves the correct list.

    int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    if ((screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE)
            || (screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
        sizesArray = getResources().getStringArray(R.array.bannersizes_largesizes);
    } else {
        sizesArray = getResources().getStringArray(R.array.bannersizes_smallsizes);
    }

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(rootView.getContext(),
            android.R.layout.simple_spinner_dropdown_item, sizesArray);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSizesSpinner.setAdapter(adapter);

    mLoadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mAdView != null) {
                mAdFrameLayout.removeView(mAdView);
                mAdView.destroy();
            }

            mAdView = new AdView(getActivity());
            mAdView.setAdUnitId(getString(R.string.admob_banner_ad_unit_id));
            mAdFrameLayout.addView(mAdView);

            switch (mSizesSpinner.getSelectedItemPosition()) {
            case 0:
                mAdView.setAdSize(AdSize.BANNER);
                break;
            case 1:
                mAdView.setAdSize(AdSize.LARGE_BANNER);
                break;
            case 2:
                mAdView.setAdSize(AdSize.SMART_BANNER);
                break;
            case 3:
                mAdView.setAdSize(AdSize.FULL_BANNER);
                break;
            case 4:
                mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE);
                break;
            case 5:
                mAdView.setAdSize(AdSize.LEADERBOARD);
                break;
            }

            mAdView.loadAd(new AdRequest.Builder().build());
        }
    });

    return rootView;
}

From source file:cm.aptoide.pt.adapters.UpdatesAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    ViewHolder holder = (ViewHolder) view.getTag();
    if (holder == null) {
        holder = new ViewHolder();
        holder.name = (TextView) view.findViewById(R.id.app_name);
        holder.icon = (ImageView) view.findViewById(R.id.app_icon);
        holder.vername = (TextView) view.findViewById(R.id.uptodate_versionname);
        holder.update = (ImageView) view.findViewById(R.id.app_update);

        if ((context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE
                || (context.getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
            holder.ignore_update = (ImageView) view.findViewById(R.id.app_ignore_update);
        }//w  ww . j  a v a2s . c  o m

        //            holder.downloads= (TextView) view.findViewById(R.id.downloads);
        //            holder.rating= (RatingBar) view.findViewById(R.id.stars);
        view.setTag(holder);
    }
    final long id = cursor.getLong(0);
    final String name = cursor.getString(1);
    final String apkId = cursor.getString(7);
    final String vername = cursor.getString(2);
    final int vercode = cursor.getInt(8);
    final String md5 = cursor.getString(10);
    final String apkpath = cursor.getString(11) + cursor.getString(12);
    String iconspath = cursor.getString(9) + cursor.getString(4);
    final String hash = (cursor.getString(cursor.getColumnIndex("apkid")) + "|"
            + cursor.getString(cursor.getColumnIndex("vercode")));
    holder.name.setText(name);
    ImageLoader.getInstance().displayImage(iconspath, holder.icon);
    //       try{
    //              holder.rating.setRating(Float.parseFloat(cursor.getString(5)));
    //           }catch (Exception e) {
    //              holder.rating.setRating(0);
    //         }
    //       holder.downloads.setText(cursor.getString(6));
    holder.vername.setText(context.getString(R.string.update_to) + ": " + vername);
    holder.update.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            new GetApkWebserviceInfo(mContext, serviceDownloadManager, true).execute(id);
        }
    });
    if ((context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE
            || (context.getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        holder.ignore_update.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ViewApk apk = Database.getInstance().getApk(id, Category.INFOXML);
                Database.getInstance().addToExcludeUpdate((int) id);
                if (loader != null)
                    loader.forceLoad();
                Toast toast = Toast.makeText(context,
                        context.getString(R.string.added_to_excluded_updates_list, apk.getName()),
                        Toast.LENGTH_SHORT);
                toast.show();
            }
        });
    }
}