Skip to content

Show a dialog with 'Don't show again' option to remember the preference, with just 1 line of code.

License

Notifications You must be signed in to change notification settings

tashilapathum/NeverAgain

Repository files navigation

NeverAgain

A simple dialog with a 'Don't show again' option to remember the preference.

Preview

Customized dialog With default labels Dark mode
Screenshot_20250212_213951 Screenshot_20250212_214028 Screenshot_20250212_214135

Features

  • Stores the preference based on the hash value of the passed message
  • Simply updating the message will show the dialog again with the new information
  • Can reset a specific dialog or all dialogs
  • Supports the latest Material 3 design
  • Follows Dark and Light modes automatically
  • Lightweight and Easy to implement

Installation

Add JitPack to your settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        maven("https://jitpack.io")
    }
}

Then, add the dependency to your module-level build.gradle.kts:

dependencies {
    implementation("com.github.tashilapathum:NeverAgain:latest-version")
}

Replace latest-version with the latest release at the top of this file.

Usage

Minimal example

NeverAgainDialog
    .create("Tip", "This is a helpful tip!")
    .show(supportFragmentManager, "NeverAgainDialog")

Full example

NeverAgainDialog.create(
    title = "Enable Notifications",
    message = "Please allow notification permission to receive latest updates.",
    positiveButtonText = "OK",
    checkboxText = "Never show again",
    isChecked = false,
).setOnDismissedListener { isChecked ->
    if (isChecked) {
        // Handle user preference
    }
}.show(supportFragmentManager, "NeverAgainDialog")

Clear preferences

private val tip1 = "This is a helpful tip."
NeverAgainDialog.create("Tip", tip1).show(supportFragmentManager, "NeverAgainDialog")
NeverAgainDialog().clear(context, tip1)

Clears a specific dialog preference

NeverAgainDialog.create("Tip", tip1).show(supportFragmentManager, "NeverAgainDialog")
NeverAgainDialog().clearAll(context)

Clears all dialog preferences

About

Show a dialog with 'Don't show again' option to remember the preference, with just 1 line of code.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages