Misskeyで音声アップロード完了後に表示が変わらない問題の修正
This commit is contained in:
parent
ccd16c52e6
commit
4f43dba3c4
|
@ -40,7 +40,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -311,12 +311,17 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
}
|
||||
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_IMAGE -> loadBitmap(ta)
|
||||
TootAttachmentLike.TYPE_VIDEO,
|
||||
TootAttachmentLike.TYPE_GIFV,
|
||||
TootAttachmentLike.TYPE_AUDIO -> loadVideo(ta, state)
|
||||
// maybe TYPE_UNKNOWN
|
||||
else -> showError(getString(R.string.media_attachment_type_error, ta.type))
|
||||
|
||||
TootAttachmentType.Unknown ->
|
||||
showError(getString(R.string.media_attachment_type_error, ta.type.id))
|
||||
|
||||
TootAttachmentType.Image ->
|
||||
loadBitmap(ta)
|
||||
|
||||
TootAttachmentType.Video,
|
||||
TootAttachmentType.GIFV,
|
||||
TootAttachmentType.Audio ->
|
||||
loadVideo(ta, state)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -358,7 +363,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
|||
|
||||
exoPlayer.prepare(mediaSource)
|
||||
exoPlayer.repeatMode = when(ta.type) {
|
||||
TootAttachmentLike.TYPE_VIDEO -> Player.REPEAT_MODE_OFF
|
||||
TootAttachmentType.Video -> Player.REPEAT_MODE_OFF
|
||||
// GIFV or AUDIO
|
||||
else -> Player.REPEAT_MODE_ALL
|
||||
}
|
||||
|
|
|
@ -1456,21 +1456,20 @@ class ActPost : AppCompatActivity(),
|
|||
|
||||
a == null || pa.status != PostAttachment.STATUS_UPLOADED -> {
|
||||
iv.setDefaultImage(defaultColorIcon(this, R.drawable.ic_upload))
|
||||
iv.setErrorImage(defaultColorIcon(this, R.drawable.ic_unknown))
|
||||
iv.setErrorImage(defaultColorIcon(this, R.drawable.ic_clip))
|
||||
iv.setImageUrl(pref, Styler.calcIconRound(iv.layoutParams.width), null)
|
||||
}
|
||||
|
||||
else -> {
|
||||
iv.setDefaultImage(defaultColorIcon(this, R.drawable.ic_upload))
|
||||
iv.setErrorImage(
|
||||
defaultColorIcon(
|
||||
this,
|
||||
when {
|
||||
a.isAudio -> R.drawable.ic_music_note
|
||||
else -> R.drawable.ic_unknown
|
||||
}
|
||||
)
|
||||
)
|
||||
else ->{
|
||||
val defaultIconId = when(a.type) {
|
||||
TootAttachmentType.Image -> R.drawable.ic_image
|
||||
TootAttachmentType.Video,
|
||||
TootAttachmentType.GIFV ->R.drawable.ic_videocam
|
||||
TootAttachmentType.Audio ->R.drawable.ic_music_note
|
||||
else -> R.drawable.ic_clip
|
||||
}
|
||||
iv.setDefaultImage(defaultColorIcon(this,defaultIconId))
|
||||
iv.setErrorImage(defaultColorIcon(this,defaultIconId))
|
||||
iv.setImageUrl(pref, Styler.calcIconRound(iv.layoutParams.width), a.preview_url)
|
||||
}
|
||||
}
|
||||
|
@ -1485,25 +1484,25 @@ class ActPost : AppCompatActivity(),
|
|||
showToast(this, false, ex.withCaption("can't get attachment item[$idx]."))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
val a = ActionsDialog()
|
||||
.addAction( getString(R.string.set_description) ){
|
||||
.addAction(getString(R.string.set_description)) {
|
||||
editAttachmentDescription(pa)
|
||||
}
|
||||
|
||||
if( pa.attachment?.isAudio == true ){
|
||||
|
||||
if(pa.attachment?.isAudio == true) {
|
||||
// can't set focus
|
||||
}else{
|
||||
a.addAction(getString(R.string.set_focus_point)){
|
||||
} else {
|
||||
a.addAction(getString(R.string.set_focus_point)) {
|
||||
openFocusPoint(pa)
|
||||
}
|
||||
}
|
||||
|
||||
a.addAction(getString(R.string.delete)){
|
||||
|
||||
a.addAction(getString(R.string.delete)) {
|
||||
deleteAttachment(pa)
|
||||
}
|
||||
|
||||
a.show(this,title = getString(R.string.media_attachment))
|
||||
|
||||
a.show(this, title = getString(R.string.media_attachment))
|
||||
}
|
||||
|
||||
private fun openFocusPoint(pa : PostAttachment) {
|
||||
|
|
|
@ -1632,14 +1632,14 @@ internal class ItemViewHolder(
|
|||
val showUrl : Boolean
|
||||
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_AUDIO -> {
|
||||
TootAttachmentType.Audio -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_music))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
showUrl = true
|
||||
}
|
||||
|
||||
TootAttachmentLike.TYPE_UNKNOWN -> {
|
||||
TootAttachmentType.Unknown -> {
|
||||
iv.setMediaType(0)
|
||||
iv.setDefaultImage(defaultColorIcon(activity, R.drawable.wide_question))
|
||||
iv.setImageUrl(activity.pref, 0f, null)
|
||||
|
@ -1657,8 +1657,8 @@ internal class ItemViewHolder(
|
|||
else -> {
|
||||
iv.setMediaType(
|
||||
when(ta.type) {
|
||||
TootAttachmentLike.TYPE_VIDEO -> R.drawable.media_type_video
|
||||
TootAttachmentLike.TYPE_GIFV -> R.drawable.media_type_gifv
|
||||
TootAttachmentType.Video -> R.drawable.media_type_video
|
||||
TootAttachmentType.GIFV -> R.drawable.media_type_gifv
|
||||
else -> 0
|
||||
}
|
||||
)
|
||||
|
@ -2098,7 +2098,7 @@ internal class ItemViewHolder(
|
|||
is TootAttachment -> when {
|
||||
|
||||
// unknownが1枚だけなら内蔵ビューアを使わずにインテントを投げる
|
||||
item.type == TootAttachmentLike.TYPE_UNKNOWN && media_attachments.size == 1 ->
|
||||
item.type == TootAttachmentType.Unknown && media_attachments.size == 1 ->
|
||||
App1.openCustomTab(activity, item)
|
||||
|
||||
// 内蔵メディアビューアを使う
|
||||
|
|
|
@ -36,13 +36,13 @@ class TootAttachment : TootAttachmentLike {
|
|||
|
||||
fun decodeJson(src : JSONObject) = TootAttachment(src, decode = true)
|
||||
|
||||
private val ext_audio = arrayOf(".mpga",".mp3",".aac",".ogg")
|
||||
private val ext_audio = arrayOf(".mpga", ".mp3", ".aac", ".ogg")
|
||||
|
||||
private fun guessMediaTypeByUrl(src : String?) : String? {
|
||||
private fun guessMediaTypeByUrl(src : String?) : TootAttachmentType? {
|
||||
val uri = src.mayUri() ?: return null
|
||||
|
||||
if( ext_audio.find { uri.path?.endsWith(it) == true } != null ){
|
||||
return TootAttachmentLike.TYPE_AUDIO
|
||||
if(ext_audio.find { uri.path?.endsWith(it) == true } != null) {
|
||||
return TootAttachmentType.Audio
|
||||
}
|
||||
|
||||
return null
|
||||
|
@ -56,7 +56,7 @@ class TootAttachment : TootAttachmentLike {
|
|||
val id : EntityId
|
||||
|
||||
//One of: "image", "video", "gifv". or may null ? may "unknown" ?
|
||||
override val type : String?
|
||||
override val type : TootAttachmentType
|
||||
|
||||
//URL of the locally hosted version of the image
|
||||
val url : String?
|
||||
|
@ -65,6 +65,8 @@ class TootAttachment : TootAttachmentLike {
|
|||
val remote_url : String?
|
||||
|
||||
// URL of the preview image
|
||||
// (Mastodon 2.9.2) audioのpreview_url は .mpga のURL
|
||||
// (Misskey v11) audioのpreview_url は null
|
||||
val preview_url : String?
|
||||
|
||||
// Shorter URL for the image, for insertion into text (only present on local images)
|
||||
|
@ -92,10 +94,10 @@ class TootAttachment : TootAttachmentLike {
|
|||
else -> false
|
||||
}
|
||||
|
||||
override fun getUrlString() :String? =
|
||||
if( remote_url?.isNotEmpty()==true){
|
||||
override fun getUrlString() : String? =
|
||||
if(remote_url?.isNotEmpty() == true) {
|
||||
remote_url
|
||||
}else{
|
||||
} else {
|
||||
url
|
||||
}
|
||||
|
||||
|
@ -106,12 +108,12 @@ class TootAttachment : TootAttachmentLike {
|
|||
id = EntityId.mayDefault(src.parseString("id"))
|
||||
|
||||
val mimeType = src.parseString("type") ?: "?"
|
||||
|
||||
|
||||
this.type = when {
|
||||
mimeType.startsWith("image/") -> TootAttachmentLike.TYPE_IMAGE
|
||||
mimeType.startsWith("video/") -> TootAttachmentLike.TYPE_VIDEO
|
||||
mimeType.startsWith("audio/") -> TootAttachmentLike.TYPE_AUDIO
|
||||
else -> TootAttachmentLike.TYPE_UNKNOWN
|
||||
mimeType.startsWith("image/") -> TootAttachmentType.Image
|
||||
mimeType.startsWith("video/") -> TootAttachmentType.Video
|
||||
mimeType.startsWith("audio/") -> TootAttachmentType.Audio
|
||||
else -> TootAttachmentType.Unknown
|
||||
}
|
||||
|
||||
url = src.parseString("url")
|
||||
|
@ -142,11 +144,13 @@ class TootAttachment : TootAttachmentLike {
|
|||
description = src.parseString("description")
|
||||
isSensitive = false // Misskey用のパラメータなので、マストドンでは適当な値を使ってOK
|
||||
|
||||
var t = src.parseString("type")
|
||||
if( t ==null || t == TootAttachmentLike.TYPE_UNKNOWN ){
|
||||
t = guessMediaTypeByUrl( remote_url ?: url)
|
||||
type = when(val tmpType = parseType(src.parseString("type"))) {
|
||||
null, TootAttachmentType.Unknown -> {
|
||||
guessMediaTypeByUrl(remote_url ?: url) ?: TootAttachmentType.Unknown
|
||||
}
|
||||
|
||||
else -> tmpType
|
||||
}
|
||||
type = t ?: TootAttachmentLike.TYPE_UNKNOWN
|
||||
|
||||
val focus = src.optJSONObject("meta")?.optJSONObject("focus")
|
||||
focusX = parseFocusValue(focus, "x")
|
||||
|
@ -159,6 +163,8 @@ class TootAttachment : TootAttachmentLike {
|
|||
|
||||
}
|
||||
|
||||
private fun parseType(src : String?) =
|
||||
TootAttachmentType.values().find { it.id == src }
|
||||
|
||||
override val urlForThumbnail : String?
|
||||
get() = when {
|
||||
|
@ -191,7 +197,7 @@ class TootAttachment : TootAttachmentLike {
|
|||
fun encodeJson() = jsonObject {
|
||||
put(KEY_IS_STRING_ID, true)
|
||||
put(KEY_ID, id.toString())
|
||||
put(KEY_TYPE, type)
|
||||
put(KEY_TYPE, type.id)
|
||||
put(KEY_URL, url)
|
||||
put(KEY_REMOTE_URL, remote_url)
|
||||
put(KEY_PREVIEW_URL, preview_url)
|
||||
|
@ -217,12 +223,19 @@ class TootAttachment : TootAttachmentLike {
|
|||
) {
|
||||
|
||||
id = EntityId.mayDefault(src.parseString(KEY_ID))
|
||||
|
||||
type = src.parseString(KEY_TYPE)
|
||||
url = src.parseString(KEY_URL)
|
||||
remote_url = src.parseString(KEY_REMOTE_URL)
|
||||
preview_url = src.parseString(KEY_PREVIEW_URL)
|
||||
text_url = src.parseString(KEY_TEXT_URL)
|
||||
|
||||
type = when(val tmpType = parseType(src.parseString(KEY_TYPE))) {
|
||||
null, TootAttachmentType.Unknown -> {
|
||||
guessMediaTypeByUrl(remote_url ?: url) ?: TootAttachmentType.Unknown
|
||||
}
|
||||
|
||||
else -> tmpType
|
||||
}
|
||||
|
||||
description = src.parseString(KEY_DESCRIPTION)
|
||||
isSensitive = src.optBoolean(KEY_IS_SENSITIVE)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package jp.juggler.subwaytooter.api.entity
|
||||
|
||||
interface TootAttachmentLike{
|
||||
|
||||
companion object {
|
||||
const val TYPE_IMAGE = "image"
|
||||
const val TYPE_VIDEO = "video"
|
||||
const val TYPE_GIFV = "gifv"
|
||||
const val TYPE_UNKNOWN = "unknown"
|
||||
const val TYPE_AUDIO = "audio"
|
||||
}
|
||||
enum class TootAttachmentType(val id:String){
|
||||
Unknown("unknown"),
|
||||
Image( "image"),
|
||||
Video("video"),
|
||||
GIFV("gifv"),
|
||||
Audio("audio")
|
||||
}
|
||||
|
||||
val type : String?
|
||||
interface TootAttachmentLike{
|
||||
|
||||
val type : TootAttachmentType
|
||||
val description : String?
|
||||
val urlForThumbnail : String?
|
||||
|
||||
|
@ -23,6 +23,11 @@ interface TootAttachmentLike{
|
|||
|
||||
|
||||
val isAudio : Boolean
|
||||
get()= type == TYPE_AUDIO
|
||||
get()= type == TootAttachmentType.Audio
|
||||
|
||||
// GIFVの考慮漏れに注意?
|
||||
val isVideo : Boolean
|
||||
get()= type == TootAttachmentType.Video
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ class TootAttachmentMSP(
|
|||
) : TootAttachmentLike {
|
||||
|
||||
|
||||
override val type : String?
|
||||
get() = null
|
||||
override val type : TootAttachmentType
|
||||
get() = TootAttachmentType.Unknown
|
||||
|
||||
override val description : String?
|
||||
get() = null
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M2,12.5C2,9.46 4.46,7 7.5,7H18c2.21,0 4,1.79 4,4s-1.79,4 -4,4H9.5C8.12,15 7,13.88 7,12.5S8.12,10 9.5,10H17v2H9.41c-0.55,0 -0.55,1 0,1H18c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2H7.5C5.57,9 4,10.57 4,12.5S5.57,16 7.5,16H17v2H7.5C4.46,18 2,15.54 2,12.5z"/>
|
||||
</vector>
|
|
@ -5,5 +5,5 @@
|
|||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19L5,19L5,5h14v14z"/>
|
||||
android:pathData="M17,10.5V7c0,-0.55 -0.45,-1 -1,-1H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4z"/>
|
||||
</vector>
|
|
@ -517,7 +517,7 @@
|
|||
android:layout_height="48dp"
|
||||
android:background="@drawable/btn_bg_transparent"
|
||||
android:contentDescription="@string/media_attachment"
|
||||
android:src="@drawable/ic_attachment"
|
||||
android:src="@drawable/ic_clip"
|
||||
android:tint="?attr/colorVectorDrawable"
|
||||
/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue