Example usage for android.util DisplayMetrics DENSITY_XHIGH

List of usage examples for android.util DisplayMetrics DENSITY_XHIGH

Introduction

In this page you can find the example usage for android.util DisplayMetrics DENSITY_XHIGH.

Prototype

int DENSITY_XHIGH

To view the source code for android.util DisplayMetrics DENSITY_XHIGH.

Click Source Link

Document

Standard quantized DPI for extra-high-density screens.

Usage

From source file:count.ly.messaging.DeviceInfo.java

/**
 * Maps the current display density to a string constant.
 * @param context context to use to retrieve the current display metrics
 * @return a string constant representing the current display density, or the
 *         empty string if the density is unknown
 *///  w  w  w .j a v  a2  s . co m
static String getDensity(final Context context) {
    String densityStr = "";
    final int density = context.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        densityStr = "LDPI";
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        densityStr = "MDPI";
        break;
    case DisplayMetrics.DENSITY_TV:
        densityStr = "TVDPI";
        break;
    case DisplayMetrics.DENSITY_HIGH:
        densityStr = "HDPI";
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        densityStr = "XHDPI";
        break;
    case DisplayMetrics.DENSITY_400:
        densityStr = "XMHDPI";
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXXHIGH:
        densityStr = "XXXHDPI";
        break;
    }
    return densityStr;
}

From source file:ly.count.android.sdk.DeviceInfo.java

/**
 * Maps the current display density to a string constant.
 * @param context context to use to retrieve the current display metrics
 * @return a string constant representing the current display density, or the
 *         empty string if the density is unknown
 *///ww  w . j  a va  2 s.  com
static String getDensity(final Context context) {
    String densityStr = "";
    final int density = context.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        densityStr = "LDPI";
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        densityStr = "MDPI";
        break;
    case DisplayMetrics.DENSITY_TV:
        densityStr = "TVDPI";
        break;
    case DisplayMetrics.DENSITY_HIGH:
        densityStr = "HDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_260:
    //    densityStr = "XHDPI";
    //    break;
    case DisplayMetrics.DENSITY_280:
        densityStr = "XHDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_300:
    //    densityStr = "XHDPI";
    //    break;
    case DisplayMetrics.DENSITY_XHIGH:
        densityStr = "XHDPI";
        break;
    //todo uncomment in android sdk 25
    //case DisplayMetrics.DENSITY_340:
    //    densityStr = "XXHDPI";
    //    break;
    case DisplayMetrics.DENSITY_360:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_400:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_420:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        densityStr = "XXHDPI";
        break;
    case DisplayMetrics.DENSITY_560:
        densityStr = "XXXHDPI";
        break;
    case DisplayMetrics.DENSITY_XXXHIGH:
        densityStr = "XXXHDPI";
        break;
    default:
        densityStr = "other";
        break;
    }
    return densityStr;
}

From source file:ly.count.android.api.DeviceInfoTests.java

public void testGetDensity() {
    Context mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_LOW);
    assertEquals("LDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_MEDIUM);
    assertEquals("MDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_TV);
    assertEquals("TVDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_HIGH);
    assertEquals("HDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XHIGH);
    assertEquals("XHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXHIGH);
    assertEquals("XXHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXXHIGH);
    assertEquals("XXXHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_400);
    assertEquals("XMHDPI", DeviceInfo.getDensity(mockContext));
    mockContext = mockContextForTestingDensity(0);
    assertEquals("", DeviceInfo.getDensity(mockContext));
}

From source file:es.usc.citius.servando.calendula.fragments.RoutineCreateOrEditFragment.java

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

    pColor = DB.patients().getActive(getActivity()).color();

    mNameTextView = (TextView) rootView.findViewById(R.id.routine_edit_name);
    timeButton = (Button) rootView.findViewById(R.id.button2);

    timeButton.setTextColor(pColor);/*from w w w.  j  a  v a  2 s. c o  m*/

    long routineId = -1;

    if (getArguments() != null) {
        routineId = getArguments().getLong(CalendulaApp.INTENT_EXTRA_ROUTINE_ID, -1);
    }

    if (routineId == -1 && savedInstanceState != null) {
        routineId = savedInstanceState.getLong(CalendulaApp.INTENT_EXTRA_ROUTINE_ID, -1);
    }

    if (routineId != -1) {
        mRoutine = Routine.findById(routineId);
        setRoutine(mRoutine);
        hour = mRoutine.time().getHourOfDay();
        minute = mRoutine.time().getMinuteOfHour();
    } else {
        DateTime now = DateTime.now();
        hour = now.getHourOfDay();
        minute = now.getMinuteOfHour();
    }

    if (getDialog() != null) {
        getDialog().setTitle(R.string.title_create_routine_activity);
        mConfirmButton = (Button) rootView.findViewById(R.id.done_button);
        mConfirmButton.setVisibility(View.VISIBLE);
        mConfirmButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onEdit();
            }
        });
    }

    timeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            float density = getResources().getDisplayMetrics().densityDpi;
            Log.d("RoutineCreateOrEditFragment", "Density: " + density);
            if (density >= DisplayMetrics.DENSITY_XHIGH) {
                RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog
                        .newInstance(RoutineCreateOrEditFragment.this, hour, minute, true);
                timePickerDialog.show(getChildFragmentManager(), "111");
            } else {
                TimePickerBuilder tpb = new TimePickerBuilder().setFragmentManager(getChildFragmentManager())
                        .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                tpb.addTimePickerDialogHandler(RoutineCreateOrEditFragment.this);
                tpb.show();
            }

        }
    });

    updateTime();

    return rootView;
}

From source file:com.lendingtree.view.BaseActivity.java

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

    setTitle(mTitleRes);// w  w  w.  jav a 2  s  .c o m

    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    if (savedInstanceState == null) {
        FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
        mFrag = new SlidingMenuFragment();
        t.replace(R.id.menu_frame, mFrag);
        t.commit();
    } else {
        mFrag = (Fragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
    }

    // Ramesh Gundala for Menu Icon showing
    ActionBar ab = getSupportActionBar();
    ab.setHomeButtonEnabled(true);
    // ab.setDisplayHomeAsUpEnabled(true);
    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(Constants.ZERO_POINT_THREE_FIVE);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    switch (metrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:

        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        sm.setTouchmodeMarginThreshold(Constants.SIXTY);
        break;
    case DisplayMetrics.DENSITY_HIGH:
        sm.setTouchmodeMarginThreshold(Constants.SIXTY);
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        sm.setTouchmodeMarginThreshold(Constants.EIGHTY);
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        sm.setTouchmodeMarginThreshold(Constants.HUNDRED);
        break;
    default:
        sm.setTouchmodeMarginThreshold(Constants.SIXTY);
    }
    onStartCount = 1;
    if (savedInstanceState == null) // 1st time
    {
        if (sliding) {
            this.overridePendingTransition(0, 0);
        } else {
            this.overridePendingTransition(R.anim.anim_slide_in_left, R.anim.anim_slide_out_left);
        }
    } else // already created so reverse animation
    {
        onStartCount = 2;
    }
    // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // getSupportActionBar().setDisplayShowHomeEnabled(false);
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.db.charts.PieChartActivity.java

private void applySize() {
    switch (getResources().getDisplayMetrics().densityDpi) {
    case Constants.DENSITY_XXHIGH:
        renderer.setMargins(new int[] { 50, 130, 30, 10 });
        // renderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XXHDPI);
        renderer.setChartTitleTextSize(Constants.TEXT_SIZE_XXXHDPI);
        renderer.setLabelsTextSize(Constants.TEXT_SIZE_XXHDPI);
        renderer.setLegendTextSize(Constants.TEXT_SIZE_XXHDPI);
        break;/*from  w w  w . ja  v a 2  s . c o  m*/
    case DisplayMetrics.DENSITY_XHIGH:
        renderer.setMargins(new int[] { 40, 90, 25, 10 });
        // renderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XHDPI);
        renderer.setChartTitleTextSize(Constants.TEXT_SIZE_XHDPI);
        renderer.setLabelsTextSize(Constants.TEXT_SIZE_XHDPI);
        renderer.setLegendTextSize(Constants.TEXT_SIZE_XHDPI);
        break;
    case DisplayMetrics.DENSITY_HIGH:
        renderer.setMargins(new int[] { 30, 50, 20, 10 });
        // renderer.setAxisTitleTextSize(Constants.TEXT_SIZE_HDPI);
        renderer.setChartTitleTextSize(Constants.TEXT_SIZE_HDPI);
        renderer.setLabelsTextSize(Constants.TEXT_SIZE_HDPI);
        renderer.setLegendTextSize(Constants.TEXT_SIZE_HDPI);
        break;
    default:
        renderer.setMargins(new int[] { 30, 50, 20, 10 });
        // renderer.setAxisTitleTextSize(Constants.TEXT_SIZE_LDPI);
        renderer.setChartTitleTextSize(Constants.TEXT_SIZE_LDPI);
        renderer.setLabelsTextSize(Constants.TEXT_SIZE_LDPI);
        renderer.setLegendTextSize(Constants.TEXT_SIZE_LDPI);
        break;
    }

}

From source file:com.landenlabs.all_devtool.ScreenFragment.java

void updateView() {
    m_displayMetrics = Utils.getDisplayMetrics(m_context);

    m_layout = Ui.viewById(m_rootView, R.id.screen_layout);
    m_screenDevice = Ui.viewById(m_rootView, R.id.screen_device);

    TextView screenSizeText = Ui.viewById(m_rootView, R.id.screen_size);
    TextView screenDensityText = Ui.viewById(m_rootView, R.id.screen_density);

    m_screenDevice.setText(Build.MODEL);
    int widthPx = m_displayMetrics.widthPixels;
    int heightPx = m_displayMetrics.heightPixels;
    String sizeStr = String.format(Locale.getDefault(), "%.0f dp x %.0f dp\n%d px x %d px\n%.1f in x %.1f in",
            Utils.pxToDp(widthPx), Utils.pxToDp(heightPx), widthPx, heightPx,
            (float) widthPx / m_displayMetrics.densityDpi, (float) heightPx / m_displayMetrics.densityDpi);
    screenSizeText.setText(sizeStr);// w w w . j  av  a2  s.c  o  m

    String densityStr = "Low";
    if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_MEDIUM)
        densityStr = "Medium";
    else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_HIGH)
        densityStr = "High";
    else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XHIGH)
        densityStr = "x-High";
    else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XXHIGH)
        densityStr = "xx-High";
    else if (m_displayMetrics.densityDpi > DisplayMetrics.DENSITY_XXHIGH)
        densityStr = "xxx-High";

    screenDensityText.setText(String.format("Density %s(%d) px/dp=%.2f", densityStr,
            m_displayMetrics.densityDpi, m_displayMetrics.density));

    m_horzWindowArrow = Ui.viewById(m_rootView, R.id.horz_arrow);
    m_vertPanelArrow = Ui.viewById(m_rootView, R.id.vert_panel_arrow);

    m_horzWindowText = Ui.viewById(m_rootView, R.id.horz_arrow_text);
    m_vertPanelText = Ui.viewById(m_rootView, R.id.vert_panel_text);

    TextView themeTv = Ui.viewById(m_rootView, R.id.theme);
    // themeTv.setRotation(-90);
    String themeName = GlobalInfo.s_globalInfo.themeName;
    if (!themeName.equals("Theme.Holo"))
        themeName = themeName + "\nBest with Theme.Halo";
    themeTv.setText(themeName);

    /*
     * Dynamically get theme - always returns 'AppTheme' which is set in style
    try {
        PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(GlobalInfo.s_globalInfo.pkgName, 0);
         int themeResId = packageInfo.applicationInfo.theme;
         String themeName = getResources().getResourceEntryName(themeResId);
         themeTv.setText(themeName);
    } catch (Exception ex) {
        themeTv.setVisibility(View.GONE);
    }
    */

    Message msgObj = m_handler.obtainMessage(MSG_GET_UI_SIZE);
    m_handler.sendMessageDelayed(msgObj, 1000);

    final TextView touchPos = Ui.viewById(m_rootView, R.id.touch_pos);
    m_drawPoints = Ui.viewById(m_rootView, R.id.drawPoints);
    m_drawPoints.setOnTouchInfo(new DrawView.TouchInfo() {
        public void onTouchInfo(MotionEvent event) {
            touchPos.setText(String.format("%.0f,%.0f", event.getX(), event.getY()));
        }
    });
}

From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java

private static String getDensityString(DisplayMetrics displayMetrics) {
    switch (displayMetrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
        return "ldpi";
    case DisplayMetrics.DENSITY_MEDIUM:
        return "mdpi";
    case DisplayMetrics.DENSITY_HIGH:
        return "hdpi";
    case DisplayMetrics.DENSITY_XHIGH:
        return "xhdpi";
    case DisplayMetrics.DENSITY_XXHIGH:
        return "xxhdpi";
    case DisplayMetrics.DENSITY_XXXHIGH:
        return "xxxhdpi";
    case DisplayMetrics.DENSITY_TV:
        return "tvdpi";
    default:/*  w ww  .j  a  va2s .  co m*/
        return "unknown";
    }
}

From source file:com.photon.phresco.nativeapp.eshop.activity.PhrescoActivity.java

/**
 * The screen density expressed as dpi//from w ww.j av a  2 s  . c o m
 *
 * @return int
 *
 * @return May be either DENSITY_LOW, DENSITY_MEDIUM, or DENSITY_HIGH.
 */
protected int getScreenDensity() {
    int screenDensity = 0;
    try {
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        switch (metrics.densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
            PhrescoLogger.info(TAG + "DENSITY_LOW");
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            PhrescoLogger.info(TAG + "DENSITY_MEDIUM");
            break;
        case DisplayMetrics.DENSITY_HIGH:
            PhrescoLogger.info(TAG + "DENSITY_HIGH");
            break;
        case DisplayMetrics.DENSITY_XHIGH:
            PhrescoLogger.info(TAG + "DENSITY_EXTRA_HIGH");
            break;
        }
        PhrescoLogger.info(TAG + "densityDpi: " + metrics.densityDpi);
        PhrescoLogger.info(TAG + "density: " + metrics.density);
        PhrescoLogger.info(TAG + "heightPixels: " + metrics.heightPixels);
        PhrescoLogger.info(TAG + "widthPixels: " + metrics.widthPixels);

        screenDensity = metrics.densityDpi;
    } catch (Exception ex) {
        PhrescoLogger.info(TAG + "getScreenDensity: Exception: " + ex.toString());
        PhrescoLogger.warning(ex);
    }
    return screenDensity;
}

From source file:watch.oms.omswatch.application.OMSApplication.java

/**
 * Checks if the device is a tablet or a phone
 * //from  w ww. j  av a  2s.c  o m
 * @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;
}