package nl.rmokveld.castnotifications;

import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;

class DefaultNotificationBuilder implements NotificationBuilder {

    @Override
    public void build(Context context, NotificationCompat.Builder builder, int id, String title, String subtitle, boolean castDevicesAvailable) {
        builder.setContentTitle(title)
                .setSmallIcon(R.drawable.ic_cast_dark)
                .setAutoCancel(true)
                .setOnlyAlertOnce(true)
                .setDefaults(NotificationCompat.DEFAULT_ALL);
        if (subtitle != null)
            builder.setContentText(subtitle);
    }

    @Override
    public void buildForConnecting(Context context, NotificationCompat.Builder builder, int id, String title, String deviceName) {
        build(context, builder, id, title, null, true);
        builder.setContentText(context.getString(R.string.cast_notifications_connecting, deviceName));
    }

    @Override
    public void buildForError(Context context, NotificationCompat.Builder builder, int id, String title, String subtitle) {
        build(context, builder, id, title, subtitle, false);
    }


}

@@ -217,16 +217,65 @@
 lder %7B%0A%0A
+    private boolean mSearchActionOnWear = true;%0A%0A
     @Ove
@@ -272,32 +272,32 @@
 %0A%0A    @Override%0A
-
     public void 
@@ -659,16 +659,632 @@
 T_ALL);%0A
+        if (mSearchActionOnWear && !castDevicesAvailable) %7B%0A            // If there are no notifications add an action on wear to start active discovery. Because of the wakelocks the device will wake up which is needed for discovery%0A            builder.extend(new NotificationCompat.WearableExtender()%0A                    .addAction(new NotificationCompat.Action(R.drawable.ic_cast_light, context.getString(R.string.cast_notifications_discovering),%0A                            PendingIntent.getService(context, 0, DiscoveryService.buildIntent(context, true, %22wear%22), PendingIntent.FLAG_UPDATE_CURRENT))));%0A        %7D%0A
         
@@ -1803,24 +1803,61 @@
 subtitle) %7B%0A
+        mSearchActionOnWear = false;%0A
         buil
@@ -1901,22 +1901,58 @@
 le, false);%0A
+        mSearchActionOnWear = true;%0A
     %7D%0A%0A%0A%7D%0A

add search chromecasts button to wear notifications