minor change

This commit is contained in:
Thibault Deckers 2021-04-19 12:31:08 +09:00
parent 7b97ebafca
commit b5d2ac3377
20 changed files with 27 additions and 26 deletions

View file

@ -172,7 +172,7 @@ class MainActivity : FlutterActivity() {
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(MainActivity::class.java) private val LOG_TAG = LogUtils.createTag<MainActivity>()
const val VIEWER_CHANNEL = "deckers.thibault/aves/viewer" const val VIEWER_CHANNEL = "deckers.thibault/aves/viewer"
} }
} }

View file

@ -263,7 +263,7 @@ class AppAdapterHandler(private val context: Context) : MethodCallHandler {
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(AppAdapterHandler::class.java) private val LOG_TAG = LogUtils.createTag<AppAdapterHandler>()
const val CHANNEL = "deckers.thibault/aves/app" const val CHANNEL = "deckers.thibault/aves/app"
} }
} }

View file

@ -305,7 +305,7 @@ class DebugHandler(private val context: Context) : MethodCallHandler {
) )
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(DebugHandler::class.java) private val LOG_TAG = LogUtils.createTag<DebugHandler>()
const val CHANNEL = "deckers.thibault/aves/debug" const val CHANNEL = "deckers.thibault/aves/debug"
} }
} }

View file

@ -910,7 +910,7 @@ class MetadataHandler(private val context: Context) : MethodCallHandler {
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(MetadataHandler::class.java) private val LOG_TAG = LogUtils.createTag<MetadataHandler>()
const val CHANNEL = "deckers.thibault/aves/metadata" const val CHANNEL = "deckers.thibault/aves/metadata"
private val allMetadataRedundantDirNames = setOf( private val allMetadataRedundantDirNames = setOf(

View file

@ -58,7 +58,7 @@ class ContentChangeStreamHandler(private val context: Context) : EventChannel.St
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(ContentChangeStreamHandler::class.java) private val LOG_TAG = LogUtils.createTag<ContentChangeStreamHandler>()
const val CHANNEL = "deckers.thibault/aves/contentchange" const val CHANNEL = "deckers.thibault/aves/contentchange"
} }
} }

View file

@ -175,7 +175,7 @@ class ImageByteStreamHandler(private val activity: Activity, private val argumen
} }
private fun streamBytes(inputStream: InputStream) { private fun streamBytes(inputStream: InputStream) {
val buffer = ByteArray(bufferSize) val buffer = ByteArray(BUFFER_SIZE)
var len: Int var len: Int
while (inputStream.read(buffer).also { len = it } != -1) { while (inputStream.read(buffer).also { len = it } != -1) {
// cannot decode image on Flutter side when using `buffer` directly // cannot decode image on Flutter side when using `buffer` directly
@ -184,10 +184,10 @@ class ImageByteStreamHandler(private val activity: Activity, private val argumen
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(ImageByteStreamHandler::class.java) private val LOG_TAG = LogUtils.createTag<ImageByteStreamHandler>()
const val CHANNEL = "deckers.thibault/aves/imagebytestream" const val CHANNEL = "deckers.thibault/aves/imagebytestream"
const val bufferSize = 2 shl 17 // 256kB const val BUFFER_SIZE = 2 shl 17 // 256kB
// request a fresh image with the highest quality format // request a fresh image with the highest quality format
val glideOptions = RequestOptions() val glideOptions = RequestOptions()

View file

@ -176,7 +176,7 @@ class ImageOpStreamHandler(private val context: Context, private val arguments:
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(ImageOpStreamHandler::class.java) private val LOG_TAG = LogUtils.createTag<ImageOpStreamHandler>()
const val CHANNEL = "deckers.thibault/aves/imageopstream" const val CHANNEL = "deckers.thibault/aves/imageopstream"
} }
} }

View file

@ -61,7 +61,7 @@ class MediaStoreStreamHandler(private val context: Context, arguments: Any?) : E
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(MediaStoreStreamHandler::class.java) private val LOG_TAG = LogUtils.createTag<MediaStoreStreamHandler>()
const val CHANNEL = "deckers.thibault/aves/mediastorestream" const val CHANNEL = "deckers.thibault/aves/mediastorestream"
} }
} }

View file

@ -75,7 +75,7 @@ class StorageAccessStreamHandler(private val activity: Activity, arguments: Any?
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(StorageAccessStreamHandler::class.java) private val LOG_TAG = LogUtils.createTag<StorageAccessStreamHandler>()
const val CHANNEL = "deckers.thibault/aves/storageaccessstream" const val CHANNEL = "deckers.thibault/aves/storageaccessstream"
} }
} }

View file

@ -17,7 +17,7 @@ import kotlin.math.floor
import kotlin.math.roundToLong import kotlin.math.roundToLong
object ExifInterfaceHelper { object ExifInterfaceHelper {
private val LOG_TAG = LogUtils.createTag(ExifInterfaceHelper::class.java) private val LOG_TAG = LogUtils.createTag<ExifInterfaceHelper>()
private val DATETIME_FORMAT = SimpleDateFormat("yyyy:MM:dd hh:mm:ss", Locale.ROOT) private val DATETIME_FORMAT = SimpleDateFormat("yyyy:MM:dd hh:mm:ss", Locale.ROOT)
private const val precisionErrorTolerance = 1e-10 private const val precisionErrorTolerance = 1e-10

View file

@ -13,7 +13,7 @@ import deckers.thibault.aves.utils.MimeTypes
import deckers.thibault.aves.utils.StorageUtils import deckers.thibault.aves.utils.StorageUtils
object MultiTrackMedia { object MultiTrackMedia {
private val LOG_TAG = LogUtils.createTag(MultiTrackMedia::class.java) private val LOG_TAG = LogUtils.createTag<MultiTrackMedia>()
@RequiresApi(Build.VERSION_CODES.P) @RequiresApi(Build.VERSION_CODES.P)
fun getImage(context: Context, uri: Uri, trackIndex: Int?): Bitmap? { fun getImage(context: Context, uri: Uri, trackIndex: Int?): Bitmap? {

View file

@ -82,7 +82,7 @@ class GSpherical(xmlBytes: ByteArray) {
).filterValues { it != null } ).filterValues { it != null }
companion object SphericalVideo { companion object SphericalVideo {
private val LOG_TAG = LogUtils.createTag(SphericalVideo::class.java) private val LOG_TAG = LogUtils.createTag<SphericalVideo>()
// cf https://github.com/google/spatial-media // cf https://github.com/google/spatial-media
const val SPHERICAL_VIDEO_V1_UUID = "ffcc8263-f855-4a93-8814-587a02521fdd" const val SPHERICAL_VIDEO_V1_UUID = "ffcc8263-f855-4a93-8814-587a02521fdd"

View file

@ -8,7 +8,7 @@ import deckers.thibault.aves.utils.LogUtils
import java.util.* import java.util.*
object XMP { object XMP {
private val LOG_TAG = LogUtils.createTag(XMP::class.java) private val LOG_TAG = LogUtils.createTag<XMP>()
// standard namespaces // standard namespaces
// cf com.adobe.internal.xmp.XMPConst // cf com.adobe.internal.xmp.XMPConst

View file

@ -349,6 +349,6 @@ abstract class ImageProvider {
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(ImageProvider::class.java) private val LOG_TAG = LogUtils.createTag<ImageProvider>()
} }
} }

View file

@ -335,7 +335,7 @@ class MediaStoreImageProvider : ImageProvider() {
} }
companion object { companion object {
private val LOG_TAG = LogUtils.createTag(MediaStoreImageProvider::class.java) private val LOG_TAG = LogUtils.createTag<MediaStoreImageProvider>()
private val IMAGE_CONTENT_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI private val IMAGE_CONTENT_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
private val VIDEO_CONTENT_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI private val VIDEO_CONTENT_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI

View file

@ -9,7 +9,7 @@ import deckers.thibault.aves.metadata.Metadata.getExifCode
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
object BitmapUtils { object BitmapUtils {
private val LOG_TAG = LogUtils.createTag(BitmapUtils::class.java) private val LOG_TAG = LogUtils.createTag<BitmapUtils>()
fun Bitmap.getBytes(canHaveAlpha: Boolean = false, quality: Int = 100, recycle: Boolean = true): ByteArray? { fun Bitmap.getBytes(canHaveAlpha: Boolean = false, quality: Int = 100, recycle: Boolean = true): ByteArray? {
try { try {

View file

@ -3,16 +3,17 @@ package deckers.thibault.aves.utils
import java.util.regex.Pattern import java.util.regex.Pattern
object LogUtils { object LogUtils {
private const val LOG_TAG_MAX_LENGTH = 23 const val LOG_TAG_MAX_LENGTH = 23
private val LOG_TAG_PACKAGE_PATTERN = Pattern.compile("(\\w)(\\w*)\\.") val LOG_TAG_PACKAGE_PATTERN: Pattern = Pattern.compile("(\\w)(\\w*)\\.")
// create an Android logger friendly log tag for the specified class // create an Android logger friendly log tag for the specified class
fun createTag(clazz: Class<*>): String { inline fun <reified T> createTag(): String {
val kClass = T::class
// shorten class name to "a.b.CccDdd" // shorten class name to "a.b.CccDdd"
var logTag = LOG_TAG_PACKAGE_PATTERN.matcher(clazz.name).replaceAll("$1.") var logTag = LOG_TAG_PACKAGE_PATTERN.matcher(kClass.qualifiedName!!).replaceAll("$1.")
if (logTag.length > LOG_TAG_MAX_LENGTH) { if (logTag.length > LOG_TAG_MAX_LENGTH) {
// shorten class name to "a.b.CD" // shorten class name to "a.b.CD"
val simpleName = clazz.simpleName val simpleName = kClass.simpleName!!
val shortSimpleName = simpleName.replace("[a-z]".toRegex(), "") val shortSimpleName = simpleName.replace("[a-z]".toRegex(), "")
logTag = logTag.replace(simpleName, shortSimpleName) logTag = logTag.replace(simpleName, shortSimpleName)
if (logTag.length > LOG_TAG_MAX_LENGTH) { if (logTag.length > LOG_TAG_MAX_LENGTH) {

View file

@ -16,7 +16,7 @@ import java.util.concurrent.ConcurrentHashMap
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
object PermissionManager { object PermissionManager {
private val LOG_TAG = LogUtils.createTag(PermissionManager::class.java) private val LOG_TAG = LogUtils.createTag<PermissionManager>()
const val VOLUME_ACCESS_REQUEST_CODE = 1 const val VOLUME_ACCESS_REQUEST_CODE = 1

View file

@ -23,7 +23,7 @@ import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
object StorageUtils { object StorageUtils {
private val LOG_TAG = LogUtils.createTag(StorageUtils::class.java) private val LOG_TAG = LogUtils.createTag<StorageUtils>()
/** /**
* Volume paths * Volume paths

View file

@ -5,7 +5,7 @@ import android.net.Uri
import android.util.Log import android.util.Log
object UriUtils { object UriUtils {
private val LOG_TAG = LogUtils.createTag(UriUtils::class.java) private val LOG_TAG = LogUtils.createTag<UriUtils>()
fun Uri.tryParseId(): Long? { fun Uri.tryParseId(): Long? {
try { try {