Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better app Notifications names #618

Merged
merged 3 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ class MessagingHolder {
builder.setSound(notificationToneUri)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_HIGH
val channelName = application.getString(R.string.message_notifications_channel)
val notificationChannel = NotificationChannel(
messageNotificationChannelId,
"MessageNotificationChannel",
channelName,
importance
)
builder.setChannelId(messageNotificationChannelId)
Expand All @@ -194,7 +195,7 @@ class MessagingHolder {
private fun notifyCall(
context: Context,
notificationManager: NotificationManager,
signal: WebRTCSignal
signal: WebRTCSignal,
) {
val serializedSignal = Json.gson.toJson(signal)
val contact =
Expand Down Expand Up @@ -299,7 +300,7 @@ class MessagingHolder {
contact: Model.Contact,
acceptPendingIntent: PendingIntent,
declinePendingIntent: PendingIntent
): Notification {
): Notification {
val builder = NotificationCompat.Builder(
context,
defaultNotificationChannelId
Expand Down Expand Up @@ -329,9 +330,10 @@ class MessagingHolder {
)
)
val importance = NotificationManager.IMPORTANCE_HIGH
val channelName = context.getString(R.string.call_notifications_channel)
val notificationChannel = NotificationChannel(
callNotificationChannelId,
"CallNotificationChannel",
channelName,
importance
)
notificationChannel.enableVibration(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.content.Intent
import android.graphics.drawable.BitmapDrawable
import android.os.Build
import androidx.core.app.NotificationCompat
import org.getlantern.lantern.LanternApp
import org.getlantern.lantern.MainActivity
import org.getlantern.lantern.R
import java.util.concurrent.LinkedBlockingDeque
Expand Down Expand Up @@ -55,11 +56,12 @@ class ServiceHelper(private val service: Service, private val largeIcon: Int, pr
}

@TargetApi(Build.VERSION_CODES.O)
private fun createNotificationChannel(): String? {
private fun createNotificationChannel(): String {
val channelId = "lantern_service"
val channelName = LanternApp.getAppContext().resources.getString(R.string.lantern_service)
val mNotificationManager = service.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
mNotificationManager.createNotificationChannel(
NotificationChannel(channelId, channelId, NotificationManager.IMPORTANCE_DEFAULT)
NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT)
)
return channelId
}
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,7 @@
<string name="new_message">New Message</string>
<string name="from_sender">From %1$s</string>
<string name="unnamed_contact">Unnamed Contact</string>
<string name="message_notifications_channel">Messages</string>
<string name="call_notifications_channel">Calls</string>
<string name="lantern_service">Lantern Service</string>
</resources>
6 changes: 6 additions & 0 deletions assets/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,12 @@ msgstr "Incoming Call"
msgid "call_from"
msgstr "From %s"

msgid "in_call"
msgstr "Ongoing Calls"

msgid "in_call_des"
msgstr "Notification of ongoing call"

msgid "incoming_call_from"
msgstr "Incoming call from %s"

Expand Down
3 changes: 1 addition & 2 deletions lib/messaging/calls/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class _CallState extends State<Call> with WidgetsBindingObserver {
case CallState.Connected:
return 'Connected'.i18n;
case CallState.Bye:
return 'Disconnecting'
.i18n; // TODO: this shows up very briefly on start of call (normal?)
return 'Disconnecting'.i18n;
default:
return 'Calling'.i18n;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/messaging/notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Notifications {
static final inCallNotificationId = 0;

final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
final inCallChannel = const NotificationDetails(
final inCallChannel = NotificationDetails(
android: AndroidNotificationDetails(
'10003', 'in_call', 'Notification of ongoing call',
'10003', 'in_call'.i18n, 'in_call_des'.i18n,
importance: Importance.max, priority: Priority.high, showWhen: false),
);

Expand Down Expand Up @@ -39,8 +39,8 @@ class Notifications {
Future<void> showInCallNotification(Contact contact) {
return flutterLocalNotificationsPlugin.show(
inCallNotificationId,
'In call with ${contact.displayName}'.i18n,
'Touch here to open call'.i18n,
'in_call_with'.i18n.fill([contact.displayName]),
'touch_here_to_open_call'.i18n,
inCallChannel);
}

Expand Down