use of android.graphics.Rect in project Signal-Android by WhisperSystems.
the class ContactFilterToolbar method expandTapArea.
private void expandTapArea(final View container, final View child) {
final int padding = getResources().getDimensionPixelSize(R.dimen.contact_selection_actions_tap_area);
container.post(new Runnable() {
@Override
public void run() {
Rect rect = new Rect();
child.getHitRect(rect);
rect.top -= padding;
rect.left -= padding;
rect.right += padding;
rect.bottom += padding;
container.setTouchDelegate(new TouchDelegate(rect, child));
}
});
}
use of android.graphics.Rect in project Signal-Android by WhisperSystems.
the class KeyboardAwareLinearLayout method getViewInset.
@TargetApi(VERSION_CODES.LOLLIPOP)
private int getViewInset() {
try {
Field attachInfoField = View.class.getDeclaredField("mAttachInfo");
attachInfoField.setAccessible(true);
Object attachInfo = attachInfoField.get(this);
if (attachInfo != null) {
Field stableInsetsField = attachInfo.getClass().getDeclaredField("mStableInsets");
stableInsetsField.setAccessible(true);
Rect insets = (Rect) stableInsetsField.get(attachInfo);
return insets.bottom;
}
} catch (NoSuchFieldException nsfe) {
Log.w(TAG, "field reflection error when measuring view inset", nsfe);
} catch (IllegalAccessException iae) {
Log.w(TAG, "access reflection error when measuring view inset", iae);
}
return 0;
}
use of android.graphics.Rect in project SuperRecyclerView by Malinskiy.
the class SwipeDismissRecyclerViewTouchListener method caseMotionActionDown.
private void caseMotionActionDown(MotionEvent motionEvent) {
// Find the child view that was touched (perform a hit test)
Rect rect = new Rect();
int childCount = mRecyclerView.getChildCount();
int[] listViewCoords = new int[2];
mRecyclerView.getLocationOnScreen(listViewCoords);
int x = (int) motionEvent.getRawX() - listViewCoords[0];
int y = (int) motionEvent.getRawY() - listViewCoords[1];
View child;
for (int i = 0; i < childCount; i++) {
child = mRecyclerView.getChildAt(i);
child.getHitRect(rect);
if (rect.contains(x, y)) {
mDownView = child;
break;
}
}
if (mDownView != null) {
mDownX = motionEvent.getRawX();
mDownY = motionEvent.getRawY();
mDownPosition = mRecyclerView.getChildAdapterPosition(mDownView);
if (mCallbacks.canDismiss(mDownPosition)) {
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(motionEvent);
} else {
mDownView = null;
}
}
}
use of android.graphics.Rect in project Xposed-Tinted-Status-Bar by MohammadAG.
the class OnWindowFocusedHook method afterHookedMethod.
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mSettingsHelper.reload();
if (!mSettingsHelper.getBoolean(SettingsKeys.ENABLE_AWESOME_AB_COLOR_PICKER, false))
return;
Activity activity = (Activity) param.thisObject;
String packageName = activity.getPackageName();
String activityName = activity.getLocalClassName();
final TypedArray typedArray = activity.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
int actionBarSize = (int) typedArray.getDimension(0, 0);
typedArray.recycle();
// Get the top of the window, so we can crop the status bar out.
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
int top = rect.top;
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
Bitmap bitmap1 = view.getDrawingCache();
if (bitmap1 == null)
return;
// Crop and compress the image so that we don't get a TransactionTooLargeException.
Bitmap bitmap = Bitmap.createBitmap(bitmap1, 0, top, bitmap1.getWidth(), actionBarSize);
ByteArrayOutputStream compressedBitmap = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, compressedBitmap);
ComponentName cn = new ComponentName("com.mohammadag.colouredstatusbar", "com.mohammadag.colouredstatusbar.activities.ScreenColorPickerActivity");
Intent colorPickerIntent = new Intent().setComponent(cn);
colorPickerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
colorPickerIntent.putExtra("bitmap", compressedBitmap.toByteArray());
colorPickerIntent.putExtra("pkg", packageName);
PendingIntent colorActivityPendingIntent = PendingIntent.getActivity(activity, 0, colorPickerIntent.putExtra("title", activityName), PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent colorAllPendingIntent = PendingIntent.getActivity(activity, 1, colorPickerIntent.putExtra("title", packageName), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager nm = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(activity).setContentTitle(packageName).setContentText(activityName).setSmallIcon(android.R.drawable.sym_def_app_icon).setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap)).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_activity), colorActivityPendingIntent).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_app), colorAllPendingIntent).build();
nm.notify(1240, notification);
view.setDrawingCacheEnabled(false);
}
use of android.graphics.Rect in project material-dialogs by afollestad.
the class CircleView method showHint.
public void showHint(int color) {
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
int referenceX = screenPos[0] + width / 2;
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
// mirror
referenceX = screenWidth - referenceX;
}
Toast cheatSheet = Toast.makeText(context, String.format("#%06X", 0xFFFFFF & color), Toast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, screenPos[1] + height - displayFrame.top);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
}
Aggregations