-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2752 from dimagi/handle-recording-configuration-c…
…hanges Improve audio recording configuration
- Loading branch information
Showing
5 changed files
with
181 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.commcare.utils; | ||
|
||
import static android.content.Context.NOTIFICATION_SERVICE; | ||
|
||
import android.app.NotificationManager; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
|
||
import androidx.core.app.NotificationCompat; | ||
|
||
import org.commcare.activities.DispatchActivity; | ||
import org.commcare.dalvik.R; | ||
|
||
/** | ||
* Set of methods to post notifications to the user. | ||
* | ||
* @author avazirna | ||
*/ | ||
public class NotificationUtil { | ||
public static void showNotification(Context context, String notificationChannel, int notificationId, | ||
String notificationTitle, String notificationText, Intent actionIntent) { | ||
|
||
int pendingIntentFlags = PendingIntent.FLAG_UPDATE_CURRENT; | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
pendingIntentFlags = pendingIntentFlags | PendingIntent.FLAG_IMMUTABLE; | ||
} | ||
PendingIntent contentIntent = | ||
PendingIntent.getActivity(context, 0, actionIntent, pendingIntentFlags); | ||
|
||
NotificationCompat.Builder notification = | ||
new NotificationCompat.Builder(context, notificationChannel) | ||
.setContentTitle(notificationTitle) | ||
.setContentText(notificationText) | ||
.setContentIntent(contentIntent) | ||
.setSmallIcon(R.drawable.notification) | ||
.setPriority(NotificationCompat.PRIORITY_HIGH) | ||
.setWhen(System.currentTimeMillis()); | ||
((NotificationManager) context.getSystemService(NOTIFICATION_SERVICE)) | ||
.notify(notificationId, notification.build()); | ||
} | ||
|
||
public static void cancelNotification(Context context, int notificationId) { | ||
((NotificationManager) context.getSystemService(NOTIFICATION_SERVICE)) | ||
.cancel(notificationId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters