List of usage examples for android.view Display getSize
public void getSize(Point outSize)
From source file:es.glasspixel.wlanaudit.activities.SlidingMapActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void setUpShowCaseView(SlidingMenu sm) { if (showcaseView) { mShowcaseView.setShotType(ShowcaseView.TYPE_ONE_SHOT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); mShowcaseView.setShowcasePosition(0, size.y / 2); } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { mShowcaseView.setShowcasePosition(0, getWindowManager().getDefaultDisplay().getHeight() / 2); }/*from w w w. j a va2 s . com*/ showcase_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mShowcaseView.isShown()) { mShowcaseView.hide(); showcase_button.setOnClickListener(null); mShowcaseView.onClick(v); } } }); sm.setOnOpenListener(new OnOpenListener() { @Override public void onOpen() { if (mShowcaseView.isShown()) { mShowcaseView.hide(); mShowcaseView.onClick(showcase_button); } } }); } }
From source file:com.soft.pushsender.DemoActivity.java
public void getScreenSize() { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); width = size.x;/*from w ww. j a v a 2s . c o m*/ height = size.y; }
From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java
@SuppressLint("NewApi") private Point getDisplayDimensions() { Point size = new Point(); Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else {/*from ww w.j a v a 2 s . c om*/ size.set(display.getWidth(), display.getHeight()); } return size; }
From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); mDisplayWidth = size.x;//from ww w . j av a 2 s.c o m mBugWidth = (int) getResources().getDimension(R.dimen.multi_bugs_bug_width); mMinLeftWidth = (int) getResources().getDimension(R.dimen.multi_bugs_left_min_width); mMaxLeftWidth = mDisplayWidth; int gradientWidth = (int) getResources().getDimension(R.dimen.multi_bugs_gradient_width); mCollapsedBugsWidth = mDisplayWidth - mMinLeftWidth - mBugWidth + (gradientWidth * 2); mExpandedBugsWidth = mDisplayWidth - mMinLeftWidth; View view = inflater.inflate(R.layout.fragment_bugs_multipane, null); mLeftPane = (RelativeLayout) view.findViewById(R.id.leftPane); mBugsPane = (RelativeLayout) view.findViewById(R.id.bugsPane); mBugPane = (RelativeLayout) view.findViewById(R.id.bugPane); mLeftToolbar = (FrameLayout) view.findViewById(R.id.leftToolbar); mLeftHandle = (ImageButton) view.findViewById(R.id.leftHandle); mLeftHandle.setOnTouchListener(mLeftHandleTouchListener); mLeftHandle.setOnClickListener(this); mLeftView = (FrameLayout) view.findViewById(R.id.leftView); mLeftName = (TextView) view.findViewById(R.id.leftName); mBugRefresh = (ImageButton) view.findViewById(R.id.bugRefresh); mBugBookmark = (ImageButton) view.findViewById(R.id.bugBookmark); mBugShare = (ImageButton) view.findViewById(R.id.bugShare); mBugFullscreen = (ImageButton) view.findViewById(R.id.bugFullscreen); mBugClose = (ImageButton) view.findViewById(R.id.bugClose); mBugRefresh.setOnClickListener(this); mBugBookmark.setOnClickListener(this); mBugShare.setOnClickListener(this); mBugFullscreen.setOnClickListener(this); mBugClose.setOnClickListener(this); return view; }
From source file:com.google.mist.plot.MainActivity.java
private void dumpSystemInfo() { File dataDir = getOrCreateSessionDir(); File target = new File(dataDir, "system_info.txt"); // Only write system info once. if (target.exists()) { return;//from ww w . ja va 2 s . c o m } try { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); FileWriter fw = new FileWriter(target, true); fw.write(String.format("Build.DEVICE: %s\n", Build.DEVICE)); fw.write(String.format("Build.MODEL: %s\n", Build.MODEL)); fw.write(String.format("Build.PRODUCT: %s\n", Build.PRODUCT)); fw.write(String.format("Build.VERSION.SDK_INT: %d\n", Build.VERSION.SDK_INT)); fw.write(String.format("Screen resolution: %d x %d px\n", size.x, size.y)); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:me.tigerhe.shoppingpal.BarcodeCaptureActivity.java
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances./*from w w w .j a va2s. c o m*/ * * Suppressing InlinedApi since there is a check that the minimum version is met before using * the constant. */ @SuppressLint("InlinedApi") private void createCameraSource(boolean autoFocus, boolean useFlash) { Context context = getApplicationContext(); // A barcode detector is created to track barcodes. An associated multi-processor instance // is set to receive the barcode detection results, track the barcodes, and maintain // graphics for each barcode on screen. The factory is used by the multi-processor to // create a separate tracker instance for each barcode. BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build(); BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay); barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build()); if (!barcodeDetector.isOperational()) { // Note: The first time that an app using the barcode or face API is installed on a // device, GMS will download a native libraries to the device in order to do detection. // Usually this completes before the app is run for the first time. But if that // download has not yet completed, then the above call will not detect any barcodes // and/or faces. // // isOperational() can be used to check if the required native libraries are currently // available. The detectors will automatically become operational once the library // downloads complete on device. Log.w(TAG, "Detector dependencies are not yet available."); // Check for low storage. If there is low storage, the native library will not be // downloaded, so detection will not become operational. IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW); boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null; if (hasLowStorage) { Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show(); Log.w(TAG, getString(R.string.low_storage_error)); } } // Creates and starts the camera. Note that this uses a higher resolution in comparison // to other detection examples to enable the barcode detector to detect small barcodes // at long distances. Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector) .setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(size.x, size.y) .setRequestedFps(15.0f); // make sure that auto focus is an available option if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { builder = builder.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null); } mCameraSource = builder.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null).build(); }
From source file:com.sudeep23.lollipoptabs.fixedtab.FixedTabLayout.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)}.//from ww w . j a va2 s .co m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); 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); textView.setPadding(padding, padding, padding, padding); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width = 0; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { Point size = new Point(); display.getSize(size); width = size.x; } else { width = display.getWidth(); // deprecated } textView.setWidth(width / tabCount); return textView; }
From source file:com.google.android.gms.samples.vision.face.sleepAlert.DAssistActivity.java
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances./* w ww.j av a 2 s.com*/ */ private void createCameraSource() { Context context = getApplicationContext(); FaceDetector detector = new FaceDetector.Builder(context) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS).build(); detector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build()); if (!detector.isOperational()) { // Note: The first time that an app using face API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any faces. // // isOperational() can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Log.w(TAG, "Face detector dependencies are not yet available."); } Display display = getWindowManager().getDefaultDisplay(); Point screenSize = new Point(); display.getSize(screenSize); this.width = screenSize.x; this.height = screenSize.y; System.out.println(" Srini with size" + screenSize.x); System.out.println(" Srini with size" + screenSize.y); mCameraSource = new CameraSource.Builder(context, detector) .setRequestedPreviewSize(screenSize.x, screenSize.y).setFacing(CameraSource.CAMERA_FACING_FRONT) .setRequestedFps(30.0f).build(); }
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)}./*from w w w . jav 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.joanzapata.PDFViewActivity.java
public void convertQrCode(String _message) { // TODO Auto-generated method stub // Find screen size WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point); int width = point.x; int height = point.y; int smallerDimension = width < height ? width : height; smallerDimension = smallerDimension * 3 / 4; // Encode with a QR Code image QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(_message, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), smallerDimension); try {//from w w w . j av a2 s . com Bitmap bitmap = qrCodeEncoder.encodeAsBitmap(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); bitmapQrcode = Base64.encodeToString(byteArray, Base64.DEFAULT); } catch (WriterException e) { e.printStackTrace(); } }