Search in sources :

Example 26 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method applyPredictionApps.

private void applyPredictionApps() {
    if (getChildCount() != mNumPredictedAppsPerRow) {
        while (getChildCount() > mNumPredictedAppsPerRow) {
            removeViewAt(0);
        }
        LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
        while (getChildCount() < mNumPredictedAppsPerRow) {
            BubbleTextView icon = (BubbleTextView) inflater.inflate(R.layout.all_apps_icon, this, false);
            icon.setOnClickListener(PREDICTION_CLICK_LISTENER);
            icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
            icon.setLongPressTimeoutFactor(1f);
            icon.setOnFocusChangeListener(mFocusHelper);
            LayoutParams lp = (LayoutParams) icon.getLayoutParams();
            // Ensure the all apps icon height matches the workspace icons in portrait mode.
            lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
            lp.width = 0;
            lp.weight = 1;
            addView(icon);
        }
    }
    int predictionCount = mPredictedApps.size();
    int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
    for (int i = 0; i < getChildCount(); i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        if (predictionCount > i) {
            icon.setVisibility(View.VISIBLE);
            if (mPredictedApps.get(i) instanceof AppInfo) {
                icon.applyFromApplicationInfo((AppInfo) mPredictedApps.get(i));
            } else if (mPredictedApps.get(i) instanceof WorkspaceItemInfo) {
                icon.applyFromWorkspaceItem((WorkspaceItemInfo) mPredictedApps.get(i));
            }
            icon.setTextColor(iconColor);
        } else {
            icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
        }
    }
    boolean predictionsEnabled = predictionCount > 0;
    if (predictionsEnabled != mPredictionsEnabled) {
        mPredictionsEnabled = predictionsEnabled;
        mLauncher.reapplyUi(false);
        updateVisibility();
    }
    mParent.onHeightUpdated();
}
Also used : LayoutInflater(android.view.LayoutInflater) BubbleTextView(com.android.launcher3.BubbleTextView) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 27 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project android_packages_apps_Trebuchet by LineageOS.

the class BaseDragLayer method onLayout.

protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
        if (flp instanceof LayoutParams) {
            final LayoutParams lp = (LayoutParams) flp;
            if (lp.customPosition) {
                child.layout(lp.x, lp.y, lp.x + lp.width, lp.y + lp.height);
            }
        }
    }
}
Also used : FrameLayout(android.widget.FrameLayout) InsettableFrameLayout(com.android.launcher3.InsettableFrameLayout) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 28 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class ConfigBuilder method setHotseatSearchView.

private void setHotseatSearchView() {
    mNano.allAppsCols = mActivity.getDeviceProfile().inv.numColumns;
    final int width = mActivity.getHotseat().getWidth();
    final int dimensionPixelSize = mActivity.getResources().getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
    final Columns appCol = new Columns();
    appCol.edgeMargin = dimensionPixelSize;
    appCol.iconDistance = width - dimensionPixelSize - dimensionPixelSize;
    appCol.height = mActivity.getDeviceProfile().allAppsCellHeightPx;
    mNano.apps = appCol;
    updateHotseatSearchDimens();
    AlphabeticalAppsList apps = getAppsView().getApps();
    mBubbleTextView = (BubbleTextView) mActivity.getLayoutInflater().inflate(R.layout.all_apps_icon, getAppsView(), false);
    ViewGroup.LayoutParams layoutParams = mBubbleTextView.getLayoutParams();
    layoutParams.height = appCol.height;
    layoutParams.width = appCol.iconDistance / mNano.allAppsCols;
    if (!apps.getApps().isEmpty()) {
        mBubbleTextView.applyFromApplicationInfo(apps.getApps().get(0));
    }
    mBubbleTextView.measure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(layoutParams.height, View.MeasureSpec.EXACTLY));
    mBubbleTextView.layout(0, 0, layoutParams.width, layoutParams.height);
    final ArrayList<AppIndex> list = new ArrayList<>(mNano.allAppsCols);
    mNano.index = list.toArray(new AppIndex[0]);
}
Also used : ViewGroup(android.view.ViewGroup) AlphabeticalAppsList(com.android.launcher3.allapps.AlphabeticalAppsList) ArrayList(java.util.ArrayList) Columns(com.google.android.apps.nexuslauncher.search.nano.SearchProto.Columns) AppIndex(com.google.android.apps.nexuslauncher.search.nano.SearchProto.AppIndex) Point(android.graphics.Point)

Example 29 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class IconPreview method applyPreviewIcons.

private void applyPreviewIcons() {
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) mLauncher.getLayoutInflater().inflate(R.layout.all_apps_icon, this, false);
        LayoutParams lp = (LayoutParams) icon.getLayoutParams();
        lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
        lp.width = 0;
        lp.weight = 1;
        addView(icon);
    }
    for (int i = 0; i < 5; i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        icon.setVisibility(View.VISIBLE);
        icon.applyFromApplicationInfo((AppInfo) mPreviewApps.get(getRandomApp()));
        icon.setTextColor(mIconTextColor);
    }
    mLauncher.reapplyUi();
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView)

Example 30 with LayoutParams

use of com.android.launcher3.InsettableFrameLayout.LayoutParams in project Neo-Launcher by NeoApplications.

the class SuperGContainerView method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int qsbOverlapMargin = -getResources().getDimensionPixelSize(R.dimen.qsb_overlap_margin);
    DeviceProfile deviceProfile = LauncherAppState.getIDP(getContext()).getDeviceProfile(getContext());
    int size = MeasureSpec.getSize(widthMeasureSpec) - qsbOverlapMargin;
    int qsbWidth;
    int marginStart;
    if (deviceProfile.isVerticalBarLayout()) {
        qsbWidth = size;
        marginStart = qsbOverlapMargin + getResources().getDimensionPixelSize(R.dimen.qsb_button_elevation);
    } else {
        Rect workspacePadding = deviceProfile.workspacePadding;
        int fullWidth = size - workspacePadding.left - workspacePadding.right;
        qsbWidth = DeviceProfile.calculateCellWidth(fullWidth, deviceProfile.inv.numColumns) * deviceProfile.inv.numColumns;
        marginStart = 0;
    }
    if (mQsbView != null) {
        LayoutParams layoutParams = (LayoutParams) mQsbView.getLayoutParams();
        layoutParams.width = qsbWidth / deviceProfile.inv.numColumns;
        if (deviceProfile.isVerticalBarLayout()) {
            layoutParams.width = Math.max(layoutParams.width, getResources().getDimensionPixelSize(R.dimen.qsb_min_width_with_mic));
        } else {
            layoutParams.width = Math.max(layoutParams.width, getResources().getDimensionPixelSize(R.dimen.qsb_min_width_portrait));
        }
        layoutParams.setMarginStart(marginStart);
        layoutParams.resolveLayoutDirection(layoutParams.getLayoutDirection());
    }
    if (mConnectorView != null) {
        LayoutParams layoutParams = (LayoutParams) mConnectorView.getLayoutParams();
        layoutParams.width = marginStart + layoutParams.height / 2;
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect)

Aggregations

View (android.view.View)79 SuppressLint (android.annotation.SuppressLint)61 Paint (android.graphics.Paint)59 Point (android.graphics.Point)58 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)49 DraggableView (com.android.launcher3.dragndrop.DraggableView)40 CellAndSpan (com.android.launcher3.util.CellAndSpan)35 Rect (android.graphics.Rect)23 BubbleTextView (com.android.launcher3.BubbleTextView)21 ItemInfo (com.android.launcher3.model.data.ItemInfo)17 Animator (android.animation.Animator)16 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)16 ObjectAnimator (android.animation.ObjectAnimator)15 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 FrameLayout (android.widget.FrameLayout)13 DeviceProfile (com.android.launcher3.DeviceProfile)13 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)10 ValueAnimator (android.animation.ValueAnimator)9 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)8 TimeInterpolator (android.animation.TimeInterpolator)7