mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-04-28 04:06:09 +00:00
feat(android): implement call handling and audio features, add notification channels, and enhance UI with new permissions and shortcuts
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
package com.meshchatx;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.chaquo.python.android.PyApplication;
|
||||
|
||||
public class MeshChatApplication extends PyApplication {
|
||||
public static final String CHANNEL_ID_MESSAGES = "meshchatx_messages";
|
||||
public static final String CHANNEL_ID_BACKGROUND = "meshchatx_background";
|
||||
public static final String CHANNEL_ID_CALLS = "meshchatx_calls";
|
||||
|
||||
private static volatile Context appContext;
|
||||
|
||||
@@ -49,5 +55,35 @@ public class MeshChatApplication extends PyApplication {
|
||||
);
|
||||
messages.setDescription(getString(R.string.notification_channel_messages_desc));
|
||||
nm.createNotificationChannel(messages);
|
||||
|
||||
Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||
if (ringUri == null) {
|
||||
ringUri = Settings.System.DEFAULT_RINGTONE_URI;
|
||||
}
|
||||
NotificationChannel calls = new NotificationChannel(
|
||||
CHANNEL_ID_CALLS,
|
||||
getString(R.string.notification_channel_calls_name),
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
);
|
||||
calls.setDescription(getString(R.string.notification_channel_calls_desc));
|
||||
calls.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
calls.setBypassDnd(true);
|
||||
}
|
||||
if (ringUri != null) {
|
||||
calls.setSound(
|
||||
ringUri,
|
||||
new AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
long[] pattern = new long[] {0, 400, 200, 400, 200, 600};
|
||||
try {
|
||||
calls.setVibrationPattern(pattern);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
nm.createNotificationChannel(calls);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user