milesmcc / LibreNews-Android

An Android client for the LibreNews server
GNU General Public License v3.0
35 stars 8 forks source link

Notification text is hard-coded to black #12

Closed Pixelguin closed 7 years ago

Pixelguin commented 7 years ago

The notification text from this app seems to force black rather than using the system default color. My notification background is dark and as a result I cannot read the notifications I receive.

milesmcc commented 7 years ago

Hi Pixelguin,

I'm sorry to hear you are having this issue. Could you provide screenshots, so that I can better understand the issue?

Thank you, Miles

Pixelguin commented 7 years ago

Thanks for your quick response!

Here's an example of what I see happening.

The text for all my other notifications is usually white.

milesmcc commented 7 years ago

That's odd, to say the least. Here is the code that actually creates the notifications:

 Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flash.getLink()));
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
        String text = StringEscapeUtils.unescapeHtml4(flash.getText());
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(context)
                        .setContentTitle(flash.getChannel() + " • " + flash.getSource())
                        .setStyle(new NotificationCompat.BigTextStyle()
                                .bigText(text))
                        .setContentText(text)
                        .setSound(Uri.parse(prefs.getString("notification_sound", "DEFAULT")))
                        .setContentIntent(pendingIntent);
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mBuilder.setSmallIcon(R.drawable.ic_alert);
        } else {
            mBuilder.setSmallIcon(R.drawable.ic_alert_compat);
        }
        NotificationManager mNotificationManager =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        mNotificationManager.notify(flash.getIdAsInteger(), mBuilder.build());

It seems like you are using a custom graphics/UI system (hence the dark notifications)... CyanogenMod?

This is odd, because nothing is hard coded to black (it just gives the text to Android and lets the OS do the rest).

Pixelguin commented 7 years ago

You're very close; I'm using a Substratum overlay to make the notifications dark. However, every other application I use (even those not specifically themed for Substratum/the overlay) changes from using black text to white text in the notification window. This was why I thought the notification must have been hard-coding the text color.

milesmcc commented 7 years ago

Your thought process makes sense—thinking that the color must be hard coded is a reasonable conclusion from the information you had been given.

I wonder if this is an Android API/overlay issue? LibreNews is built against the latest version of Android (7..), and if the overlay is hooking into an older API version, issues could arise.

Pixelguin commented 7 years ago

My phone is running Android 7.1.2 and the overlay only supports Android 7 and 8.

I contacted the developers of the overlay and they recommended a reboot (which I did not try since installing LibreNews). I'll update you once the next notification appears.

milesmcc commented 7 years ago

Alright, let me know how that goes. Your guess is as good as mine as to when the next notification comes out... 👍

Pixelguin commented 7 years ago

Manually refreshed and the notifications appear perfectly! Thank you so much for your help and patience.