mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Use proper method to clear notification actions
This commit is contained in:
		@@ -68,9 +68,7 @@ class BackupNotifier(private val context: Context) {
 | 
			
		||||
            setContentText(unifile.filePath ?: unifile.name)
 | 
			
		||||
 | 
			
		||||
            // Clear old actions if they exist
 | 
			
		||||
            if (mActions.isNotEmpty()) {
 | 
			
		||||
                mActions.clear()
 | 
			
		||||
            }
 | 
			
		||||
            clearActions()
 | 
			
		||||
 | 
			
		||||
            addAction(
 | 
			
		||||
                R.drawable.ic_share_24dp,
 | 
			
		||||
@@ -94,9 +92,7 @@ class BackupNotifier(private val context: Context) {
 | 
			
		||||
            setOnlyAlertOnce(true)
 | 
			
		||||
 | 
			
		||||
            // Clear old actions if they exist
 | 
			
		||||
            if (mActions.isNotEmpty()) {
 | 
			
		||||
                mActions.clear()
 | 
			
		||||
            }
 | 
			
		||||
            clearActions()
 | 
			
		||||
 | 
			
		||||
            addAction(
 | 
			
		||||
                R.drawable.ic_close_24dp,
 | 
			
		||||
@@ -137,9 +133,7 @@ class BackupNotifier(private val context: Context) {
 | 
			
		||||
            setContentText(context.resources.getQuantityString(R.plurals.restore_completed_message, errorCount, timeString, errorCount))
 | 
			
		||||
 | 
			
		||||
            // Clear old actions if they exist
 | 
			
		||||
            if (mActions.isNotEmpty()) {
 | 
			
		||||
                mActions.clear()
 | 
			
		||||
            }
 | 
			
		||||
            clearActions()
 | 
			
		||||
 | 
			
		||||
            if (errorCount > 0 && !path.isNullOrEmpty() && !file.isNullOrEmpty()) {
 | 
			
		||||
                val destFile = File(path, file)
 | 
			
		||||
 
 | 
			
		||||
@@ -66,15 +66,6 @@ internal class DownloadNotifier(private val context: Context) {
 | 
			
		||||
        context.notificationManager.notify(id, build())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Clear old actions if they exist.
 | 
			
		||||
     */
 | 
			
		||||
    private fun NotificationCompat.Builder.clearActions() {
 | 
			
		||||
        if (mActions.isNotEmpty()) {
 | 
			
		||||
            mActions.clear()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Dismiss the downloader's notification. Downloader error notifications use a different id, so
 | 
			
		||||
     * those can only be dismissed by the user.
 | 
			
		||||
 
 | 
			
		||||
@@ -60,9 +60,7 @@ class SaveImageNotifier(private val context: Context) {
 | 
			
		||||
            setAutoCancel(true)
 | 
			
		||||
 | 
			
		||||
            // Clear old actions if they exist
 | 
			
		||||
            if (mActions.isNotEmpty()) {
 | 
			
		||||
                mActions.clear()
 | 
			
		||||
            }
 | 
			
		||||
            clearActions()
 | 
			
		||||
 | 
			
		||||
            setContentIntent(NotificationHandler.openImagePendingActivity(context, file))
 | 
			
		||||
            // Share action
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user