diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 2a5f53fe..8df9c806 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/apng_android/src/main/java/jp/juggler/apng/ApngFrames.kt b/apng_android/src/main/java/jp/juggler/apng/ApngFrames.kt index b8874b5d..5996d18e 100644 --- a/apng_android/src/main/java/jp/juggler/apng/ApngFrames.kt +++ b/apng_android/src/main/java/jp/juggler/apng/ApngFrames.kt @@ -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) diff --git a/app/build.gradle b/app/build.gradle index 3b20123d..d4242c3e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt b/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt index cac74526..b81e013f 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActAccountSetting.kt @@ -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 } } diff --git a/app/src/main/java/jp/juggler/subwaytooter/appsetting/AppSettingItem.kt b/app/src/main/java/jp/juggler/subwaytooter/appsetting/AppSettingItem.kt index aa37d02c..77e771bb 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/appsetting/AppSettingItem.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/appsetting/AppSettingItem.kt @@ -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, diff --git a/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/ItemViewHolderShow.kt b/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/ItemViewHolderShow.kt index af1eafc4..430a8a07 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/ItemViewHolderShow.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/ItemViewHolderShow.kt @@ -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 } diff --git a/app/src/main/java/jp/juggler/subwaytooter/util/CustomShare.kt b/app/src/main/java/jp/juggler/subwaytooter/util/CustomShare.kt index f4aa0ec0..42ee53b3 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/util/CustomShare.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/util/CustomShare.kt @@ -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 } diff --git a/app/src/main/java/jp/juggler/subwaytooter/util/MimeTypeUtils.kt b/app/src/main/java/jp/juggler/subwaytooter/util/MimeTypeUtils.kt index 3ea50a34..15aac1b9 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/util/MimeTypeUtils.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/util/MimeTypeUtils.kt @@ -20,14 +20,11 @@ const val MIME_TYPE_GIF = "image/gif" const val MIME_TYPE_WEBP = "image/webp" private val acceptableMimeTypes = HashSet().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().apply { } private val acceptableMimeTypesPixelfed = HashSet().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.") } diff --git a/build.gradle b/build.gradle index 5e282193..be084d95 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/detektFiles.pl b/detektFiles.pl new file mode 100644 index 00000000..1084fa6a --- /dev/null +++ b/detektFiles.pl @@ -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.";