Search in sources :

Example 76 with ViewGroup

use of android.view.ViewGroup in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method updateNotification.

public void updateNotification(IBinder key, StatusBarNotification notification) {
    if (DEBUG)
        Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")");
    final NotificationData.Entry oldEntry = mNotificationData.findByKey(key);
    if (oldEntry == null) {
        Slog.w(TAG, "updateNotification for unknown key: " + key);
        return;
    }
    final StatusBarNotification oldNotification = oldEntry.notification;
    // XXX: modify when we do something more intelligent with the two content views
    final RemoteViews oldContentView = oldNotification.getNotification().contentView;
    final RemoteViews contentView = notification.getNotification().contentView;
    final RemoteViews oldBigContentView = oldNotification.getNotification().bigContentView;
    final RemoteViews bigContentView = notification.getNotification().bigContentView;
    if (DEBUG) {
        Slog.d(TAG, "old notification: when=" + oldNotification.getNotification().when + " ongoing=" + oldNotification.isOngoing() + " expanded=" + oldEntry.expanded + " contentView=" + oldContentView + " bigContentView=" + oldBigContentView + " rowParent=" + oldEntry.row.getParent());
        Slog.d(TAG, "new notification: when=" + notification.getNotification().when + " ongoing=" + oldNotification.isOngoing() + " contentView=" + contentView + " bigContentView=" + bigContentView);
    }
    // Can we just reapply the RemoteViews in place?  If when didn't change, the order
    // didn't change.
    // 1U is never null
    boolean contentsUnchanged = oldEntry.expanded != null && contentView.getPackage() != null && oldContentView.getPackage() != null && oldContentView.getPackage().equals(contentView.getPackage()) && oldContentView.getLayoutId() == contentView.getLayoutId();
    // large view may be null
    boolean bigContentsUnchanged = (oldEntry.getLargeView() == null && bigContentView == null) || ((oldEntry.getLargeView() != null && bigContentView != null) && bigContentView.getPackage() != null && oldBigContentView.getPackage() != null && oldBigContentView.getPackage().equals(bigContentView.getPackage()) && oldBigContentView.getLayoutId() == bigContentView.getLayoutId());
    ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent();
    boolean orderUnchanged = notification.getNotification().when == oldNotification.getNotification().when && notification.getScore() == oldNotification.getScore();
    // score now encompasses/supersedes isOngoing()
    boolean updateTicker = notification.getNotification().tickerText != null && !TextUtils.equals(notification.getNotification().tickerText, oldEntry.notification.getNotification().tickerText) || mHaloActive;
    boolean isTopAnyway = isTopNotification(rowParent, oldEntry);
    if (contentsUnchanged && bigContentsUnchanged && (orderUnchanged || isTopAnyway)) {
        if (DEBUG)
            Slog.d(TAG, "reusing notification for key: " + key);
        oldEntry.notification = notification;
        try {
            // Reapply the RemoteViews
            contentView.reapply(mContext, oldEntry.expanded, mOnClickHandler);
            if (bigContentView != null && oldEntry.getLargeView() != null) {
                bigContentView.reapply(mContext, oldEntry.getLargeView(), mOnClickHandler);
            }
            // update the contentIntent
            final PendingIntent contentIntent = notification.getNotification().contentIntent;
            if (contentIntent != null) {
                final View.OnClickListener listener = makeClicker(contentIntent, notification.getPackageName(), notification.getTag(), notification.getId());
                oldEntry.content.setOnClickListener(listener);
                oldEntry.floatingIntent = makeClicker(contentIntent, notification.getPackageName(), notification.getTag(), notification.getId());
                oldEntry.floatingIntent.makeFloating(true);
            } else {
                oldEntry.content.setOnClickListener(null);
                oldEntry.floatingIntent = null;
            }
            // Update the roundIcon
            prepareHaloNotification(oldEntry, notification, true);
            // Update the icon.
            final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), notification.getUser(), notification.getNotification().icon, notification.getNotification().iconLevel, notification.getNotification().number, notification.getNotification().tickerText);
            if (!oldEntry.icon.set(ic)) {
                handleNotificationError(key, notification, "Couldn't update icon: " + ic);
                return;
            }
            updateExpansionStates();
        } catch (RuntimeException e) {
            // It failed to add cleanly.  Log, and remove the view from the panel.
            Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e);
            removeNotificationViews(key);
            addNotificationViews(key, notification);
        }
    } else {
        if (DEBUG)
            Slog.d(TAG, "not reusing notification for key: " + key);
        if (DEBUG)
            Slog.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed"));
        if (DEBUG)
            Slog.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed"));
        if (DEBUG)
            Slog.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top"));
        final boolean wasExpanded = oldEntry.userExpanded();
        removeNotificationViews(key);
        addNotificationViews(key, notification);
        if (wasExpanded) {
            final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
            expandView(newEntry, true);
            newEntry.setUserExpanded(true);
        }
    }
    // Update the veto button accordingly (and as a result, whether this row is
    // swipe-dismissable)
    updateNotificationVetoButton(oldEntry.row, notification);
    // Is this for you?
    boolean isForCurrentUser = notificationIsForCurrentUser(notification);
    if (DEBUG)
        Slog.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
    // Restart the ticker if it's still running
    if (updateTicker && isForCurrentUser) {
        haltTicker();
        tick(key, notification, false);
    }
    // Recalculate the position of the sliding windows and the titles.
    setAreThereNotifications();
    updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
    // See if we need to update the intruder.
    if (ENABLE_INTRUDERS && oldNotification == mCurrentlyIntrudingNotification) {
        if (DEBUG)
            Slog.d(TAG, "updating the current intruder:" + notification);
        // the intruder.
        if (notification.getNotification().fullScreenIntent == null) {
            // TODO(dsandler): consistent logic with add()
            if (DEBUG)
                Slog.d(TAG, "no longer intrudes!");
            mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER);
        }
    }
    // Update halo
    if (mHalo != null)
        mHalo.update();
}
Also used : RemoteViews(android.widget.RemoteViews) StatusBarNotification(android.service.notification.StatusBarNotification) ViewGroup(android.view.ViewGroup) PendingIntent(android.app.PendingIntent) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SearchPanelView(com.android.systemui.SearchPanelView)

Example 77 with ViewGroup

use of android.view.ViewGroup in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method prepareHaloNotification.

public void prepareHaloNotification(NotificationData.Entry entry, StatusBarNotification notification, boolean update) {
    Notification notif = notification.getNotification();
    // Get the remote view
    try {
        if (!update) {
            ViewGroup mainView = (ViewGroup) notif.contentView.apply(mContext, null, mOnClickHandler);
            if (mainView instanceof FrameLayout) {
                entry.haloContent = mainView.getChildAt(1);
                mainView.removeViewAt(1);
            } else {
                entry.haloContent = mainView;
            }
        } else {
            notif.contentView.reapply(mContext, entry.haloContent, mOnClickHandler);
        }
    } catch (Exception e) {
        // Non uniform content?
        android.util.Log.d("PARANOID", "   Non uniform content?");
    }
    // Construct the round icon
    final float haloSize = Settings.System.getFloat(mContext.getContentResolver(), Settings.System.HALO_SIZE, 1.0f);
    int iconSize = (int) (mContext.getResources().getDimensionPixelSize(R.dimen.halo_bubble_size) * haloSize);
    int smallIconSize = (int) (mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size) * haloSize);
    int largeIconWidth = notif.largeIcon != null ? (int) (notif.largeIcon.getWidth() * haloSize) : 0;
    int largeIconHeight = notif.largeIcon != null ? (int) (notif.largeIcon.getHeight() * haloSize) : 0;
    Bitmap roundIcon = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(roundIcon);
    canvas.drawARGB(0, 0, 0, 0);
    // halo-bubble, we'll use that one and cut it round
    if (notif.largeIcon != null && largeIconWidth >= iconSize / 2) {
        Paint smoothingPaint = new Paint();
        smoothingPaint.setAntiAlias(true);
        smoothingPaint.setFilterBitmap(true);
        smoothingPaint.setDither(true);
        canvas.drawCircle(iconSize / 2, iconSize / 2, iconSize / 2.3f, smoothingPaint);
        smoothingPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
        final int newWidth = iconSize;
        final int newHeight = iconSize * largeIconWidth / largeIconHeight;
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(notif.largeIcon, newWidth, newHeight, true);
        canvas.drawBitmap(scaledBitmap, null, new Rect(0, 0, iconSize, iconSize), smoothingPaint);
    } else {
        try {
            Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(notification.getPackageName(), notification.getUser(), notif.icon, notif.iconLevel, notif.number, notif.tickerText));
            if (icon == null)
                icon = mContext.getPackageManager().getApplicationIcon(notification.getPackageName());
            int margin = (iconSize - smallIconSize) / 2;
            icon.setBounds(margin, margin, iconSize - margin, iconSize - margin);
            icon.draw(canvas);
        } catch (Exception e) {
        // NameNotFoundException
        }
    }
    entry.roundIcon = roundIcon;
}
Also used : Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Paint(android.graphics.Paint) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) ActivityNotFoundException(android.content.ActivityNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) FrameLayout(android.widget.FrameLayout) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 78 with ViewGroup

use of android.view.ViewGroup in project android_frameworks_base by ParanoidAndroid.

the class RecentsPanelView method onAnimationEnd.

public void onAnimationEnd(Animator animation) {
    if (mShowing) {
        final LayoutTransition transitioner = new LayoutTransition();
        ((ViewGroup) mRecentsContainer).setLayoutTransition(transitioner);
        createCustomAnimations(transitioner);
    } else {
        ((ViewGroup) mRecentsContainer).setLayoutTransition(null);
    }
}
Also used : ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition)

Example 79 with ViewGroup

use of android.view.ViewGroup in project android_frameworks_base by ParanoidAndroid.

the class RecentsPanelView method onTaskThumbnailLoaded.

void onTaskThumbnailLoaded(TaskDescription td) {
    synchronized (td) {
        if (mRecentsContainer != null) {
            ViewGroup container = mRecentsContainer;
            if (container instanceof RecentsScrollView) {
                container = (ViewGroup) container.findViewById(R.id.recents_linear_layout);
            }
            // Look for a view showing this thumbnail, to update.
            for (int i = 0; i < container.getChildCount(); i++) {
                View v = container.getChildAt(i);
                if (v.getTag() instanceof ViewHolder) {
                    ViewHolder h = (ViewHolder) v.getTag();
                    if (!h.loadedThumbnailAndIcon && h.taskDescription == td) {
                        // only fade in the thumbnail if recents is already visible-- we
                        // show it immediately otherwise
                        //boolean animateShow = mShowing &&
                        //    mRecentsContainer.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD;
                        boolean animateShow = false;
                        updateIcon(h, td.getIcon(), true, animateShow);
                        updateThumbnail(h, td.getThumbnail(), true, animateShow);
                        h.loadedThumbnailAndIcon = true;
                    }
                }
            }
        }
    }
    showIfReady();
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Example 80 with ViewGroup

use of android.view.ViewGroup in project android_frameworks_base by ParanoidAndroid.

the class NavbarEditor method switchId.

/**
     * Switches positions of two views and
     * updates their mIds entry
     * @param to - index for new position in mIds
     * @param from - index for old position in mIds
     * @param view - view being dragged
     */
private void switchId(int to, int from, View view) {
    View tView = mParent.findViewById(mIds.get(from));
    int[] screenLoc = new int[2];
    tView.getLocationOnScreen(screenLoc);
    ViewGroup a = (ViewGroup) view.getParent();
    if (!mVertical) {
        tView.setX((Float) mParent.getTag() - a.getLeft());
        mParent.setTag(Float.valueOf(screenLoc[0]));
    } else {
        tView.setY((Float) mParent.getTag() - a.getTop());
        mParent.setTag(Float.valueOf(screenLoc[1]));
    }
    Collections.swap(mIds, to, from);
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

ViewGroup (android.view.ViewGroup)2280 View (android.view.View)1268 TextView (android.widget.TextView)439 ImageView (android.widget.ImageView)279 ArrayList (java.util.ArrayList)198 ViewParent (android.view.ViewParent)184 ListView (android.widget.ListView)156 Paint (android.graphics.Paint)125 FrameLayout (android.widget.FrameLayout)121 LayoutInflater (android.view.LayoutInflater)115 AdapterView (android.widget.AdapterView)115 LinearLayout (android.widget.LinearLayout)110 AbsListView (android.widget.AbsListView)106 Animator (android.animation.Animator)94 Drawable (android.graphics.drawable.Drawable)93 RecyclerView (android.support.v7.widget.RecyclerView)91 AnimatedView (carbon.animation.AnimatedView)88 ComponentView (carbon.component.ComponentView)88 RippleView (carbon.drawable.ripple.RippleView)88 ShadowView (carbon.shadow.ShadowView)88