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:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
public void onRotate() { Display display = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { orient = "portrait"; } else if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { orient = "landscape"; }/*w w w .ja v a2 s . c om*/ if (orient.equals("portrait")) { if (lang.equals("prilang")) { keyboard = prilang; } else if (lang.equals("seclang")) { keyboard = seclang; } slideAnimation(); kv.setKeyboard(keyboard); doubleUp = 1; screen = 1; caps = true; if (allCaps) { capsLock = false; } kv.invalidateAllKeys(); keyboard.setShifted(caps); kv.invalidateAllKeys(); } else if (orient.equals("landscape")) { switch (screen) { case 1: if (lang.equals("prilang")) { keyboard = prilang_landscape; } else if (lang.equals("seclang")) { keyboard = seclang_landscape; } break; case 2: if (number == 1) { keyboard = new Keyboard(this, R.xml.numeric_landscape); } else if (number == 2) { keyboard = new Keyboard(this, R.xml.symbols_landscape); } break; } slideAnimation(); kv.setKeyboard(keyboard); doubleUp = 1; screen = 1; caps = true; if (allCaps) { capsLock = false; } kv.invalidateAllKeys(); keyboard.setShifted(caps); kv.invalidateAllKeys(); } }
From source file:com.miz.functions.MizLib.java
public static String getBackdropUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);//from w w w . j a v a 2 s . c om final int width = Math.max(size.x, size.y); if (width > 1280 && isTablet(c)) // We only want to download full size images on tablets, as these are the only devices where you can see the difference return "original"; else if (width > 780) return "w1280"; return "w780"; }
From source file:com.miz.functions.MizLib.java
public static String getBackdropThumbUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);//from ww w .j a va2s .c om final int width = Math.min(size.x, size.y); if (width >= 780) return "w780"; if (width >= 400) return "w500"; return "w300"; }
From source file:com.miz.functions.MizLib.java
public static String getActorUrlSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);/*w ww. ja v a2s . c o m*/ final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 400) return "h632"; if (columnWidth >= 300) return "w300"; } return "w185"; }
From source file:com.bt.download.android.gui.Librarian.java
public ScreenMetrics readScreenMetrics() { ScreenMetrics sm = new ScreenMetrics(); try {//from w ww. j a v a 2s. c om WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); context.getResources().getDisplayMetrics(); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); sm.densityDpi = dm.densityDpi; sm.heightPixels = dm.heightPixels; sm.widthPixels = dm.widthPixels; sm.xdpi = dm.xdpi; sm.ydpi = dm.ydpi; } catch (Throwable e) { Log.e(TAG, "Unable to get the device display dimensions", e); } return sm; }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
public void runExpansionAnimation() { final Interpolator interpolator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in); } else {/*ww w . jav a2 s . c o m*/ interpolator = new DecelerateInterpolator(); } WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int screenHeight = size.y; int screenWidth = size.x; final ValueAnimator heightExpansion = ValueAnimator.ofInt(expansionViewHeight, getHeight()); heightExpansion.setInterpolator(interpolator); heightExpansion.setDuration(ANIMATION_DURATION); heightExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.height = val; setLayoutParams(params); } }); heightExpansion.start(); final ValueAnimator widthExpansion = ValueAnimator.ofInt(expansionViewWidth, getWidth()); widthExpansion.setInterpolator(interpolator); widthExpansion.setDuration(ANIMATION_DURATION); widthExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.width = val; setLayoutParams(params); } }); widthExpansion.start(); ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, expansionLeftOffset, 0f); translationX.setInterpolator(interpolator); translationX.setDuration(ANIMATION_DURATION); translationX.start(); ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, expansionTopOffset, 0f); translationY.setInterpolator(interpolator); translationY.setDuration(ANIMATION_DURATION); translationY.start(); }
From source file:com.bt.download.android.gui.Librarian.java
public double getScreenSizeInInches() { double screenInches = 0; try {/* ww w . j a va 2 s. c o m*/ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); context.getResources().getDisplayMetrics(); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); double x = Math.pow(dm.widthPixels / dm.xdpi, 2); double y = Math.pow(dm.heightPixels / dm.ydpi, 2); screenInches = Math.sqrt(x + y); } catch (Throwable e) { Log.e(TAG, "Unable to get the device display dimensions", e); } return screenInches; }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
public static Point getPreviewDimension() { // Taken from: http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels View v = ((Activity) mContext).findViewById(R.id.camera_controls_layout); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from ww w . java 2s . c o m*/ Point dim = null; if (v != null) { if (getOrientation() == Surface.ROTATION_0 || getOrientation() == Surface.ROTATION_180) dim = new Point(size.x, size.y - v.getHeight()); // return size.y - v.getHeight(); else if (getOrientation() == Surface.ROTATION_90 || getOrientation() == Surface.ROTATION_270) dim = new Point(size.x - v.getWidth(), size.y); // return size.x - v.getWidth(); } return dim; }
From source file:com.fullteem.yueba.app.ui.ChatActivity.java
/** * window//from www .j av a 2 s . c om */ private void windowShow() { if (popupWindow == null) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); menuView = layoutInflater.inflate(R.layout.popwindow_msgmenu, null); listviewMsgMenus = (ListView) menuView.findViewById(R.id.listviewMsgPop); mma = new MessageMenuAdapter(this, menuTexts); listviewMsgMenus.setAdapter(mma); // PopuWidow popupWindow = new PopupWindow(menuView, 300, 500); } // ? popupWindow.setFocusable(true); // ? popupWindow.setOutsideTouchable(true); // Back??? popupWindow.setBackgroundDrawable(new BitmapDrawable()); WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); // ?:??-PopupWindow? int xPos = windowManager.getDefaultDisplay().getWidth() / 2 - popupWindow.getWidth() / 2; Log.i("coder", "windowManager.getDefaultDisplay().getWidth()/2:" + windowManager.getDefaultDisplay().getWidth() / 2); // Log.i("coder", "popupWindow.getWidth()/2:" + popupWindow.getWidth() / 2); Log.i("coder", "xPos:" + xPos); popupWindow.showAsDropDown(viewBtnMore, xPos, 0); listviewMsgMenus.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (popupWindow != null) { popupWindow.dismiss(); } // if (menuTexts[position].equals("")) { String strName = getString(R.string.add_firend); String msg = String.format(strName, userNickName); popMenu = new CommonPopWindow(ChatActivity.this, msg, new OnClickListener() { @Override public void onClick(View v) { addContact(); addFriendPop.dismiss(); } }, new OnClickListener() { @Override public void onClick(View v) { addFriendPop.dismiss(); } }); // ? popMenu.setIsEditText(false); // popMenu.preperShow(); addFriendPop = popMenu.getMenu(); addFriendPop.setOutsideTouchable(true); if (addFriendPop == null) { return; } if (addFriendPop.isShowing()) { addFriendPop.dismiss(); return; } addFriendPop.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0); } else if (menuTexts[position].equals("?")) { } // ? else if (menuTexts[position].equals("")) { // try { // EMContactManager.getInstance().deleteContact( // toChatUsername); // } catch (EaseMobException e) { // showToast(""); // } deleteFriends(); } else if (menuTexts[position].equals("?")) {// bill Intent intentDatePublish = new Intent(ChatActivity.this, DatePublishActivity.class); // TODO ????id,????????idname DBFriendListDao friendListDao = new DBFriendListDao(ChatActivity.this); UserCommonModel um = friendListDao.getContacter(toChatUsername); if (um == null) return; UmengUtil.onEvent(ChatActivity.this, "friend_chat_access_post_date_button_hits"); LogUtil.printUmengLog("friend_chat_access_post_date_button_hits"); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_ID, Integer.valueOf(TextUtils.isEmpty(um.getUserId()) ? "0" : um.getUserId())); // userIdint intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_NAME, um.getUserName()); // String intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_MOBILE, um.getUserMobile()); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_URL, um.getUserLogoUrl()); intentDatePublish.putExtra("isExist", true); startActivity(intentDatePublish); } else if (menuTexts[position].equals("")) { HttpRequest.getInstance(ChatActivity.this).getOutGroup(appContext.getUserInfo().getUserMobile(), toChatUsername, new CustomAsyncResponehandler() { @Override public void onSuccess(ResponeModel baseModel) { if (baseModel != null && baseModel.isStatus()) { showToast("?"); finish(); return; } showToast(getString(R.string.hint_operationError)); } @Override public void onFailure(Throwable error, String content) { showToast(getString(R.string.hint_operationError)); } }); } } }); }
From source file:com.android.tv.MainActivity.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); WindowManager.LayoutParams windowParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL, 0, PixelFormat.TRANSPARENT); windowParams.token = getWindow().getDecorView().getWindowToken(); ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).addView(mOverlayRootView, windowParams); }