Search in sources :

Example 6 with Point

use of android.graphics.Point in project UltimateAndroid by cymcsg.

the class QuickContactFragment method onStart.

@SuppressWarnings("deprecation")
@Override
public void onStart() {
    super.onStart();
    // change dialog width
    if (getDialog() != null) {
        int fullWidth = getDialog().getWindow().getAttributes().width;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            Display display = getActivity().getWindowManager().getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            fullWidth = size.x;
        } else {
            Display display = getActivity().getWindowManager().getDefaultDisplay();
            fullWidth = display.getWidth();
        }
        final int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
        int w = fullWidth - padding;
        int h = getDialog().getWindow().getAttributes().height;
        getDialog().getWindow().setLayout(w, h);
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Display(android.view.Display)

Example 7 with Point

use of android.graphics.Point in project Launcher3 by chislon.

the class LauncherTransitionable method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (DEBUG_STRICT_MODE) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
    }
    super.onCreate(savedInstanceState);
    LauncherAppState.setApplicationContext(getApplicationContext());
    LauncherAppState app = LauncherAppState.getInstance();
    // Determine the dynamic grid properties
    Point smallestSize = new Point();
    Point largestSize = new Point();
    Point realSize = new Point();
    Display display = getWindowManager().getDefaultDisplay();
    display.getCurrentSizeRange(smallestSize, largestSize);
    display.getRealSize(realSize);
    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);
    // Lazy-initialize the dynamic grid
    DeviceProfile grid = app.initDynamicGrid(this, Math.min(smallestSize.x, smallestSize.y), Math.min(largestSize.x, largestSize.y), realSize.x, realSize.y, dm.widthPixels, dm.heightPixels);
    // the LauncherApplication should call this, but in case of Instrumentation it might not be present yet
    mSharedPrefs = getSharedPreferences(LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE);
    mModel = app.setLauncher(this);
    mIconCache = app.getIconCache();
    mIconCache.flushInvalidIcons(grid);
    mDragController = new DragController(this);
    mInflater = getLayoutInflater();
    mStats = new Stats(this);
    mAppWidgetManager = AppWidgetManager.getInstance(this);
    mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
    mAppWidgetHost.startListening();
    // If we are getting an onCreate, we can actually preempt onResume and unset mPaused here,
    // this also ensures that any synchronous binding below doesn't re-trigger another
    // LauncherModel load.
    mPaused = false;
    if (PROFILE_STARTUP) {
        android.os.Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "/launcher");
    }
    checkForLocaleChange();
    setContentView(R.layout.launcher);
    setupViews();
    grid.layout(this);
    registerContentObservers();
    lockAllApps();
    mSavedState = savedInstanceState;
    restoreState(mSavedState);
    // Update customization drawer _after_ restoring the states
    if (mAppsCustomizeContent != null) {
        mAppsCustomizeContent.onPackagesUpdated(LauncherModel.getSortedWidgetsAndShortcuts(this));
    }
    if (PROFILE_STARTUP) {
        android.os.Debug.stopMethodTracing();
    }
    if (!mRestoring) {
        if (sPausedFromUserAction) {
            // If the user leaves launcher, then we should just load items asynchronously when
            // they return.
            mModel.startLoader(true, -1);
        } else {
            // We only load the page synchronously if the user rotates (or triggers a
            // configuration change) while launcher is in the foreground
            mModel.startLoader(true, mWorkspace.getCurrentPage());
        }
    }
    // For handling default keys
    mDefaultKeySsb = new SpannableStringBuilder();
    Selection.setSelection(mDefaultKeySsb, 0);
    IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    registerReceiver(mCloseSystemDialogsReceiver, filter);
    updateGlobalIcons();
    // On large interfaces, we want the screen to auto-rotate based on the current orientation
    unlockScreenOrientation(true);
    showFirstRunCling();
}
Also used : StrictMode(android.os.StrictMode) IntentFilter(android.content.IntentFilter) SpannableStringBuilder(android.text.SpannableStringBuilder) Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) SpannableStringBuilder(android.text.SpannableStringBuilder) Display(android.view.Display)

Example 8 with Point

use of android.graphics.Point in project cw-omnibus by commonsguy.

the class FreecarTileService method onClick.

@Override
public void onClick() {
    super.onClick();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String cnFlat = prefs.getString(PREF_TO_LAUNCH, null);
    if (cnFlat != null) {
        ComponentName cn = ComponentName.unflattenFromString(cnFlat);
        try {
            ActivityInfo info = getPackageManager().getActivityInfo(cn, 0);
            ActivityInfo.WindowLayout layout = info.windowLayout;
            Intent i = new Intent().setComponent(cn).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Point size = new Point();
            getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
            if (layout == null) {
                size.x = size.x / 2;
                size.y = size.y / 2;
            } else {
                if (layout.widthFraction > 0.0f) {
                    size.x = Math.max(layout.minWidth, (int) (size.x * layout.widthFraction));
                } else {
                    size.x = layout.width;
                }
                if (layout.heightFraction > 0.0f) {
                    size.y = Math.max(layout.minHeight, (int) (size.y * layout.heightFraction));
                } else {
                    size.y = layout.height;
                }
            }
            ActivityOptions opts = ActivityOptions.makeBasic().setLaunchBounds(new Rect(0, 0, size.x, size.y));
            startActivity(i, opts.toBundle());
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "Exception trying to launch activity", e);
            toast(R.string.msg_sorry);
        }
    } else {
        toast(R.string.msg_choose);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Rect(android.graphics.Rect) SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 9 with Point

use of android.graphics.Point in project UltimateAndroid by cymcsg.

the class MaterialRippleLayout method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean superOnTouchEvent = super.onTouchEvent(event);
    if (!isEnabled() || !childView.isEnabled())
        return superOnTouchEvent;
    boolean isEventInBounds = bounds.contains((int) event.getX(), (int) event.getY());
    if (isEventInBounds) {
        previousCoords.set(currentCoords.x, currentCoords.y);
        currentCoords.set((int) event.getX(), (int) event.getY());
    }
    boolean gestureResult = gestureDetector.onTouchEvent(event);
    if (gestureResult) {
        return true;
    } else {
        int action = event.getActionMasked();
        switch(action) {
            case MotionEvent.ACTION_UP:
                pendingClickEvent = new PerformClickEvent();
                if (prepressed) {
                    childView.setPressed(true);
                    postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            childView.setPressed(false);
                        }
                    }, ViewConfiguration.getPressedStateDuration());
                }
                if (isEventInBounds) {
                    startRipple(pendingClickEvent);
                } else if (!rippleHover) {
                    setRadius(0);
                }
                if (!rippleDelayClick && isEventInBounds) {
                    pendingClickEvent.run();
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_DOWN:
                setPositionInAdapter();
                eventCancelled = false;
                if (isInScrollingContainer()) {
                    cancelPressedEvent();
                    prepressed = true;
                    pendingPressEvent = new PressedEvent(event);
                    postDelayed(pendingPressEvent, ViewConfiguration.getTapTimeout());
                } else {
                    childView.onTouchEvent(event);
                    childView.setPressed(true);
                    if (rippleHover) {
                        startHover();
                    }
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                if (rippleInAdapter) {
                    // dont use current coords in adapter since they tend to jump drastically on scroll
                    currentCoords.set(previousCoords.x, previousCoords.y);
                    previousCoords = new Point();
                }
                childView.onTouchEvent(event);
                if (rippleHover) {
                    if (!prepressed) {
                        startRipple(null);
                    }
                } else {
                    childView.setPressed(false);
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_MOVE:
                if (rippleHover) {
                    if (isEventInBounds && !eventCancelled) {
                        invalidate();
                    } else if (!isEventInBounds) {
                        startRipple(null);
                    }
                }
                if (!isEventInBounds) {
                    cancelPressedEvent();
                    if (hoverAnimator != null) {
                        hoverAnimator.cancel();
                    }
                    childView.onTouchEvent(event);
                    eventCancelled = true;
                }
                break;
        }
        return true;
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 10 with Point

use of android.graphics.Point in project Launcher3 by chislon.

the class CellLayout method visualizeDropLocation.

void visualizeDropLocation(View v, Bitmap dragOutline, int originX, int originY, int cellX, int cellY, int spanX, int spanY, boolean resize, Point dragOffset, Rect dragRegion) {
    final int oldDragCellX = mDragCell[0];
    final int oldDragCellY = mDragCell[1];
    if (dragOutline == null && v == null) {
        return;
    }
    if (cellX != oldDragCellX || cellY != oldDragCellY) {
        mDragCell[0] = cellX;
        mDragCell[1] = cellY;
        // Find the top left corner of the rect the object will occupy
        final int[] topLeft = mTmpPoint;
        cellToPoint(cellX, cellY, topLeft);
        int left = topLeft[0];
        int top = topLeft[1];
        if (v != null && dragOffset == null) {
            // When drawing the drag outline, it did not account for margin offsets
            // added by the view's parent.
            MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
            left += lp.leftMargin;
            top += lp.topMargin;
            // Offsets due to the size difference between the View and the dragOutline.
            // There is a size difference to account for the outer blur, which may lie
            // outside the bounds of the view.
            top += (v.getHeight() - dragOutline.getHeight()) / 2;
            // We center about the x axis
            left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap) - dragOutline.getWidth()) / 2;
        } else {
            if (dragOffset != null && dragRegion != null) {
                // Center the drag region *horizontally* in the cell and apply a drag
                // outline offset
                left += dragOffset.x + ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap) - dragRegion.width()) / 2;
                int cHeight = getShortcutsAndWidgets().getCellContentHeight();
                int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
                top += dragOffset.y + cellPaddingY;
            } else {
                // Center the drag outline in the cell
                left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap) - dragOutline.getWidth()) / 2;
                top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap) - dragOutline.getHeight()) / 2;
            }
        }
        final int oldIndex = mDragOutlineCurrent;
        mDragOutlineAnims[oldIndex].animateOut();
        mDragOutlineCurrent = (oldIndex + 1) % mDragOutlines.length;
        Rect r = mDragOutlines[mDragOutlineCurrent];
        r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight());
        if (resize) {
            cellToRect(cellX, cellY, spanX, spanY, r);
        }
        mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline);
        mDragOutlineAnims[mDragOutlineCurrent].animateIn();
    }
}
Also used : Rect(android.graphics.Rect) Point(android.graphics.Point) Paint(android.graphics.Paint)

Aggregations

Point (android.graphics.Point)1121 Display (android.view.Display)211 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)164 WindowManager (android.view.WindowManager)131 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)55 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)40 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)26 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22