Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00c1b603 authored by Jake Hamby's avatar Jake Hamby Committed by Android (Google) Code Review
Browse files

Merge "Use Notification.Builder.setProgress() for progress notifications."

parents 33805fdc dec631a7
Loading
Loading
Loading
Loading
+0 −80
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >

        <LinearLayout
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="8dp"
            android:focusable="true"
            >
            <ImageView
                android:id="@+id/appIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@android:drawable/sym_def_app_icon"
                />
            <TextView android:id="@+id/progress_text" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:textColor="?android:attr/textColorPrimary"
                android:singleLine="true"
                android:textSize="14sp"
                android:layout_gravity="center_horizontal"
                />
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:focusable="true"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:focusable="true"
                android:layout_alignParentTop="true"
                android:paddingTop="10dp"
                >
                <TextView android:id="@+id/description"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="?android:attr/textColorPrimary"
                    android:singleLine="true"
                    android:textSize="14sp"
                    android:paddingLeft="5dp"
                    />
            </LinearLayout>
            <ProgressBar android:id="@+id/progress_bar"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:paddingBottom="8dp"
                android:paddingRight="25dp"
                />
        </RelativeLayout>
    </LinearLayout>
        
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@android:drawable/divider_horizontal_bright"
        />

</LinearLayout>
+12 −24
Original line number Diff line number Diff line
@@ -273,41 +273,29 @@ class BluetoothOppNotification {

        // Add the notifications
        for (NotificationItem item : mNotifications.values()) {
            // Build the RemoteView object
            RemoteViews expandedView = new RemoteViews(Constants.THIS_PACKAGE_NAME,
                    R.layout.status_bar_ongoing_event_progress_bar);

            expandedView.setTextViewText(R.id.description, item.description);

            expandedView.setProgressBar(R.id.progress_bar, item.totalTotal, item.totalCurrent,
                    item.totalTotal == -1);

            expandedView.setTextViewText(R.id.progress_text, BluetoothOppUtility
                    .formatProgressText(item.totalTotal, item.totalCurrent));

            // Build the notification object
            Notification n = new Notification();
            n.when = item.timeStamp;
            // TODO: split description into two rows with filename in second row
            Notification.Builder b = new Notification.Builder(mContext);
            b.setContentTitle(item.description);
            b.setContentInfo(
                    BluetoothOppUtility.formatProgressText(item.totalTotal, item.totalCurrent));
            b.setProgress(item.totalTotal, item.totalCurrent, item.totalTotal == -1);
            b.setWhen(item.timeStamp);
            if (item.direction == BluetoothShare.DIRECTION_OUTBOUND) {
                n.icon = android.R.drawable.stat_sys_upload;
                expandedView.setImageViewResource(R.id.appIcon, android.R.drawable.stat_sys_upload);
                b.setSmallIcon(android.R.drawable.stat_sys_upload);
            } else if (item.direction == BluetoothShare.DIRECTION_INBOUND) {
                n.icon = android.R.drawable.stat_sys_download;
                expandedView.setImageViewResource(R.id.appIcon,
                        android.R.drawable.stat_sys_download);
                b.setSmallIcon(android.R.drawable.stat_sys_download);
            } else {
                if (V) Log.v(TAG, "mDirection ERROR!");
            }

            n.flags |= Notification.FLAG_ONGOING_EVENT;
            n.contentView = expandedView;
            b.setOngoing(true);

            Intent intent = new Intent(Constants.ACTION_LIST);
            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            intent.setData(Uri.parse(BluetoothShare.CONTENT_URI + "/" + item.id));

            n.contentIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
            mNotificationMgr.notify(item.id, n);
            b.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0));
            mNotificationMgr.notify(item.id, b.getNotification());

            mActiveNotificationId = item.id;
        }