mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Merge pull request #2109 from nextcloud/bugfix/beautifyEmptyString
Don't beautify empty inputs
This commit is contained in:
commit
2c59093bd8
1 changed files with 11 additions and 9 deletions
|
@ -38,11 +38,13 @@ import android.graphics.drawable.PictureDrawable;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.Menu;
|
||||
|
@ -188,20 +190,20 @@ public class DisplayUtils {
|
|||
* @param url to be beautified url
|
||||
* @return beautified url
|
||||
*/
|
||||
public static String beautifyURL(String url) {
|
||||
if (url == null) {
|
||||
public static String beautifyURL(@Nullable String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (url.length() >= 7 && url.substring(0, 7).equalsIgnoreCase(HTTP_PROTOCOLL)) {
|
||||
return url.substring(HTTP_PROTOCOLL.length());
|
||||
return url.substring(HTTP_PROTOCOLL.length()).trim();
|
||||
}
|
||||
|
||||
if (url.length() >= 8 && url.substring(0, 8).equalsIgnoreCase(HTTPS_PROTOCOLL)) {
|
||||
return url.substring(HTTPS_PROTOCOLL.length());
|
||||
return url.substring(HTTPS_PROTOCOLL.length()).trim();
|
||||
}
|
||||
|
||||
return url;
|
||||
return url.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,15 +212,15 @@ public class DisplayUtils {
|
|||
* @param handle to be beautified twitter handle
|
||||
* @return beautified twitter handle
|
||||
*/
|
||||
public static String beautifyTwitterHandle(String handle) {
|
||||
if (handle == null) {
|
||||
public static String beautifyTwitterHandle(@Nullable String handle) {
|
||||
if (TextUtils.isEmpty(handle)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (handle.startsWith(TWITTER_HANDLE_PREFIX)) {
|
||||
return handle;
|
||||
return handle.trim();
|
||||
} else {
|
||||
return TWITTER_HANDLE_PREFIX + handle;
|
||||
return TWITTER_HANDLE_PREFIX + handle.trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue