YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.DisplayName Class Reference

Makes names that come from another app safe to show on one line. More...

Collaboration diagram for de.yaacc.share.DisplayName:
Collaboration graph

Static Public Member Functions

static String clean (String untrusted)
 
static String forShare (String providerName, String fallback)
 The name to show for a shared file: the provider's name, cleaned, or, if nothing visible is left, the cleaned fallback (a fixed, localized text such as "a shared file").
 

Static Public Attributes

static final int MAX_LENGTH = 200
 The longest cleaned name, in chars.
 

Detailed Description

Makes names that come from another app safe to show on one line.

Plain Java so it can be unit tested on the JVM. The name of a shared file is shown to the user before anything is played (the receiver picker names what is about to be shared), so it must not be able to fake or hide parts of itself.

This is the one cleaner for LAN- and app-supplied texts; MiniPlayerPresenter delegates here, so the rules are the same everywhere: whitespace runs (including line breaks and tabs) become one space, control characters, format characters (Unicode category Cf: bidirectional controls, zero-width characters, soft hyphen, tag characters, ...) and the blank Hangul letters are dropped (the zero-width joiner is kept so emoji sequences survive, and the non-joiner for scripts that need it), the result is trimmed and cut at MAX_LENGTH chars without splitting a surrogate pair. Show the result with setText; it is not markup-escaped.

Member Function Documentation

◆ clean()

static String de.yaacc.share.DisplayName.clean ( String untrusted)
static
Parameters
untrustedthe text from another app or device, may be null
Returns
the cleaned text, possibly empty; never null

Referenced by de.yaacc.share.DisplayName.forShare(), and de.yaacc.share.PendingShare.offer().

Here is the caller graph for this function:

◆ forShare()

static String de.yaacc.share.DisplayName.forShare ( String providerName,
String fallback )
static

The name to show for a shared file: the provider's name, cleaned, or, if nothing visible is left, the cleaned fallback (a fixed, localized text such as "a shared file").

Parameters
providerNamethe display name the sending app reported, may be null
fallbackthe text for "no usable name", may be null
Returns
a cleaned, non-empty name (a single ? only if the fallback is unusable too)
Here is the call graph for this function:

The documentation for this class was generated from the following file: