List of usage examples for android.content Context WINDOW_SERVICE
String WINDOW_SERVICE
To view the source code for android.content Context WINDOW_SERVICE.
Click Source Link
From source file:ca.nehil.rter.streamingapp2.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); screenWidth = display.getWidth();/*w w w .j a v a2s . co m*/ screenHeight = display.getHeight(); FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); FrameLayout topLayout = new FrameLayout(this); setContentView(topLayout); // openGLview mGLView = overlay.getGLView(); /* add camera view */ // int display_width_d = (int) (1.0 * bg_screen_width * screenWidth / // bg_width); // int display_height_d = (int) (1.0 * bg_screen_height * screenHeight / // bg_height); // int prev_rw, prev_rh; // if (1.0 * display_width_d / display_height_d > 1.0 * live_width / // live_height) { // prev_rh = display_height_d; // prev_rw = (int) (1.0 * display_height_d * live_width / live_height); // } else { // prev_rw = display_width_d; // prev_rh = (int) (1.0 * display_width_d * live_height / live_width); // } // layoutParam = new RelativeLayout.LayoutParams(prev_rw, prev_rh); // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight / // bg_height); // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth / // bg_width); int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); //layoutParam = new FrameLayout.LayoutParams(prev_rw / 2, prev_rh / 2, Gravity.BOTTOM | Gravity.CENTER_VERTICAL); // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight / // bg_height); // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth / // bg_width); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); final Button recorderButton = (Button) findViewById(R.id.recorder_control); recorderButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!recording) { Log.d(TAG, "attemptHandshaking"); attemptHandshake(); Log.w(LOG_TAG, "Start Button Pushed"); recorderButton.setText("Stop"); } else { stopRecording(); Log.w(LOG_TAG, "Stop Button Pushed"); recorderButton.setText("Start"); } } }); }
From source file:com.yamin.kk.vlc.Util.java
public static int convertPxToDp(int px) { WindowManager wm = (WindowManager) VLCApplication.getAppContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*from w ww .j a v a2 s.co m*/ float logicalDensity = metrics.density; int dp = Math.round(px / logicalDensity); return dp; }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ??X/* w w w .ja v 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.nextgis.maplibui.util.ControlHelper.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static void lockScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; }/*from ww w . j ava2 s . c o m*/ } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; } } }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java
/** * Adjusts the layout parameters of the barcode picker according to the margins set through java script. * * @param bundle The bundle with the java script parameters. * @param animationDuration Over how long the change should be animated. *//* w w w . ja v a 2 s . c om*/ private void adjustLayout(Bundle bundle, double animationDuration) { if (mBarcodePicker == null) { return; } final RelativeLayout.LayoutParams rLayoutParams = (RelativeLayout.LayoutParams) mBarcodePicker .getLayoutParams(); Display display = ((WindowManager) webView.getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); if (bundle.containsKey(ScanditSDKParameterParser.paramPortraitMargins) && display.getHeight() > display.getWidth()) { String portraitMargins = bundle.getString(ScanditSDKParameterParser.paramPortraitMargins); String[] split = portraitMargins.split("[/]"); if (split.length == 4) { try { final Rect oldPortraitMargins = new Rect(mPortraitMargins); mPortraitMargins = new Rect(Integer.valueOf(split[0]), Integer.valueOf(split[1]), Integer.valueOf(split[2]), Integer.valueOf(split[3])); if (animationDuration > 0) { Animation anim = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { rLayoutParams.topMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldPortraitMargins.top + (mPortraitMargins.top - oldPortraitMargins.top) * interpolatedTime)); rLayoutParams.rightMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldPortraitMargins.right + (mPortraitMargins.right - oldPortraitMargins.right) * interpolatedTime)); rLayoutParams.bottomMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldPortraitMargins.bottom + (mPortraitMargins.bottom - oldPortraitMargins.bottom) * interpolatedTime)); rLayoutParams.leftMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldPortraitMargins.left + (mPortraitMargins.left - oldPortraitMargins.left) * interpolatedTime)); mBarcodePicker.setLayoutParams(rLayoutParams); } }; anim.setDuration((int) (animationDuration * 1000)); mBarcodePicker.startAnimation(anim); } else { rLayoutParams.topMargin = SbSystemUtils.pxFromDp(webView.getContext(), mPortraitMargins.top); rLayoutParams.rightMargin = SbSystemUtils.pxFromDp(webView.getContext(), mPortraitMargins.right); rLayoutParams.bottomMargin = SbSystemUtils.pxFromDp(webView.getContext(), mPortraitMargins.bottom); rLayoutParams.leftMargin = SbSystemUtils.pxFromDp(webView.getContext(), mPortraitMargins.left); mBarcodePicker.setLayoutParams(rLayoutParams); } } catch (NumberFormatException e) { } } } else if (bundle.containsKey(ScanditSDKParameterParser.paramLandscapeMargins) && display.getWidth() > display.getHeight()) { String landscapeMargins = bundle.getString(ScanditSDKParameterParser.paramLandscapeMargins); String[] split = landscapeMargins.split("[/]"); if (split.length == 4) { final Rect oldLandscapeMargins = new Rect(mLandscapeMargins); mLandscapeMargins = new Rect(Integer.valueOf(split[0]), Integer.valueOf(split[1]), Integer.valueOf(split[2]), Integer.valueOf(split[3])); Animation anim = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { rLayoutParams.topMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldLandscapeMargins.top + (mLandscapeMargins.top - oldLandscapeMargins.top) * interpolatedTime)); rLayoutParams.rightMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldLandscapeMargins.right + (mLandscapeMargins.right - oldLandscapeMargins.right) * interpolatedTime)); rLayoutParams.bottomMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldLandscapeMargins.bottom + (mLandscapeMargins.bottom - oldLandscapeMargins.bottom) * interpolatedTime)); rLayoutParams.leftMargin = SbSystemUtils.pxFromDp(webView.getContext(), (int) (oldLandscapeMargins.left + (mLandscapeMargins.left - oldLandscapeMargins.left) * interpolatedTime)); mBarcodePicker.setLayoutParams(rLayoutParams); } }; anim.setDuration((int) (animationDuration * 1000)); mBarcodePicker.startAnimation(anim); } } }
From source file:com.example.admin.news.mvp.ui.activities.base.BaseActivity.java
private void initNightView() { if (mIsAddedView) { return;/* ww w . j a va 2 s.c om*/ } // ?? WindowManager.LayoutParams nightViewParam = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT); mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); mNightView = new View(this); mWindowManager.addView(mNightView, nightViewParam); mIsAddedView = true; }
From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override/*from w w w . jav a 2 s. c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.DISPLAY_NAME }; String selection = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?"; String[] selectionArgs = new String[] { TEMP_WALLPAPER_DIR }; Cursor mImageCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null); mImageCursor.moveToFirst(); if (mImageCursor.getCount() == 1) { imageId = mImageCursor.getInt((mImageCursor.getColumnIndex(MediaStore.Images.Media._ID))); Log.e("CROP", "" + imageId); mImageCursor.close(); } checkDir(); timerTasks = new TimerTasks(context); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE_SMALL); supportPostponeEnterTransition(); superCategory = getIntent().getExtras().getInt(EXTRA_SUPER_CATEGORY); floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_set_as_wallpaper); floatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setAsWallpaper(imageId); } }); toolbar = ((Toolbar) findViewById(R.id.toolbar)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setVisibility(View.GONE); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); progressBar = (ProgressBar) findViewById(R.id.progressBarImage); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); imageView = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE_SMALL)).into(imageView, new Callback() { @SuppressWarnings("NewApi") @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); float ImageHieghtTemp = bitmap.getHeight(); float ImageWidthTemp = bitmap.getWidth(); Point size = new Point(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getRealSize(size); float widthMain = size.x; float heightMain = size.y; imageView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int addWidth = imageView.getMeasuredWidth(); // Display display = getWindowManager().getDefaultDisplay(); // float widthMain = display.getWidth(); // float heightMain = display.getHeight(); Log.e(LOG_TAG, "IMAGE_MAIN : " + ImageWidthTemp + " : " + ImageHieghtTemp); float imageHeight = widthMain * ((float) (bitmap.getHeight()) / (float) (bitmap.getWidth())); float scaleXY = heightMain / imageHeight; if (scaleXY > 1.0007f) { Log.e(LOG_TAG, "SCALE FACTORE : " + scaleXY + " : " + 1.10454545f * scaleXY); scaleXY = 1.8f * scaleXY; } PhotoViewAttacher mAttacherTest = new PhotoViewAttacher(imageView, true, false); mAttacherTest.setZoomScale(scaleXY); mAttacherTest.setScale(scaleXY, (widthMain) / 2, heightMain / 2, true); Log.e(LOG_TAG, "DETAILS : " + widthMain + " : " + heightMain + " : " + scaleXY + " : " + bitmap.getWidth() + " : " + bitmap.getHeight()); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } // clearApplicationData(); new ImageLoadTask().execute(""); initDownloadComponents(); mAdView = (AdView) findViewById(R.id.adViewFullImage); mAdView.setVisibility(View.GONE); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); // Start loading the ad in sthe background. mAdView.loadAd(adRequest); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); mAdView.setVisibility(View.VISIBLE); } }); }
From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java
public WearableDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mFlingWatcher = new FlingWatcherFactory(this); mTopDrawerDraggerCallback = new TopDrawerDraggerCallback(); mTopDrawerDragger = ViewDragHelper.create(this, 1f /* sensitivity */, mTopDrawerDraggerCallback); mTopDrawerDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); mBottomDrawerDraggerCallback = new BottomDrawerDraggerCallback(); mBottomDrawerDragger = ViewDragHelper.create(this, 1f /* sensitivity */, mBottomDrawerDraggerCallback); mBottomDrawerDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); windowManager.getDefaultDisplay().getMetrics(metrics); mNestedScrollSlopPx = Math.round(metrics.density * NESTED_SCROLL_SLOP_DP); AccessibilityManager accessibilityManager = (AccessibilityManager) context .getSystemService(Context.ACCESSIBILITY_SERVICE); mIsAccessibilityEnabled = accessibilityManager.isEnabled(); }
From source file:com.gh4a.utils.HttpImageGetter.java
public HttpImageGetter(Context context) { mContext = context;//from w w w . j ava2 s. c o m mCacheDir = context.getCacheDir(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final Point size = new Point(); wm.getDefaultDisplay().getSize(size); mWidth = size.x; mHeight = size.y; mLoadingDrawable = ContextCompat.getDrawable(context, UiUtils.resolveDrawable(context, R.attr.loadingPictureIcon)); mLoadingDrawable.setBounds(0, 0, mLoadingDrawable.getIntrinsicWidth(), mLoadingDrawable.getIntrinsicHeight()); mErrorDrawable = ContextCompat.getDrawable(context, UiUtils.resolveDrawable(context, R.attr.contentPictureIcon)); mErrorDrawable.setBounds(0, 0, mErrorDrawable.getIntrinsicWidth(), mErrorDrawable.getIntrinsicHeight()); }
From source file:com.appassit.common.Utils.java
public static float sp2px(Context context, float sp) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics displaymetrics = new DisplayMetrics(); display.getMetrics(displaymetrics);// ww w .ja va 2 s .co m final float scale = displaymetrics.scaledDensity; return sp * scale; }