Java Code Examples for org.telegram.messenger.AndroidUtilities#statusBarHeight()
The following examples show how to use
org.telegram.messenger.AndroidUtilities#statusBarHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CropView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void onScale(float scale, float x, float y) { if (animating) { return; } float newScale = state.getScale() * scale; if (newScale > MAX_SCALE) scale = MAX_SCALE / state.getScale(); float statusBarHeight = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); float pivotX = (x - imageView.getWidth() / 2) / areaView.getCropWidth() * state.getOrientedWidth(); float pivotY = (y - (imageView.getHeight() - bottomPadding - statusBarHeight) / 2) / areaView.getCropHeight() * state.getOrientedHeight(); state.scale(scale, pivotX, pivotY); updateMatrix(); }
Example 2
Source File: SettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()); if (user != null && user.photo != null && user.photo.photo_big != null) { TLRPC.FileLocation photoBig = user.photo.photo_big; if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) { int coords[] = new int[2]; avatarImage.getLocationInWindow(coords); PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight); object.parentView = avatarImage; object.imageReceiver = avatarImage.getImageReceiver(); object.dialogId = UserConfig.getInstance(currentAccount).getClientUserId(); object.thumb = object.imageReceiver.getBitmapSafe(); object.size = -1; object.radius = avatarImage.getImageReceiver().getRoundRadius(); object.scale = avatarImage.getScaleX(); return object; } } return null; }
Example 3
Source File: DialogsEmptyCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int totalHeight = MeasureSpec.getSize(heightMeasureSpec); if (totalHeight == 0) { totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); } if (currentType == 0) { ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs; if (!arrayList.isEmpty()) { totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38); } super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY)); } else { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.AT_MOST)); } }
Example 4
Source File: SettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()); if (user != null && user.photo != null && user.photo.photo_big != null) { TLRPC.FileLocation photoBig = user.photo.photo_big; if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) { int coords[] = new int[2]; avatarImage.getLocationInWindow(coords); PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight); object.parentView = avatarImage; object.imageReceiver = avatarImage.getImageReceiver(); object.dialogId = UserConfig.getInstance(currentAccount).getClientUserId(); object.thumb = object.imageReceiver.getBitmapSafe(); object.size = -1; object.radius = avatarImage.getImageReceiver().getRoundRadius(); object.scale = avatarImage.getScaleX(); return object; } } return null; }
Example 5
Source File: ChatAvatarContainer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int actionBarHeight = ActionBar.getCurrentActionBarHeight(); int viewTop = (actionBarHeight - AndroidUtilities.dp(42)) / 2 + (Build.VERSION.SDK_INT >= 21 && occupyStatusBar ? AndroidUtilities.statusBarHeight : 0); avatarImageView.layout(AndroidUtilities.dp(8), viewTop, AndroidUtilities.dp(42 + 8), viewTop + AndroidUtilities.dp(42)); if (subtitleTextView.getVisibility() == VISIBLE) { titleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(1.3f), AndroidUtilities.dp(8 + 54) + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(1.3f)); } else { titleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(11), AndroidUtilities.dp(8 + 54) + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(11)); } if (timeItem != null) { timeItem.layout(AndroidUtilities.dp(8 + 16), viewTop + AndroidUtilities.dp(15), AndroidUtilities.dp(8 + 16 + 34), viewTop + AndroidUtilities.dp(15 + 34)); } subtitleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(24), AndroidUtilities.dp(8 + 54) + subtitleTextView.getMeasuredWidth(), viewTop + subtitleTextView.getTextHeight() + AndroidUtilities.dp(24)); }
Example 6
Source File: CropAreaView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void calculateRect(RectF rect, float cropAspectRatio) { float statusBarHeight = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); float left, top, right, bottom; float measuredHeight = (float) getMeasuredHeight() - bottomPadding - statusBarHeight; float aspectRatio = (float) getMeasuredWidth() / measuredHeight; float minSide = Math.min(getMeasuredWidth(), measuredHeight) - 2 * sidePadding; float width = getMeasuredWidth() - 2 * sidePadding; float height = measuredHeight - 2 * sidePadding; float centerX = getMeasuredWidth() / 2.0f; float centerY = statusBarHeight + measuredHeight / 2.0f; if (Math.abs(1.0f - cropAspectRatio) < 0.0001) { left = centerX - (minSide / 2.0f); top = centerY - (minSide / 2.0f); right = centerX + (minSide / 2.0f); bottom = centerY + (minSide / 2.0f); } else if (cropAspectRatio > aspectRatio) { left = centerX - (width / 2.0f); top = centerY - ((width / cropAspectRatio) / 2.0f); right = centerX + (width / 2.0f); bottom = centerY + ((width / cropAspectRatio) / 2.0f); } else { left = centerX - ((height * cropAspectRatio) / 2.0f); top = centerY - (height / 2.0f); right = centerX + ((height * cropAspectRatio) / 2.0f); bottom = centerY + (height / 2.0f); } rect.set(left, top, right, bottom); }
Example 7
Source File: CropAreaView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void calculateRect(RectF rect, float cropAspectRatio) { float statusBarHeight = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); float left, top, right, bottom; float measuredHeight = (float)getMeasuredHeight() - bottomPadding - statusBarHeight; float aspectRatio = (float)getMeasuredWidth() / measuredHeight; float minSide = Math.min(getMeasuredWidth(), measuredHeight) - 2 * sidePadding; float width = getMeasuredWidth() - 2 * sidePadding; float height = measuredHeight - 2 * sidePadding; float centerX = getMeasuredWidth() / 2.0f; float centerY = statusBarHeight + measuredHeight / 2.0f; if (Math.abs(1.0f - cropAspectRatio) < 0.0001) { left = centerX - (minSide / 2.0f); top = centerY - (minSide / 2.0f); right = centerX + (minSide / 2.0f); bottom = centerY + (minSide / 2.0f); } else if (cropAspectRatio > aspectRatio) { left = centerX - (width / 2.0f); top = centerY - ((width / cropAspectRatio) / 2.0f); right = centerX + (width / 2.0f); bottom = centerY + ((width / cropAspectRatio) / 2.0f); } else { left = centerX - ((height * cropAspectRatio) / 2.0f); top = centerY - (height / 2.0f); right = centerX + ((height * cropAspectRatio) / 2.0f); bottom = centerY + (height / 2.0f); } rect.set(left, top, right, bottom); }
Example 8
Source File: BottomSheet.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); int containerHeight = height; View rootView = getRootView(); getWindowVisibleDisplayFrame(rect); if (rect.bottom != 0 && rect.top != 0) { int usableViewHeight = rootView.getHeight() - (rect.top != 0 ? AndroidUtilities.statusBarHeight : 0) - AndroidUtilities.getViewInset(rootView); keyboardHeight = Math.max(0, usableViewHeight - (rect.bottom - rect.top)); if (keyboardHeight < AndroidUtilities.dp(20)) { keyboardHeight = 0; } bottomInset -= keyboardHeight; } else { keyboardHeight = 0; } keyboardVisible = keyboardHeight > AndroidUtilities.dp(20); if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { bottomInset = lastInsets.getSystemWindowInsetBottom(); if (Build.VERSION.SDK_INT >= 29) { bottomInset += getAdditionalMandatoryOffsets(); } if (keyboardVisible && rect.bottom != 0 && rect.top != 0) { bottomInset -= keyboardHeight; } if (!drawNavigationBar) { containerHeight -= bottomInset; } } setMeasuredDimension(width, containerHeight); if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { int inset = lastInsets.getSystemWindowInsetBottom(); if (Build.VERSION.SDK_INT >= 29) { inset += getAdditionalMandatoryOffsets(); } height -= inset; } if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { width -= lastInsets.getSystemWindowInsetRight() + lastInsets.getSystemWindowInsetLeft(); } boolean isPortrait = width < height; if (containerView != null) { if (!fullWidth) { int widthSpec; if (AndroidUtilities.isTablet()) { widthSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY); } else { widthSpec = MeasureSpec.makeMeasureSpec(isPortrait ? width + backgroundPaddingLeft * 2 : (int) Math.max(width * 0.8f, Math.min(AndroidUtilities.dp(480), width)) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY); } containerView.measure(widthSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } else { containerView.measure(MeasureSpec.makeMeasureSpec(width + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child.getVisibility() == GONE || child == containerView) { continue; } if (!onCustomMeasure(child, width, height)) { measureChildWithMargins(child, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY), 0); } } }
Example 9
Source File: PhotoCropView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public float getRectY() { return cropView.getCropTop() - AndroidUtilities.dp(14) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); }
Example 10
Source File: BottomSheet.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); int containerHeight = height; View rootView = getRootView(); getWindowVisibleDisplayFrame(rect); if (rect.bottom != 0 && rect.top != 0) { int usableViewHeight = rootView.getHeight() - (rect.top != 0 ? AndroidUtilities.statusBarHeight : 0) - AndroidUtilities.getViewInset(rootView); keyboardHeight = Math.max(0, usableViewHeight - (rect.bottom - rect.top)); if (keyboardHeight < AndroidUtilities.dp(20)) { keyboardHeight = 0; } bottomInset -= keyboardHeight; } else { keyboardHeight = 0; } keyboardVisible = keyboardHeight > AndroidUtilities.dp(20); if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { bottomInset = lastInsets.getSystemWindowInsetBottom(); if (Build.VERSION.SDK_INT >= 29) { bottomInset += getAdditionalMandatoryOffsets(); } if (keyboardVisible && rect.bottom != 0 && rect.top != 0) { bottomInset -= keyboardHeight; } if (!drawNavigationBar) { containerHeight -= bottomInset; } } setMeasuredDimension(width, containerHeight); if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { int inset = lastInsets.getSystemWindowInsetBottom(); if (Build.VERSION.SDK_INT >= 29) { inset += getAdditionalMandatoryOffsets(); } height -= inset; } if (lastInsets != null && Build.VERSION.SDK_INT >= 21) { width -= lastInsets.getSystemWindowInsetRight() + lastInsets.getSystemWindowInsetLeft(); } boolean isPortrait = width < height; if (containerView != null) { if (!fullWidth) { int widthSpec; if (AndroidUtilities.isTablet()) { widthSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY); } else { widthSpec = MeasureSpec.makeMeasureSpec(isPortrait ? width + backgroundPaddingLeft * 2 : (int) Math.max(width * 0.8f, Math.min(AndroidUtilities.dp(480), width)) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY); } containerView.measure(widthSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } else { containerView.measure(MeasureSpec.makeMeasureSpec(width + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child.getVisibility() == GONE || child == containerView) { continue; } if (!onCustomMeasure(child, width, height)) { measureChildWithMargins(child, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 0, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY), 0); } } }
Example 11
Source File: LocationActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void fixLayoutInternal(final boolean resume) { if (listView != null) { int height = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); int viewHeight = fragmentView.getMeasuredHeight(); if (viewHeight == 0) { return; } if (locationType == 2) { overScrollHeight = viewHeight - AndroidUtilities.dp(66 + 7) - height; } else { overScrollHeight = viewHeight - AndroidUtilities.dp(66) - height; } FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.topMargin = height; listView.setLayoutParams(layoutParams); layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams(); layoutParams.topMargin = height; layoutParams.height = overScrollHeight; mapViewClip.setLayoutParams(layoutParams); if (searchListView != null) { layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams(); layoutParams.topMargin = height; searchListView.setLayoutParams(layoutParams); } adapter.setOverScrollHeight(overScrollHeight); layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams(); if (layoutParams != null) { layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); if (googleMap != null) { googleMap.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10)); } mapView.setLayoutParams(layoutParams); } if (overlayView != null) { layoutParams = (FrameLayout.LayoutParams) overlayView.getLayoutParams(); if (layoutParams != null) { layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); overlayView.setLayoutParams(layoutParams); } } adapter.notifyDataSetChanged(); if (resume) { int top; if (locationType == 3) { top = 73; } else if (locationType == 1 || locationType == 2) { top = 66; } else { top = 0; } layoutManager.scrollToPositionWithOffset(0, -AndroidUtilities.dp(top)); updateClipView(); listView.post(() -> { layoutManager.scrollToPositionWithOffset(0, -AndroidUtilities.dp(top)); updateClipView(); }); } else { updateClipView(); } } }
Example 12
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void checkCameraViewPosition() { if (!deviceHasGoodCamera) { return; } int count = attachPhotoRecyclerView.getChildCount(); for (int a = 0; a < count; a++) { View child = attachPhotoRecyclerView.getChildAt(a); if (child instanceof PhotoAttachCameraCell) { if (Build.VERSION.SDK_INT >= 19) { if (!child.isAttachedToWindow()) { break; } } child.getLocationInWindow(cameraViewLocation); cameraViewLocation[0] -= getLeftInset(); float listViewX = listView.getX() + backgroundPaddingLeft - getLeftInset(); if (cameraViewLocation[0] < listViewX) { cameraViewOffsetX = (int) (listViewX - cameraViewLocation[0]); if (cameraViewOffsetX >= AndroidUtilities.dp(80)) { cameraViewOffsetX = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; } else { cameraViewLocation[0] += cameraViewOffsetX; } } else { cameraViewOffsetX = 0; } if (Build.VERSION.SDK_INT >= 21 && cameraViewLocation[1] < AndroidUtilities.statusBarHeight) { cameraViewOffsetY = AndroidUtilities.statusBarHeight - cameraViewLocation[1]; if (cameraViewOffsetY >= AndroidUtilities.dp(80)) { cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; } else { cameraViewLocation[1] += cameraViewOffsetY; } } else { cameraViewOffsetY = 0; } applyCameraViewPosition(); return; } } cameraViewOffsetX = 0; cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; applyCameraViewPosition(); }
Example 13
Source File: LocationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void fixLayoutInternal(final boolean resume) { if (listView != null) { int height = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); int viewHeight = fragmentView.getMeasuredHeight(); if (viewHeight == 0) { return; } overScrollHeight = viewHeight - AndroidUtilities.dp(66) - height; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.topMargin = height; listView.setLayoutParams(layoutParams); layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams(); layoutParams.topMargin = height; layoutParams.height = overScrollHeight; mapViewClip.setLayoutParams(layoutParams); if (searchListView != null) { layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams(); layoutParams.topMargin = height; searchListView.setLayoutParams(layoutParams); } adapter.setOverScrollHeight(overScrollHeight); layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams(); if (layoutParams != null) { layoutParams.height = overScrollHeight + AndroidUtilities.dp(10); if (googleMap != null) { googleMap.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10)); } mapView.setLayoutParams(layoutParams); } adapter.notifyDataSetChanged(); if (resume) { layoutManager.scrollToPositionWithOffset(0, -AndroidUtilities.dp(32 + (liveLocationType == 1 || liveLocationType == 2 ? 66 : 0))); updateClipView(layoutManager.findFirstVisibleItemPosition()); listView.post(new Runnable() { @Override public void run() { layoutManager.scrollToPositionWithOffset(0, -AndroidUtilities.dp(32 + (liveLocationType == 1 || liveLocationType == 2 ? 66 : 0))); updateClipView(layoutManager.findFirstVisibleItemPosition()); } }); } else { updateClipView(layoutManager.findFirstVisibleItemPosition()); } } }
Example 14
Source File: PhotoCropView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public float getRectY() { return cropView.getCropTop() - AndroidUtilities.dp(14) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); }
Example 15
Source File: PhotoCropView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public float getBitmapY() { float additionalY = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); return bitmapY - AndroidUtilities.dp(14) - additionalY; }
Example 16
Source File: FireworksEffect.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void onDraw(View parent, Canvas canvas) { if (parent == null || canvas == null) { return; } int count = particles.size(); for (int a = 0; a < count; a++) { Particle particle = particles.get(a); particle.draw(canvas); } if (Utilities.random.nextBoolean() && particles.size() + 8 < 150) { int statusBarHeight = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); float cx = Utilities.random.nextFloat() * parent.getMeasuredWidth(); float cy = statusBarHeight + Utilities.random.nextFloat() * (parent.getMeasuredHeight() - AndroidUtilities.dp(20) - statusBarHeight); int color; switch (Utilities.random.nextInt(4)) { case 0: { color = 0xff342eda; break; } case 1: { color = 0xfff32015; break; } case 2: { color = 0xfffcd753; break; } case 3: { color = 0xff19c43a; break; } case 4: default: { color = 0xffffe988; break; } } for (int a = 0; a < 8; a++) { int angle = Utilities.random.nextInt(270) - 225; float vx = (float) Math.cos(Math.PI / 180.0 * angle); float vy = (float) Math.sin(Math.PI / 180.0 * angle); Particle newParticle; if (!freeParticles.isEmpty()) { newParticle = freeParticles.get(0); freeParticles.remove(0); } else { newParticle = new Particle(); } newParticle.x = cx; newParticle.y = cy; newParticle.vx = vx * 1.5f; newParticle.vy = vy; newParticle.color = color; newParticle.alpha = 1.0f; newParticle.currentTime = 0; newParticle.scale = Math.max(1.0f, Utilities.random.nextFloat() * 1.5f); newParticle.type = 0;//Utilities.random.nextInt(2); newParticle.lifeTime = 1000 + Utilities.random.nextInt(1000); newParticle.velocity = 20.0f + Utilities.random.nextFloat() * 4.0f; particles.add(newParticle); } } long newTime = System.currentTimeMillis(); long dt = Math.min(17, newTime - lastAnimationTime); updateParticles(dt); lastAnimationTime = newTime; parent.invalidate(); }
Example 17
Source File: PhotoCropView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public float getLimitHeight() { float additionalY = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); return getHeight() - AndroidUtilities.dp(14) - additionalY - rectY - (int) Math.max(0, Math.ceil((getHeight() - AndroidUtilities.dp(28) - bitmapHeight * bitmapGlobalScale - additionalY) / 2)) - rectSizeY; }
Example 18
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void checkCameraViewPosition() { if (Build.VERSION.SDK_INT >= 21) { if (cameraView != null) { cameraView.invalidateOutline(); } RecyclerView.ViewHolder holder = gridView.findViewHolderForAdapterPosition(itemsPerRow - 1); if (holder != null) { holder.itemView.invalidateOutline(); } if (!adapter.needCamera || !deviceHasGoodCamera || selectedAlbumEntry != galleryAlbumEntry) { holder = gridView.findViewHolderForAdapterPosition(0); if (holder != null) { holder.itemView.invalidateOutline(); } } } if (!deviceHasGoodCamera) { return; } int count = gridView.getChildCount(); for (int a = 0; a < count; a++) { View child = gridView.getChildAt(a); if (child instanceof PhotoAttachCameraCell) { if (Build.VERSION.SDK_INT >= 19) { if (!child.isAttachedToWindow()) { break; } } child.getLocationInWindow(cameraViewLocation); cameraViewLocation[0] -= parentAlert.getLeftInset(); float listViewX = gridView.getX() - parentAlert.getLeftInset(); if (cameraViewLocation[0] < listViewX) { cameraViewOffsetX = (int) (listViewX - cameraViewLocation[0]); if (cameraViewOffsetX >= itemSize) { cameraViewOffsetX = 0; cameraViewLocation[0] = AndroidUtilities.dp(-400); cameraViewLocation[1] = 0; } else { cameraViewLocation[0] += cameraViewOffsetX; } } else { cameraViewOffsetX = 0; } int maxY = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); if (cameraViewLocation[1] < maxY) { cameraViewOffsetY = maxY - cameraViewLocation[1]; if (cameraViewOffsetY >= itemSize) { cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-400); cameraViewLocation[1] = 0; } else { cameraViewLocation[1] += cameraViewOffsetY; } } else { cameraViewOffsetY = 0; } int containerHeight = parentAlert.getSheetContainer().getMeasuredHeight(); int keyboardSize = parentAlert.sizeNotifierFrameLayout.getKeyboardHeight(); if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) { containerHeight -= parentAlert.commentTextView.getEmojiPadding(); } maxY = (int) (containerHeight - parentAlert.buttonsRecyclerView.getMeasuredHeight() + parentAlert.buttonsRecyclerView.getTranslationY() + parentAlert.getSheetContainer().getTranslationY()); if (cameraViewLocation[1] + itemSize > maxY) { cameraViewOffsetBottomY = cameraViewLocation[1] + itemSize - maxY; if (cameraViewOffsetBottomY >= itemSize) { cameraViewOffsetBottomY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-400); cameraViewLocation[1] = 0; } } else { cameraViewOffsetBottomY = 0; } applyCameraViewPosition(); return; } } cameraViewOffsetX = 0; cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-400); cameraViewLocation[1] = 0; applyCameraViewPosition(); }
Example 19
Source File: DrawerLayoutContainer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@SuppressLint("NewApi") @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); setMeasuredDimension(widthSize, heightSize); if (Build.VERSION.SDK_INT < 21) { inLayout = true; if (heightSize == AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) { if (getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { setPadding(0, AndroidUtilities.statusBarHeight, 0, 0); } heightSize = AndroidUtilities.displaySize.y; } else { if (getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { setPadding(0, 0, 0, 0); } } inLayout = false; } final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21; final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (applyInsets) { if (child.getFitsSystemWindows()) { dispatchChildInsets(child, lastInsets, lp.gravity); } else if (child.getTag() == null) { applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21); } } if (drawerLayout != child) { final int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY); final int contentHeightSpec = MeasureSpec.makeMeasureSpec(heightSize - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY); child.measure(contentWidthSpec, contentHeightSpec); } else { child.setPadding(0, 0, 0, 0); final int drawerWidthSpec = getChildMeasureSpec(widthMeasureSpec, minDrawerMargin + lp.leftMargin + lp.rightMargin, lp.width); final int drawerHeightSpec = getChildMeasureSpec(heightMeasureSpec, lp.topMargin + lp.bottomMargin, lp.height); child.measure(drawerWidthSpec, drawerHeightSpec); } } }
Example 20
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void checkCameraViewPosition() { if (!deviceHasGoodCamera) { return; } int count = attachPhotoRecyclerView.getChildCount(); for (int a = 0; a < count; a++) { View child = attachPhotoRecyclerView.getChildAt(a); if (child instanceof PhotoAttachCameraCell) { if (Build.VERSION.SDK_INT >= 19) { if (!child.isAttachedToWindow()) { break; } } child.getLocationInWindow(cameraViewLocation); cameraViewLocation[0] -= getLeftInset(); float listViewX = listView.getX() + backgroundPaddingLeft - getLeftInset(); if (cameraViewLocation[0] < listViewX) { cameraViewOffsetX = (int) (listViewX - cameraViewLocation[0]); if (cameraViewOffsetX >= AndroidUtilities.dp(80)) { cameraViewOffsetX = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; } else { cameraViewLocation[0] += cameraViewOffsetX; } } else { cameraViewOffsetX = 0; } if (Build.VERSION.SDK_INT >= 21 && cameraViewLocation[1] < AndroidUtilities.statusBarHeight) { cameraViewOffsetY = AndroidUtilities.statusBarHeight - cameraViewLocation[1]; if (cameraViewOffsetY >= AndroidUtilities.dp(80)) { cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; } else { cameraViewLocation[1] += cameraViewOffsetY; } } else { cameraViewOffsetY = 0; } applyCameraViewPosition(); return; } } cameraViewOffsetX = 0; cameraViewOffsetY = 0; cameraViewLocation[0] = AndroidUtilities.dp(-150); cameraViewLocation[1] = 0; applyCameraViewPosition(); }