List of usage examples for android.graphics Point Point
public Point()
From source file:com.gm.goldencity.util.Utils.java
/** * Get display height//from w ww . ja v a 2s . co m * * @param context Application context * @return */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static int getDisplayHeight(Context context) { Activity activity = (Activity) context; if (Integer.valueOf(Build.VERSION.SDK_INT) < 13) { Display display = activity.getWindowManager().getDefaultDisplay(); return display.getHeight(); } else { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.y; } }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
public void setUpWindow() { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Params for the window. // You can easily set the alpha and the dim behind the window from here WindowManager.LayoutParams params = getWindow().getAttributes(); params.alpha = 1.0f; // lower than one makes it more transparent params.dimAmount = .6f; // set it higher if you want to dim behind the window getWindow().setAttributes(params);/*from w w w . j a v a 2 s . co m*/ getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent))); // Gets the display size so that you can set the window to a percent of that Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // You could also easily used an integer value from the shared preferences to set the percent if (height > width) { getWindow().setLayout((int) (width * .9), (int) (height * .9)); } else { getWindow().setLayout((int) (width * .7), (int) (height * .8)); } }
From source file:com.tealeaf.TeaLeaf.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PluginManager.init(this); instance = this; setFullscreenFlag();/*from ww w .jav a 2 s . co m*/ configureActivity(); String appID = findAppID(); options = new TeaLeafOptions(this); PluginManager.callAll("onCreate", this, savedInstanceState); //check intent for test app info Bundle bundle = getIntent().getExtras(); boolean isTestApp = false; if (bundle != null) { isTestApp = bundle.getBoolean("isTestApp", false); if (isTestApp) { options.setAppID(appID); boolean isPortrait = bundle.getBoolean("isPortrait", false); if (isPortrait) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } options.setCodeHost(bundle.getString("hostValue")); options.setCodePort(bundle.getInt("portValue")); String simulateID = bundle.getString("simulateID"); options.setSimulateID(simulateID); } } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); group = new FrameLayout(this); setContentView(group); // TextEditViewHandler setup textEditView = new TextEditViewHandler(this); settings = new Settings(this); remoteLogger = (ILogger) getLoggerInstance(this); checkUpdate(); compareVersions(); setLaunchUri(); // defer building all of these things until we have the absolutely correct options logger.buildLogger(this, remoteLogger); resourceManager = new ResourceManager(this, options); contactList = new ContactList(this, resourceManager); soundQueue = new SoundQueue(this, resourceManager); localStorage = new LocalStorage(this, options); // start push notifications, but defer for 10 seconds to give us time to start up PushBroadcastReceiver.scheduleNext(this, 10); glView = new TeaLeafGLSurfaceView(this); glViewPaused = false; // default screen dimensions Display display = getWindow().getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); int orientation = getRequestedOrientation(); // gets real screen dimensions without nav bars on recent API versions if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Point screenSize = new Point(); try { display.getRealSize(screenSize); width = screenSize.x; height = screenSize.y; } catch (NoSuchMethodError e) { } } // flip width and height based on orientation if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && height > width) || (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && width > height)) { int tempWidth = width; width = height; height = tempWidth; } final AbsoluteLayout absLayout = new AbsoluteLayout(this); absLayout.setLayoutParams(new android.view.ViewGroup.LayoutParams(width, height)); absLayout.addView(glView, new android.view.ViewGroup.LayoutParams(width, height)); group.addView(absLayout); editText = EditTextView.Init(this); if (isTestApp) { startGame(); } soundQueue.playSound(SoundQueue.LOADING_SOUND); doFirstRun(); remoteLogger.sendLaunchEvent(this); paused = false; menuButtonHandler = MenuButtonHandlerFactory.getButtonHandler(this); group.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { // get visible area of the view Rect r = new Rect(); group.getWindowVisibleDisplayFrame(r); int visibleHeight = r.bottom; // TODO // maybe this should be renamed if (visibleHeight != lastVisibleHeight) { lastVisibleHeight = visibleHeight; EventQueue.pushEvent(new KeyboardScreenResizeEvent(visibleHeight)); } } }); }
From source file:com.gh4a.utils.HttpImageGetter.java
public HttpImageGetter(Context context) { mContext = context;/* www .jav a2 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.hippo.ehviewer.ui.scene.FavoritesScene.java
private void guideCollections() { Activity activity = getActivity2();/* w w w .j av a2s . c o m*/ if (null == activity || !Settings.getGuideCollections()) { return; } Display display = activity.getWindowManager().getDefaultDisplay(); Point point = new Point(); display.getSize(point); mShowcaseView = new ShowcaseView.Builder(activity).withMaterialShowcase().setStyle(R.style.Guide) .setTarget(new PointTarget(point.x, point.y / 3)).blockAllTouches() .setContentTitle(R.string.guide_collections_title).setContentText(R.string.guide_collections_text) .replaceEndButton(R.layout.button_guide) .setShowcaseEventListener(new SimpleShowcaseEventListener() { @Override public void onShowcaseViewDidHide(ShowcaseView showcaseView) { mShowcaseView = null; ViewUtils.removeFromParent(showcaseView); Settings.putGuideCollections(false); openDrawer(Gravity.RIGHT); } }).build(); }
From source file:com.mumu.joshautomation.HeadService.java
private void initGameLibrary() { int w, h;// www .j a va2 s .c om int userWidth, userHeight, userAmbValue, userTouchShift; int userScreenXOffset, userScreenYOffset, userWaitTransactTime; // try to get user's setting try { userWidth = Integer.parseInt(mAPV.getPrefs().getString("userSetWidth", "0")); userHeight = Integer.parseInt(mAPV.getPrefs().getString("userSetHeight", "0")); userAmbValue = Integer.parseInt(mAPV.getPrefs().getString("userAmbValue", "0")); userTouchShift = Integer.parseInt(mAPV.getPrefs().getString("userSetTouchShift", "0")); userScreenXOffset = Integer.parseInt(mAPV.getPrefs().getString("userSetScreenXOffset", "0")); userScreenYOffset = Integer.parseInt(mAPV.getPrefs().getString("userSetScreenYOffset", "0")); userWaitTransactTime = Integer .parseInt(mAPV.getPrefs().getString("userSetWaitTransactionDoneTime", "0")); } catch (NumberFormatException e) { Log.e(TAG, "Setting value format error: " + e.getMessage()); userWidth = 0; userHeight = 0; userAmbValue = 0; userTouchShift = 0; userScreenXOffset = 0; userScreenYOffset = 0; userWaitTransactTime = 0; } // Initial DefinitionLoader DefinitionLoader.getInstance().setResources(mContext.getResources()); Display display = mWindowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); // we always treat the short edge as width // TODO: we need to find a new way to get actual panel width and height if (size.x > size.y) { w = size.y; if (size.x > 2000) h = 2160; else h = size.x; } else { w = size.x; if (size.y > 2000) h = 2160; else h = size.y; } mGL = JoshGameLibrary.getInstance(); mGL.setContext(mContext); // Check if user override settings if (userWidth != 0 && userHeight != 0) mGL.setScreenDimension(userWidth, userHeight); else mGL.setScreenDimension(w, h); mGL.getCaptureService().setChatty(mAPV.getPrefs().getBoolean("captureServiceChatty", false)); if (userAmbValue != 0) mGL.setAmbiguousRange(new int[] { userAmbValue, userAmbValue, userAmbValue }); else mGL.setAmbiguousRange(new int[] { JoshGameLibrary.DEFAULT_AMBIGUOUS_VALUE, JoshGameLibrary.DEFAULT_AMBIGUOUS_VALUE, JoshGameLibrary.DEFAULT_AMBIGUOUS_VALUE }); if (userScreenXOffset != 0 || userScreenYOffset != 0) mGL.setScreenOffset(userScreenXOffset, userScreenYOffset, ScreenPoint.SO_Portrait); if (userTouchShift != 0) mGL.setTouchShift(userTouchShift); else mGL.setTouchShift(JoshGameLibrary.DEFAULT_TOUCH_SHIFT); if (userWaitTransactTime != 0) mGL.setWaitTransactionTime(userWaitTransactTime); else mGL.setWaitTransactionTime(JoshGameLibrary.DEFAULT_WAIT_TRANSACT_TIME); if (mAPV.getPrefs().getBoolean("ssEnabled", false)) { String pn = mAPV.getPrefs().getString("ssPackageName", ""); String sn = mAPV.getPrefs().getString("ssServiceName", ""); String in = mAPV.getPrefs().getString("ssInterfaceName", ""); int code = Integer.parseInt(mAPV.getPrefs().getString("ssTransactCode", "0")); mGL.setHackParams(pn, sn, in, code); mGL.setHackSS(true); } else { mGL.setHackSS(false); } mGL.getCaptureService().setChatty(mAPV.getPrefs().getBoolean("captureServiceChatty", false)); mAutoJobHandler = AutoJobHandler.getHandler(); if (!mAutoJobAdded) { mAutoJobHandler.addJob(new LoopBattleJob()); mAutoJobHandler.addJob(new AutoBattleJob()); mAutoJobHandler.addJob(new PureBattleJob()); mAutoJobHandler.addJob(new NewFlushJob()); mAutoJobHandler.addJob(new TWAutoLoginJob()); mAutoJobHandler.addJob(new ShinobiLoopBattleJob()); mAutoJobHandler.addJob(new FlushJob()); mAutoJobHandler.addJob(new FlushMoneyJob()); mAutoJobHandler.addJob(new ROAutoDrinkJob()); mAutoJobHandler.addJob(new AutoBoxJob()); mAutoJobHandler.setJobEventListener(LoopBattleJob.jobName, this); mAutoJobHandler.setJobEventListener(PureBattleJob.jobName, this); mAutoJobHandler.setJobEventListener(AutoBattleJob.jobName, this); mAutoJobHandler.setJobEventListener(NewFlushJob.jobName, this); mAutoJobHandler.setJobEventListener(TWAutoLoginJob.jobName, this); mAutoJobHandler.setJobEventListener(ShinobiLoopBattleJob.jobName, this); mAutoJobHandler.setJobEventListener(FlushJob.jobName, this); mAutoJobHandler.setJobEventListener(FlushMoneyJob.jobName, this); mAutoJobHandler.setJobEventListener(AutoBoxJob.jobName, this); //add service itself to job mAutoJobHandler.setExtra(LoopBattleJob.jobName, this); mAutoJobHandler.setExtra(ShinobiLoopBattleJob.jobName, this); mAutoJobHandler.setExtra(FlushJob.jobName, this); mAutoJobHandler.setExtra(FlushMoneyJob.jobName, this); mAutoJobAdded = true; } }
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);/*from w w w. java 2s . c o m*/ 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 { 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(); } }
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;/* ww w . j ava 2 s.co 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:com.javielinux.tweettopics2.TweetActivity.java
public void hideImage() { int screenHeight = 0; try {//from w w w. j a v a2 s . c om Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); screenHeight = size.y; } catch (NoSuchMethodError e) { screenHeight = getWindowManager().getDefaultDisplay().getHeight(); } Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int statusBarHeight = rect.top; float translationOffset = (float) screenHeight - statusBarHeight - tweetActionsContainer.getTop(); ObjectAnimator tweetInfoLayoutAnimator = ObjectAnimator.ofFloat(tweetInfoLayout, "translationY", translationOffset, 0.0f); tweetInfoLayoutAnimator.setDuration(250); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { imageLargerDisplayed = false; ivImageLarger.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); animatorSet.playTogether(tweetInfoLayoutAnimator); animatorSet.start(); }
From source file:com.miz.utils.ViewUtils.java
public static int getNavigationDrawerWidth(Context context) { int drawerWidth; // The navigation drawer should have a width equal to // the screen width minus the Toolbar height - at least // on mobile devices. Tablets are accounted for below. int toolbarHeight = MizLib.getActionBarHeight(context); // Get the display size Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from www . j a va 2s. c om // Get the smallest number int smallestDisplayWidth = Math.min(size.x, size.y); // Calculate the drawer width drawerWidth = smallestDisplayWidth - toolbarHeight; // Make sure that the calculated drawer width // isn't greater than the max width, i.e. // 5 times the standard increment (56dp for // mobile or 64dp for tablets). int maxWidth = MizLib.convertDpToPixels(context, 5 * (MizLib.isTablet(context) ? 64 : 56)); if (drawerWidth > maxWidth) drawerWidth = maxWidth; return drawerWidth; }