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: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   w w  w  .j  a va  2 s  .c om

        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: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 w ww .j ava 2  s .c o  m*/
    } 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:net.kevxu.muzei.interfacelift.InterfaceliftMacdropsClient.java

/**
 * Get suitable photo size based on the screen size of phone.
 *
 * @return Dimension Dimension of suitable photo size.
 *///from www .  j av a 2 s  .c om
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: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 ww  w. j av 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.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 va2 s  . c  om*/

    // 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);
        }/*from   w w w .j  a v a  2 s  . co 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();
            }
        });
    }
}

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:// w w  w .java2 s  . c o m
        return "tablet";
    default:
        return UNKNOWN;
    }
}

From source file:com.health.openscale.gui.TableFragment.java

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

    tableDataView = (TableLayout) tableView.findViewById(R.id.tableDataView);

    tableView.findViewById(R.id.btnImportData).setOnClickListener(new onClickListenerImport());

    tableView.findViewById(R.id.btnExportData).setOnClickListener(new onClickListenerExport());

    tableView.findViewById(R.id.btnDeleteAll).setOnClickListener(new onClickListenerDeleteAll());

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE
            && (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) {
        TextView txtDateTableHeader = (TextView) tableView.findViewById(R.id.txtDateTableHeader);
        txtDateTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        TextView txtTimeTableHeader = (TextView) tableView.findViewById(R.id.txtTimeTableHeader);
        txtTimeTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        TextView txtWeightTableHeader = (TextView) tableView.findViewById(R.id.txtWeightTableHeader);
        txtWeightTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        TextView txtFatTableHeader = (TextView) tableView.findViewById(R.id.txtFatTableHeader);
        txtFatTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        TextView txtWaterTableHeader = (TextView) tableView.findViewById(R.id.txtWaterTableHeader);
        txtWaterTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        TextView txtMuscleTableHeader = (TextView) tableView.findViewById(R.id.txtMuscleTableHeader);
        txtMuscleTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        Button btnDeleteAll = (Button) tableView.findViewById(R.id.btnDeleteAll);
        btnDeleteAll.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
    }//from   w w w .  j a  v a2s.  c om

    return tableView;
}

From source file:com.brayanarias.alarmproject.fragment.AlarmListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.fragment_alarm_list, container, false);
    RecyclerView recyclerView = (RecyclerView) layout.findViewById(R.id.alarmList);
    AlarmListAdapter alarmListAdapter = new AlarmListAdapter(getData(), (MainActivity) getActivity());
    recyclerView.setAdapter(alarmListAdapter);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    linearLayoutManager.scrollToPosition(0);
    recyclerView.setLayoutManager(linearLayoutManager);
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        GridLayoutManager gridLayoutManager;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            gridLayoutManager = new GridLayoutManager(getActivity().getBaseContext(), 3);
            recyclerView.setLayoutManager(gridLayoutManager);
        } else {//from  w w w .j a v  a  2 s . c  o m
            gridLayoutManager = new GridLayoutManager(getActivity().getBaseContext(), 2);
            recyclerView.setLayoutManager(gridLayoutManager);
        }
        recyclerView.setLayoutManager(gridLayoutManager);
    }
    FloatingActionButton fab = (FloatingActionButton) layout.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    return layout;
}

From source file:org.flexlabs.widgets.dualbattery.widgetsettings.WidgetActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startService(new Intent(this, MonitorService.class));
    Bundle extras = getIntent().getExtras();
    appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);

    fragments = new Fragment[5];
    fragments[0] = new BatteryInfoFragment();
    fragments[1] = new PropertiesFragment();
    fragments[2] = new FeedbackFragment();
    fragments[3] = new DonateFragment();
    fragments[4] = new AboutFragment();
    titles = new String[5];
    titles[0] = getString(R.string.propHeader_BatteryInfo);
    titles[1] = getString(R.string.propHeader_Properties);
    titles[2] = getString(R.string.propHeader_Feedback);
    titles[3] = getString(R.string.propHeader_Donate);
    titles[4] = 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  w  w w.ja va2s .c  o 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);
    }

    if (WidgetSettingsContainer.getUpgradeSwappedSingle(this, appWidgetId)) {
        new AlertDialog.Builder(this).setTitle(R.string.app_name).setMessage(R.string.alert_just_swapped)
                .setPositiveButton("OK", null).show();
    }
}