src/main/java/de/blau/android/util/Util.java
/**
     * Remove formating from s and truncate it if necessary, typically used in a TextWatcher
     * 
     * @param context if non-null and the string has been truncated display a toast with this context
     * @param s Editable that needs to be sanitized
     * @param maxStringLength maximum length the string is allowed to have
     */
Remove formating from s and truncate it if necessary, typically used in a TextWatcher

@param context if non-null and the string has been truncated display a toast with this context
@param s Editable that needs to be sanitized
@param maxStringLength maximum length the string is allowed to have
Remove formating from s and truncate it if necessary typically used in a TextWatcher @param context if non - null and the string has been truncated display a toast with this context @param s Editable that needs to be sanitized @param maxStringLength maximum length the string is allowed to have
public static void sanitizeString(@Nullable Context context, @NonNull Editable s, int maxStringLength) {
        CharacterStyle[] toBeRemovedSpans = s.getSpans(0, s.length(), MetricAffectingSpan.class);
        for (CharacterStyle toBeRemovedSpan : toBeRemovedSpans) {
            s.removeSpan(toBeRemovedSpan);
        }
        int len = s.length();
        if (len > maxStringLength) {
            s.delete(maxStringLength, len);
            if (context != null) {
                Snack.toastTopWarning(context, context.getString(R.string.toast_string_too_long, len));
            }
        }
    }
public static void sanitizeString ( @ Nullable Context context , @ NonNull Editable s , int maxStringLength ) { CharacterStyle [ ] toBeRemovedSpans = s . getSpans ( 0 , s . length ( ) , MetricAffectingSpan . class ) ; for ( CharacterStyle toBeRemovedSpan : toBeRemovedSpans ) { s . removeSpan ( toBeRemovedSpan ) ; } int len = s . length ( ) ; if ( len > maxStringLength ) { s . delete ( maxStringLength , len ) ; if ( context != null ) { Snack . toastTopWarning ( context , context . getString ( R . string . toast_string_too_long , len ) ) ; } } }
Remove formating from s and truncate it if necessary, typically used in a TextWatcher
Remove formating from s and truncate it if necessary typically used in a TextWatcher
// remove formating from pastes etc // truncate if longer than max supported string length