to avoid https://issuetracker.google.com/issues/158753935, use androidx.exifinterface:exifinterface:1.2.0

This commit is contained in:
tateisu 2020-08-25 09:04:18 +09:00
parent 58ae3a9b69
commit 1aa15618c9
8 changed files with 24 additions and 18 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ output.json
/.idea/caches/
/.idea/codeStyles/
/_Emoji/*
/app/rc/release/

View File

@ -16,7 +16,6 @@
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/colorpicker" />
<option value="$PROJECT_DIR$/emoji" />
<option value="$PROJECT_DIR$/exif" />
<option value="$PROJECT_DIR$/sample_apng" />
</set>
</option>

View File

@ -44,7 +44,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -8,7 +8,6 @@
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" group="SubwayTooter/app" />
<module fileurl="file://$PROJECT_DIR$/colorpicker/colorpicker.iml" filepath="$PROJECT_DIR$/colorpicker/colorpicker.iml" group="SubwayTooter/colorpicker" />
<module fileurl="file://$PROJECT_DIR$/emoji/emoji.iml" filepath="$PROJECT_DIR$/emoji/emoji.iml" group="SubwayTooter/emoji" />
<module fileurl="file://$PROJECT_DIR$/exif/exif.iml" filepath="$PROJECT_DIR$/exif/exif.iml" group="SubwayTooter/exif" />
<module fileurl="file://$PROJECT_DIR$/sample_apng/sample_apng.iml" filepath="$PROJECT_DIR$/sample_apng/sample_apng.iml" group="SubwayTooter/sample_apng" />
</modules>
</component>

View File

@ -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"

View File

@ -511,7 +511,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
@Suppress("SameParameterValue") pixel_max : Int
) : Pair<Bitmap?, String?> {
val orientation : Int? = ByteArrayInputStream(data).imageOrientation
val orientation : Int? = ByteArrayInputStream(data).imageOrientation()
// detects image size
options.inJustDecodeBounds = true

View File

@ -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()
}
// 画像のサイズを調べる

View File

@ -1 +1 @@
include ':app', ':sample_apng', ':apng_android', ':apng', ':exif', ':colorpicker', ':emoji'
include ':app', ':sample_apng', ':apng_android', ':apng', ':colorpicker', ':emoji'