List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:com.poepoemyintswe.popularmovies.ui.MainFragment.java
private int calculateWidth() { int measuredWidth; WindowManager w = getActivity().getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); w.getDefaultDisplay().getSize(size); measuredWidth = size.x;//from w ww . j a v a 2 s.c o m } else { Display d = w.getDefaultDisplay(); measuredWidth = d.getWidth(); } measuredWidth = measuredWidth / 6; return measuredWidth; }
From source file:com.androchill.call411.MainActivity.java
private Phone getHardwareSpecs() { ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); PhoneBuilder pb = new PhoneBuilder(); pb.setModelNumber(Build.MODEL);//w w w . j a v a2 s .co m pb.setManufacturer(Build.MANUFACTURER); Process p = null; String board_platform = "No data available"; try { p = new ProcessBuilder("/system/bin/getprop", "ro.chipname").redirectErrorStream(true).start(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = br.readLine()) != null) { board_platform = line; } p.destroy(); } catch (IOException e) { e.printStackTrace(); board_platform = "No data available"; } pb.setProcessor(board_platform); ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(mInfo); pb.setRam((int) (mInfo.totalMem / 1048576L)); pb.setBatteryCapacity(getBatteryCapacity()); pb.setTalkTime(-1); pb.setDimensions("No data available"); WindowManager mWindowManager = getWindowManager(); Display mDisplay = mWindowManager.getDefaultDisplay(); Point mPoint = new Point(); mDisplay.getSize(mPoint); pb.setScreenResolution(mPoint.x + " x " + mPoint.y + " pixels"); DisplayMetrics mDisplayMetrics = new DisplayMetrics(); mDisplay.getMetrics(mDisplayMetrics); int mDensity = mDisplayMetrics.densityDpi; pb.setScreenSize( Math.sqrt(Math.pow(mPoint.x / (double) mDensity, 2) + Math.pow(mPoint.y / (double) mDensity, 2))); Camera camera = Camera.open(0); android.hardware.Camera.Parameters params = camera.getParameters(); List sizes = params.getSupportedPictureSizes(); Camera.Size result = null; ArrayList<Integer> arrayListForWidth = new ArrayList<Integer>(); ArrayList<Integer> arrayListForHeight = new ArrayList<Integer>(); for (int i = 0; i < sizes.size(); i++) { result = (Camera.Size) sizes.get(i); arrayListForWidth.add(result.width); arrayListForHeight.add(result.height); } if (arrayListForWidth.size() != 0 && arrayListForHeight.size() != 0) { pb.setCameraMegapixels( Collections.max(arrayListForHeight) * Collections.max(arrayListForWidth) / (double) 1000000); } else { pb.setCameraMegapixels(-1); } camera.release(); pb.setPrice(-1); pb.setWeight(-1); pb.setSystem("Android " + Build.VERSION.RELEASE); StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); StatFs statInternal = new StatFs(Environment.getRootDirectory().getAbsolutePath()); double storageSize = ((stat.getBlockSizeLong() * stat.getBlockCountLong()) + (statInternal.getBlockSizeLong() * statInternal.getBlockCountLong())) / 1073741824L; pb.setStorageOptions(storageSize + " GB"); TelephonyManager telephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)); String operatorName = telephonyManager.getNetworkOperatorName(); if (operatorName.length() == 0) operatorName = "No data available"; pb.setCarrier(operatorName); pb.setNetworkFrequencies("No data available"); pb.setImage(null); return pb.createPhone(); }
From source file:com.duckduckgo.mobile.android.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* w w w. ja v a 2 s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.TOP | Gravity.CENTER); textView.setTextAppearance(context, R.style.TabTitle); textView.setHeight((int) getResources().getDimension(R.dimen.actionbar_tab_height2)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); int halfPadding = (int) (padding * 0.5); //textView.setPadding(padding, padding, padding, padding); textView.setPadding(padding, halfPadding, padding, padding); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); int width; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); display.getSize(size); width = size.x; } else { width = display.getWidth(); } if (width > getResources().getDimension(R.dimen.tab_small) || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { textView.setWidth(width / mViewPager.getAdapter().getCount()); } return textView; }
From source file:com.github.mobile.util.HttpImageGetter.java
@SuppressWarnings("deprecation") private Point fetchDisplaySizePreHoneycomb(WindowManager wm) { Display display = wm.getDefaultDisplay(); return new Point(display.getWidth(), display.getHeight()); }
From source file:de.radiohacks.frinmean.emojicon.EmojiconsPopup.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public int calculateScreenHeightForLollipop() { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww .j av a2s . c o m return size.y; }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ??X//from w w w. j av a 2 s . co m * * @return */ private int getLastX() { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); final Point size = new Point(); display.getSize(size); final int measureText = (int) mTextPaint.measureText(mText); if (measureText >= size.x) { // ???? return -measureText; } else { return -measureText; } }
From source file:com.golden.android.eyecare.ForegroundService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { ////w w w .j a va 2s. com //Do nothing If you already exist Manager if (mFloatingViewManager != null) { return START_REDELIVER_INTENT; } final DisplayMetrics metrics = new DisplayMetrics(); final WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metrics); final LayoutInflater inflater = LayoutInflater.from(this); // Vibrator v = (Vibrator) this.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); // // Vibrate for 500 milliseconds // v.vibrate(1000); // if(intent.getExtras()==null) // { // // } // else { // Boolean data = (Boolean) intent.getExtras().getBoolean("noticlick"); // // if (data) { // // launchCount(); // //Do your stuff here mate :) // } // } final ImageView iconView = (ImageView) inflater.inflate(R.layout.floating, null, false); iconView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // ? // final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.mail_address), null)); // intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_title)); // intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.mail_content)); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // startActivity(intent); launchCount(); } }); // String ToastString = getString(R.string.Toasttext1) + " " + checkTime() + " " + getString(R.string.Toasttext2); // Toast toast = Toast.makeText(getApplicationContext(), ToastString, Toast.LENGTH_SHORT); //// Set the Gravity to Top and Left // toast.setGravity(Gravity.TOP | Gravity.LEFT, 100, 200); // toast.setDuration(Toast.LENGTH_LONG); // // ViewGroup group = (ViewGroup) toast.getView(); // TextView messageTextView = (TextView) group.getChildAt(0); // messageTextView.setTextSize(20); // toast.show(); mFloatingViewManager = new FloatingViewManager(this, this); mFloatingViewManager.setFixedTrashIconImage(R.drawable.ic_trash_fixed); mFloatingViewManager.setActionTrashIconImage(R.drawable.ic_trash_action); // Setting Options(you can change options at any time) loadDynamicOptions(); // Initial Setting Options (you can't change options after created.) final FloatingViewManager.Options options = loadOptions(metrics); mFloatingViewManager.addViewToWindow(iconView, options); mFloatingViewManager.setDisplayMode(FloatingViewManager.DISPLAY_MODE_SHOW_ALWAYS); notify(intent); return START_REDELIVER_INTENT; }
From source file:com.online.fullsail.SaveWebMedia.java
public Bitmap decodeBitmapFile(String filename) { System.gc();/*from w ww .j ava 2s. co m*/ WindowManager wManager = (WindowManager) this.context.getApplicationContext() .getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wManager.getDefaultDisplay().getMetrics(metrics); final float scale = this.context.getResources().getDisplayMetrics().density; int reqWidth = (int) (metrics.widthPixels * scale + 0.5f); int reqHeight = (int) (metrics.heightPixels * scale + 0.5f); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile(filename, options); int heightRatio = (int) Math.ceil(options.outHeight / (float) reqHeight); int widthRatio = (int) Math.ceil(options.outWidth / (float) reqWidth); if (heightRatio > 1 || widthRatio > 1) { if (heightRatio > widthRatio) { options.inSampleSize = heightRatio; } else { options.inSampleSize = widthRatio; } } options.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeFile(filename, options); return bitmap; }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ??//ww w . java 2s.c om * * @param measureSpec * @return */ private int measureWidth(int measureSpec) { final int result; final int specMode = MeasureSpec.getMode(measureSpec); final int specSize = MeasureSpec.getSize(measureSpec); if (specMode == MeasureSpec.EXACTLY) { // We were told how big to be result = specSize; } else { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); result = display.getWidth(); } return result; }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ???X?/*from www .j ava 2 s. c om*/ * * @return */ private int getMarqueeStartX() { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); final Point size = new Point(); display.getSize(size); final int measureText = (int) mTextPaint.measureText(mText); final int measureWidth = getMeasuredWidth(); if (size.x == measureWidth) { return measureWidth; } else if (measureText > size.x) { // ???? return size.x; } else if (measureWidth > measureText) { return measureWidth; } else { return measureText; } }