Skip to content

Commit

Permalink
Add an action to hide the annoying notif on O+
Browse files Browse the repository at this point in the history
  • Loading branch information
nkming2 committed Nov 3, 2018
1 parent 406bce4 commit e59f82a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nkming/powermenu/PersistentService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import android.provider.Settings
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -150,6 +151,19 @@ class PersistentService : com.nkming.utils.widget.PersistentService()
PendingIntent.FLAG_UPDATE_CURRENT)
builder.setContentIntent(pi)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE,
BuildConfig.APPLICATION_ID)
intent.putExtra(Settings.EXTRA_CHANNEL_ID, CHANNEL_ID)
val pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT)
builder.addAction(R.drawable.outline_visibility_off_white_24,
getString(R.string.notification_action_hide),
pendingIntent)
}

return builder.build()
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<string name="notification_ticker">Persistent power menu enabled</string>
<string name="notification_title">@string/app_name</string>
<string name="notification_text">Click to open config</string>
<string name="notification_action_hide">Hide</string>
<string name="notification_channel_name">Persistent View Service</string>
<string name="notification_channel_description">Keep the persistent view active</string>

Expand Down

0 comments on commit e59f82a

Please sign in to comment.