kotlin 1.8.21, force convert heic,heif,avif

This commit is contained in:
tateisu 2023-05-15 10:03:30 +09:00
parent 3e83522143
commit 462041f8b0
10 changed files with 71 additions and 44 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="KotlinJpsPluginSettings"> <component name="KotlinJpsPluginSettings">
<option name="version" value="1.8.20" /> <option name="version" value="1.8.21" />
</component> </component>
</project> </project>

View File

@ -78,7 +78,7 @@ class ApngFrames private constructor(
) )
val wDstInt = max(1, round(wDst).toInt()) val wDstInt = max(1, round(wDst).toInt())
val hDstInt = max(1, round(hDst).toInt()) val hDstInt = max(1, round(hDst).toInt())
if (wSrc <= wDstInt && hSrc <= hDstInt ) { if (wSrc <= wDstInt && hSrc <= hDstInt) {
return when { return when {
recycleSrc -> src recycleSrc -> src
else -> src.copy(Bitmap.Config.ARGB_8888, false) else -> src.copy(Bitmap.Config.ARGB_8888, false)

View File

@ -31,8 +31,8 @@ android {
targetSdkVersion stTargetSdkVersion targetSdkVersion stTargetSdkVersion
minSdkVersion stMinSdkVersion minSdkVersion stMinSdkVersion
versionCode 531 versionCode 532
versionName "5.531" versionName "5.532"
applicationId "jp.juggler.subwaytooter" applicationId "jp.juggler.subwaytooter"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -232,19 +232,14 @@ repositories {
def willApplyGoogleService() { def willApplyGoogleService() {
Gradle gradle = getGradle() Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() String taskRequestsString = gradle.getStartParameter().getTaskRequests().toString()
Matcher matcher
matcher = Pattern.compile( def isMatch = Pattern.compile(
"(assemble|generate|connected)Fcm", "(assemble|generate|connected)Fcm",
).matcher(tskReqStr) ).matcher(taskRequestsString).find()
if (!matcher.find()) {
println "willApplyGoogleService=false. $tskReqStr" println "willApplyGoogleService=$isMatch. $taskRequestsString"
return false return isMatch
} else {
println "willApplyGoogleService=true. $tskReqStr"
return true
}
} }
if (willApplyGoogleService()) apply plugin: "com.google.gms.google-services" if (willApplyGoogleService()) apply plugin: "com.google.gms.google-services"

View File

@ -31,7 +31,6 @@ import jp.juggler.subwaytooter.dialog.actionsDialog
import jp.juggler.subwaytooter.notification.* import jp.juggler.subwaytooter.notification.*
import jp.juggler.subwaytooter.push.PushBase import jp.juggler.subwaytooter.push.PushBase
import jp.juggler.subwaytooter.push.pushRepo import jp.juggler.subwaytooter.push.pushRepo
import jp.juggler.subwaytooter.util.emojiSizeMode
import jp.juggler.subwaytooter.table.SavedAccount import jp.juggler.subwaytooter.table.SavedAccount
import jp.juggler.subwaytooter.table.daoAcctColor import jp.juggler.subwaytooter.table.daoAcctColor
import jp.juggler.subwaytooter.table.daoSavedAccount import jp.juggler.subwaytooter.table.daoSavedAccount
@ -182,7 +181,7 @@ class ActAccountSetting : AppCompatActivity(),
uploadImage( uploadImage(
state.propName, state.propName,
it.uri, it.uri,
it.mimeType?.notEmpty() ?: contentResolver.getType(it.uri) it.uri.resolveMimeType(it.mimeType, this),
) )
} }
} }
@ -198,8 +197,11 @@ class ActAccountSetting : AppCompatActivity(),
// 画像のURL // 画像のURL
val uri = r.data?.data ?: state.uriCameraImage val uri = r.data?.data ?: state.uriCameraImage
if (uri != null) { if (uri != null) {
val type = contentResolver.getType(uri) uploadImage(
uploadImage(state.propName, uri, type) state.propName,
uri,
uri.resolveMimeType(null, this),
)
} }
} }
} }
@ -374,15 +376,19 @@ class ActAccountSetting : AppCompatActivity(),
} }
} }
) )
is EditText -> is EditText ->
it.addTextChangedListener(watcher1) it.addTextChangedListener(watcher1)
is Spinner -> is Spinner ->
it.onItemSelectedListener = this@ActAccountSetting it.onItemSelectedListener = this@ActAccountSetting
// CompoundButton はButtonでもあるので上に置く // CompoundButton はButtonでもあるので上に置く
is CompoundButton -> is CompoundButton ->
it.setOnCheckedChangeListener(this@ActAccountSetting) it.setOnCheckedChangeListener(this@ActAccountSetting)
is ImageButton -> is ImageButton ->
it.setOnClickListener(this@ActAccountSetting) it.setOnClickListener(this@ActAccountSetting)
is Button -> is Button ->
it.setOnClickListener(this@ActAccountSetting) it.setOnClickListener(this@ActAccountSetting)
} }
@ -644,6 +650,7 @@ class ActAccountSetting : AppCompatActivity(),
views.cbLocked -> { views.cbLocked -> {
if (!profileBusy) sendLocked(isChecked) if (!profileBusy) sendLocked(isChecked)
} }
views.swNotificationPullEnabled -> { views.swNotificationPullEnabled -> {
saveUIToData() saveUIToData()
showPushSetting() showPushSetting()
@ -689,9 +696,11 @@ class ActAccountSetting : AppCompatActivity(),
R.id.btnPushSubscription -> launchAndShowError { R.id.btnPushSubscription -> launchAndShowError {
updatePushSubscription(force = true) updatePushSubscription(force = true)
} }
R.id.btnPushSubscriptionNotForce -> launchAndShowError { R.id.btnPushSubscriptionNotForce -> launchAndShowError {
updatePushSubscription(force = false) updatePushSubscription(force = false)
} }
R.id.btnResetNotificationTracking -> R.id.btnResetNotificationTracking ->
resetNotificationTracking(account) resetNotificationTracking(account)
@ -1558,6 +1567,7 @@ class ActAccountSetting : AppCompatActivity(),
showNotificationColor() showNotificationColor()
saveUIToData() saveUIToData()
} }
else -> Unit else -> Unit
} }
} }

View File

@ -375,8 +375,8 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
sw(PrefB.bpEnableDomainTimeline, R.string.enable_domain_timeline) sw(PrefB.bpEnableDomainTimeline, R.string.enable_domain_timeline)
} }
section(R.string.translate_or_custom_share){ section(R.string.translate_or_custom_share) {
CustomShareTarget.values().forEach{ target-> CustomShareTarget.values().forEach { target ->
item( item(
SettingType.TextWithSelector, SettingType.TextWithSelector,
target.pref, target.pref,

View File

@ -61,7 +61,7 @@ fun ItemViewHolder.bind(
when (v) { when (v) {
// ボタンは太字なので触らない // ボタンは太字なので触らない
is Button, is CountImageButton -> is Button, is CountImageButton ->
if(v is Button && tvMediaDescriptions.contains(v)){ if (v is Button && tvMediaDescriptions.contains(v)) {
v.typeface = fontNormal v.typeface = fontNormal
} }

View File

@ -74,13 +74,14 @@ object CustomShare {
val pm = context.packageManager val pm = context.packageManager
var queryIntent = Intent().apply { component = cn } var queryIntent = Intent().apply { component = cn }
var ri = pm.resolveActivityCompat(queryIntent, PackageManager.MATCH_ALL) var ri = pm.resolveActivityCompat(queryIntent, PackageManager.MATCH_ALL)
if( ri ==null){ if (ri == null) {
queryIntent = Intent().apply { queryIntent = Intent().apply {
action = Intent.ACTION_SEND action = Intent.ACTION_SEND
type = "text/plain" type = "text/plain"
putExtra(Intent.EXTRA_TEXT, context.getString(R.string.content_sample)) putExtra(Intent.EXTRA_TEXT, context.getString(R.string.content_sample))
} }
val listResolveInfo = pm.queryIntentActivitiesCompat(queryIntent, PackageManager.MATCH_ALL) val listResolveInfo =
pm.queryIntentActivitiesCompat(queryIntent, PackageManager.MATCH_ALL)
ri = listResolveInfo.find { ri = listResolveInfo.find {
"${it.activityInfo.packageName}/${it.activityInfo.name}" == cnStr "${it.activityInfo.packageName}/${it.activityInfo.name}" == cnStr
} }

View File

@ -20,14 +20,11 @@ const val MIME_TYPE_GIF = "image/gif"
const val MIME_TYPE_WEBP = "image/webp" const val MIME_TYPE_WEBP = "image/webp"
private val acceptableMimeTypes = HashSet<String>().apply { private val acceptableMimeTypes = HashSet<String>().apply {
//
add("image/*") // Android標準のギャラリーが image/* を出してくることがあるらしい
add("video/*") // Android標準のギャラリーが image/* を出してくることがあるらしい
add("audio/*") // Android標準のギャラリーが image/* を出してくることがあるらしい
// //
add("image/jpeg") add("image/jpeg")
add("image/png") add("image/png")
add("image/gif") add("image/gif")
//
add("video/webm") add("video/webm")
add("video/mp4") add("video/mp4")
add("video/quicktime") add("video/quicktime")
@ -50,13 +47,11 @@ private val acceptableMimeTypes = HashSet<String>().apply {
} }
private val acceptableMimeTypesPixelfed = HashSet<String>().apply { private val acceptableMimeTypesPixelfed = HashSet<String>().apply {
//
add("image/*") // Android標準のギャラリーが image/* を出してくることがあるらしい
add("video/*") // Android標準のギャラリーが image/* を出してくることがあるらしい
// //
add("image/jpeg") add("image/jpeg")
add("image/png") add("image/png")
add("image/gif") add("image/gif")
//
add("video/mp4") add("video/mp4")
add("video/m4v") add("video/m4v")
} }
@ -120,7 +115,7 @@ private val sigM4a = arrayOf(
"M4P " "M4P "
).map { it.toCharArray().toLowerByteArray() } ).map { it.toCharArray().toLowerByteArray() }
private const val wild = '?'.code.toByte() private const val BYTE_QUESTION = '?'.code.toByte()
private val sigFtyp = "ftyp".toCharArray().toLowerByteArray() private val sigFtyp = "ftyp".toCharArray().toLowerByteArray()
@ -148,7 +143,7 @@ private fun ByteArray.startWithWildcard(
for (i in 0 until length) { for (i in 0 until length) {
val cThis = this[i + thisOffset] val cThis = this[i + thisOffset]
val cKey = key[i + keyOffset] val cKey = key[i + keyOffset]
if (cKey != wild && cKey != cThis) return false if (cKey != BYTE_QUESTION && cKey != cThis) return false
} }
return true return true
} }
@ -267,7 +262,7 @@ fun String.mimeTypeIsSupported(instance: TootInstance) = when {
}.contains(this) }.contains(this)
} }
fun Uri.resolveMimeType(mimeTypeArg1: String?, context: Context): String? { fun Uri.resolveMimeType(mimeTypeArg: String?, context: Context): String? {
// BitmapFactory で静止画の mimeType を調べる // BitmapFactory で静止画の mimeType を調べる
// image/j()pg だの image/j(e)pg だの、mime type を誤記するアプリがあまりに多い // image/j()pg だの image/j(e)pg だの、mime type を誤記するアプリがあまりに多い
// application/octet-stream などが誤設定されてることもある // application/octet-stream などが誤設定されてることもある
@ -286,8 +281,7 @@ fun Uri.resolveMimeType(mimeTypeArg1: String?, context: Context): String? {
// ContentResolverに尋ねる // ContentResolverに尋ねる
try { try {
context.contentResolver.getType(this) context.contentResolver.getType(this)
?.notEmpty() ?.notEmpty()?.let { return it }
?.let { return it }
} catch (ex: Throwable) { } catch (ex: Throwable) {
log.w(ex, "contentResolver.getType failed.") log.w(ex, "contentResolver.getType failed.")
} }
@ -295,17 +289,14 @@ fun Uri.resolveMimeType(mimeTypeArg1: String?, context: Context): String? {
// gboardのステッカーではUriのクエリパラメータにmimeType引数がある // gboardのステッカーではUriのクエリパラメータにmimeType引数がある
try { try {
getQueryParameter("mimeType") getQueryParameter("mimeType")
?.notEmpty() ?.notEmpty()?.let { return it }
?.let { return it }
} catch (ex: Throwable) { } catch (ex: Throwable) {
log.w(ex, "getQueryParameter(mimeType) failed.") log.w(ex, "getQueryParameter(mimeType) failed.")
} }
// 引数のmimeTypeがサーバでサポートされているならソレ // 引数のmimeType
try { try {
mimeTypeArg1 mimeTypeArg?.notEmpty()?.let { return it }
?.notEmpty()
?.let { return it }
} catch (ex: Throwable) { } catch (ex: Throwable) {
log.w(ex, "mimeTypeArg1 check failed.") log.w(ex, "mimeTypeArg1 check failed.")
} }

View File

@ -22,9 +22,9 @@ buildscript {
ext.koinVersion = "3.3.3" ext.koinVersion = "3.3.3"
ext.kotlinJvmTarget = "1.8" ext.kotlinJvmTarget = "1.8"
ext.kotlinJvmToolchain = 17 ext.kotlinJvmToolchain = 17
ext.kotlinVersion = "1.8.20" ext.kotlinVersion = "1.8.21"
ext.kotlinxCoroutinesVersion = "1.6.4" ext.kotlinxCoroutinesVersion = "1.6.4"
ext.kspVersion = "1.8.20-1.0.11" ext.kspVersion = "1.8.21-1.0.11"
ext.lifecycleVersion = "2.6.1" ext.lifecycleVersion = "2.6.1"
ext.materialVersion = "1.9.0" ext.materialVersion = "1.9.0"
ext.okhttpVersion = "4.10.0" ext.okhttpVersion = "4.10.0"

30
detektFiles.pl Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/perl --
use 5.32.0;
use strict;
use warnings;
my $inFile = "app/build/reports/detekt/st-detektAll.txt";
my $rv = system qq(./gradlew :app:detektAll);
$rv and die "gradle failed.";
my @lines;
open(my $fh, "<:encoding(UTF-8)",$inFile) or die "$! $inFile";
while(<$fh>){
s/[\x0d\x0a]+//;
next if not length;
# TopLevelPropertyNaming - [wild] at Z:\mastodon-related\SubwayTooter\app\src\main\java\jp\juggler\subwaytooter\util\MimeTypeUtils.kt:118:19 - Signature=MimeTypeUtils.kt$private const val wild = '?'.code.toByte()
if(not /\A(.+) at (\S+?:\d+:\d+) - (.+)/){
say "?? $_";
next;
}
my($name,$pos,$other)=($1,$2,$3);
$pos =~ s|\A.+\\SubwayTooter\\||;
$pos =~ s|\\|/|g;
push @lines, "$pos $name $other";
}
say $_ for sort @lines;
@lines or say "no problems found.";