mirror of https://github.com/jitsi/jitsi-meet
feat(android): separate MediaProjection and OngoingConference notifications (#14363)
* feat(android): separate MediaProjection and OngoingConference notificationspull/14365/head jitsi-meet_9281
parent
a7b2726ebe
commit
ba20fc71a8
@ -0,0 +1,59 @@ |
||||
/* |
||||
* Copyright @ 2019-present 8x8, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import static org.jitsi.meet.sdk.NotificationChannels.ONGOING_CONFERENCE_CHANNEL_ID; |
||||
|
||||
import android.app.Notification; |
||||
import android.content.Context; |
||||
|
||||
import androidx.core.app.NotificationCompat; |
||||
|
||||
import org.jitsi.meet.sdk.log.JitsiMeetLogger; |
||||
|
||||
/** |
||||
* Helper class for creating the media projection notification which is used with |
||||
* {@link JitsiMeetMediaProjectionService}. |
||||
*/ |
||||
class MediaProjectionNotification { |
||||
private static final String TAG = MediaProjectionNotification.class.getSimpleName(); |
||||
|
||||
static Notification buildMediaProjectionNotification() { |
||||
Context context = ReactInstanceManagerHolder.getCurrentActivity(); |
||||
|
||||
if (context == null) { |
||||
JitsiMeetLogger.d(TAG, " Cannot create notification: no current context"); |
||||
return null; |
||||
} |
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, ONGOING_CONFERENCE_CHANNEL_ID); |
||||
|
||||
builder |
||||
.setCategory(NotificationCompat.CATEGORY_CALL) |
||||
.setContentTitle(context.getString(R.string.media_projection_notification_title)) |
||||
.setContentText(context.getString(R.string.media_projection_notification_text)) |
||||
.setPriority(NotificationCompat.PRIORITY_LOW) |
||||
.setOngoing(false) |
||||
.setUsesChronometer(false) |
||||
.setAutoCancel(true) |
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) |
||||
.setOnlyAlertOnce(true) |
||||
.setSmallIcon(context.getResources().getIdentifier("ic_notification", "drawable", context.getPackageName())); |
||||
|
||||
return builder.build(); |
||||
} |
||||
} |
@ -0,0 +1,45 @@ |
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import static org.jitsi.meet.sdk.NotificationChannels.ONGOING_CONFERENCE_CHANNEL_ID; |
||||
|
||||
import android.app.Activity; |
||||
import android.app.NotificationChannel; |
||||
import android.app.NotificationManager; |
||||
import android.content.Context; |
||||
import android.os.Build; |
||||
|
||||
import org.jitsi.meet.sdk.log.JitsiMeetLogger; |
||||
|
||||
class NotificationUtils { |
||||
|
||||
private static final String TAG = NotificationUtils.class.getSimpleName(); |
||||
|
||||
static void createNotificationChannel(Activity context) { |
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { |
||||
return; |
||||
} |
||||
|
||||
if (context == null) { |
||||
JitsiMeetLogger.w(TAG + " Cannot create notification channel: no current context"); |
||||
return; |
||||
} |
||||
|
||||
NotificationManager notificationManager |
||||
= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
||||
|
||||
NotificationChannel channel |
||||
= notificationManager.getNotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID); |
||||
|
||||
if (channel != null) { |
||||
// The channel was already created, no need to do it again.
|
||||
return; |
||||
} |
||||
|
||||
channel = new NotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID, context.getString(R.string.ongoing_notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT); |
||||
channel.enableLights(false); |
||||
channel.enableVibration(false); |
||||
channel.setShowBadge(false); |
||||
|
||||
notificationManager.createNotificationChannel(channel); |
||||
} |
||||
} |
@ -1,11 +1,12 @@ |
||||
<resources> |
||||
<string name="app_name">Jitsi Meet SDK</string> |
||||
<string name="dropbox_app_key"></string> |
||||
<string name="media_projection_notification_title">Media projection</string> |
||||
<string name="media_projection_notification_text">You are currently sharing your screen.</string> |
||||
<string name="ongoing_notification_title">Ongoing meeting</string> |
||||
<string name="ongoing_notification_text">You are currently in a meeting. Tap to return to it.</string> |
||||
<string name="ongoing_notification_action_hang_up">Hang up</string> |
||||
<string name="ongoing_notification_action_mute">Mute</string> |
||||
<string name="ongoing_notification_action_screenshare">You are currently screen-sharing. Tap to return to the meeting.</string> |
||||
<string name="ongoing_notification_action_unmute">Unmute</string> |
||||
<string name="ongoing_notification_channel_name">Ongoing Conference Notifications</string> |
||||
</resources> |
||||
|
Loading…
Reference in new issue