Skip to content

Commit

Permalink
QA - Condition with logs extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitorbp committed Nov 24, 2023
1 parent 3441944 commit a4f7d07
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions owncloudApp/src/main/java/com/owncloud/android/utils/UriUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
public class UriUtils {

public static final String URI_CONTENT_SCHEME = "content://";
public static final String LOG_EXTENSION = "log";

public static String getDisplayNameForUri(Uri uri, Context context) {

Expand All @@ -63,15 +64,17 @@ public static String getDisplayNameForUri(Uri uri, Context context) {

// Add best possible extension
int index = displayName.lastIndexOf(".");
if (index == -1 || MimeTypeMap.getSingleton().
getMimeTypeFromExtension(displayName.substring(index + 1)) == null) {
String mimeType = context.getContentResolver().getType(uri);
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
if (extension != null) {
displayName += "." + extension;
String fileExtension = displayName.substring(index + 1);
if(!(LOG_EXTENSION.equalsIgnoreCase(fileExtension))) {
if (index == -1 || MimeTypeMap.getSingleton().
getMimeTypeFromExtension(fileExtension) == null) {
String mimeType = context.getContentResolver().getType(uri);
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
if (extension != null) {
displayName += "." + extension;
}
}
}

} catch (Exception e) {
Timber.e(e, "No way to get a display name for %s", uri.toString());
}
Expand Down

0 comments on commit a4f7d07

Please sign in to comment.