diff --git a/.gitignore b/.gitignore index eccf7d77..a2fc1404 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ output.json /.idea/caches/ /.idea/codeStyles/ /_Emoji/* +/app/rc/release/ diff --git a/.idea/gradle.xml b/.idea/gradle.xml index e00078b5..7bb3bb20 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -16,7 +16,6 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 3f62b3fa..c91ec4cc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -44,7 +44,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index f7d9ad76..e6a909fe 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -8,7 +8,6 @@ - diff --git a/app/build.gradle b/app/build.gradle index 3ea641cf..2f933f66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -91,11 +91,12 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation project(':exif') + // implementation project(':exif') implementation project(':colorpicker') implementation project(':emoji') implementation project(':apng_android') + implementation "androidx.appcompat:appcompat:$appcompat_version" // DrawerLayout @@ -107,6 +108,8 @@ dependencies { // PreferenceManager implementation "androidx.preference:preference-ktx:1.1.1" + implementation "androidx.exifinterface:exifinterface:1.2.0" + // CustomTabs implementation "androidx.browser:browser:1.2.0" diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActMediaViewer.kt b/app/src/main/java/jp/juggler/subwaytooter/ActMediaViewer.kt index 81d05dd4..88aa3877 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActMediaViewer.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActMediaViewer.kt @@ -511,7 +511,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener { @Suppress("SameParameterValue") pixel_max : Int ) : Pair { - val orientation : Int? = ByteArrayInputStream(data).imageOrientation + val orientation : Int? = ByteArrayInputStream(data).imageOrientation() // detects image size options.inJustDecodeBounds = true diff --git a/app/src/main/java/jp/juggler/util/BitmapUtils.kt b/app/src/main/java/jp/juggler/util/BitmapUtils.kt index bf6c98a9..086e63fc 100644 --- a/app/src/main/java/jp/juggler/util/BitmapUtils.kt +++ b/app/src/main/java/jp/juggler/util/BitmapUtils.kt @@ -2,8 +2,9 @@ package jp.juggler.util import android.content.Context import android.graphics.* +import androidx.exifinterface.media.ExifInterface import android.net.Uri -import it.sephiroth.android.library.exif2.ExifInterface +//import it.sephiroth.android.library.exif2.ExifInterface import java.io.FileNotFoundException import java.io.InputStream import kotlin.math.max @@ -11,16 +12,17 @@ import kotlin.math.sqrt private val log = LogCategory("BitmapUtils") -val InputStream.imageOrientation : Int? - get() = try { - ExifInterface() - .readExif( - this@imageOrientation, - ExifInterface.Options.OPTION_IFD_0 - or ExifInterface.Options.OPTION_IFD_1 - or ExifInterface.Options.OPTION_IFD_EXIF - ) - .getTagIntValue(ExifInterface.TAG_ORIENTATION) +fun InputStream.imageOrientation() : Int? = + try { + ExifInterface(this) + // .readExif( + // this@imageOrientation, + // ExifInterface.Options.OPTION_IFD_0 + // or ExifInterface.Options.OPTION_IFD_1 + // or ExifInterface.Options.OPTION_IFD_EXIF + // ) + .getAttributeInt(ExifInterface.TAG_ORIENTATION, - 1) + .takeIf { it >= 0 } } catch(ex : Throwable) { log.w(ex, "imageOrientation: exif parse failed.") null @@ -60,8 +62,10 @@ fun Matrix.resolveOrientation(orientation : Int?) : Matrix { enum class ResizeType { // リサイズなし None, + // 長辺がsize以下になるようリサイズ LongSide, + // 平方ピクセルが size*size 以下になるようリサイズ SquarePixel, } @@ -104,7 +108,7 @@ fun createResizedBitmap( try { val orientation : Int? = context.contentResolver.openInputStream(uri)?.use { - it.imageOrientation + it.imageOrientation() } // 画像のサイズを調べる diff --git a/settings.gradle b/settings.gradle index 7d5ad4e7..7706b5a7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':sample_apng', ':apng_android', ':apng', ':exif', ':colorpicker', ':emoji' +include ':app', ':sample_apng', ':apng_android', ':apng', ':colorpicker', ':emoji'