From e5482d48c06bc400745e043fbbe0018328a1ff26 Mon Sep 17 00:00:00 2001 From: onurays Date: Thu, 26 Mar 2020 16:02:50 +0300 Subject: [PATCH] Remove deprecated & unused ImageTools class. --- .../im/vector/riotx/core/images/ImageTools.kt | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 vector/src/main/java/im/vector/riotx/core/images/ImageTools.kt diff --git a/vector/src/main/java/im/vector/riotx/core/images/ImageTools.kt b/vector/src/main/java/im/vector/riotx/core/images/ImageTools.kt deleted file mode 100644 index 84cba7392f..0000000000 --- a/vector/src/main/java/im/vector/riotx/core/images/ImageTools.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2019 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package im.vector.riotx.core.images - -import android.content.Context -import android.net.Uri -import android.provider.MediaStore -import androidx.exifinterface.media.ExifInterface -import timber.log.Timber -import javax.inject.Inject - -class ImageTools @Inject constructor(private val context: Context) { - - /** - * Gets the [ExifInterface] value for the orientation for this local bitmap Uri. - * - * @param uri The URI to find the orientation for. Must be local. - * @return The orientation value, which may be [ExifInterface.ORIENTATION_UNDEFINED]. - */ - fun getOrientationForBitmap(uri: Uri): Int { - var orientation = ExifInterface.ORIENTATION_UNDEFINED - - if (uri.scheme == "content") { - val proj = arrayOf(MediaStore.Images.Media.DATA) - try { - val cursor = context.contentResolver.query(uri, proj, null, null, null) - cursor?.use { - if (it.moveToFirst()) { - val idxData = it.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) - val path = it.getString(idxData) - if (path.isNullOrBlank()) { - Timber.w("Cannot find path in media db for uri $uri") - return orientation - } - val exif = ExifInterface(path) - orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED) - } - } - } catch (e: Exception) { - // eg SecurityException from com.google.android.apps.photos.content.GooglePhotosImageProvider URIs - // eg IOException from trying to parse the returned path as a file when it is an http uri. - Timber.e(e, "Cannot get orientation for bitmap") - } - } else if (uri.scheme == "file") { - try { - val path = uri.path - if (path != null) { - val exif = ExifInterface(path) - orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED) - } - } catch (e: Exception) { - Timber.e(e, "Cannot get EXIF for file uri $uri") - } - } - - return orientation - } -}