Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2023-07-26 20:06:28 +02:00
parent 72e21c4c5c
commit 46322b2b63
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 36 additions and 0 deletions

View file

@ -23,10 +23,12 @@
*/
package com.nextcloud.talk.jobs
import android.Manifest
import android.app.Notification
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.media.AudioAttributes
import android.media.MediaPlayer
@ -41,6 +43,7 @@ import android.text.TextUtils
import android.util.Base64
import android.util.Log
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.Person
@ -734,6 +737,15 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
private fun sendNotification(notificationId: Int, notification: Notification) {
Log.d(TAG, "show notification with id $notificationId")
Log.d(TAG, "notification enabled: " + notificationManager.areNotificationsEnabled())
if (ActivityCompat.checkSelfPermission(
context!!,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
) {
Log.d(TAG, "notification not allowed!")
}
notificationManager.notify(notificationId, notification)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

View file

@ -57,6 +57,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.work.Data
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkInfo
import androidx.work.WorkManager
@ -78,7 +79,9 @@ import com.nextcloud.talk.jobs.CapabilitiesWorker
import com.nextcloud.talk.jobs.ContactAddressBookWorker
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.checkPermission
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.deleteAll
import com.nextcloud.talk.jobs.PushRegistrationWorker
import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.models.json.push.PushConfigurationState
import com.nextcloud.talk.models.json.userprofile.UserProfileOverall
import com.nextcloud.talk.profile.ProfileActivity
import com.nextcloud.talk.users.UserManager
@ -159,7 +162,16 @@ class SettingsActivity : BaseActivity() {
setupPrivacyUrl()
setupSourceCodeUrl()
binding.settingsLicence.setOnClickListener{
Log.d(TAG, "Token:" + appPreferences.pushToken)
}
binding.settingsVersionSummary.text = String.format("v" + BuildConfig.VERSION_NAME)
binding.settingsVersionSummary.setOnClickListener {
Log.d(TAG, "re-register push")
registerForPush()
}
setupSoundSettings()
@ -168,6 +180,18 @@ class SettingsActivity : BaseActivity() {
setupClientCertView()
}
private fun registerForPush() {
val data =
Data.Builder()
.putString(PushRegistrationWorker.ORIGIN, "AccountVerificationController#registerForPush")
.build()
val pushRegistrationWork =
OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java)
.setInputData(data)
.build()
WorkManager.getInstance().enqueue(pushRegistrationWork)
}
override fun onResume() {
super.onResume()
supportActionBar?.show()