two-slices icon indicating copy to clipboard operation
two-slices copied to clipboard

Exclude notification type from title

Open avently opened this issue 2 years ago • 4 comments

Hello. Thank you for this great library! I'm just thinking, is it possible to exclude notification type from title? Because, for example, in NotificationCenter you have this line: https://github.com/sshtools/two-slices/blob/master/src/main/java/com/sshtools/twoslices/impl/NotificationCenterToaster.java#L893 which basically adds unneeded text before title. Would be great to have it configurable in builder like so:

boolean includeTypeInTitleIfUnsupportedByToaster;

I would pass false here to disable this feature for all toaster's implementations. So, if toaster implementation supports differentiation by type, it should still be used. But if not, the type should be in title.

What do you think about it?

avently avatar Sep 06 '23 19:09 avently

Hi, thanks for your report.

I've just pushed version 0.9.1 to Maven Central, that will support what you are trying to do. I have been meaning to improve how "hints" are provided to the various different implementations, and took the opportunity to do so here.

You will need the BasicToastHint.NO_TYPE_IN_TEXT hint. You can set this either globally via ToasterSettings, or use ToastBuilder.hints().

var builder = Toast.builder();
builder.hints().put(BasicToastHint.NO_TYPE_IN_TEXT, true);
builder.title("My Title");
builder.content("Some content");
builder.toast();

Hope this helps you.

brett-smith avatar Oct 09 '23 21:10 brett-smith

@brett-smith wow, cool, thank you very much for such option!

avently avatar Oct 09 '23 22:10 avently

Returned to the subject and tried to find the place where this setting is applied: https://github.com/search?q=repo%3Asshtools%2Ftwo-slices%20NO_TYPE_IN_TEXT&type=code

But it shows only declaration, no usage. Am I mistaken or is it really not used in the code?

avently avatar Mar 26 '24 06:03 avently

You are not mistaken! I somehow managed to do everything except actually implement the original suggestion :-\

Anyway, this is fixed in 0.9.4-SNAPSHOT, full release to follow shortly.

brett-smith avatar Jul 09 '24 21:07 brett-smith