|
|
@@ -3,6 +3,11 @@ package br.com.diarista.provider;
|
|
|
import android.graphics.Color;
|
|
|
import android.os.Bundle;
|
|
|
import android.webkit.WebView;
|
|
|
+import android.app.NotificationChannel;
|
|
|
+import android.app.NotificationManager;
|
|
|
+import android.media.AudioAttributes;
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Build;
|
|
|
|
|
|
import com.getcapacitor.BridgeActivity;
|
|
|
|
|
|
@@ -14,6 +19,9 @@ public class MainActivity extends BridgeActivity {
|
|
|
// WebView, então o WebView precisa ser transparente onde o mapa é exibido.
|
|
|
// (O background do body cobre isso nas telas normais — só o LocationMapDialog
|
|
|
// torna a cadeia html/body/#q-app transparente para revelar o mapa.)
|
|
|
+
|
|
|
+ createNotificationChannel();
|
|
|
+
|
|
|
getBridge().getWebView().setBackgroundColor(Color.TRANSPARENT);
|
|
|
}
|
|
|
|
|
|
@@ -23,4 +31,35 @@ public class MainActivity extends BridgeActivity {
|
|
|
WebView webview = getBridge().getWebView();
|
|
|
webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
|
|
|
}
|
|
|
+
|
|
|
+ private void createNotificationChannel() {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
+
|
|
|
+ Uri sound = Uri.parse(
|
|
|
+ "android.resource://" + getPackageName() + "/" + R.raw.diaria
|
|
|
+ );
|
|
|
+
|
|
|
+ AudioAttributes audioAttributes = new AudioAttributes.Builder()
|
|
|
+ .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
|
|
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ NotificationChannel channel = new NotificationChannel(
|
|
|
+ "diaria",
|
|
|
+ "Novas Diárias",
|
|
|
+ NotificationManager.IMPORTANCE_HIGH
|
|
|
+ );
|
|
|
+
|
|
|
+ channel.setDescription("Canal para novas solicitações de diária");
|
|
|
+ channel.setShowBadge(true);
|
|
|
+ channel.enableLights(true);
|
|
|
+ channel.enableVibration(true);
|
|
|
+ channel.setSound(sound, audioAttributes);
|
|
|
+
|
|
|
+ NotificationManager notificationManager =
|
|
|
+ getSystemService(NotificationManager.class);
|
|
|
+
|
|
|
+ notificationManager.createNotificationChannel(channel);
|
|
|
+ }
|
|
|
+}
|
|
|
}
|