skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.73k stars 291 forks source link

Clear SharedPreferences (preferenceName, showTimes) #241

Closed utkualtas closed 3 years ago

utkualtas commented 3 years ago

Is your feature request related to a problem? We have a logout feature in our app. The problem is that when the user logged out we need to clear the showTime but as far as I could see there is not a function for that. Am I wrong?

Describe the solution you'd like: Actually, I can clear the preferences like this way; context.getSharedPreferences("com.skydoves.balloon", Context.MODE_PRIVATE).edit { clear() }

But I prefer to do that Balloon.clearAllPreferences() as like with Only

skydoves commented 3 years ago

Hi @utkualtas, Thanks for your issue! A new snapshot 1.3.8-SNAPSHOT is released. You can use the Balloon.clearAllPreferences() function in this release.

utkualtas commented 3 years ago

Thank you, that was fast @skydoves 👍

utkualtas commented 3 years ago

Hi again @skydoves, I just noticed that we need a Balloon instance to call clearAllPreferences(). Do we have a chance convert Balloon.Builder(context).build().clearAllPreferences() to direct access without creating the Balloon instance Balloon.clearAllPreferences() as like with Only

skydoves commented 3 years ago

Oh, that's a good point. You can use like this BalloonPersistence.getInstance(context).clearAllPreferences() in the new snapshot version 1.3.8.1-SNAPSHOT. If your project uses a design pattern like dependency injection, I recommend providing the instance of the BalloonPersistence on your class via DI. Thanks for your feedback and sponsorship! 😄

utkualtas commented 3 years ago

I will consider the DI. Thanks again for the great works! 🙂