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"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.8.20" />
<option name="version" value="1.8.21" />
</component>
</project>

View File

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

View File

@ -31,8 +31,8 @@ android {
targetSdkVersion stTargetSdkVersion
minSdkVersion stMinSdkVersion
versionCode 531
versionName "5.531"
versionCode 532
versionName "5.532"
applicationId "jp.juggler.subwaytooter"
vectorDrawables.useSupportLibrary = true
@ -232,19 +232,14 @@ repositories {
def willApplyGoogleService() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Matcher matcher
String taskRequestsString = gradle.getStartParameter().getTaskRequests().toString()
matcher = Pattern.compile(
def isMatch = Pattern.compile(
"(assemble|generate|connected)Fcm",
).matcher(tskReqStr)
if (!matcher.find()) {
println "willApplyGoogleService=false. $tskReqStr"
return false
} else {
println "willApplyGoogleService=true. $tskReqStr"
return true
}
).matcher(taskRequestsString).find()
println "willApplyGoogleService=$isMatch. $taskRequestsString"
return isMatch
}
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.push.PushBase
import jp.juggler.subwaytooter.push.pushRepo
import jp.juggler.subwaytooter.util.emojiSizeMode
import jp.juggler.subwaytooter.table.SavedAccount
import jp.juggler.subwaytooter.table.daoAcctColor
import jp.juggler.subwaytooter.table.daoSavedAccount
@ -182,7 +181,7 @@ class ActAccountSetting : AppCompatActivity(),
uploadImage(
state.propName,
it.uri,
it.mimeType?.notEmpty() ?: contentResolver.getType(it.uri)
it.uri.resolveMimeType(it.mimeType, this),
)
}
}
@ -198,8 +197,11 @@ class ActAccountSetting : AppCompatActivity(),
// 画像のURL
val uri = r.data?.data ?: state.uriCameraImage
if (uri != null) {
val type = contentResolver.getType(uri)
uploadImage(state.propName, uri, type)
uploadImage(
state.propName,
uri,
uri.resolveMimeType(null, this),
)
}
}
}
@ -374,15 +376,19 @@ class ActAccountSetting : AppCompatActivity(),
}
}
)
is EditText ->
it.addTextChangedListener(watcher1)
is Spinner ->
it.onItemSelectedListener = this@ActAccountSetting
// CompoundButton はButtonでもあるので上に置く
is CompoundButton ->
it.setOnCheckedChangeListener(this@ActAccountSetting)
is ImageButton ->
it.setOnClickListener(this@ActAccountSetting)
is Button ->
it.setOnClickListener(this@ActAccountSetting)
}
@ -644,6 +650,7 @@ class ActAccountSetting : AppCompatActivity(),
views.cbLocked -> {
if (!profileBusy) sendLocked(isChecked)
}
views.swNotificationPullEnabled -> {
saveUIToData()
showPushSetting()
@ -689,9 +696,11 @@ class ActAccountSetting : AppCompatActivity(),
R.id.btnPushSubscription -> launchAndShowError {
updatePushSubscription(force = true)
}
R.id.btnPushSubscriptionNotForce -> launchAndShowError {
updatePushSubscription(force = false)
}
R.id.btnResetNotificationTracking ->
resetNotificationTracking(account)
@ -1558,6 +1567,7 @@ class ActAccountSetting : AppCompatActivity(),
showNotificationColor()
saveUIToData()
}
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)
}
section(R.string.translate_or_custom_share){
CustomShareTarget.values().forEach{ target->
section(R.string.translate_or_custom_share) {
CustomShareTarget.values().forEach { target ->
item(
SettingType.TextWithSelector,
target.pref,

View File

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

View File

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

View File

@ -22,9 +22,9 @@ buildscript {
ext.koinVersion = "3.3.3"
ext.kotlinJvmTarget = "1.8"
ext.kotlinJvmToolchain = 17
ext.kotlinVersion = "1.8.20"
ext.kotlinVersion = "1.8.21"
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.materialVersion = "1.9.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.";