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

Commit 04c4617c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Update deprecated Notification builder to new API"

parents d39648a6 365c938c
Loading
Loading
Loading
Loading
+38 −34
Original line number Diff line number Diff line
@@ -352,9 +352,6 @@ class BluetoothOppNotification {
    }

    private void updateCompletedNotification() {
        String title;
        String unsuccess_caption;
        String caption;
        long timeStamp = 0;
        int outboundSuccNumber = 0;
        int outboundFailNumber = 0;
@@ -362,7 +359,6 @@ class BluetoothOppNotification {
        int inboundNum;
        int inboundSuccNumber = 0;
        int inboundFailNumber = 0;
        Intent intent;

        // If there is active transfer, no need to update complete transfer
        // notification
@@ -409,24 +405,28 @@ class BluetoothOppNotification {
        outboundNum = outboundSuccNumber + outboundFailNumber;
        // create the outbound notification
        if (outboundNum > 0) {
            Notification outNoti = new Notification();
            outNoti.icon = android.R.drawable.stat_sys_upload_done;
            title = mContext.getString(R.string.outbound_noti_title);
            unsuccess_caption = mContext.getResources().getQuantityString(
            String unsuccess_caption = mContext.getResources().getQuantityString(
                    R.plurals.noti_caption_unsuccessful, outboundFailNumber, outboundFailNumber);
            caption = mContext.getResources().getQuantityString(
            String caption = mContext.getResources().getQuantityString(
                    R.plurals.noti_caption_success, outboundSuccNumber, outboundSuccNumber,
                    unsuccess_caption);
            intent = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER);
            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            outNoti.color = mContext.getResources().getColor(
                    com.android.internal.R.color.system_notification_accent_color);
            outNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(
                    mContext, 0, intent, 0));
            intent = new Intent(Constants.ACTION_COMPLETE_HIDE);
            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            outNoti.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
            outNoti.when = timeStamp;
            Intent content_intent = new Intent(Constants.ACTION_OPEN_OUTBOUND_TRANSFER)
                    .setClassName(Constants.THIS_PACKAGE_NAME,
                            BluetoothOppReceiver.class.getName());
            Intent delete_intent = new Intent(Constants.ACTION_COMPLETE_HIDE)
                    .setClassName(Constants.THIS_PACKAGE_NAME,
                            BluetoothOppReceiver.class.getName());
            Notification outNoti = new Notification.Builder(mContext)
                    .setContentTitle(mContext.getString(R.string.outbound_noti_title))
                    .setContentText(caption)
                    .setSmallIcon(android.R.drawable.stat_sys_upload_done)
                    .setColor(mContext.getResources().getColor(
                            com.android.internal.R.color.system_notification_accent_color,
                            mContext.getTheme()))
                    .setContentIntent(PendingIntent.getBroadcast(mContext, 0, content_intent, 0))
                    .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0, delete_intent, 0))
                    .setWhen(timeStamp)
                    .build();
            mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, outNoti);
        } else {
            if (mNotificationMgr != null) {
@@ -461,24 +461,28 @@ class BluetoothOppNotification {
        inboundNum = inboundSuccNumber + inboundFailNumber;
        // create the inbound notification
        if (inboundNum > 0) {
            Notification inNoti = new Notification();
            inNoti.icon = android.R.drawable.stat_sys_download_done;
            title = mContext.getString(R.string.inbound_noti_title);
            unsuccess_caption = mContext.getResources().getQuantityString(
            String unsuccess_caption = mContext.getResources().getQuantityString(
                    R.plurals.noti_caption_unsuccessful, inboundFailNumber, inboundFailNumber);
            caption = mContext.getResources().getQuantityString(
            String caption = mContext.getResources().getQuantityString(
                    R.plurals.noti_caption_success, inboundSuccNumber, inboundSuccNumber,
                    unsuccess_caption);
            intent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER);
            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            inNoti.color = mContext.getResources().getColor(
                    com.android.internal.R.color.system_notification_accent_color);
            inNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(
                    mContext, 0, intent, 0));
            intent = new Intent(Constants.ACTION_COMPLETE_HIDE);
            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            inNoti.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
            inNoti.when = timeStamp;
            Intent content_intent = new Intent(Constants.ACTION_OPEN_INBOUND_TRANSFER)
                    .setClassName(Constants.THIS_PACKAGE_NAME,
                            BluetoothOppReceiver.class.getName());
            Intent delete_intent = new Intent(Constants.ACTION_COMPLETE_HIDE)
                    .setClassName(Constants.THIS_PACKAGE_NAME,
                            BluetoothOppReceiver.class.getName());
            Notification inNoti = new Notification.Builder(mContext)
                    .setContentTitle(mContext.getString(R.string.inbound_noti_title))
                    .setContentText(caption)
                    .setSmallIcon(android.R.drawable.stat_sys_download_done)
                    .setColor(mContext.getResources().getColor(
                            com.android.internal.R.color.system_notification_accent_color,
                            mContext.getTheme()))
                    .setContentIntent(PendingIntent.getBroadcast(mContext, 0, content_intent, 0))
                    .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0, delete_intent, 0))
                    .setWhen(timeStamp)
                    .build();
            mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, inNoti);
        } else {
            if (mNotificationMgr != null) {
+16 −14
Original line number Diff line number Diff line
@@ -777,23 +777,25 @@ public class BluetoothPbapService extends Service {
        Intent deleteIntent = new Intent();
        deleteIntent.setClass(this, BluetoothPbapReceiver.class);

        Notification notification = null;
        String name = getRemoteDeviceName();

        if (action.equals(AUTH_CHALL_ACTION)) {
            deleteIntent.setAction(AUTH_CANCELLED_ACTION);
            notification = new Notification(android.R.drawable.stat_sys_data_bluetooth,
                getString(R.string.auth_notif_ticker), System.currentTimeMillis());
            notification.color = getResources().getColor(
                    com.android.internal.R.color.system_notification_accent_color);
            notification.setLatestEventInfo(this, getString(R.string.auth_notif_title),
                    getString(R.string.auth_notif_message, name), PendingIntent
                            .getActivity(this, 0, clickIntent, 0));

            notification.flags |= Notification.FLAG_AUTO_CANCEL;
            notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
            notification.defaults = Notification.DEFAULT_SOUND;
            notification.deleteIntent = PendingIntent.getBroadcast(this, 0, deleteIntent, 0);
            Notification notification = new Notification.Builder(this)
                    .setWhen(System.currentTimeMillis())
                    .setContentTitle(getString(R.string.auth_notif_title))
                    .setContentText(getString(R.string.auth_notif_message, name))
                    .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
                    .setTicker(getString(R.string.auth_notif_ticker))
                    .setColor(getResources().getColor(
                            com.android.internal.R.color.system_notification_accent_color,
                            this.getTheme()))
                    .setFlag(Notification.FLAG_AUTO_CANCEL, true)
                    .setFlag(Notification.FLAG_ONLY_ALERT_ONCE, true)
                    .setDefaults(Notification.DEFAULT_SOUND)
                    .setContentIntent(PendingIntent.getActivity(this, 0, clickIntent, 0))
                    .setDeleteIntent(PendingIntent.getBroadcast(this, 0,
                            deleteIntent.setAction(AUTH_CANCELLED_ACTION), 0))
                    .build();
            nm.notify(NOTIFICATION_ID_AUTH, notification);
        }
    }