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.tlhInganHol.android.klingonassistant.BaseActivity.java

public boolean isHorizontalTablet() {
    Configuration config = getResources().getConfiguration();
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE && (config.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
        return true;
    }/*from   w w w.jav  a 2 s  .com*/
    return false;
}

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

@Override
public void updateOnView(ArrayList<ScaleData> scaleDataList) {
    TableRow headerRow = (TableRow) tableView.findViewById(R.id.tableHeader);
    tableDataView.removeAllViews();//ww  w .  ja v a2  s  . co m
    tableDataView.addView(headerRow);

    for (ScaleData scaleData : scaleDataList) {
        TableRow dataRow = new TableRow(tableView.getContext());
        dataRow.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        TextView idView = new TextView(tableView.getContext());
        idView.setText(Long.toString(scaleData.id));
        idView.setVisibility(View.GONE);
        dataRow.addView(idView);

        TextView dateTextView = new TextView(tableView.getContext());
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE
                || (getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
            dateTextView.setText(new SimpleDateFormat("dd. MMM yyyy (EE)").format(scaleData.date_time));
        } else {
            dateTextView.setText(new SimpleDateFormat("dd/MM/yy").format(scaleData.date_time));
        }
        dateTextView.setPadding(0, 5, 5, 5);
        dataRow.addView(dateTextView);

        TextView timeTextView = new TextView(tableView.getContext());
        timeTextView.setText(new SimpleDateFormat("HH:mm").format(scaleData.date_time));
        timeTextView.setPadding(0, 5, 5, 5);
        dataRow.addView(timeTextView);

        TextView weightView = new TextView(tableView.getContext());
        weightView.setText(Float.toString(scaleData.weight));
        weightView.setPadding(0, 5, 5, 5);
        dataRow.addView(weightView);

        TextView fatView = new TextView(tableView.getContext());
        fatView.setText(Float.toString(scaleData.fat));
        fatView.setPadding(0, 5, 5, 5);
        dataRow.addView(fatView);

        TextView waterView = new TextView(tableView.getContext());
        waterView.setText(Float.toString(scaleData.water));
        waterView.setPadding(0, 5, 5, 5);
        dataRow.addView(waterView);

        TextView muscleView = new TextView(tableView.getContext());
        muscleView.setText(Float.toString(scaleData.muscle));
        muscleView.setPadding(0, 5, 5, 5);
        dataRow.addView(muscleView);

        Button deleteButton = new Button(tableView.getContext());
        deleteButton.setText("X");
        deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setBackgroundResource(R.drawable.flat_selector);
        deleteButton.setGravity(Gravity.CENTER);
        deleteButton.setPadding(0, 0, 0, 0);
        deleteButton.setMinimumHeight(35);
        deleteButton.setHeight(35);
        deleteButton.setOnClickListener(new onClickListenerDelete());
        dataRow.addView(deleteButton);

        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE
                && (getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) {
            dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            timeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            weightView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            fatView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            waterView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            muscleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        }

        tableDataView.addView(dataRow,
                new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }
}

From source file:org.site_monitor.activity.PrefSettingsActivity.java

/**
 * Helper method to determine if the device has an extra-large screen. For example, 10" tablets are extra-large.
 *///  w ww  .  j  a  va 2s .  co  m

private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:com.ohso.omgubuntu.BaseFragment.java

public static int getColumnByScreenSize() {
    int columnNumber = 1;
    final int sizeMask = OMGUbuntuApplication.getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    final int orientation = OMGUbuntuApplication.getContext().getResources().getConfiguration().orientation;
    switch (sizeMask) {
    case (Configuration.SCREENLAYOUT_SIZE_LARGE):
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            columnNumber = 2;//from   w ww  .j av  a  2  s . c  o  m
        }
        break;
    case (Configuration.SCREENLAYOUT_SIZE_XLARGE):
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            columnNumber = 3;
        } else {
            columnNumber = 2;
        }
        break;
    }

    return columnNumber;
}

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

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

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;// w ww. j av  a 2 s .  co  m
    } else
        isLandscapeLarge = false;

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

From source file:com.coinblesk.client.KeyboardFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final int screenLayout = getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE
            || screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        this.initCustomButtons("1");
        this.initCustomButtons("2");
        this.initCustomButtons("3");
        this.initCustomButtons("4");
        this.initCustomButtons("5");
        this.initCustomButtons("6");
        this.initCustomButtons("7");
        this.initCustomButtons("8");
    }//  w w w  . ja va2 s. com
}

From source file:com.playhaven.android.req.PlayHavenRequest.java

@SuppressWarnings("deprecation")
protected UriComponentsBuilder createUrl(Context context) throws PlayHavenException {
    try {/* ww  w  . j  a  va2 s  . c  o m*/
        SharedPreferences pref = PlayHaven.getPreferences(context);

        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getString(pref, APIServer));
        builder.path(context.getResources().getString(getApiPath(context)));
        builder.queryParam("app", getString(pref, AppPkg));
        builder.queryParam("opt_out", getString(pref, OptOut, "0"));
        builder.queryParam("app_version", getString(pref, AppVersion));
        builder.queryParam("os", getInt(pref, OSVersion, 0));
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        builder.queryParam("orientation", display.getRotation());
        builder.queryParam("hardware", getString(pref, DeviceModel));
        PlayHaven.ConnectionType connectionType = getConnectionType(context);
        builder.queryParam("connection", connectionType.ordinal());
        builder.queryParam("idiom",
                context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);

        /**
         * For height/width we will use getSize(Point) not getRealSize(Point) as this will allow us to automatically
         * account for rotation and screen decorations like the status bar. We only want to know available space.
         *
         * @playhaven.apihack for SDK_INT < 13, have to use getHeight and getWidth!
         */
        Point size = new Point();
        if (Build.VERSION.SDK_INT >= 13) {
            display.getSize(size);
        } else {
            size.x = display.getWidth();
            size.y = display.getHeight();
        }
        builder.queryParam("width", size.x);
        builder.queryParam("height", size.y);

        /**
         * SDK Version needs to be reported as a dotted numeric value
         * So, if it is a -SNAPSHOT build, we will replace -SNAPSHOT with the date of the build
         * IE: 2.0.0.20130201
         * as opposed to an actual released build, which would be like 2.0.0
         */
        String sdkVersion = getString(pref, SDKVersion);
        String[] date = Version.PLUGIN_BUILD_TIME.split("[\\s]");
        sdkVersion = sdkVersion.replace("-SNAPSHOT", "." + date[0].replaceAll("-", ""));
        builder.queryParam("sdk_version", sdkVersion);

        builder.queryParam("plugin", getString(pref, PluginIdentifer));

        Locale locale = context.getResources().getConfiguration().locale;
        builder.queryParam("languages", String.format("%s,%s", locale.toString(), locale.getLanguage()));
        builder.queryParam("token", getString(pref, Token));

        builder.queryParam("device", getString(pref, DeviceId));
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        builder.queryParam("dpi", metrics.densityDpi);

        String uuid = UUID.randomUUID().toString();
        String nonce = base64Digest(uuid);
        builder.queryParam("nonce", nonce);

        ktsid = KontagentUtil.getSenderId(context);
        if (ktsid != null)
            builder.queryParam("sid", ktsid);

        addSignature(builder, pref, nonce);

        // Setup for signature verification
        String secret = getString(pref, Secret);
        SecretKeySpec key = new SecretKeySpec(secret.getBytes(UTF8), HMAC);
        sigMac = Mac.getInstance(HMAC);
        sigMac.init(key);
        sigMac.update(nonce.getBytes(UTF8));

        return builder;
    } catch (Exception e) {
        throw new PlayHavenException(e);
    }
}

From source file:com.jpventura.alexandria.MainActivity.java

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

From source file:net.olejon.spotcommander.MyTools.java

public boolean allowLandscape() {
    final int size = mContext.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;

    return ((size) == Configuration.SCREENLAYOUT_SIZE_LARGE
            || (size) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
}

From source file:gr.scify.newsum.ui.SearchViewActivity.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 ww  .  ja v a  2  s . c om
    SharedPreferences usertheme = getSharedPreferences("theme", 0);
    int newTheme = usertheme.getInt("theme", 2);
    Utils.onActivityCreateSetTheme(this, newTheme);

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

    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.view, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    gestureOverlayView.setGestureColor(Color.TRANSPARENT);
    gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gestureLib.load()) {
        finish();
    }
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(gestureOverlayView);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    ImageView title_image = (ImageView) findViewById(R.id.title_image);
    title_image.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify)));
            startActivity(browse);
        }

    });

    // setContentView(R.layout.view);
    // TODO: Add Loading dialog

    SharedPreferences setvmassage = getSharedPreferences("dialog", 0);
    boolean dialogShown = setvmassage.getBoolean("dialogShown", false);

    if (!dialogShown) {
        // prepare the alert box
        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage(R.string.view_massage);
        alertbox.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {

            }
        });
        alertbox.setCancelable(false);
        alertbox.show();

        SharedPreferences.Editor editor = setvmassage.edit();
        editor.putBoolean("dialogShown", true);
        editor.commit();
    }

    // Init waiting dialog
    showWaitingDialog();

    initLayoutAndControls();

}