ボタン画像のデータを24dpに変更。デフォルト表示サイズを24dpに変更。添付メディアの種別がunknwonとaudioの際のサムネイル表示を改善。

This commit is contained in:
tateisu 2019-01-16 21:33:07 +09:00
parent 563e25d17f
commit 240da00dc9
691 changed files with 1044 additions and 804 deletions

View File

@ -47,6 +47,7 @@
<w>kotlinx</w> <w>kotlinx</w>
<w>mailto</w> <w>mailto</w>
<w>mimumedon</w> <w>mimumedon</w>
<w>mpga</w>
<w>navi</w> <w>navi</w>
<w>nicodic</w> <w>nicodic</w>
<w>nicoru</w> <w>nicoru</w>

View File

@ -25,6 +25,7 @@ import android.text.SpannableString
import android.text.TextWatcher import android.text.TextWatcher
import android.view.View import android.view.View
import android.widget.* import android.widget.*
import jp.juggler.subwaytooter.Styler.defaultColorIcon
import jp.juggler.subwaytooter.api.* import jp.juggler.subwaytooter.api.*
import jp.juggler.subwaytooter.api.entity.* import jp.juggler.subwaytooter.api.entity.*
import jp.juggler.subwaytooter.dialog.ActionsDialog import jp.juggler.subwaytooter.dialog.ActionsDialog
@ -725,9 +726,9 @@ class ActAccountSetting
private fun initializeProfile() { private fun initializeProfile() {
// 初期状態 // 初期状態
val question_id = getAttributeResourceId(this, R.attr.ic_question) val question_id = R.drawable.wide_question
ivProfileAvatar.setErrorImageResId(question_id) ivProfileAvatar.setErrorImage( defaultColorIcon(this,question_id))
ivProfileAvatar.setDefaultImageResId(question_id) ivProfileAvatar.setDefaultImage( defaultColorIcon(this,question_id))
val loadingText = when(account.isPseudo) { val loadingText = when(account.isPseudo) {
true -> "(disabled for pseudo account)" true -> "(disabled for pseudo account)"

View File

@ -679,10 +679,10 @@ class ActAppSettingChild : AppCompatActivity()
) )
tvColumnName !!.textColor = header_fg tvColumnName !!.textColor = header_fg
setIconAttr( setIconDrawableId(
this, this,
ivColumnHeader !!, ivColumnHeader !!,
R.attr.btn_federate_tl, R.drawable.ic_bike,
color = header_fg color = header_fg
) )
} }
@ -1092,13 +1092,9 @@ class ActAppSettingChild : AppCompatActivity()
} }
c = footer_button_fg_color c = footer_button_fg_color
if(c == 0) { if(c == 0) c= getAttributeColor(this,R.attr.colorVectorDrawable)
setIconAttr(this, ivFooterToot !!, R.attr.ic_edit) setIconDrawableId(this, ivFooterToot !!, R.drawable.ic_edit, color = c)
setIconAttr(this, ivFooterMenu !!, R.attr.ic_hamburger) setIconDrawableId(this, ivFooterMenu !!, R.drawable.ic_hamburger, color = c)
} else {
setIconAttr(this, ivFooterToot !!, R.attr.ic_edit, color = c)
setIconAttr(this, ivFooterMenu !!, R.attr.ic_hamburger, color = c)
}
c = footer_tab_bg_color c = footer_tab_bg_color
if(c == 0) { if(c == 0) {

View File

@ -392,10 +392,10 @@ class ActColumnCustomize : AppCompatActivity(), View.OnClickListener, ColorPicke
val c = column.getHeaderNameColor() val c = column.getHeaderNameColor()
tvColumnName.textColor = c tvColumnName.textColor = c
setIconAttr( setIconDrawableId(
this, this,
ivColumnHeader, ivColumnHeader,
column.getIconAttrId(column.column_type), column.getIconId(column.column_type),
color = c color = c
) )

View File

@ -3,7 +3,9 @@ package jp.juggler.subwaytooter
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.view.View import android.view.View
@ -265,10 +267,11 @@ class ActColumnList : AppCompatActivity() {
tvAccess.setBackgroundColor(item.acct_color_bg) tvAccess.setBackgroundColor(item.acct_color_bg)
tvAccess.setPaddingRelative(acct_pad_lr, 0, acct_pad_lr, 0) tvAccess.setPaddingRelative(acct_pad_lr, 0, acct_pad_lr, 0)
tvName.text = item.name tvName.text = item.name
ivColumnIcon.setImageResource( ivColumnIcon.setImageDrawable(
getAttributeResourceId( ContextCompat.getDrawable(this@ActColumnList,Column.getIconId(item.acct, item.type))?.also{
this@ActColumnList, Column.getIconAttrId(item.acct, item.type) it.setTint(getAttributeColor(this@ActColumnList,R.attr.colorVectorDrawable))
) it.setTintMode(PorterDuff.Mode.SRC_IN)
}
) )
} }
@ -299,10 +302,11 @@ class ActColumnList : AppCompatActivity() {
tv.text = item.name tv.text = item.name
val ivColumnIcon = dragView.findViewById<ImageView>(R.id.ivColumnIcon) val ivColumnIcon = dragView.findViewById<ImageView>(R.id.ivColumnIcon)
ivColumnIcon.setImageResource( ivColumnIcon.setImageDrawable(
getAttributeResourceId( ContextCompat.getDrawable(this@ActColumnList,Column.getIconId(item.acct, item.type))?.also{
this@ActColumnList, Column.getIconAttrId(item.acct, item.type) it.setTint( getAttributeColor(this@ActColumnList,R.attr.colorVectorDrawable))
) it.setTintMode(PorterDuff.Mode.SRC_IN)
}
) )
dragView.findViewById<View>(R.id.ivBookmark).visibility = dragView.findViewById<View>(R.id.ivBookmark).visibility =

View File

@ -1518,10 +1518,10 @@ class ActMain : AppCompatActivity()
column.setHeaderBackground(viewRoot) column.setHeaderBackground(viewRoot)
setIconAttr( setIconDrawableId(
this, this,
ivIcon, ivIcon,
column.getIconAttrId(column.column_type), column.getIconId(column.column_type),
column.getHeaderNameColor() column.getHeaderNameColor()
) )
@ -2427,15 +2427,10 @@ class ActMain : AppCompatActivity()
} }
c = footer_button_fg_color c = footer_button_fg_color
if(c == 0) { if(c == 0) c= getAttributeColor(this,R.attr.colorVectorDrawable)
setIconAttr(this, btnToot, R.attr.ic_edit) setIconDrawableId(this, btnToot, R.drawable.ic_edit, c)
setIconAttr(this, btnMenu, R.attr.ic_hamburger) setIconDrawableId(this, btnMenu, R.drawable.ic_hamburger, c)
setIconAttr(this, btnQuickToot, R.attr.btn_post) setIconDrawableId(this, btnQuickToot, R.drawable.ic_send, c)
} else {
setIconAttr(this, btnToot, R.attr.ic_edit, c)
setIconAttr(this, btnMenu, R.attr.ic_hamburger, c)
setIconAttr(this, btnQuickToot, R.attr.btn_post, c)
}
c = footer_tab_bg_color c = footer_tab_bg_color
if(c == 0) c = getAttributeColor(this, R.attr.colorColumnStripBackground) if(c == 0) c = getAttributeColor(this, R.attr.colorColumnStripBackground)

View File

@ -30,6 +30,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.widget.* import android.widget.*
import jp.juggler.subwaytooter.Styler.defaultColorIcon
import jp.juggler.subwaytooter.api.* import jp.juggler.subwaytooter.api.*
import jp.juggler.subwaytooter.api.entity.* import jp.juggler.subwaytooter.api.entity.*
import jp.juggler.subwaytooter.dialog.* import jp.juggler.subwaytooter.dialog.*
@ -191,9 +192,9 @@ class ActPost : AppCompatActivity(),
// (Misskey) 返信を引用リノートにする // (Misskey) 返信を引用リノートにする
quotedRenote : Boolean = false, quotedRenote : Boolean = false,
//(Mastodon) 予約投稿の編集 //(Mastodon) 予約投稿の編集
scheduledStatus: TootScheduled? = null scheduledStatus : TootScheduled? = null
) { ) {
val intent = Intent(activity, ActPost::class.java) val intent = Intent(activity, ActPost::class.java)
@ -215,7 +216,7 @@ class ActPost : AppCompatActivity(),
if(sent_intent != null) { if(sent_intent != null) {
intent.putExtra(KEY_SENT_INTENT, sent_intent) intent.putExtra(KEY_SENT_INTENT, sent_intent)
} }
if( scheduledStatus != null ){ if(scheduledStatus != null) {
intent.putExtra(KEY_SCHEDULED_STATUS, scheduledStatus.src.toString()) intent.putExtra(KEY_SCHEDULED_STATUS, scheduledStatus.src.toString())
} }
activity.startActivityForResult(intent, request_code) activity.startActivityForResult(intent, request_code)
@ -263,7 +264,7 @@ class ActPost : AppCompatActivity(),
private lateinit var llReply : View private lateinit var llReply : View
private lateinit var tvReplyTo : TextView private lateinit var tvReplyTo : TextView
private lateinit var btnRemoveReply : View private lateinit var btnRemoveReply : ImageButton
private lateinit var ivReply : MyNetworkImageView private lateinit var ivReply : MyNetworkImageView
private lateinit var scrollView : ScrollView private lateinit var scrollView : ScrollView
@ -461,10 +462,10 @@ class ActPost : AppCompatActivity(),
this.visibility = TootVisibility.fromId(savedInstanceState.getInt(KEY_VISIBILITY, - 1)) this.visibility = TootVisibility.fromId(savedInstanceState.getInt(KEY_VISIBILITY, - 1))
val a = account val a = account
if( a != null) { if(a != null) {
savedInstanceState.getString(STATE_SCHEDULED_STATUS)?.let { savedInstanceState.getString(STATE_SCHEDULED_STATUS)?.let {
scheduledStatus = scheduledStatus =
parseItem(::TootScheduled, TootParser(this@ActPost, a), JSONObject(it),log) parseItem(::TootScheduled, TootParser(this@ActPost, a), JSONObject(it), log)
} }
} }
@ -493,8 +494,7 @@ class ActPost : AppCompatActivity(),
sv.toJsonArray().forEach { sv.toJsonArray().forEach {
if(it !is JSONObject) return@forEach if(it !is JSONObject) return@forEach
try { try {
val a = TootAttachment.decodeJson(it) attachment_list.add(PostAttachment(TootAttachment.decodeJson(it)))
attachment_list.add(PostAttachment(a))
} catch(ex : Throwable) { } catch(ex : Throwable) {
log.trace(ex) log.trace(ex)
} }
@ -738,9 +738,14 @@ class ActPost : AppCompatActivity(),
// 予約編集の再編集 // 予約編集の再編集
sv = intent.getStringExtra(KEY_SCHEDULED_STATUS) sv = intent.getStringExtra(KEY_SCHEDULED_STATUS)
if(sv != null && account != null) { if(sv != null && account != null) {
try{ try {
val item = parseItem(::TootScheduled, TootParser(this@ActPost, account), JSONObject(sv),log) val item = parseItem(
if( item != null){ ::TootScheduled,
TootParser(this@ActPost, account),
JSONObject(sv),
log
)
if(item != null) {
scheduledStatus = item scheduledStatus = item
timeSchedule = item.timeScheduledAt timeSchedule = item.timeScheduledAt
@ -749,34 +754,34 @@ class ActPost : AppCompatActivity(),
etContent.setText(text) etContent.setText(text)
val cw = item.spoiler_text val cw = item.spoiler_text
if( cw?.isNotEmpty() == true ){ if(cw?.isNotEmpty() == true) {
etContentWarning.setText(cw) etContentWarning.setText(cw)
cbContentWarning.isChecked = true cbContentWarning.isChecked = true
}else{ } else {
cbContentWarning.isChecked = false cbContentWarning.isChecked = false
} }
cbNSFW.isChecked = item.sensitive cbNSFW.isChecked = item.sensitive
visibility = item.visibility visibility = item.visibility
// 2019/1/7 どうも添付データを古い投稿から引き継げないようだ…。 // 2019/1/7 どうも添付データを古い投稿から引き継げないようだ…。
// バグ臭い // バグ臭い
// val src_attachments = item.media_attachments // val src_attachments = item.media_attachments
// if(src_attachments?.isNotEmpty() == true) { // if(src_attachments?.isNotEmpty() == true) {
// app_state.attachment_list = this.attachment_list // app_state.attachment_list = this.attachment_list
// this.attachment_list.clear() // this.attachment_list.clear()
// try { // try {
// for(src in src_attachments) { // for(src in src_attachments) {
// if(src is TootAttachment) { // if(src is TootAttachment) {
// src.redraft = true // src.redraft = true
// val pa = PostAttachment(src) // val pa = PostAttachment(src)
// pa.status = PostAttachment.STATUS_UPLOADED // pa.status = PostAttachment.STATUS_UPLOADED
// this.attachment_list.add(pa) // this.attachment_list.add(pa)
// } // }
// } // }
// } catch(ex : Throwable) { // } catch(ex : Throwable) {
// log.trace(ex) // log.trace(ex)
// } // }
// } // }
} }
} catch(ex : Throwable) { } catch(ex : Throwable) {
log.trace(ex) log.trace(ex)
@ -794,7 +799,7 @@ class ActPost : AppCompatActivity(),
// 表示を未選択に更新 // 表示を未選択に更新
selectAccount(null) selectAccount(null)
} }
updateContentWarning() updateContentWarning()
showMediaAttachment() showMediaAttachment()
showVisibility() showVisibility()
@ -978,7 +983,7 @@ class ActPost : AppCompatActivity(),
tvSchedule = findViewById(R.id.tvSchedule) tvSchedule = findViewById(R.id.tvSchedule)
ibSchedule = findViewById(R.id.ibSchedule) ibSchedule = findViewById(R.id.ibSchedule)
ibScheduleReset= findViewById(R.id.ibScheduleReset) ibScheduleReset = findViewById(R.id.ibScheduleReset)
ibSchedule.setOnClickListener(this) ibSchedule.setOnClickListener(this)
ibScheduleReset.setOnClickListener(this) ibScheduleReset.setOnClickListener(this)
@ -1002,15 +1007,18 @@ class ActPost : AppCompatActivity(),
for(iv in ivMedia) { for(iv in ivMedia) {
iv.setOnClickListener(this) iv.setOnClickListener(this)
iv.setDefaultImageResId(getAttributeResourceId(this, R.attr.ic_loading)) iv.setDefaultImage(defaultColorIcon(this, R.drawable.ic_upload))
iv.setErrorImageResId(getAttributeResourceId(this, R.attr.ic_unknown)) iv.setErrorImage(defaultColorIcon(this, R.drawable.ic_unknown))
} }
setIcon(btnPost, R.drawable.btn_post) // setIcon(btnPost, R.drawable.ic_send)
setIcon(btnMore, R.drawable.btn_more) // setIcon(btnMore, R.drawable.ic_more)
setIcon(btnPlugin, R.drawable.ic_plugin) // setIcon(btnPlugin, R.drawable.ic_extension)
setIcon(btnEmojiPicker, R.drawable.ic_face) // setIcon(btnEmojiPicker, R.drawable.ic_face)
setIcon(btnAttachment, R.drawable.btn_attachment) // setIcon(btnAttachment, R.drawable.ic_attachment)
// setIcon(ibSchedule, R.drawable.ic_edit)
// setIcon(ibScheduleReset, R.drawable.ic_close)
// setIcon(btnRemoveReply, R.drawable.ic_close)
cbContentWarning.setOnCheckedChangeListener { _, _ -> cbContentWarning.setOnCheckedChangeListener { _, _ ->
updateContentWarning() updateContentWarning()
@ -1046,15 +1054,6 @@ class ActPost : AppCompatActivity(),
} }
private fun setIcon(iv : ImageView, drawableId : Int) {
setIconDrawableId(
this,
iv,
drawableId,
getAttributeColor(this, R.attr.colorColumnHeaderName)
)
}
private var lastInstanceTask : TootTaskRunner? = null private var lastInstanceTask : TootTaskRunner? = null
private fun getMaxCharCount() : Int { private fun getMaxCharCount() : Int {
@ -1188,7 +1187,7 @@ class ActPost : AppCompatActivity(),
private fun performAccountChooser() { private fun performAccountChooser() {
if( scheduledStatus!= null ) { if(scheduledStatus != null) {
// 予約投稿の再編集ではアカウントを切り替えられない // 予約投稿の再編集ではアカウントを切り替えられない
showToast(this, false, R.string.cant_change_account_when_editing_scheduled_status) showToast(this, false, R.string.cant_change_account_when_editing_scheduled_status)
return return
@ -2059,15 +2058,15 @@ class ActPost : AppCompatActivity(),
} }
} }
private fun showVisibility() { private fun showVisibility() = setIconDrawableId(
setIcon( this,
btnVisibility, Styler.getVisibilityIcon( btnVisibility,
this Styler.getVisibilityIconId(
, account?.isMisskey == true account?.isMisskey == true
, visibility ?: TootVisibility.Public , visibility ?: TootVisibility.Public
) ),
) getAttributeColor(this, R.attr.colorVectorDrawable)
} )
private fun performVisibility() { private fun performVisibility() {
val list = if(account?.isMisskey == true) { val list = if(account?.isMisskey == true) {
@ -2190,7 +2189,7 @@ class ActPost : AppCompatActivity(),
post_helper.scheduledId = scheduledStatus?.id post_helper.scheduledId = scheduledStatus?.id
post_helper.post(account,callback=object:PostHelper.PostCompleteCallback{ post_helper.post(account, callback = object : PostHelper.PostCompleteCallback {
override fun onPostComplete( override fun onPostComplete(
target_account : SavedAccount, target_account : SavedAccount,
status : TootStatus status : TootStatus
@ -2206,7 +2205,7 @@ class ActPost : AppCompatActivity(),
} }
override fun onScheduledPostComplete(target_account : SavedAccount) { override fun onScheduledPostComplete(target_account : SavedAccount) {
showToast(this@ActPost,false,getString(R.string.scheduled_status_sent)) showToast(this@ActPost, false, getString(R.string.scheduled_status_sent))
val data = Intent() val data = Intent()
data.putExtra(EXTRA_POSTED_ACCT, target_account.acct) data.putExtra(EXTRA_POSTED_ACCT, target_account.acct)
setResult(RESULT_OK, data) setResult(RESULT_OK, data)
@ -2677,8 +2676,8 @@ class ActPost : AppCompatActivity(),
showSchedule() showSchedule()
} }
} }
private fun resetSchedule(){ private fun resetSchedule() {
timeSchedule = 0L timeSchedule = 0L
showSchedule() showSchedule()
} }

View File

@ -293,42 +293,42 @@ class Column(
} }
} }
internal fun getIconAttrId(acct : String, type : Int) : Int { internal fun getIconId(acct : String, type : Int) : Int {
return when(type) { return when(type) {
TYPE_REPORTS -> R.attr.ic_info TYPE_REPORTS -> R.drawable.ic_info
TYPE_HOME -> R.attr.btn_home TYPE_HOME -> R.drawable.ic_home
TYPE_LOCAL_AROUND -> R.attr.btn_local_tl TYPE_LOCAL_AROUND -> R.drawable.ic_run
TYPE_FEDERATED_AROUND -> R.attr.btn_federate_tl TYPE_FEDERATED_AROUND -> R.drawable.ic_bike
TYPE_ACCOUNT_AROUND -> R.attr.btn_statuses TYPE_ACCOUNT_AROUND -> R.drawable.ic_account_box
TYPE_LOCAL -> R.attr.btn_local_tl TYPE_LOCAL -> R.drawable.ic_run
TYPE_FEDERATE -> R.attr.btn_federate_tl TYPE_FEDERATE -> R.drawable.ic_bike
TYPE_MISSKEY_HYBRID -> R.attr.ic_share TYPE_MISSKEY_HYBRID -> R.drawable.ic_share
TYPE_PROFILE -> R.attr.btn_statuses TYPE_PROFILE -> R.drawable.ic_account_box
TYPE_FAVOURITES -> if(SavedAccount.isNicoru(acct)) R.attr.ic_nicoru else R.attr.btn_favourite TYPE_FAVOURITES -> if(SavedAccount.isNicoru(acct)) R.drawable.ic_nicoru else R.drawable.ic_star
TYPE_NOTIFICATIONS -> R.attr.btn_notification TYPE_NOTIFICATIONS -> R.drawable.ic_announcement
TYPE_CONVERSATION -> R.attr.ic_conversation TYPE_CONVERSATION -> R.drawable.ic_forum
TYPE_BOOSTED_BY -> R.attr.btn_boost TYPE_BOOSTED_BY -> R.drawable.ic_repeat
TYPE_FAVOURITED_BY -> if(SavedAccount.isNicoru(acct)) R.attr.ic_nicoru else R.attr.btn_favourite TYPE_FAVOURITED_BY -> if(SavedAccount.isNicoru(acct)) R.drawable.ic_nicoru else R.drawable.ic_star
TYPE_HASHTAG -> R.attr.ic_hashtag TYPE_HASHTAG -> R.drawable.ic_hashtag
TYPE_MUTES -> R.attr.ic_mute TYPE_MUTES -> R.drawable.ic_volume_off
TYPE_KEYWORD_FILTER -> R.attr.ic_mute TYPE_KEYWORD_FILTER -> R.drawable.ic_volume_off
TYPE_BLOCKS -> R.attr.ic_block TYPE_BLOCKS -> R.drawable.ic_block
TYPE_DOMAIN_BLOCKS -> R.attr.ic_domain_block TYPE_DOMAIN_BLOCKS -> R.drawable.ic_cloud_off
TYPE_SEARCH, TYPE_SEARCH_MSP, TYPE_SEARCH_TS -> R.attr.ic_search TYPE_SEARCH, TYPE_SEARCH_MSP, TYPE_SEARCH_TS -> R.drawable.ic_search
TYPE_INSTANCE_INFORMATION -> R.attr.ic_info TYPE_INSTANCE_INFORMATION -> R.drawable.ic_info
TYPE_FOLLOW_REQUESTS -> R.attr.ic_follow_wait TYPE_FOLLOW_REQUESTS -> R.drawable.ic_follow_wait
TYPE_FOLLOW_SUGGESTION -> R.attr.ic_follow_plus TYPE_FOLLOW_SUGGESTION -> R.drawable.ic_follow_plus
TYPE_ENDORSEMENT -> R.attr.ic_follow_plus TYPE_ENDORSEMENT -> R.drawable.ic_follow_plus
TYPE_LIST_LIST -> R.attr.ic_list_list TYPE_LIST_LIST -> R.drawable.ic_list_list
TYPE_LIST_MEMBER -> R.attr.ic_list_member TYPE_LIST_MEMBER -> R.drawable.ic_list_member
TYPE_LIST_TL -> R.attr.ic_list_tl TYPE_LIST_TL -> R.drawable.ic_list_tl
TYPE_DIRECT_MESSAGES -> R.attr.ic_mail TYPE_DIRECT_MESSAGES -> R.drawable.ic_mail
TYPE_TREND_TAG -> R.attr.ic_hashtag TYPE_TREND_TAG -> R.drawable.ic_hashtag
TYPE_SCHEDULED_STATUS -> R.attr.ic_timer TYPE_SCHEDULED_STATUS -> R.drawable.ic_timer
else -> R.attr.ic_info else -> R.drawable.ic_info
} }
} }
@ -1096,8 +1096,8 @@ class Column(
} }
} }
internal fun getIconAttrId(type : Int) : Int { internal fun getIconId(type : Int) : Int {
return getIconAttrId(access_info.acct, type) return getIconId(access_info.acct, type)
} }
// ブーストやお気に入りの更新に使う。ステータスを列挙する。 // ブーストやお気に入りの更新に使う。ステータスを列挙する。
@ -6444,10 +6444,6 @@ class Column(
s.markDeleted(context, ev.deletedAt) ?: false s.markDeleted(context, ev.deletedAt) ?: false
} }
} }
else -> {
log.d("onNoteUpdated: unknown type: ${ev.type}")
}
} }
if(changeList.isNotEmpty()) { if(changeList.isNotEmpty()) {

View File

@ -760,15 +760,15 @@ class ColumnViewHolder(
// カラムヘッダ文字色(A) // カラムヘッダ文字色(A)
var c = column.getHeaderNameColor() var c = column.getHeaderNameColor()
tvColumnName.textColor = c tvColumnName.textColor = c
setIconAttr( setIconDrawableId(
activity, activity,
ivColumnIcon, ivColumnIcon,
column.getIconAttrId(column.column_type), column.getIconId(column.column_type),
c c
) )
setIconAttr(activity, btnColumnSetting, R.attr.ic_tune, c) setIconDrawableId(activity, btnColumnSetting, R.drawable.ic_tune, c)
setIconAttr(activity, btnColumnReload, R.attr.btn_refresh, c) setIconDrawableId(activity, btnColumnReload, R.drawable.ic_refresh, c)
setIconAttr(activity, btnColumnClose, R.attr.btn_close, c) setIconDrawableId(activity, btnColumnClose, R.drawable.ic_close, c)
// カラムヘッダ文字色(B) // カラムヘッダ文字色(B)
c = column.getHeaderPageNumberColor() c = column.getHeaderPageNumberColor()
@ -1562,19 +1562,19 @@ class ColumnViewHolder(
showQuickFilterButton( showQuickFilterButton(
btnQuickFilterMention, btnQuickFilterMention,
R.drawable.btn_reply, R.drawable.ic_reply,
column.quick_filter == Column.QUICK_FILTER_MENTION column.quick_filter == Column.QUICK_FILTER_MENTION
) )
showQuickFilterButton( showQuickFilterButton(
btnQuickFilterFavourite, btnQuickFilterFavourite,
R.drawable.btn_favourite, R.drawable.ic_star,
column.quick_filter == Column.QUICK_FILTER_FAVOURITE column.quick_filter == Column.QUICK_FILTER_FAVOURITE
) )
showQuickFilterButton( showQuickFilterButton(
btnQuickFilterBoost, btnQuickFilterBoost,
R.drawable.btn_boost, R.drawable.ic_repeat,
column.quick_filter == Column.QUICK_FILTER_BOOST column.quick_filter == Column.QUICK_FILTER_BOOST
) )

View File

@ -298,21 +298,16 @@ internal class DlgContextMenu(
ivFollowedBy.visibility = View.GONE ivFollowedBy.visibility = View.GONE
} else { } else {
ivFollowedBy.visibility = View.VISIBLE ivFollowedBy.visibility = View.VISIBLE
ivFollowedBy.setImageResource( ivFollowedBy.setImageResource(R.drawable.ic_followed_by)
getAttributeResourceId(
activity,
R.attr.ic_followed_by
)
)
} }
btnFollow.setImageDrawable( btnFollow.setImageDrawable(
createColoredDrawable( createColoredDrawable(
activity, activity,
when { when {
relation.getRequested(who) -> R.drawable.ic_follow_wait_dark relation.getRequested(who) -> R.drawable.ic_follow_wait
relation.getFollowing(who) -> R.drawable.ic_follow_cross_dark relation.getFollowing(who) -> R.drawable.ic_follow_cross
else -> R.drawable.ic_follow_plus_dark else -> R.drawable.ic_follow_plus
}, },
getAttributeColor( getAttributeColor(
activity, activity,
@ -328,7 +323,7 @@ internal class DlgContextMenu(
btnMute.setImageDrawable( btnMute.setImageDrawable(
createColoredDrawable( createColoredDrawable(
activity, activity,
R.drawable.ic_mute_dark, R.drawable.ic_volume_off,
getAttributeColor( getAttributeColor(
activity, activity,
when(relation.muting) { when(relation.muting) {
@ -342,7 +337,7 @@ internal class DlgContextMenu(
btnBlock.setImageDrawable( btnBlock.setImageDrawable(
createColoredDrawable( createColoredDrawable(
activity, activity,
R.drawable.ic_block_dark, R.drawable.ic_block,
getAttributeColor( getAttributeColor(
activity, activity,
when(relation.blocking) { when(relation.blocking) {

View File

@ -19,6 +19,7 @@ import android.widget.*
import com.google.android.flexbox.FlexWrap import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayout import com.google.android.flexbox.FlexboxLayout
import com.google.android.flexbox.JustifyContent import com.google.android.flexbox.JustifyContent
import jp.juggler.subwaytooter.Styler.defaultColorIcon
import jp.juggler.subwaytooter.action.* import jp.juggler.subwaytooter.action.*
import jp.juggler.subwaytooter.api.* import jp.juggler.subwaytooter.api.*
import jp.juggler.subwaytooter.api.entity.* import jp.juggler.subwaytooter.api.entity.*
@ -33,7 +34,6 @@ import jp.juggler.util.*
import org.jetbrains.anko.* import org.jetbrains.anko.*
import org.json.JSONObject import org.json.JSONObject
import kotlin.math.max import kotlin.math.max
import kotlin.math.min
internal class ItemViewHolder( internal class ItemViewHolder(
val activity : ActMain val activity : ActMain
@ -266,7 +266,7 @@ internal class ItemViewHolder(
ivFollow.layoutParams.width = s ivFollow.layoutParams.width = s
ivBoosted.layoutParams.width = s ivBoosted.layoutParams.width = s
s = ActMain.replyIconSize + (activity.density*8).toInt() s = ActMain.replyIconSize + (activity.density * 8).toInt()
ivReply.layoutParams.width = s ivReply.layoutParams.width = s
ivReply.layoutParams.height = s ivReply.layoutParams.height = s
@ -459,7 +459,7 @@ internal class ItemViewHolder(
item.hasAnyContent() -> { item.hasAnyContent() -> {
// 引用Renote // 引用Renote
showReply( showReply(
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.renote_to, R.string.renote_to,
reblog reblog
) )
@ -471,7 +471,7 @@ internal class ItemViewHolder(
showBoost( showBoost(
item.accountRef, item.accountRef,
item.time_created_at, item.time_created_at,
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.display_name_boosted_by R.string.display_name_boosted_by
) )
showStatusOrReply(item.reblog) showStatusOrReply(item.reblog)
@ -500,9 +500,10 @@ internal class ItemViewHolder(
showConversationIcons(item) showConversationIcons(item)
} }
is TootScheduled ->{ is TootScheduled -> {
showScheduled(item) showScheduled(item)
} }
else -> { else -> {
} }
} }
@ -518,9 +519,9 @@ internal class ItemViewHolder(
showStatusTimeScheduled(activity, tvTime, item) showStatusTimeScheduled(activity, tvTime, item)
val who = access_info.loginAccount!! val who = access_info.loginAccount !!
val whoRef = TootAccountRef(TootParser(activity, access_info), who) val whoRef = TootAccountRef(TootParser(activity, access_info), who)
this.status_account =whoRef this.status_account = whoRef
setAcct(tvAcct, access_info.getFullAcct(who), who.acct) setAcct(tvAcct, access_info.getFullAcct(who), who.acct)
@ -533,26 +534,23 @@ internal class ItemViewHolder(
access_info.supplyBaseUrl(who.avatar) access_info.supplyBaseUrl(who.avatar)
) )
val content = SpannableString(item.text?:"") val content = SpannableString(item.text ?: "")
tvMentions.visibility = View.GONE tvMentions.visibility = View.GONE
tvContent.text = content tvContent.text = content
content_invalidator.register(content) content_invalidator.register(content)
tvContent.minLines = -1 tvContent.minLines = - 1
val decoded_spoiler_text = SpannableString(item.spoiler_text ?: "")
val decoded_spoiler_text = SpannableString(item.spoiler_text?:"")
when { when {
decoded_spoiler_text.isNotEmpty() -> { decoded_spoiler_text.isNotEmpty() -> {
// 元データに含まれるContent Warning を使う // 元データに含まれるContent Warning を使う
llContentWarning.visibility = View.VISIBLE llContentWarning.visibility = View.VISIBLE
tvContentWarning.text = decoded_spoiler_text tvContentWarning.text = decoded_spoiler_text
spoiler_invalidator.register(decoded_spoiler_text) spoiler_invalidator.register(decoded_spoiler_text)
val cw_shown = ContentWarning.isShown(item.uri,false) val cw_shown = ContentWarning.isShown(item.uri, false)
showContent(cw_shown) showContent(cw_shown)
} }
@ -564,7 +562,7 @@ internal class ItemViewHolder(
} }
val media_attachments = item.media_attachments val media_attachments = item.media_attachments
if(media_attachments?.isEmpty() != false ) { if(media_attachments?.isEmpty() != false) {
flMedia.visibility = View.GONE flMedia.visibility = View.GONE
llMedia.visibility = View.GONE llMedia.visibility = View.GONE
btnShowMedia.visibility = View.GONE btnShowMedia.visibility = View.GONE
@ -577,7 +575,7 @@ internal class ItemViewHolder(
access_info.dont_hide_nsfw -> true access_info.dont_hide_nsfw -> true
else -> ! item.sensitive else -> ! item.sensitive
} }
val is_shown = MediaShown.isShown(item.uri, default_shown) val is_shown = MediaShown.isShown(item.uri, default_shown)
btnShowMedia.visibility = if(! is_shown) View.VISIBLE else View.GONE btnShowMedia.visibility = if(! is_shown) View.VISIBLE else View.GONE
llMedia.visibility = if(! is_shown) View.GONE else View.VISIBLE llMedia.visibility = if(! is_shown) View.GONE else View.VISIBLE
@ -591,10 +589,10 @@ internal class ItemViewHolder(
tvMediaDescription.text = sb tvMediaDescription.text = sb
} }
setIconAttr( setIconDrawableId(
activity, activity,
btnHideMedia, btnHideMedia,
R.attr.btn_close, R.drawable.ic_close,
color = content_color, color = content_color,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
@ -603,16 +601,17 @@ internal class ItemViewHolder(
buttons_for_status?.hide() buttons_for_status?.hide()
tvApplication.visibility = View.GONE tvApplication.visibility = View.GONE
}catch(ex:Throwable){ } catch(ex : Throwable) {
} }
llSearchTag.visibility = View.VISIBLE llSearchTag.visibility = View.VISIBLE
btnSearchTag.text = activity.getString(R.string.scheduled_status) + " "+ TootStatus.formatTime( btnSearchTag.text = activity.getString(R.string.scheduled_status) + " " +
activity, TootStatus.formatTime(
item.timeScheduledAt, activity,
true item.timeScheduledAt,
) true
)
} }
private fun removeExtraView() { private fun removeExtraView() {
@ -705,14 +704,14 @@ internal class ItemViewHolder(
when { when {
reply != null -> reply != null ->
showReply( showReply(
R.attr.btn_reply, R.drawable.ic_reply,
R.string.reply_to, R.string.reply_to,
reply reply
) )
in_reply_to_id != null && in_reply_to_account_id != null -> { in_reply_to_id != null && in_reply_to_account_id != null -> {
showReply( showReply(
R.attr.btn_reply, R.drawable.ic_reply,
in_reply_to_account_id, in_reply_to_account_id,
item item
) )
@ -755,7 +754,7 @@ internal class ItemViewHolder(
else -> { else -> {
// 引用Renote // 引用Renote
showReply( showReply(
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.renote_to, R.string.renote_to,
reblog reblog
) )
@ -770,7 +769,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
if(access_info.isNicoru(n_account)) R.attr.ic_nicoru else R.attr.btn_favourite, if(access_info.isNicoru(n_account)) R.drawable.ic_nicoru else R.drawable.ic_star,
R.string.display_name_favourited_by R.string.display_name_favourited_by
) )
if(n_status != null) { if(n_status != null) {
@ -782,7 +781,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.display_name_boosted_by R.string.display_name_boosted_by
) )
if(n_status != null) { if(n_status != null) {
@ -796,7 +795,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.display_name_boosted_by R.string.display_name_boosted_by
) )
if(n_status != null) { if(n_status != null) {
@ -809,7 +808,7 @@ internal class ItemViewHolder(
showBoost( showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_follow_plus, R.drawable.ic_follow_plus,
R.string.display_name_followed_by R.string.display_name_followed_by
) )
showAccount(n_accountRef) showAccount(n_accountRef)
@ -821,7 +820,7 @@ internal class ItemViewHolder(
showBoost( showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_follow_cross, R.drawable.ic_follow_cross,
R.string.display_name_unfollowed_by R.string.display_name_unfollowed_by
) )
showAccount(n_accountRef) showAccount(n_accountRef)
@ -842,7 +841,7 @@ internal class ItemViewHolder(
showBoost( showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.btn_reply, R.drawable.ic_reply,
R.string.display_name_mentioned_by R.string.display_name_mentioned_by
) )
} }
@ -858,7 +857,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_question, // not used R.drawable.ic_question, // not used
R.string.display_name_reaction_by R.string.display_name_reaction_by
, reactionDrawableId = reaction?.btnDrawableId , reactionDrawableId = reaction?.btnDrawableId
) )
@ -871,7 +870,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.btn_boost, R.drawable.ic_repeat,
R.string.display_name_quoted_by R.string.display_name_quoted_by
) )
if(n_status != null) { if(n_status != null) {
@ -883,7 +882,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_vote, R.drawable.ic_vote,
R.string.display_name_voted_by R.string.display_name_voted_by
) )
if(n_status != null) { if(n_status != null) {
@ -895,7 +894,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_follow_wait, R.drawable.ic_follow_wait,
R.string.display_name_follow_request_by R.string.display_name_follow_request_by
) )
boostedAction = { boostedAction = {
@ -911,7 +910,7 @@ internal class ItemViewHolder(
if(n_account != null) showBoost( if(n_account != null) showBoost(
n_accountRef, n_accountRef,
n.time_created_at, n.time_created_at,
R.attr.ic_question, R.drawable.ic_question,
R.string.unknown_notification_from R.string.unknown_notification_from
) )
if(n_status != null) { if(n_status != null) {
@ -973,15 +972,15 @@ internal class ItemViewHolder(
} }
private fun showReply( private fun showReply(
iconAttrId : Int, iconId : Int,
text : Spannable text : Spannable
) { ) {
llReply.visibility = View.VISIBLE llReply.visibility = View.VISIBLE
setIconAttr( setIconDrawableId(
activity, activity,
ivReply, ivReply,
iconAttrId, iconId,
color = content_color, color = content_color,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
@ -991,7 +990,7 @@ internal class ItemViewHolder(
} }
private fun showReply( private fun showReply(
iconAttrId : Int, iconId : Int,
stringId : Int, stringId : Int,
reply : TootStatus reply : TootStatus
) { ) {
@ -1002,11 +1001,11 @@ internal class ItemViewHolder(
// setAcct(tvReplyAcct, access_info.getFullAcct(who), who.acct) // setAcct(tvReplyAcct, access_info.getFullAcct(who), who.acct)
val text = reply.accountRef.decoded_display_name.intoStringResource(activity, stringId) val text = reply.accountRef.decoded_display_name.intoStringResource(activity, stringId)
showReply(iconAttrId, text) showReply(iconId, text)
} }
private fun showReply( private fun showReply(
iconAttrId : Int, iconId : Int,
accountId : EntityId, accountId : EntityId,
replyStatus : TootStatus replyStatus : TootStatus
) { ) {
@ -1029,13 +1028,13 @@ internal class ItemViewHolder(
// showStatusTime(activity, tvReplyTime, who, time = reply.time_created_at) // showStatusTime(activity, tvReplyTime, who, time = reply.time_created_at)
// setAcct(tvReplyAcct, access_info.getFullAcct(who), who.acct) // setAcct(tvReplyAcct, access_info.getFullAcct(who), who.acct)
showReply(iconAttrId, text) showReply(iconId, text)
} }
private fun showBoost( private fun showBoost(
whoRef : TootAccountRef, whoRef : TootAccountRef,
time : Long, time : Long,
icon_attr_id : Int, iconId : Int,
string_id : Int, string_id : Int,
reactionDrawableId : Int? = null reactionDrawableId : Int? = null
) { ) {
@ -1053,10 +1052,10 @@ internal class ItemViewHolder(
if(reactionDrawableId != null) { if(reactionDrawableId != null) {
setIconDrawableId(activity, ivBoosted, reactionDrawableId) setIconDrawableId(activity, ivBoosted, reactionDrawableId)
} else { } else {
setIconAttr( setIconDrawableId(
activity, activity,
ivBoosted, ivBoosted,
icon_attr_id, iconId,
color = content_color, color = content_color,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
@ -1271,10 +1270,10 @@ internal class ItemViewHolder(
tvMediaDescription.text = sb tvMediaDescription.text = sb
} }
setIconAttr( setIconDrawableId(
activity, activity,
btnHideMedia, btnHideMedia,
R.attr.btn_close, R.drawable.ic_close,
color = content_color, color = content_color,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
@ -1408,13 +1407,13 @@ internal class ItemViewHolder(
} }
// visibility // visibility
val visIconAttrId = val visIconId =
Styler.getVisibilityIconAttr(access_info.isMisskey, status.visibility) Styler.getVisibilityIconId(access_info.isMisskey, status.visibility)
if(R.attr.ic_public != visIconAttrId) { if(R.drawable.ic_public != visIconId) {
if(sb.isNotEmpty()) sb.append('\u200B') if(sb.isNotEmpty()) sb.append('\u200B')
sb.appendColorShadeIcon( sb.appendColorShadeIcon(
activity, activity,
getAttributeResourceId(activity, visIconAttrId), visIconId,
Styler.getVisibilityString( Styler.getVisibilityString(
activity, activity,
access_info.isMisskey, access_info.isMisskey,
@ -1486,28 +1485,28 @@ internal class ItemViewHolder(
) { ) {
val sb = SpannableStringBuilder() val sb = SpannableStringBuilder()
// NSFWマーク // NSFWマーク
if(item.hasMedia() && item.sensitive) { if(item.hasMedia() && item.sensitive) {
if(sb.isNotEmpty()) sb.append('\u200B') if(sb.isNotEmpty()) sb.append('\u200B')
sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW") sb.appendColorShadeIcon(activity, R.drawable.ic_eye_off, "NSFW")
} }
// visibility // visibility
val visIconAttrId = val visIconId =
Styler.getVisibilityIconAttr(access_info.isMisskey, item.visibility ) Styler.getVisibilityIconId(access_info.isMisskey, item.visibility)
if(R.attr.ic_public != visIconAttrId) { if(R.drawable.ic_public != visIconId) {
if(sb.isNotEmpty()) sb.append('\u200B') if(sb.isNotEmpty()) sb.append('\u200B')
sb.appendColorShadeIcon( sb.appendColorShadeIcon(
activity,
visIconId,
Styler.getVisibilityString(
activity, activity,
getAttributeResourceId(activity, visIconAttrId), access_info.isMisskey,
Styler.getVisibilityString( item.visibility
activity,
access_info.isMisskey,
item.visibility
)
) )
} )
}
if(sb.isNotEmpty()) sb.append(' ') if(sb.isNotEmpty()) sb.append(' ')
sb.append( sb.append(
@ -1591,13 +1590,13 @@ internal class ItemViewHolder(
when(ta.type) { when(ta.type) {
TootAttachmentLike.TYPE_AUDIO -> { TootAttachmentLike.TYPE_AUDIO -> {
iv.setMediaType(0) iv.setMediaType(0)
iv.setDefaultImageResId(getAttributeResourceId(activity, R.attr.ic_music)) iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_music))
iv.setImageUrl(activity.pref, 0f, null) iv.setImageUrl(activity.pref, 0f, null)
} }
TootAttachmentLike.TYPE_UNKNOWN -> { TootAttachmentLike.TYPE_UNKNOWN -> {
iv.setMediaType(0) iv.setMediaType(0)
iv.setDefaultImageResId(getAttributeResourceId(activity, R.attr.ic_question)) iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_question))
iv.setImageUrl(activity.pref, 0f, null) iv.setImageUrl(activity.pref, 0f, null)
} }
@ -1606,12 +1605,7 @@ internal class ItemViewHolder(
when { when {
url?.isEmpty() != false -> { url?.isEmpty() != false -> {
iv.setMediaType(0) iv.setMediaType(0)
iv.setDefaultImageResId( iv.setDefaultImage(defaultColorIcon(activity,R.drawable.wide_question))
getAttributeResourceId(
activity,
R.attr.ic_question
)
)
iv.setImageUrl(activity.pref, 0f, null) iv.setImageUrl(activity.pref, 0f, null)
} }
@ -1623,7 +1617,7 @@ internal class ItemViewHolder(
else -> 0 else -> 0
} }
) )
iv.setDefaultImageResId(0) iv.setDefaultImage(null)
iv.setImageUrl( iv.setImageUrl(
activity.pref, activity.pref,
0f, 0f,
@ -1666,7 +1660,7 @@ internal class ItemViewHolder(
val notification = (item as? TootNotification) val notification = (item as? TootNotification)
boost_account?.let { whoRef -> boost_account?.let { whoRef ->
if(access_info.isPseudo) { if(access_info.isPseudo) {
DlgContextMenu(activity, column, whoRef, null, notification,tvContent).show() DlgContextMenu(activity, column, whoRef, null, notification, tvContent).show()
} else { } else {
Action_User.profileLocal(activity, pos, access_info, whoRef.get()) Action_User.profileLocal(activity, pos, access_info, whoRef.get())
} }
@ -1687,21 +1681,21 @@ internal class ItemViewHolder(
btnShowMedia.visibility = View.VISIBLE btnShowMedia.visibility = View.VISIBLE
llMedia.visibility = View.GONE llMedia.visibility = View.GONE
} }
(item as? TootScheduled)?.let{ item -> if( item is TootScheduled){
MediaShown.save(item.uri, false) MediaShown.save(item.uri, false)
btnShowMedia.visibility = View.VISIBLE btnShowMedia.visibility = View.VISIBLE
llMedia.visibility = View.GONE llMedia.visibility = View.GONE
} }
} }
btnShowMedia ->{ btnShowMedia -> {
status_showing?.let { status -> status_showing?.let { status ->
MediaShown.save(status, true) MediaShown.save(status, true)
btnShowMedia.visibility = View.GONE btnShowMedia.visibility = View.GONE
llMedia.visibility = View.VISIBLE llMedia.visibility = View.VISIBLE
} }
(item as? TootScheduled)?.let{ item -> if( item is TootScheduled){
MediaShown.save(item.uri, true) MediaShown.save(item.uri, true)
btnShowMedia.visibility = View.GONE btnShowMedia.visibility = View.GONE
llMedia.visibility = View.VISIBLE llMedia.visibility = View.VISIBLE
@ -1713,7 +1707,7 @@ internal class ItemViewHolder(
ivMedia3 -> clickMedia(2) ivMedia3 -> clickMedia(2)
ivMedia4 -> clickMedia(3) ivMedia4 -> clickMedia(3)
btnContentWarning ->{ btnContentWarning -> {
status_showing?.let { status -> status_showing?.let { status ->
val new_shown = llContents.visibility == View.GONE val new_shown = llContents.visibility == View.GONE
ContentWarning.save(status, new_shown) ContentWarning.save(status, new_shown)
@ -1722,7 +1716,7 @@ internal class ItemViewHolder(
list_adapter.notifyChange(reason = "ContentWarning onClick", reset = true) list_adapter.notifyChange(reason = "ContentWarning onClick", reset = true)
} }
(item as? TootScheduled)?.let{ item -> if(item is TootScheduled){
val new_shown = llContents.visibility == View.GONE val new_shown = llContents.visibility == View.GONE
ContentWarning.save(item.uri, new_shown) ContentWarning.save(item.uri, new_shown)
@ -1769,14 +1763,14 @@ internal class ItemViewHolder(
llFollow -> follow_account?.let { whoRef -> llFollow -> follow_account?.let { whoRef ->
if(access_info.isPseudo) { if(access_info.isPseudo) {
DlgContextMenu(activity, column, whoRef, null, notification,tvContent).show() DlgContextMenu(activity, column, whoRef, null, notification, tvContent).show()
} else { } else {
Action_User.profileLocal(activity, pos, access_info, whoRef.get()) Action_User.profileLocal(activity, pos, access_info, whoRef.get())
} }
} }
btnFollow -> follow_account?.let { who -> btnFollow -> follow_account?.let { who ->
DlgContextMenu(activity, column, who, null, notification,tvContent).show() DlgContextMenu(activity, column, who, null, notification, tvContent).show()
} }
btnSearchTag, llTrendTag -> when(item) { btnSearchTag, llTrendTag -> when(item) {
@ -1810,16 +1804,16 @@ internal class ItemViewHolder(
) )
} }
is TootScheduled ->{ is TootScheduled -> {
ActionsDialog() ActionsDialog()
.addAction(activity.getString(R.string.delete)){ .addAction(activity.getString(R.string.delete)) {
Action_Toot.deleteScheduledPost(activity,access_info,item){ Action_Toot.deleteScheduledPost(activity, access_info, item) {
column.onScheduleDeleted(item) column.onScheduleDeleted(item)
showToast(activity,false,R.string.scheduled_post_deleted) showToast(activity, false, R.string.scheduled_post_deleted)
} }
} }
.addAction(activity.getString(R.string.edit)){ .addAction(activity.getString(R.string.edit)) {
Action_Toot.editScheduledPost(activity,access_info,item) Action_Toot.editScheduledPost(activity, access_info, item)
} }
.show(activity) .show(activity)
} }
@ -2035,7 +2029,9 @@ internal class ItemViewHolder(
private fun clickMedia(i : Int) { private fun clickMedia(i : Int) {
try { try {
val media_attachments = status_showing?.media_attachments ?: (item as? TootScheduled)?.media_attachments ?: return val media_attachments =
status_showing?.media_attachments ?: (item as? TootScheduled)?.media_attachments
?: return
val item = if(i < media_attachments.size) media_attachments[i] else return val item = if(i < media_attachments.size) media_attachments[i] else return
when(item) { when(item) {
is TootAttachmentMSP -> { is TootAttachmentMSP -> {
@ -2770,7 +2766,7 @@ internal class ItemViewHolder(
ivReply = imageView { ivReply = imageView {
scaleType = ImageView.ScaleType.FIT_END scaleType = ImageView.ScaleType.FIT_END
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
padding=dip(4) padding = dip(4)
}.lparams(dip(32), dip(32)) { }.lparams(dip(32), dip(32)) {
endMargin = dip(4) endMargin = dip(4)
} }
@ -2848,11 +2844,7 @@ internal class ItemViewHolder(
R.drawable.btn_bg_transparent R.drawable.btn_bg_transparent
) )
contentDescription = "@string/hide" contentDescription = "@string/hide"
imageResource = imageResource = R.drawable.ic_close
getAttributeResourceId(
context,
R.attr.btn_close
)
}.lparams(dip(32), dip(32)) { }.lparams(dip(32), dip(32)) {
gravity = Gravity.END gravity = Gravity.END
} }
@ -3005,11 +2997,7 @@ internal class ItemViewHolder(
R.drawable.btn_bg_transparent R.drawable.btn_bg_transparent
) )
contentDescription = "@string/hide" contentDescription = "@string/hide"
imageResource = imageResource = R.drawable.ic_close
getAttributeResourceId(
context,
R.attr.btn_close
)
}.lparams(dip(32), matchParent) { }.lparams(dip(32), matchParent) {
startMargin = dip(8) startMargin = dip(8)
} }
@ -3023,11 +3011,10 @@ internal class ItemViewHolder(
) )
gravity = Gravity.CENTER gravity = Gravity.CENTER
text = context.getString(R.string.tap_to_show) text = context.getString(R.string.tap_to_show)
textColor = textColor = getAttributeColor(
getAttributeColor( context,
context, R.attr.colorShowMediaText
R.attr.colorShowMediaText )
)
}.lparams(matchParent, matchParent) }.lparams(matchParent, matchParent)
} }
@ -3188,7 +3175,7 @@ internal class ItemViewHolder(
background = background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent) ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
imageResource = getAttributeResourceId(context, R.attr.btn_more) imageResource = R.drawable.ic_more
contentDescription = context.getString(R.string.more) contentDescription = context.getString(R.string.more)
}.lparams(dip(40), dip(40)) { }.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
@ -3209,7 +3196,7 @@ internal class ItemViewHolder(
background = background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent) ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
contentDescription = context.getString(R.string.follow_accept) contentDescription = context.getString(R.string.follow_accept)
imageResource = getAttributeResourceId(context, R.attr.ic_check) imageResource = R.drawable.ic_check
setPadding(0, 0, 0, 0) setPadding(0, 0, 0, 0)
}.lparams(dip(48f), dip(32f)) }.lparams(dip(48f), dip(32f))
@ -3217,7 +3204,7 @@ internal class ItemViewHolder(
background = background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent) ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
contentDescription = context.getString(R.string.follow_deny) contentDescription = context.getString(R.string.follow_deny)
imageResource = getAttributeResourceId(context, R.attr.btn_close) imageResource = R.drawable.ic_close
setPadding(0, 0, 0, 0) setPadding(0, 0, 0, 0)
}.lparams(dip(48f), dip(32f)) { }.lparams(dip(48f), dip(32f)) {
startMargin = dip(4) startMargin = dip(4)

View File

@ -421,11 +421,11 @@ object Pref {
val spAutoCWLines = StringPref("auto_cw_lines", "0") val spAutoCWLines = StringPref("auto_cw_lines", "0")
val spCardDescriptionLength = StringPref("CardDescriptionLength", "64") val spCardDescriptionLength = StringPref("CardDescriptionLength", "64")
val spAvatarIconSize = StringPref("avatar_icon_size", "48") val spAvatarIconSize = StringPref("avatar_icon_size", "48")
val spNotificationTlIconSize = StringPref("notification_tl_icon_size", "32") val spNotificationTlIconSize = StringPref("notification_tl_icon_size", "24")
val spBoostButtonSize = StringPref("BoostButtonSize", "35") val spBoostButtonSize = StringPref("BoostButtonSize", "35")
val spReplyIconSize = StringPref("ReplyIconSize", "24") val spReplyIconSize = StringPref("ReplyIconSize", "24")
val spHeaderIconSize = StringPref("HeaderIconSize", "32") val spHeaderIconSize = StringPref("HeaderIconSize", "24")
val spStripIconSize = StringPref("StripIconSize", "32") val spStripIconSize = StringPref("StripIconSize", "24")
val spMediaSizeMax = StringPref("max_media_size", "8") val spMediaSizeMax = StringPref("max_media_size", "8")
val spMovieSizeMax = StringPref("max_movie_size", "40") val spMovieSizeMax = StringPref("max_movie_size", "40")
val spTimelineFont = StringPref("timeline_font", "", skipImport = true) val spTimelineFont = StringPref("timeline_font", "", skipImport = true)

View File

@ -75,7 +75,6 @@ internal class StatusButtons(
btnReply.setOnLongClickListener(this) btnReply.setOnLongClickListener(this)
} }
fun hide() { fun hide() {
holder.viewRoot.visibility = View.GONE holder.viewRoot.visibility = View.GONE
} }
@ -86,8 +85,8 @@ internal class StatusButtons(
this.notification = notification this.notification = notification
val fav_icon_drawable = when { val fav_icon_drawable = when {
access_info.isNicoru(status.account) -> R.drawable.ic_nicoru_dark access_info.isNicoru(status.account) -> R.drawable.ic_nicoru
else -> R.drawable.btn_favourite_dark else -> R.drawable.ic_star
} }
val replies_count = status.replies_count val replies_count = status.replies_count
@ -95,35 +94,35 @@ internal class StatusButtons(
setIconDrawableId( setIconDrawableId(
activity, activity,
btnConversation, btnConversation,
R.drawable.ic_conversation_dark, R.drawable.ic_forum,
color = color_normal, color = color_normal,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
setIconDrawableId( setIconDrawableId(
activity, activity,
btnMore, btnMore,
R.drawable.btn_more_dark, R.drawable.ic_more,
color = color_normal, color = color_normal,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
// val a = (((color_normal ushr 24)/255f) * 0.7f) // val a = (((color_normal ushr 24)/255f) * 0.7f)
// setIconDrawableId で色を指定するとアルファ値も反映されるらしい // setIconDrawableId で色を指定するとアルファ値も反映されるらしい
// btnConversation.alpha = a // btnConversation.alpha = a
// btnMore.alpha = a // btnMore.alpha = a
// //
// btnReply.alpha = a // btnReply.alpha = a
// btnBoost.alpha = a // btnBoost.alpha = a
// btnFavourite.alpha = a // btnFavourite.alpha = a
// btnFollow2.alpha = a // btnFollow2.alpha = a
// ivFollowedBy2.alpha = a // ivFollowedBy2.alpha = a
setButton( setButton(
btnReply, btnReply,
true, true,
color_normal, color_normal,
R.drawable.btn_reply_dark, R.drawable.ic_reply,
when(replies_count) { when(replies_count) {
null -> "" null -> ""
else -> when(Pref.ipRepliesCount(activity.pref)) { else -> when(Pref.ipRepliesCount(activity.pref)) {
@ -146,7 +145,7 @@ internal class StatusButtons(
btnBoost, btnBoost,
false, false,
color_accent, color_accent,
R.drawable.ic_mail_dark, R.drawable.ic_repeat,
"", "",
activity.getString(R.string.boost) activity.getString(R.string.boost)
) )
@ -155,7 +154,7 @@ internal class StatusButtons(
btnBoost, btnBoost,
false, false,
color_normal, color_normal,
R.drawable.btn_refresh_dark, R.drawable.ic_refresh,
"?", "?",
activity.getString(R.string.boost) activity.getString(R.string.boost)
) )
@ -164,7 +163,7 @@ internal class StatusButtons(
btnBoost, btnBoost,
true, true,
if(status.reblogged) color_accent else color_normal, if(status.reblogged) color_accent else color_normal,
R.drawable.btn_boost_dark, R.drawable.ic_repeat,
status.reblogs_count?.toString() ?: "", status.reblogs_count?.toString() ?: "",
activity.getString(R.string.boost) activity.getString(R.string.boost)
) )
@ -175,7 +174,7 @@ internal class StatusButtons(
btnFavourite, btnFavourite,
false, false,
color_normal, color_normal,
R.drawable.btn_refresh_dark, R.drawable.ic_refresh,
"?", "?",
activity.getString(R.string.favourite) activity.getString(R.string.favourite)
) )
@ -220,7 +219,8 @@ internal class StatusButtons(
count : String, count : String,
contentDescription : String contentDescription : String
) { ) {
val d = createColoredDrawable(activity,drawableId,color,alphaMultiplier = Styler.boost_alpha) val d =
createColoredDrawable(activity, drawableId, color, alphaMultiplier = Styler.boost_alpha)
b.setImageDrawable(d) b.setImageDrawable(d)
b.setPaddingAndText(holder.paddingH, holder.paddingV, count, 14f, holder.compoundPaddingDp) b.setPaddingAndText(holder.paddingH, holder.paddingV, count, 14f, holder.compoundPaddingDp)
b.setTextColor(color.applyAlphaMultiplier(Styler.boost_alpha)) b.setTextColor(color.applyAlphaMultiplier(Styler.boost_alpha))
@ -418,7 +418,6 @@ internal class StatusButtons(
return true return true
} }
} }
open class _FlexboxLayout(ctx : Context) : FlexboxLayout(ctx) { open class _FlexboxLayout(ctx : Context) : FlexboxLayout(ctx) {
@ -481,8 +480,7 @@ class StatusButtonsViewHolder(
setPadding(paddingH, paddingV, paddingH, paddingV) setPadding(paddingH, paddingV, paddingH, paddingV)
scaleType = ImageView.ScaleType.FIT_CENTER scaleType = ImageView.ScaleType.FIT_CENTER
imageResource = imageResource = R.drawable.ic_forum
getAttributeResourceId(context, R.attr.ic_conversation)
}.lparams(buttonHeight, buttonHeight) }.lparams(buttonHeight, buttonHeight)
btnReply = customView<CountImageButton> { btnReply = customView<CountImageButton> {
@ -560,8 +558,7 @@ class StatusButtonsViewHolder(
scaleType = ImageView.ScaleType.FIT_CENTER scaleType = ImageView.ScaleType.FIT_CENTER
contentDescription = context.getString(R.string.more) contentDescription = context.getString(R.string.more)
imageResource = imageResource = R.drawable.ic_more
getAttributeResourceId(context, R.attr.btn_more)
}.lparams(buttonHeight, buttonHeight) { }.lparams(buttonHeight, buttonHeight) {
startMargin = marginBetween startMargin = marginBetween
} }

View File

@ -1,10 +1,9 @@
package jp.juggler.subwaytooter package jp.juggler.subwaytooter
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.graphics.PorterDuff
import android.graphics.drawable.* import android.graphics.drawable.Drawable
import android.graphics.drawable.shapes.RectShape import android.support.v4.content.ContextCompat
import android.os.Build
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.Spanned import android.text.Spanned
import android.view.View import android.view.View
@ -19,7 +18,13 @@ import jp.juggler.util.*
object Styler { object Styler {
fun getVisibilityIconAttr(isMisskeyData : Boolean, visibility : TootVisibility) : Int { fun defaultColorIcon(context : Context, iconId : Int) : Drawable? =
ContextCompat.getDrawable(context, iconId)?.also {
it.setTint(getAttributeColor(context, R.attr.colorVectorDrawable))
it.setTintMode(PorterDuff.Mode.SRC_IN)
}
fun getVisibilityIconId(isMisskeyData : Boolean, visibility : TootVisibility) : Int {
val isMisskey = when(Pref.ipVisibilityStyle(App1.pref)) { val isMisskey = when(Pref.ipVisibilityStyle(App1.pref)) {
Pref.VS_MASTODON -> false Pref.VS_MASTODON -> false
Pref.VS_MISSKEY -> true Pref.VS_MISSKEY -> true
@ -27,42 +32,34 @@ object Styler {
} }
return when { return when {
isMisskey -> when(visibility) { isMisskey -> when(visibility) {
TootVisibility.Public -> R.attr.ic_public TootVisibility.Public -> R.drawable.ic_public
TootVisibility.UnlistedHome -> R.attr.btn_home TootVisibility.UnlistedHome -> R.drawable.ic_home
TootVisibility.PrivateFollowers -> R.attr.ic_lock_open TootVisibility.PrivateFollowers -> R.drawable.ic_lock_open
TootVisibility.DirectSpecified -> R.attr.ic_mail TootVisibility.DirectSpecified -> R.drawable.ic_mail
TootVisibility.DirectPrivate -> R.attr.ic_lock TootVisibility.DirectPrivate -> R.drawable.ic_lock
TootVisibility.WebSetting -> R.attr.ic_question TootVisibility.WebSetting -> R.drawable.ic_question
TootVisibility.LocalPublic -> R.attr.ic_local_ltl TootVisibility.LocalPublic -> R.drawable.ic_local_ltl
TootVisibility.LocalHome -> R.attr.ic_local_home TootVisibility.LocalHome -> R.drawable.ic_local_home
TootVisibility.LocalFollowers -> R.attr.ic_local_lock_open TootVisibility.LocalFollowers -> R.drawable.ic_local_lock_open
} }
else -> when(visibility) { else -> when(visibility) {
TootVisibility.Public -> R.attr.ic_public TootVisibility.Public -> R.drawable.ic_public
TootVisibility.UnlistedHome -> R.attr.ic_lock_open TootVisibility.UnlistedHome -> R.drawable.ic_lock_open
TootVisibility.PrivateFollowers -> R.attr.ic_lock TootVisibility.PrivateFollowers -> R.drawable.ic_lock
TootVisibility.DirectSpecified -> R.attr.ic_mail TootVisibility.DirectSpecified -> R.drawable.ic_mail
TootVisibility.DirectPrivate -> R.attr.ic_mail TootVisibility.DirectPrivate -> R.drawable.ic_mail
TootVisibility.WebSetting -> R.attr.ic_question TootVisibility.WebSetting -> R.drawable.ic_question
TootVisibility.LocalPublic -> R.attr.ic_local_ltl TootVisibility.LocalPublic -> R.drawable.ic_local_ltl
TootVisibility.LocalHome -> R.attr.ic_local_lock_open TootVisibility.LocalHome -> R.drawable.ic_local_lock_open
TootVisibility.LocalFollowers -> R.attr.ic_local_lock TootVisibility.LocalFollowers -> R.drawable.ic_local_lock
} }
} }
} }
fun getVisibilityIcon(
context : Context,
isMisskeyData : Boolean,
visibility : TootVisibility
) : Int {
return getAttributeResourceId(context, getVisibilityIconAttr(isMisskeyData, visibility))
}
fun getVisibilityString( fun getVisibilityString(
context : Context, context : Context,
isMisskeyData : Boolean, isMisskeyData : Boolean,
@ -110,16 +107,26 @@ object Styler {
visibility : TootVisibility visibility : TootVisibility
) : CharSequence { ) : CharSequence {
val icon_id = getVisibilityIcon(context, isMisskeyData, visibility) val icon_id = getVisibilityIconId(isMisskeyData, visibility)
val sv = getVisibilityString(context, isMisskeyData, visibility) val sv = getVisibilityString(context, isMisskeyData, visibility)
val color = getAttributeColor(context, R.attr.colorVectorDrawable)
val sb = SpannableStringBuilder() val sb = SpannableStringBuilder()
// アイコン部分 // アイコン部分
val start = sb.length val start = sb.length
sb.append(" ") sb.append(" ")
val end = sb.length val end = sb.length
sb.setSpan(EmojiImageSpan(context, icon_id), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) sb.setSpan(
EmojiImageSpan(
context,
icon_id,
useColorShader = true,
color = color
),
start,
end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
// 文字列部分 // 文字列部分
sb.append(' ') sb.append(' ')
@ -168,10 +175,10 @@ object Styler {
relation.followed_by -> { relation.followed_by -> {
ivDot.visibility = View.VISIBLE ivDot.visibility = View.VISIBLE
setIconAttr( setIconDrawableId(
context, context,
ivDot, ivDot,
R.attr.ic_followed_by, R.drawable.ic_followed_by,
color = colorAccent(), color = colorAccent(),
alphaMultiplier = alphaMultiplier alphaMultiplier = alphaMultiplier
) )
@ -188,46 +195,51 @@ object Styler {
// フォローボタン // フォローボタン
// follow button // follow button
val color : Int val color : Int
val icon_attr : Int val iconId : Int
val contentDescription : String val contentDescription : String
when { when {
relation.blocking -> { relation.blocking -> {
icon_attr = R.attr.ic_block iconId = R.drawable.ic_block
color = defaultColor color = defaultColor
contentDescription = context.getString(R.string.follow) contentDescription = context.getString(R.string.follow)
} }
relation.muting -> { relation.muting -> {
icon_attr = R.attr.ic_mute iconId = R.drawable.ic_volume_off
color = defaultColor color = defaultColor
contentDescription = context.getString(R.string.follow) contentDescription = context.getString(R.string.follow)
} }
relation.getFollowing(who) -> { relation.getFollowing(who) -> {
icon_attr = R.attr.ic_follow_cross iconId = R.drawable.ic_follow_cross
color = colorAccent() color = colorAccent()
contentDescription = context.getString(R.string.unfollow) contentDescription = context.getString(R.string.unfollow)
} }
relation.getRequested(who) -> { relation.getRequested(who) -> {
icon_attr = R.attr.ic_follow_wait iconId = R.drawable.ic_follow_wait
color = colorError() color = colorError()
contentDescription = context.getString(R.string.unfollow) contentDescription = context.getString(R.string.unfollow)
} }
else -> { else -> {
icon_attr = R.attr.ic_follow_plus iconId = R.drawable.ic_follow_plus
color = defaultColor color = defaultColor
contentDescription = context.getString(R.string.follow) contentDescription = context.getString(R.string.follow)
} }
} }
setIconAttr(context, ibFollow, icon_attr, color = color, alphaMultiplier = alphaMultiplier) setIconDrawableId(
context,
ibFollow,
iconId,
color = color,
alphaMultiplier = alphaMultiplier
)
ibFollow.contentDescription = contentDescription ibFollow.contentDescription = contentDescription
} }
private fun getHorizontalPadding(v : View, delta_dp : Float) : Int { private fun getHorizontalPadding(v : View, delta_dp : Float) : Int {
val form_width_max = 420f val form_width_max = 420f
val dm = v.resources.displayMetrics val dm = v.resources.displayMetrics

View File

@ -165,7 +165,7 @@ internal class ViewHolderHeaderProfile(
setIconDrawableId( setIconDrawableId(
activity, activity,
btnMore, btnMore,
R.drawable.btn_more, R.drawable.ic_more,
color = contentColor, color = contentColor,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )

View File

@ -146,10 +146,6 @@ class TootApiClient(
bodyString : String? = null, bodyString : String? = null,
jsonErrorParser : (json : JSONObject) -> String? = DEFAULT_JSON_ERROR_PARSER jsonErrorParser : (json : JSONObject) -> String? = DEFAULT_JSON_ERROR_PARSER
) : String { ) : String {
val url = response.request()?.url()
if(url?.toString()?.contains("misskey") == true) {
log.d("Misskey response error: url=$url")
}
val sb = StringBuilder() val sb = StringBuilder()
try { try {
// body は既に読み終わっているか、そうでなければこれから読む // body は既に読み終わっているか、そうでなければこれから読む
@ -171,9 +167,7 @@ class TootApiClient(
sb.append("(HTTP ").append(Integer.toString(response.code())) sb.append("(HTTP ").append(Integer.toString(response.code()))
val message = response.message() val message = response.message()
if(message != null && message.isNotEmpty()) { if(message.isNotEmpty()) sb.append(' ').append(message)
sb.append(' ').append(message)
}
sb.append(")") sb.append(")")
if(caption.isNotEmpty()) { if(caption.isNotEmpty()) {
@ -308,15 +302,13 @@ class TootApiClient(
val response = result.response !! val response = result.response !!
val request = response.request() val request = response.request()
if(request != null) { publishApiProgress(
publishApiProgress( context.getString(
context.getString( R.string.reading_api,
R.string.reading_api, request.method(),
request.method(), progressPath ?: result.caption
progressPath ?: result.caption
)
) )
} )
val bodyString = response.body()?.string() val bodyString = response.body()?.string()
if(isApiCancelled) return null if(isApiCancelled) return null
@ -359,7 +351,6 @@ class TootApiClient(
val response = result.response !! val response = result.response !!
val request = response.request() val request = response.request()
if(request != null) {
publishApiProgress( publishApiProgress(
context.getString( context.getString(
R.string.reading_api, R.string.reading_api,
@ -367,7 +358,6 @@ class TootApiClient(
progressPath ?: result.caption progressPath ?: result.caption
) )
) )
}
val bodyBytes = response.body()?.bytes() val bodyBytes = response.body()?.bytes()
if(isApiCancelled) return null if(isApiCancelled) return null
@ -479,15 +469,12 @@ class TootApiClient(
sb.append("(HTTP ").append(Integer.toString(response.code())) sb.append("(HTTP ").append(Integer.toString(response.code()))
val message = response.message() val message = response.message()
if(message != null && message.isNotEmpty()) { if(message.isNotEmpty()) sb.append(' ').append(message)
sb.append(' ').append(message)
}
sb.append(")") sb.append(")")
val url = response.request()?.url()?.toString() val url = response.request().url().toString()
if(url?.isNotEmpty() == true) { if(url.isNotEmpty()) sb.append(' ').append(url)
sb.append(' ').append(url)
}
result.error = sb.toString() result.error = sb.toString()
} }

View File

@ -40,7 +40,7 @@ class TootAttachment : TootAttachmentLike {
private fun guessMediaTypeByUrl(src : String?) : String? { private fun guessMediaTypeByUrl(src : String?) : String? {
val uri = src.mayUri() ?: return null val uri = src.mayUri() ?: return null
if( ext_audio.find { uri.path.endsWith(it) } != null ){ if( ext_audio.find { uri.path?.endsWith(it) == true } != null ){
return TootAttachmentLike.TYPE_AUDIO return TootAttachmentLike.TYPE_AUDIO
} }

View File

@ -99,7 +99,7 @@ object LoginForm {
val dialog = Dialog(activity) val dialog = Dialog(activity)
dialog.setContentView(view) dialog.setContentView(view)
// 警告がでるが、パラメータ名の指定を削ってはいけない // 警告がでるが、パラメータ名の指定を削ってはいけない
btnOk.setOnClickListener { v -> btnOk.setOnClickListener { _ ->
val instance = etInstance.text.toString().trim { it <= ' ' } val instance = etInstance.text.toString().trim { it <= ' ' }
when { when {

View File

@ -36,10 +36,10 @@ class MyNetworkImageView : AppCompatImageView {
} }
// ロード中などに表示するDrawableのリソースID // ロード中などに表示するDrawableのリソースID
private var mDefaultImageId = 0 private var mDefaultImage :Drawable? = null
// エラー時に表示するDrawableのリソースID // エラー時に表示するDrawableのリソースID
private var mErrorImageId = 0 private var mErrorImage :Drawable? = null
// 角丸の半径。元画像の短辺に対する割合を指定するらしい // 角丸の半径。元画像の短辺に対する割合を指定するらしい
internal var mCornerRadius = 0f internal var mCornerRadius = 0f
@ -67,13 +67,13 @@ class MyNetworkImageView : AppCompatImageView {
constructor(context : Context, attrs : AttributeSet, defStyleAttr : Int) constructor(context : Context, attrs : AttributeSet, defStyleAttr : Int)
: super(context, attrs, defStyleAttr) : super(context, attrs, defStyleAttr)
fun setDefaultImageResId(defaultImage : Int) { fun setDefaultImage(defaultImage : Drawable?) {
mDefaultImageId = defaultImage mDefaultImage = defaultImage
loadImageIfNecessary() loadImageIfNecessary()
} }
fun setErrorImageResId(errorImage : Int) { fun setErrorImage(errorImage : Drawable?) {
mErrorImageId = errorImage mErrorImage = errorImage
loadImageIfNecessary() loadImageIfNecessary()
} }
@ -138,14 +138,7 @@ class MyNetworkImageView : AppCompatImageView {
} }
// デフォルト画像かnull
private fun getDefaultDrawable(context : Context?) : Drawable? {
return if(context != null && mDefaultImageId != 0) {
ContextCompat.getDrawable(context, mDefaultImageId)
} else {
null
}
}
// 必要なら非同期処理を開始する // 必要なら非同期処理を開始する
private fun loadImageIfNecessary() { private fun loadImageIfNecessary() {
@ -154,7 +147,7 @@ class MyNetworkImageView : AppCompatImageView {
if(url?.isEmpty() != false) { if(url?.isEmpty() != false) {
// if the URL to be loaded in this view is empty, // if the URL to be loaded in this view is empty,
// cancel any old requests and clear the currently loaded image. // cancel any old requests and clear the currently loaded image.
cancelLoading(getDefaultDrawable(context)) cancelLoading(mDefaultImage)
return return
} }
@ -162,7 +155,7 @@ class MyNetworkImageView : AppCompatImageView {
if((mTarget as? UrlTarget)?.urlLoading == url) return if((mTarget as? UrlTarget)?.urlLoading == url) return
// if there is a pre-existing request, cancel it if it's fetching a different URL. // if there is a pre-existing request, cancel it if it's fetching a different URL.
cancelLoading(getDefaultDrawable(context)) cancelLoading(mDefaultImage)
// 非表示状態ならロードを延期する // 非表示状態ならロードを延期する
if(! isShown) return if(! isShown) return
@ -239,9 +232,9 @@ class MyNetworkImageView : AppCompatImageView {
// 別の画像を表示するよう指定が変化していたなら何もしない // 別の画像を表示するよう指定が変化していたなら何もしない
if(urlLoading != mUrl) return if(urlLoading != mUrl) return
if(mErrorImageId != 0) { if(mErrorImage != null) {
// エラー表示用の画像リソースが指定されていたら使う // エラー表示用の画像リソースが指定されていたら使う
setImageResource(mErrorImageId) setImageDrawable(mErrorImage)
} else { } else {
// このタイミングでImageViewのDrawableを変更するとチラつきの元になるので何もしない // このタイミングでImageViewのDrawableを変更するとチラつきの元になるので何もしない
} }

View File

@ -42,23 +42,25 @@ fun getAttributeColor(context : Context, attrId : Int) : Int {
return color return color
} }
fun getAttributeResourceId(context : Context, attrId : Int) : Int {
val theme = context.theme
val a = theme.obtainStyledAttributes(intArrayOf(attrId))
val resourceId = a.getResourceId(0, 0)
a.recycle()
if(resourceId == 0)
throw RuntimeException(
String.format(
Locale.JAPAN,
"attr not defined.attr_id=0x%x",
attrId
)
)
return resourceId
}
fun getAttributeDrawable(context : Context, attrId : Int) : Drawable { fun getAttributeDrawable(context : Context, attrId : Int) : Drawable {
fun getAttributeResourceId(context : Context, attrId : Int) : Int {
val theme = context.theme
val a = theme.obtainStyledAttributes(intArrayOf(attrId))
val resourceId = a.getResourceId(0, 0)
a.recycle()
if(resourceId == 0)
throw RuntimeException(
String.format(
Locale.JAPAN,
"attr not defined.attr_id=0x%x",
attrId
)
)
return resourceId
}
val drawableId = getAttributeResourceId(context, attrId) val drawableId = getAttributeResourceId(context, attrId)
val d = ContextCompat.getDrawable(context, drawableId) val d = ContextCompat.getDrawable(context, drawableId)
return d ?: throw RuntimeException( return d ?: throw RuntimeException(
@ -233,21 +235,21 @@ fun setIconDrawableId(
} }
} }
fun setIconAttr( //fun setIconAttr(
context : Context, // context : Context,
imageView : ImageView, // imageView : ImageView,
iconAttrId : Int, // iconAttrId : Int,
color : Int? = null, // color : Int? = null,
alphaMultiplier : Float? = null // alphaMultiplier : Float? = null
) { //) {
setIconDrawableId( // setIconDrawableId(
context, // context,
imageView, // imageView,
getAttributeResourceId(context, iconAttrId), // getAttributeResourceId(context, iconAttrId),
color, // color,
alphaMultiplier // alphaMultiplier
) // )
} //}
fun CharSequence.copyToClipboard(context:Context) { fun CharSequence.copyToClipboard(context:Context) {
try { try {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 B

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Some files were not shown because too many files have changed in this diff Show More