Search in sources :

Example 61 with Rect

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));
        }
    });
}
Also used : Rect(android.graphics.Rect) TouchDelegate(android.view.TouchDelegate)

Example 62 with Rect

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;
}
Also used : Field(java.lang.reflect.Field) Rect(android.graphics.Rect) TargetApi(android.annotation.TargetApi)

Example 63 with Rect

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;
        }
    }
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Example 64 with Rect

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);
}
Also used : Rect(android.graphics.Rect) NotificationManager(android.app.NotificationManager) Activity(android.app.Activity) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) View(android.view.View) Notification(android.app.Notification) Bitmap(android.graphics.Bitmap) TypedArray(android.content.res.TypedArray) NotificationCompat(android.support.v4.app.NotificationCompat) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent)

Example 65 with Rect

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();
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Toast(android.widget.Toast) Paint(android.graphics.Paint)

Aggregations

Rect (android.graphics.Rect)4805 Paint (android.graphics.Paint)1052 View (android.view.View)687 Point (android.graphics.Point)563 Bitmap (android.graphics.Bitmap)467 Canvas (android.graphics.Canvas)372 RectF (android.graphics.RectF)266 Drawable (android.graphics.drawable.Drawable)241 Matrix (android.graphics.Matrix)125 ViewGroup (android.view.ViewGroup)121 ArrayList (java.util.ArrayList)121 TextView (android.widget.TextView)119 SuppressLint (android.annotation.SuppressLint)116 Resources (android.content.res.Resources)112 TextPaint (android.text.TextPaint)110 PorterDuffXfermode (android.graphics.PorterDuffXfermode)105 ImageView (android.widget.ImageView)97 BitmapDrawable (android.graphics.drawable.BitmapDrawable)95 SmallTest (android.test.suitebuilder.annotation.SmallTest)94 RemoteException (android.os.RemoteException)93