Example usage for android.util DisplayMetrics DENSITY_HIGH

List of usage examples for android.util DisplayMetrics DENSITY_HIGH

Introduction

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

Prototype

int DENSITY_HIGH

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

Click Source Link

Document

Standard quantized DPI for high-density screens.

Usage

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  .jav  a 2 s  .  co 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: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
 *//*from   w  ww .  j a  va2s .  c om*/
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:com.github.marcosalis.kraken.demo.fragments.PhotosListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    switch (mPhotosSize) {
    case SMALL:/* ww  w.  ja  v a  2s. com*/
        mPhotosTask = new PhotosListTask("photos_130x130.json");
        break;
    case FULL_SCREEN:
        final DisplayMetrics metrics = DroidUtils.getDefaultDisplayMetrics(getActivity());
        if (metrics.densityDpi >= DisplayMetrics.DENSITY_HIGH) {
            mPhotosTask = new PhotosListTask("photos_720x720.json");
        } else {
            mPhotosTask = new PhotosListTask("photos_480x480.json");
        }
        break;
    }
    mPhotosTask.parallelExec(getActivity().getAssets());
}

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
 *///from  ww  w .j  a  va2s. c o 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;
    //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:com.lendingtree.view.BaseActivity.java

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

    setTitle(mTitleRes);// ww  w  . ja v  a2s .co  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.mozilla.fennec_satyanarayan.LauncherShortcuts.java

public void onListItemClick(int id) {
    HashMap<String, String> map = mWebappsList.get(id);

    String uri = map.get("uri").toString();
    String title = map.get("title").toString();
    String appKey = map.get("appKey").toString();
    String favicon = map.get("favicon").toString();

    File manifestFile = new File(mWebappsFolder, appKey + "/manifest.json");

    // Parse the contents into a string
    String manifestJson = new String();
    try {//w w w.java 2  s  . c o  m
        BufferedReader in = new BufferedReader(new FileReader(manifestFile));
        String line = new String();

        while ((line = in.readLine()) != null) {
            manifestJson += line;
        }
    } catch (IOException e) {
    }

    try {
        JSONObject manifest = (JSONObject) new JSONTokener(manifestJson).nextValue();
        uri += manifest.getString("launch_path");
    } catch (JSONException e) {
    }

    Intent shortcutintent = new Intent("org.mozilla.gecko.WEBAPP");
    shortcutintent.setClass(this, App.class);
    shortcutintent.putExtra("args", "--webapp=" + uri);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutintent);

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int size;
    switch (dm.densityDpi) {
    case DisplayMetrics.DENSITY_MEDIUM:
        size = 48;
        break;
    case DisplayMetrics.DENSITY_HIGH:
        size = 72;
        break;
    default:
        size = 72;
    }

    Bitmap bitmap = BitmapFactory.decodeFile(favicon);
    if (bitmap != null) {
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, size, size, true);
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap);
    }

    // Now, return the result to the launcher
    setResult(RESULT_OK, intent);
    finish();
}

From source file:com.adjust.sdk.Util.java

private static String getScreenDensity(final DisplayMetrics displayMetrics) {
    final int density = displayMetrics.densityDpi;
    final int low = (DisplayMetrics.DENSITY_MEDIUM + DisplayMetrics.DENSITY_LOW) / 2;
    final int high = (DisplayMetrics.DENSITY_MEDIUM + DisplayMetrics.DENSITY_HIGH) / 2;

    if (0 == density) {
        return UNKNOWN;
    } else if (density < low) {
        return LOW;
    } else if (density > high) {
        return HIGH;
    }/*from   w w  w .  j av  a  2  s .  c  om*/
    return MEDIUM;
}

From source file:net.evecom.androidecssp.base.BaseWebActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    temp = HttpUtil.getPageSize(this);
    setContentView(R.layout.message_post_web);
    // dialog = ProgressDialog.show(BaseWebActivity.this, null,
    // "..");// w  w  w.j  av  a2s  .c  om
    // dialog.setCancelable(true);

    lineProgressBar = (ProgressBar) findViewById(R.id.webview_progress_id);
    imageView = (ImageView) findViewById(R.id.image_view_at_web);
    webView = (WebView) this.findViewById(R.id.wv_oauth_message);
    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    CookieManager.getInstance().removeSessionCookie();

    webView.setWebViewClient(new BaseWebViewClient((BaseWebActivity) instance));
    webView.setWebChromeClient(new BaseChromeClient((BaseWebActivity) instance));

    // 
    webView.setDownloadListener(new MyWebViewDownLoadListener());
    WebSettings webSettings = webView.getSettings();
    webSettings.setSupportZoom(true);
    // WebViewJavaScript
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setBuiltInZoomControls(true);// support zoom
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    /**  */
    // //
    webSettings.setDatabaseEnabled(true);
    String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    // 
    webSettings.setGeolocationEnabled(true);
    // 
    webSettings.setGeolocationDatabasePath(dir);
    // 
    webSettings.setDomStorageEnabled(true);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    if (mDensity == 240) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == 160) {
        webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
    } else if (mDensity == 120) {
        webSettings.setDefaultZoom(ZoomDensity.CLOSE);
        // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){
        // webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == DisplayMetrics.DENSITY_HIGH) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    }

    dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0")
            .setPositiveButton("", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();

    webView.addJavascriptInterface(new JsInterface(getApplicationContext()), "androidbase");
    String url = HttpUtil.getPCURL() + "jfs/mobile/androidIndex/jqmobileTest";
    // post
    // webView.postUrl(url, postData) postDatabyte[] 
    // EncodingUtils.getBytes("&pwd=888", charset)
    webView.postUrl(url, EncodingUtils.getBytes("", "BASE64"));

}

From source file:net.evecom.android.web.Web2Activity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    temp = HttpUtil.getPageSize(this);
    setContentView(R.layout.message_post_web);
    imageView = (ImageView) findViewById(R.id.image_view_at_web);
    webView = (WebView) this.findViewById(R.id.wv_oauth_message);
    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    CookieManager.getInstance().removeSessionCookie();
    /**//from   w w  w.  j av  a2 s. c om
     * WebViewJavaScript
     */
    webView.getSettings().setJavaScriptEnabled(true);

    /**
     * loadUrl()
     */
    webView.setWebViewClient(new HelloWebViewClient());
    dialog = ProgressDialog.show(Web2Activity.this, null, "..");
    dialog.setCancelable(true);
    // http://localhost/gssms/mobile/loginController/dailyOfficeLogin?loginname=sysadmin&pwd=888888
    String url = HttpUtil.BASE_PC_URL + "mobile/loginController/dailyOfficeLogin";
    // post
    // String postDate = "loginname=sysadmin&pwd=888888";
    String postDate = "loginname=" + ShareUtil.getString(getApplicationContext(), "SESSION", "USERNAME", "")
            + "&pwd=" + ShareUtil.getString(getApplicationContext(), "SESSION", "PASSWORD", "") + "&pageSize="
            + temp;
    // webView.postUrl(url, postData) postDatabyte[] 
    // EncodingUtils.getBytes(data, charset)
    webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64"));
    // 
    webView.setDownloadListener(new MyWebViewDownLoadListener());
    WebSettings webSettings = webView.getSettings();
    webSettings.setSupportZoom(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setBuiltInZoomControls(true);// support zoom
    // webSettings.setPluginsEnabled(true);//support flash
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    // webSettings.setPluginsEnabled(true); //(flash)
    /**  */
    // //
    webSettings.setDatabaseEnabled(true);
    String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    // 
    webSettings.setGeolocationEnabled(true);
    // 
    webSettings.setGeolocationDatabasePath(dir);
    // 
    webSettings.setDomStorageEnabled(true);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    // DebugLog.d(TAG, "densityDpi = " + mDensity);
    if (mDensity == 240) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == 160) {
        webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
    } else if (mDensity == 120) {
        webSettings.setDefaultZoom(ZoomDensity.CLOSE);
        // }else if(mDensity == DisplayMetrics..DENSITY_XHIGH){
        // webSettings.setDefaultZoom(ZoomDensity.FAR);
    } else if (mDensity == DisplayMetrics.DENSITY_HIGH) {
        webSettings.setDefaultZoom(ZoomDensity.FAR);
    }
    webView.setWebChromeClient(m_chromeClient);// (flash)

    dialogPress = new AlertDialog.Builder(this).setTitle("").setMessage(":0/0")
            .setPositiveButton("", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
}