Java Code Examples for android.util.DisplayMetrics#DENSITY_XXHIGH

The following examples show how to use android.util.DisplayMetrics#DENSITY_XXHIGH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DebugView.java    From u2020-mvp with Apache License 2.0 6 votes vote down vote up
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:
            return String.valueOf(displayMetrics.densityDpi);
    }
}
 
Example 2
Source File: DeviceInfo.java    From Cangol-appcore with Apache License 2.0 6 votes vote down vote up
/**
 * 获取设备Densitydpi 类型
 *
 * @param context
 * @return
 */
public static String getDensityDpiStr(Context context) {
    switch (context.getResources().getDisplayMetrics().densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
            return "LDPI";
        case DisplayMetrics.DENSITY_MEDIUM:
            return "MDPI";
        case DisplayMetrics.DENSITY_TV:
            return "TVDPI";
        case DisplayMetrics.DENSITY_HIGH:
            return "HDPI";
        case DisplayMetrics.DENSITY_XHIGH:
            return "XHDPI";
        case DisplayMetrics.DENSITY_XXHIGH:
            return "XXHDPI";
        case DisplayMetrics.DENSITY_XXXHIGH:
            return "XXXHDPI";
        default:
            return "";
    }
}
 
Example 3
Source File: DeviceInfoModule.java    From debugdrawer with Apache License 2.0 6 votes vote down vote up
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:
            return "unknown";
    }
}
 
Example 4
Source File: InvariantDeviceProfile.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
private int getLauncherIconDensity(int requiredSize) {
    // Densities typically defined by an app.
    int[] densityBuckets = new int[] {
            DisplayMetrics.DENSITY_LOW,
            DisplayMetrics.DENSITY_MEDIUM,
            DisplayMetrics.DENSITY_TV,
            DisplayMetrics.DENSITY_HIGH,
            DisplayMetrics.DENSITY_XHIGH,
            DisplayMetrics.DENSITY_XXHIGH,
            DisplayMetrics.DENSITY_XXXHIGH
    };

    int density = DisplayMetrics.DENSITY_XXXHIGH;
    for (int i = densityBuckets.length - 1; i >= 0; i--) {
        float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
                / DisplayMetrics.DENSITY_DEFAULT;
        if (expectedSize >= requiredSize) {
            density = densityBuckets[i];
        }
    }

    return density;
}
 
Example 5
Source File: BugReportLens.java    From u2020 with Apache License 2.0 6 votes vote down vote up
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:
      return String.valueOf(displayMetrics.densityDpi);
  }
}
 
Example 6
Source File: ScreenDensityInterceptor.java    From px-android with MIT License 6 votes vote down vote up
private String getDensityName(@NonNull final Context context) {
    final float densityScale = 1.0f / DisplayMetrics.DENSITY_DEFAULT;
    final float density = context.getResources().getDisplayMetrics().density / densityScale;

    if (density >= DisplayMetrics.DENSITY_XXXHIGH) {
        return "xxxhdpi";
    }
    if (density >= DisplayMetrics.DENSITY_XXHIGH) {
        return "xxhdpi";
    }
    if (density >= DisplayMetrics.DENSITY_XHIGH) {
        return "xhdpi";
    }
    if (density >= DisplayMetrics.DENSITY_HIGH) {
        return "hdpi";
    }
    if (density >= DisplayMetrics.DENSITY_MEDIUM) {
        return "mdpi";
    }
    return "ldpi";
}
 
Example 7
Source File: AptoideUtils.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
public static String getScreenDensity() {

            Context context = Aptoide.getContext();
            int density = context.getResources().getDisplayMetrics().densityDpi;

            switch (density) {
                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";

                default:
                    return "hdpi";
            }

        }
 
Example 8
Source File: WeekLabelView.java    From Android-LunarView with Apache License 2.0 6 votes vote down vote up
private static int dip2px(Context context) {
  int dpValue = 10;
  int dpi = context.getResources().getDisplayMetrics().densityDpi;
  if (dpi >= DisplayMetrics.DENSITY_XXXHIGH) {
    dpValue = 18;
  } else if (dpi >= DisplayMetrics.DENSITY_XXHIGH) {
    dpValue = 16;
  } else if (dpi >= DisplayMetrics.DENSITY_XHIGH) {
    dpValue = 15;
  } else if (dpi >= DisplayMetrics.DENSITY_HIGH) {
    dpValue = 14;
  }

  final float scale = context.getResources().getDisplayMetrics().density;
  return (int) (dpValue * scale + 0.5f);
}
 
Example 9
Source File: DeviceModule.java    From DebugDrawer with Apache License 2.0 6 votes vote down vote up
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:
            return String.valueOf(displayMetrics.densityDpi);
    }
}
 
Example 10
Source File: UIUtils.java    From sms-ticket with Apache License 2.0 6 votes vote down vote up
public static String getScreenDensityAsString(Context context) {
    String size = null;
    int density = context.getResources().getDisplayMetrics().densityDpi;
    if (density == DisplayMetrics.DENSITY_LOW) {
        size = "ldpi";
    }
    if (density == DisplayMetrics.DENSITY_MEDIUM) {
        size = "mdpi";
    }
    if (density == DisplayMetrics.DENSITY_TV) {
        size = "tvdpi";
    }
    if (density == DisplayMetrics.DENSITY_HIGH) {
        size = "hdpi";
    }
    if (density == DisplayMetrics.DENSITY_XHIGH) {
        size = "xhdpi";
    }
    if (density == DisplayMetrics.DENSITY_XXHIGH) {
        size = "xxhdpi";
    }
    return size;
}
 
Example 11
Source File: DebugView.java    From u2020 with Apache License 2.0 6 votes vote down vote up
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:
      return String.valueOf(displayMetrics.densityDpi);
  }
}
 
Example 12
Source File: ActivityManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * Get the preferred density of icons for the launcher. This is used when
 * custom drawables are created (e.g., for shortcuts).
 *
 * @return density in terms of DPI
 */
public int getLauncherLargeIconDensity() {
    final Resources res = mContext.getResources();
    final int density = res.getDisplayMetrics().densityDpi;
    final int sw = res.getConfiguration().smallestScreenWidthDp;

    if (sw < 600) {
        // Smaller than approx 7" tablets, use the regular icon size.
        return density;
    }

    switch (density) {
        case DisplayMetrics.DENSITY_LOW:
            return DisplayMetrics.DENSITY_MEDIUM;
        case DisplayMetrics.DENSITY_MEDIUM:
            return DisplayMetrics.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_TV:
            return DisplayMetrics.DENSITY_XHIGH;
        case DisplayMetrics.DENSITY_HIGH:
            return DisplayMetrics.DENSITY_XHIGH;
        case DisplayMetrics.DENSITY_XHIGH:
            return DisplayMetrics.DENSITY_XXHIGH;
        case DisplayMetrics.DENSITY_XXHIGH:
            return DisplayMetrics.DENSITY_XHIGH * 2;
        default:
            // The density is some abnormal value.  Return some other
            // abnormal value that is a reasonable scaling of it.
            return (int)((density*1.5f)+.5f);
    }
}
 
Example 13
Source File: EmailDeviceInfoLens.java    From telescope with Apache License 2.0 5 votes vote down vote up
public static String getDensityString(DisplayMetrics displayMetrics) {
  switch (displayMetrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
      return "ldpi";
    case DisplayMetrics.DENSITY_MEDIUM:
      return "mdpi";
    case DisplayMetrics.DENSITY_TV:
      return "tvdpi";
    case DisplayMetrics.DENSITY_HIGH:
      return "hdpi";
    case DisplayMetrics.DENSITY_260:
    case DisplayMetrics.DENSITY_280:
    case DisplayMetrics.DENSITY_300:
    case DisplayMetrics.DENSITY_XHIGH:
      return "xhdpi";
    case DisplayMetrics.DENSITY_340:
    case DisplayMetrics.DENSITY_360:
    case DisplayMetrics.DENSITY_400:
    case DisplayMetrics.DENSITY_420:
    case DisplayMetrics.DENSITY_XXHIGH:
      return "xxhdpi";
    case DisplayMetrics.DENSITY_560:
    case DisplayMetrics.DENSITY_XXXHIGH:
      return "xxxhdpi";
    default:
      return "unknown";
  }
}
 
Example 14
Source File: StatsChart.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the chart text size based on screen metrics
 */
private void setTextSize() {
	try {
		DisplayMetrics displayMetrics = new DisplayMetrics(); 
		displayMetrics = context.getResources().getDisplayMetrics();
		log("setting text size, density is " + displayMetrics.densityDpi);
		switch(displayMetrics.densityDpi){
	     case DisplayMetrics.DENSITY_LOW:
	    	 textSize = 12;
	    	 pointSize = 1f;
	         break;
	     case DisplayMetrics.DENSITY_MEDIUM:
	    	 textSize = 16;
	    	 pointSize = 1f;
	    	 break;
	     case DisplayMetrics.DENSITY_HIGH:
	    	 textSize = 18;
	    	 pointSize = 1f;
	    	 break;
	     case DisplayMetrics.DENSITY_XHIGH:
	    	 textSize = 20;
	    	 pointSize = 1f;
                break;
	     case DisplayMetrics.DENSITY_XXHIGH:
	    	 textSize = 26;
	    	 pointSize = 1f;
                break;
	     default:
	    	 break;
		}
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 15
Source File: EasyDisplayMod.java    From easydeviceinfo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets density.
 *
 * @return the density
 */
public final String getDensity() {
  String densityStr = null;
  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;
    default:
      //do nothing
      break;
  }
  return CheckValidityUtil.checkValidData(densityStr);
}
 
Example 16
Source File: ActivityManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
static int getLauncherLargeIconSizeInner(Context context) {
    final Resources res = context.getResources();
    final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
    final int sw = res.getConfiguration().smallestScreenWidthDp;

    if (sw < 600) {
        // Smaller than approx 7" tablets, use the regular icon size.
        return size;
    }

    final int density = res.getDisplayMetrics().densityDpi;

    switch (density) {
        case DisplayMetrics.DENSITY_LOW:
            return (size * DisplayMetrics.DENSITY_MEDIUM) / DisplayMetrics.DENSITY_LOW;
        case DisplayMetrics.DENSITY_MEDIUM:
            return (size * DisplayMetrics.DENSITY_HIGH) / DisplayMetrics.DENSITY_MEDIUM;
        case DisplayMetrics.DENSITY_TV:
            return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_HIGH:
            return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_XHIGH:
            return (size * DisplayMetrics.DENSITY_XXHIGH) / DisplayMetrics.DENSITY_XHIGH;
        case DisplayMetrics.DENSITY_XXHIGH:
            return (size * DisplayMetrics.DENSITY_XHIGH*2) / DisplayMetrics.DENSITY_XXHIGH;
        default:
            // The density is some abnormal value.  Return some other
            // abnormal value that is a reasonable scaling of it.
            return (int)((size*1.5f) + .5f);
    }
}
 
Example 17
Source File: Chart.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the chart text size based on screen metrics
 */
private void setTextSize() {
	try {
		DisplayMetrics displayMetrics = new DisplayMetrics(); 
		displayMetrics = context.getResources().getDisplayMetrics();
		log("setting text size, density is " + displayMetrics.densityDpi);
		switch(displayMetrics.densityDpi){
	     case DisplayMetrics.DENSITY_LOW:
	    	 textSize = 12;
	    	 pointSize = 2f;
	         break;
	     case DisplayMetrics.DENSITY_MEDIUM:
	    	 textSize = 16;
	    	 pointSize = 3f;
	    	 break;
	     case DisplayMetrics.DENSITY_HIGH:
	    	 textSize = 18;
	    	 pointSize = 4f;
	    	 break;
	     case DisplayMetrics.DENSITY_XHIGH:
	    	 textSize = 20;
	    	 pointSize = 5f;
                break;
	     case DisplayMetrics.DENSITY_XXHIGH:
	    	 textSize = 26;
	    	 pointSize = 7f;
                break;
	     default:
	    	 break;
		}
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 18
Source File: ActivityManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
static int getLauncherLargeIconSizeInner(Context context) {
    final Resources res = context.getResources();
    final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
    final int sw = res.getConfiguration().smallestScreenWidthDp;

    if (sw < 600) {
        // Smaller than approx 7" tablets, use the regular icon size.
        return size;
    }

    final int density = res.getDisplayMetrics().densityDpi;

    switch (density) {
        case DisplayMetrics.DENSITY_LOW:
            return (size * DisplayMetrics.DENSITY_MEDIUM) / DisplayMetrics.DENSITY_LOW;
        case DisplayMetrics.DENSITY_MEDIUM:
            return (size * DisplayMetrics.DENSITY_HIGH) / DisplayMetrics.DENSITY_MEDIUM;
        case DisplayMetrics.DENSITY_TV:
            return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_HIGH:
            return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH;
        case DisplayMetrics.DENSITY_XHIGH:
            return (size * DisplayMetrics.DENSITY_XXHIGH) / DisplayMetrics.DENSITY_XHIGH;
        case DisplayMetrics.DENSITY_XXHIGH:
            return (size * DisplayMetrics.DENSITY_XHIGH*2) / DisplayMetrics.DENSITY_XXHIGH;
        default:
            // The density is some abnormal value.  Return some other
            // abnormal value that is a reasonable scaling of it.
            return (int)((size*1.5f) + .5f);
    }
}
 
Example 19
Source File: MobileDeviceInfo.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
private void getScreenDensity() {

        int density;

        density = mContext.getResources().getDisplayMetrics().densityDpi;

        switch(density)
        {
            case DisplayMetrics.DENSITY_LOW:
                //  not used; but can't hurt adding it in case something changes
                formFactor = "LDPI";
                break;
            case DisplayMetrics.DENSITY_MEDIUM:
                formFactor = "MDPI";
                break;
            case DisplayMetrics.DENSITY_HIGH:
                formFactor = "HDPI";
                break;
            case DisplayMetrics.DENSITY_XHIGH:
                formFactor = "XHDPI";
                break;
            case DisplayMetrics.DENSITY_XXHIGH:
                formFactor = "XXHDPI";
                break;
            case DisplayMetrics.DENSITY_XXXHIGH:
                formFactor = "XXXHDPI";
                break;
            default:
                formFactor = "UNKNOWN";
                break;
        }
    }
 
Example 20
Source File: AbstractAppLaunchShortcut.java    From island with Apache License 2.0 4 votes vote down vote up
private static int getDpiForLargeIcon(final int dpi) {
	if (dpi >= DisplayMetrics.DENSITY_XHIGH) return DisplayMetrics.DENSITY_XXHIGH;
	if (dpi >= DisplayMetrics.DENSITY_HIGH) return DisplayMetrics.DENSITY_XHIGH;
	if (dpi >= DisplayMetrics.DENSITY_MEDIUM) return DisplayMetrics.DENSITY_HIGH;
	return DisplayMetrics.DENSITY_MEDIUM;
}