Не пересоздаём нотификацию

pull/49/head
Umnik 10 months ago
parent 369f044fe7
commit 967a6d03f2

@ -12,8 +12,8 @@ android {
applicationId "xyz.myachin.saveto"
minSdkVersion 23
targetSdkVersion 32
versionCode 18
versionName '1.15.3'
versionCode 19
versionName '1.15.4'
}
buildTypes {
@ -34,11 +34,11 @@ android {
}
compileOptions {
sourceCompatibility "1.8"
targetCompatibility "1.8"
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
@ -47,7 +47,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'

@ -15,6 +15,9 @@ import androidx.core.app.NotificationManagerCompat
import xyz.myachin.saveto.R
class ResetDefaultsNotification(private val context: Context) {
private val manager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
private val notificationChannel by lazy {
NotificationChannelCompat.Builder(REMOVE_DEFAULT_NOTIFICATION_CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_DEFAULT)
@ -41,7 +44,7 @@ class ResetDefaultsNotification(private val context: Context) {
init {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager)
manager
.createNotificationChannel(NotificationChannel(
notificationChannel.id,
notificationChannel.name,
@ -50,6 +53,8 @@ class ResetDefaultsNotification(private val context: Context) {
}
fun reset() {
manager.activeNotifications.forEach { if (it.id == REMOVE_DEFAULT_REQUEST_CODE) return }
NotificationManagerCompat.from(context.applicationContext)
.notify(REMOVE_DEFAULT_REQUEST_CODE, NotificationCompat
.Builder(context.applicationContext, REMOVE_DEFAULT_NOTIFICATION_CHANNEL_ID)

@ -10,7 +10,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong

@ -0,0 +1,2 @@
1. Updating dependencies
2. Notification for ACTION_VIEW defaults reset is no longer recreated if it already exists

@ -0,0 +1,2 @@
1. Обновление зависимостей
2. Уведомление об установке приложения по умолчанию для обраотки ACTION_VIEW теперь не пересоздаётся, если оно уже существует

@ -1,6 +1,6 @@
#Wed Sep 01 13:49:20 MSK 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Loading…
Cancel
Save