1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-02-07 06:04:23 +01:00

refactor. change order of app,lang in timeline

This commit is contained in:
tateisu 2019-12-16 00:34:46 +09:00
parent 5191e9342e
commit b8b376af24
14 changed files with 173 additions and 182 deletions

View File

@ -367,7 +367,7 @@ class ActAccountSetting
btnNotificationStyleEditReply = findViewById(R.id.btnNotificationStyleEditReply) btnNotificationStyleEditReply = findViewById(R.id.btnNotificationStyleEditReply)
btnNotificationStyleEdit.setOnClickListener(this) btnNotificationStyleEdit.setOnClickListener(this)
btnNotificationStyleEditReply.setOnClickListener(this) btnNotificationStyleEditReply.setOnClickListener(this)
vg(btnNotificationStyleEditReply, Pref.bpSeparateReplyNotificationGroup(pref)) btnNotificationStyleEditReply.vg(Pref.bpSeparateReplyNotificationGroup(pref))
name_invalidator = NetworkEmojiInvalidator(handler, etDisplayName) name_invalidator = NetworkEmojiInvalidator(handler, etDisplayName)
note_invalidator = NetworkEmojiInvalidator(handler, etNote) note_invalidator = NetworkEmojiInvalidator(handler, etNote)
@ -941,9 +941,9 @@ class ActAccountSetting
var profile_busy : Boolean = false var profile_busy : Boolean = false
internal fun showProfile(src : TootAccount) { internal fun showProfile(src : TootAccount) {
if( isDestroyed ) return if(isDestroyed) return
profile_busy = true profile_busy = true
try { try {
ivProfileAvatar.setImageUrl( ivProfileAvatar.setImageUrl(
@ -1000,8 +1000,8 @@ class ActAccountSetting
if(src.source?.fields != null) { if(src.source?.fields != null) {
val fields = src.source.fields val fields = src.source.fields
listEtFieldName.forEachIndexed { i, et -> listEtFieldName.forEachIndexed { i, et ->
val handler =et.handler // may null val handler = et.handler // may null
if( handler != null){ if(handler != null) {
// いつからかfields name にもカスタム絵文字が使えるようになった // いつからかfields name にもカスタム絵文字が使えるようになった
// https://github.com/tootsuite/mastodon/pull/11350 // https://github.com/tootsuite/mastodon/pull/11350
// しかし // しかし
@ -1019,8 +1019,8 @@ class ActAccountSetting
} }
listEtFieldValue.forEachIndexed { i, et -> listEtFieldValue.forEachIndexed { i, et ->
val handler =et.handler // may null val handler = et.handler // may null
if( handler != null){ if(handler != null) {
val text = decodeOptions.decodeEmoji( val text = decodeOptions.decodeEmoji(
when { when {
i >= fields.size -> "" i >= fields.size -> ""
@ -1038,8 +1038,8 @@ class ActAccountSetting
val fields = src.fields val fields = src.fields
listEtFieldName.forEachIndexed { i, et -> listEtFieldName.forEachIndexed { i, et ->
val handler =et.handler // may null val handler = et.handler // may null
if( handler != null){ if(handler != null) {
// いつからかfields name にもカスタム絵文字が使えるようになった // いつからかfields name にもカスタム絵文字が使えるようになった
// https://github.com/tootsuite/mastodon/pull/11350 // https://github.com/tootsuite/mastodon/pull/11350
val text = decodeOptions.decodeEmoji( val text = decodeOptions.decodeEmoji(
@ -1057,8 +1057,8 @@ class ActAccountSetting
} }
listEtFieldValue.forEachIndexed { i, et -> listEtFieldValue.forEachIndexed { i, et ->
val handler =et.handler // may null val handler = et.handler // may null
if( handler != null){ if(handler != null) {
val text = decodeOptions.decodeHTML( val text = decodeOptions.decodeHTML(
when { when {
fields == null || i >= fields.size -> "" fields == null || i >= fields.size -> ""

View File

@ -163,8 +163,8 @@ class ActAppSetting : AppCompatActivity() {
fun bind(item : Item) { fun bind(item : Item) {
tvTitle.setText(item.titleId) tvTitle.setText(item.titleId)
vg(tvDesc, item.descId != null) val descId = item.descId ?: 0
item.descId?.let { tvDesc.setText(it) } tvDesc.vg(descId != 0)?.setText(descId)
} }
} }

View File

@ -163,13 +163,15 @@ class ActHighlightWordList : AppCompatActivity(), View.OnClickListener {
?: getAttributeColor(this@ActHighlightWordList, android.R.attr.textColorPrimary) ?: getAttributeColor(this@ActHighlightWordList, android.R.attr.textColorPrimary)
) )
vg(btnSound, item.sound_type != HighlightWord.SOUND_TYPE_NONE) btnSound.vg(item.sound_type != HighlightWord.SOUND_TYPE_NONE)?.apply{
btnSound.setOnClickListener(this) setOnClickListener(this@MyViewHolder)
btnSound.tag = item tag = item
}
vg(ivSpeech,item.speech != 0 ) ivSpeech.vg(item.speech != 0 )?.apply{
ivSpeech.setOnClickListener(this) setOnClickListener(this@MyViewHolder)
ivSpeech.tag = item tag = item
}
} }
// @Override // @Override

View File

@ -119,7 +119,7 @@ class ActMain : AppCompatActivity()
var acct_font_size_sp = Float.NaN var acct_font_size_sp = Float.NaN
var notification_tl_font_size_sp = Float.NaN var notification_tl_font_size_sp = Float.NaN
var header_text_size_sp = Float.NaN var header_text_size_sp = Float.NaN
var timeline_spacing:Float? = null var timeline_spacing : Float? = null
var avatarIconSize : Int = 0 var avatarIconSize : Int = 0
var notificationTlIconSize : Int = 0 var notificationTlIconSize : Int = 0
@ -190,14 +190,14 @@ class ActMain : AppCompatActivity()
val cancel_follow_request_complete_callback : EmptyCallback = { val cancel_follow_request_complete_callback : EmptyCallback = {
showToast(this@ActMain, false, R.string.follow_request_cancelled) showToast(this@ActMain, false, R.string.follow_request_cancelled)
} }
val favourite_complete_callback : EmptyCallback = { val favourite_complete_callback : EmptyCallback = {
showToast(this@ActMain, false, R.string.favourite_succeeded) showToast(this@ActMain, false, R.string.favourite_succeeded)
} }
val unfavourite_complete_callback : EmptyCallback = { val unfavourite_complete_callback : EmptyCallback = {
showToast(this@ActMain, false, R.string.unfavourite_succeeded) showToast(this@ActMain, false, R.string.unfavourite_succeeded)
} }
val bookmark_complete_callback : EmptyCallback = { val bookmark_complete_callback : EmptyCallback = {
showToast(this@ActMain, false, R.string.bookmark_succeeded) showToast(this@ActMain, false, R.string.bookmark_succeeded)
} }
@ -441,8 +441,8 @@ class ActMain : AppCompatActivity()
notification_tl_font_size_sp = Pref.fpNotificationTlFontSize(pref).clipFontSize() notification_tl_font_size_sp = Pref.fpNotificationTlFontSize(pref).clipFontSize()
header_text_size_sp = Pref.fpHeaderTextSize(pref).clipFontSize() header_text_size_sp = Pref.fpHeaderTextSize(pref).clipFontSize()
val fv = Pref.spTimelineSpacing(pref).toFloatOrNull() val fv = Pref.spTimelineSpacing(pref).toFloatOrNull()
timeline_spacing = if(fv!=null && fv.isFinite() && fv!=0f) fv else null timeline_spacing = if(fv != null && fv.isFinite() && fv != 0f) fv else null
initUI() initUI()
@ -492,7 +492,7 @@ class ActMain : AppCompatActivity()
override fun onConfigurationChanged(newConfig : Configuration) { override fun onConfigurationChanged(newConfig : Configuration) {
log.d("onConfigurationChanged") log.d("onConfigurationChanged")
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
if(newConfig.screenHeightDp > 0 || newConfig.screenHeightDp >0){ if(newConfig.screenHeightDp > 0 || newConfig.screenHeightDp > 0) {
tabOnly { env -> resizeColumnWidth(env) } tabOnly { env -> resizeColumnWidth(env) }
} }
} }
@ -1019,7 +1019,7 @@ class ActMain : AppCompatActivity()
REQUEST_CODE_COLUMN_COLOR -> if(data != null) { REQUEST_CODE_COLUMN_COLOR -> if(data != null) {
app_state.saveColumnList() app_state.saveColumnList()
val idx = data.getIntExtra(ActColumnCustomize.EXTRA_COLUMN_INDEX, 0) val idx = data.getIntExtra(ActColumnCustomize.EXTRA_COLUMN_INDEX, 0)
if(idx in app_state.column_list.indices ) { if(idx in app_state.column_list.indices) {
app_state.column_list[idx].fireColumnColor() app_state.column_list[idx].fireColumnColor()
app_state.column_list[idx].fireShowContent( app_state.column_list[idx].fireShowContent(
reason = "ActMain column color changed", reason = "ActMain column color changed",
@ -1028,11 +1028,11 @@ class ActMain : AppCompatActivity()
} }
updateColumnStrip() updateColumnStrip()
} }
REQUEST_CODE_LANGUAGE_FILTER -> if(data != null) { REQUEST_CODE_LANGUAGE_FILTER -> if(data != null) {
app_state.saveColumnList() app_state.saveColumnList()
val idx = data.getIntExtra(ActLanguageFilter.EXTRA_COLUMN_INDEX, 0) val idx = data.getIntExtra(ActLanguageFilter.EXTRA_COLUMN_INDEX, 0)
if(idx in app_state.column_list.indices ) { if(idx in app_state.column_list.indices) {
app_state.column_list[idx].onLanguageFilterChanged() app_state.column_list[idx].onLanguageFilterChanged()
} }
} }
@ -1465,7 +1465,7 @@ class ActMain : AppCompatActivity()
) )
internal fun updateColumnStrip() { internal fun updateColumnStrip() {
vg(llEmpty, app_state.column_list.isEmpty()) llEmpty.vg(app_state.column_list.isEmpty())
val iconSize = stripIconSize val iconSize = stripIconSize
val rootW = (iconSize * 1.25f + 0.5f).toInt() val rootW = (iconSize * 1.25f + 0.5f).toInt()
@ -1746,7 +1746,7 @@ class ActMain : AppCompatActivity()
if(dataIdString != null) { if(dataIdString != null) {
try { try {
val dataId = dataIdString.toLong(10) val dataId = dataIdString.toLong(10)
val type = uri.getQueryParameter("type")?:"" val type = uri.getQueryParameter("type") ?: ""
val account = SavedAccount.loadAccount(this@ActMain, dataId) val account = SavedAccount.loadAccount(this@ActMain, dataId)
if(account != null) { if(account != null) {
var column = app_state.column_list.firstOrNull { var column = app_state.column_list.firstOrNull {
@ -1771,7 +1771,7 @@ class ActMain : AppCompatActivity()
column.startLoading() column.startLoading()
} }
PollingWorker.queueNotificationClicked(this, dataId,type) PollingWorker.queueNotificationClicked(this, dataId, type)
} }
} catch(ex : Throwable) { } catch(ex : Throwable) {
@ -2846,10 +2846,10 @@ class ActMain : AppCompatActivity()
if(! timeline_font_size_sp.isNaN()) { if(! timeline_font_size_sp.isNaN()) {
tv.textSize = timeline_font_size_sp tv.textSize = timeline_font_size_sp
} }
val fv = timeline_spacing val fv = timeline_spacing
if( fv != null) tv.setLineSpacing(0f,fv) if(fv != null) tv.setLineSpacing(0f, fv)
tv.typeface = timeline_font tv.typeface = timeline_font
tv.text = text tv.text = text
tv.measure( tv.measure(

View File

@ -361,7 +361,7 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private fun loadVideo(ta : TootAttachment, state : Bundle? = null) { private fun loadVideo(ta : TootAttachment, state : Bundle? = null) {
vg(cbMute,true) cbMute.vg(true)
if(cbMute.isChecked && lastVolume.isFinite() ) { if(cbMute.isChecked && lastVolume.isFinite() ) {
exoPlayer.volume = 0f exoPlayer.volume = 0f
} }

View File

@ -1394,13 +1394,13 @@ class ActPost : AppCompatActivity(),
val account = account val account = account
if(account == null || account.isPseudo) { if(account == null || account.isPseudo) {
vg(btnFeaturedTag, false) btnFeaturedTag.vg(false)
return return
} }
val cache = featuredTagCache[account.acct] val cache = featuredTagCache[account.acct]
vg(btnFeaturedTag, cache?.list?.isNotEmpty() == true) btnFeaturedTag.vg(cache?.list?.isNotEmpty() == true)
val now = SystemClock.elapsedRealtime() val now = SystemClock.elapsedRealtime()
if(cache != null && now - cache.time <= 300000L) return if(cache != null && now - cache.time <= 300000L) return
@ -1611,7 +1611,7 @@ class ActPost : AppCompatActivity(),
if(isFinishing) return if(isFinishing) return
vg(llAttachment, attachment_list.isNotEmpty()) llAttachment.vg(attachment_list.isNotEmpty())
ivMedia.forEachIndexed { i, v -> showAttachment_sub(v, i) } ivMedia.forEachIndexed { i, v -> showAttachment_sub(v, i) }
} }
@ -3058,10 +3058,10 @@ class ActPost : AppCompatActivity(),
private fun showEnquete() { private fun showEnquete() {
val i = spEnquete.selectedItemPosition val i = spEnquete.selectedItemPosition
vg(llEnquete, i != 0) llEnquete.vg(i != 0)
vg(llExpire, i == 1) llExpire.vg(i == 1)
vg(cbHideTotals, i == 1) cbHideTotals.vg(i == 1)
vg(cbMultipleChoice, i == 1) cbMultipleChoice.vg(i == 1)
} }
private val commitContentListener = private val commitContentListener =

View File

@ -584,41 +584,41 @@ class ColumnViewHolder(
etSearch.setText(column.search_query) etSearch.setText(column.search_query)
cbResolve.isCheckedNoAnime = column.search_resolve cbResolve.isCheckedNoAnime = column.search_resolve
vg(cbWithAttachment, bAllowFilter) cbWithAttachment.vg(bAllowFilter)
vg(cbWithHighlight, bAllowFilter) cbWithHighlight.vg(bAllowFilter)
vg(etRegexFilter, bAllowFilter) etRegexFilter.vg(bAllowFilter)
vg(llRegexFilter, bAllowFilter) llRegexFilter.vg(bAllowFilter)
vg(btnLanguageFilter,bAllowFilter) btnLanguageFilter.vg(bAllowFilter)
vg(cbDontShowBoost, column.canFilterBoost()) cbDontShowBoost.vg(column.canFilterBoost())
vg(cbDontShowReply, column.canFilterReply()) cbDontShowReply.vg(column.canFilterReply())
vg(cbDontShowNormalToot, column.canFilterNormalToot()) cbDontShowNormalToot.vg(column.canFilterNormalToot())
vg(cbDontShowReaction, isNotificationColumn && column.isMisskey) cbDontShowReaction.vg(isNotificationColumn && column.isMisskey)
vg(cbDontShowVote, isNotificationColumn) cbDontShowVote.vg(isNotificationColumn)
vg(cbDontShowFavourite, isNotificationColumn && ! column.isMisskey) cbDontShowFavourite.vg(isNotificationColumn && ! column.isMisskey)
vg(cbDontShowFollow, isNotificationColumn) cbDontShowFollow.vg(isNotificationColumn)
vg(cbInstanceLocal, column.type == ColumnType.HASHTAG) cbInstanceLocal.vg(column.type == ColumnType.HASHTAG)
vg(cbDontStreaming, column.canStreaming()) cbDontStreaming.vg(column.canStreaming())
vg(cbDontAutoRefresh, column.canAutoRefresh()) cbDontAutoRefresh.vg(column.canAutoRefresh())
vg(cbHideMediaDefault, column.canNSFWDefault()) cbHideMediaDefault.vg(column.canNSFWDefault())
vg(cbSystemNotificationNotRelated, column.isNotificationColumn) cbSystemNotificationNotRelated.vg(column.isNotificationColumn)
vg(cbEnableSpeech, column.canSpeech()) cbEnableSpeech.vg(column.canSpeech())
vg(cbOldApi, column.type == ColumnType.DIRECT_MESSAGES) cbOldApi.vg(column.type == ColumnType.DIRECT_MESSAGES)
vg(btnDeleteNotification, column.isNotificationColumn) btnDeleteNotification.vg(column.isNotificationColumn)
if(vg(llSearch, column.isSearchColumn)) { if(llSearch.vg(column.isSearchColumn) != null) {
vg(btnSearchClear, Pref.bpShowSearchClear(activity.pref)) btnSearchClear.vg(Pref.bpShowSearchClear(activity.pref))
} }
vg(llListList, column.type == ColumnType.LIST_LIST) llListList.vg(column.type == ColumnType.LIST_LIST)
vg(cbResolve, column.type == ColumnType.SEARCH) cbResolve.vg(column.type == ColumnType.SEARCH)
vg(llHashtagExtra, column.hasHashtagExtra()) llHashtagExtra.vg(column.hasHashtagExtra())
etHashtagExtraAny.setText(column.hashtag_any) etHashtagExtraAny.setText(column.hashtag_any)
etHashtagExtraAll.setText(column.hashtag_all) etHashtagExtraAll.setText(column.hashtag_all)
etHashtagExtraNone.setText(column.hashtag_none) etHashtagExtraNone.setText(column.hashtag_none)
@ -1033,7 +1033,7 @@ class ColumnViewHolder(
ActColumnCustomize.open(activity, idx, ActMain.REQUEST_CODE_COLUMN_COLOR) ActColumnCustomize.open(activity, idx, ActMain.REQUEST_CODE_COLUMN_COLOR)
} }
btnLanguageFilter ->{ btnLanguageFilter -> {
val idx = activity.app_state.column_list.indexOf(column) val idx = activity.app_state.column_list.indexOf(column)
ActLanguageFilter.open(activity, idx, ActMain.REQUEST_CODE_LANGUAGE_FILTER) ActLanguageFilter.open(activity, idx, ActMain.REQUEST_CODE_LANGUAGE_FILTER)
} }
@ -1459,12 +1459,10 @@ class ColumnViewHolder(
private fun showQuickFilter() { private fun showQuickFilter() {
val column = this.column ?: return val column = this.column ?: return
val isNotificationColumn = column.isNotificationColumn svQuickFilter.vg(column.isNotificationColumn) ?: return
vg(svQuickFilter, isNotificationColumn)
if(! isNotificationColumn) return
vg(btnQuickFilterReaction, column.isMisskey) btnQuickFilterReaction.vg(column.isMisskey)
vg(btnQuickFilterFavourite, ! column.isMisskey) btnQuickFilterFavourite.vg(! column.isMisskey)
val insideColumnSetting = Pref.bpMoveNotificationsQuickFilter(activity.pref) val insideColumnSetting = Pref.bpMoveNotificationsQuickFilter(activity.pref)
@ -1577,7 +1575,7 @@ class ColumnViewHolder(
lp.width = matchParent lp.width = matchParent
lp.height = matchParent lp.height = matchParent
if(lp is ViewGroup.MarginLayoutParams) { if(lp is ViewGroup.MarginLayoutParams) {
lp.setMargins(0,0,0,0) lp.setMargins(0, 0, 0, 0)
} }
layoutParams = lp layoutParams = lp
} }
@ -1884,7 +1882,7 @@ class ColumnViewHolder(
isAllCaps = false isAllCaps = false
text = context.getString(R.string.language_filter) text = context.getString(R.string.language_filter)
}.lparams(matchParent, wrapContent) }.lparams(matchParent, wrapContent)
} }
} // end of column setting scroll view } // end of column setting scroll view

View File

@ -304,16 +304,15 @@ internal class DlgContextMenu(
addLinkButton(tag, href) addLinkButton(tag, href)
} }
} }
vg(llLinks, llLinks.childCount > 1) llLinks.vg(llLinks.childCount > 1)
vg(btnYourToot, status_by_me) btnYourToot.vg(status_by_me)
vg(btnBoostWithVisibility, ! access_info.isPseudo && ! access_info.isMisskey) btnBoostWithVisibility.vg(! access_info.isPseudo && ! access_info.isMisskey)
btnReportStatus.visibility = btnReportStatus.vg(! (status_by_me || access_info.isPseudo))
if(status_by_me || access_info.isPseudo) View.GONE else View.VISIBLE
val application_name = status.application?.name val application_name = status.application?.name
if(status_by_me || application_name == null || application_name.isEmpty()) { if(status_by_me || application_name == null || application_name.isEmpty()) {
@ -323,8 +322,8 @@ internal class DlgContextMenu(
} }
val canPin = status.canPin(access_info) val canPin = status.canPin(access_info)
vg(btnProfileUnpin, canPin && status.pinned) btnProfileUnpin.vg(canPin && status.pinned)
vg(btnProfilePin, canPin && ! status.pinned) btnProfilePin.vg(canPin && ! status.pinned)
} }
val bShowConversationMute = when { val bShowConversationMute = when {
@ -334,17 +333,20 @@ internal class DlgContextMenu(
else -> false else -> false
} }
if(vg(btnConversationMute, bShowConversationMute)) { val muted = status?.muted ?: false
val muted = status?.muted ?: false btnConversationMute.vg(bShowConversationMute)
btnConversationMute.setText(if(muted) R.string.unmute_this_conversation else R.string.mute_this_conversation) ?.setText(
} if(muted)
R.string.unmute_this_conversation
else R.string.mute_this_conversation
)
vg(llNotification, notification != null) llNotification.vg(notification != null)
fun showRelation(relation : UserRelation) { fun showRelation(relation : UserRelation) {
// 被フォロー状態 // 被フォロー状態
// Styler.setFollowIconとは異なり細かい状態を表示しない // Styler.setFollowIconとは異なり細かい状態を表示しない
vg(ivFollowedBy, relation.followed_by) ivFollowedBy.vg(relation.followed_by)
// フォロー状態 // フォロー状態
// Styler.setFollowIconとは異なりミュートやブロックを表示しない // Styler.setFollowIconとは異なりミュートやブロックを表示しない
@ -393,7 +395,7 @@ internal class DlgContextMenu(
// 疑似アカミュートができたのでアカウントアクションを表示する // 疑似アカミュートができたのでアカウントアクションを表示する
showRelation(UserRelation()) showRelation(UserRelation())
llAccountActionBar.visibility = View.VISIBLE llAccountActionBar.visibility = View.VISIBLE
vg(ivFollowedBy, false) ivFollowedBy.vg(false)
btnFollow.setImageResource(R.drawable.ic_follow_plus) btnFollow.setImageResource(R.drawable.ic_follow_plus)
btnFollow.imageTintList = btnFollow.imageTintList =
ColorStateList.valueOf(getAttributeColor(activity, R.attr.colorImageButton)) ColorStateList.valueOf(getAttributeColor(activity, R.attr.colorImageButton))
@ -405,19 +407,17 @@ internal class DlgContextMenu(
val who_host = getUserHost() val who_host = getUserHost()
val llInstance : View = viewRoot.findViewById(R.id.llInstance) val llInstance : View = viewRoot.findViewById(R.id.llInstance)
if(vg(llInstance, ! (who_host.isEmpty() || who_host == "?"))) { if(llInstance.vg(! (who_host.isEmpty() || who_host == "?")) != null) {
val tvInstanceActions : TextView = viewRoot.findViewById(R.id.tvInstanceActions) val tvInstanceActions : TextView = viewRoot.findViewById(R.id.tvInstanceActions)
tvInstanceActions.text = activity.getString(R.string.instance_actions_for, who_host) tvInstanceActions.text = activity.getString(R.string.instance_actions_for, who_host)
// 疑似アカウントではドメインブロックできない // 疑似アカウントではドメインブロックできない
// 自ドメインはブロックできない // 自ドメインはブロックできない
vg( btnDomainBlock.vg(
btnDomainBlock,
! (access_info.isPseudo || access_info.host.equals(who_host, ignoreCase = true)) ! (access_info.isPseudo || access_info.host.equals(who_host, ignoreCase = true))
) )
vg( btnDomainTimeline.vg(
btnDomainTimeline,
Pref.bpEnableDomainTimeline(activity.pref) && Pref.bpEnableDomainTimeline(activity.pref) &&
! access_info.isPseudo && ! access_info.isPseudo &&
! access_info.isMisskey ! access_info.isMisskey
@ -436,12 +436,10 @@ internal class DlgContextMenu(
btnCopyAccountId.visibility = View.VISIBLE btnCopyAccountId.visibility = View.VISIBLE
btnCopyAccountId.text = activity.getString(R.string.copy_account_id, who.id.toString()) btnCopyAccountId.text = activity.getString(R.string.copy_account_id, who.id.toString())
vg(btnOpenAccountInAdminWebUi, ! access_info.isPseudo) btnOpenAccountInAdminWebUi.vg(! access_info.isPseudo)
vg(btnOpenInstanceInAdminWebUi, ! access_info.isPseudo) btnOpenInstanceInAdminWebUi.vg(! access_info.isPseudo)
btnReportUser.visibility =
if(access_info.isPseudo || access_info.isMe(who)) View.GONE else View.VISIBLE
btnReportUser.vg(! (access_info.isPseudo || access_info.isMe(who)))
} }
viewRoot.findViewById<View>(R.id.btnAccountText).setOnClickListener(this) viewRoot.findViewById<View>(R.id.btnAccountText).setOnClickListener(this)
@ -539,17 +537,17 @@ internal class DlgContextMenu(
private fun updateGroup(btn : Button, group : View, toggle : Boolean = false) { private fun updateGroup(btn : Button, group : View, toggle : Boolean = false) {
if(btn.visibility != View.VISIBLE) { if(btn.visibility != View.VISIBLE) {
vg(group, false) group.vg(false)
return return
} }
when { when {
Pref.bpAlwaysExpandContextMenuItems(activity.pref) -> { Pref.bpAlwaysExpandContextMenuItems(activity.pref) -> {
vg(group, true) group.vg(true)
btn.background = null btn.background = null
} }
toggle -> vg(group, group.visibility != View.VISIBLE) toggle -> group.vg(group.visibility != View.VISIBLE)
else -> btn.setOnClickListener(this) else -> btn.setOnClickListener(this)
} }

View File

@ -309,7 +309,7 @@ internal class ItemViewHolder(
this.follow_invalidator = NetworkEmojiInvalidator(activity.handler, tvFollowerName) this.follow_invalidator = NetworkEmojiInvalidator(activity.handler, tvFollowerName)
this.name_invalidator = NetworkEmojiInvalidator(activity.handler, tvName) this.name_invalidator = NetworkEmojiInvalidator(activity.handler, tvName)
this.lastActive_invalidator = NetworkEmojiInvalidator(activity.handler, tvLastStatusAt) this.lastActive_invalidator = NetworkEmojiInvalidator(activity.handler, tvLastStatusAt)
val cardBackground = llCardOuter.background val cardBackground = llCardOuter.background
if(cardBackground is PreviewCardBorder) { if(cardBackground is PreviewCardBorder) {
val density = activity.density val density = activity.density
@ -1151,8 +1151,7 @@ internal class ItemViewHolder(
setAcct(tvFollowerAcct, access_info.getFullAcct(who), who.acct) setAcct(tvFollowerAcct, access_info.getFullAcct(who), who.acct)
who.setAccountExtra(access_info,tvLastStatusAt,lastActive_invalidator ) who.setAccountExtra(access_info, tvLastStatusAt, lastActive_invalidator)
val relation = UserRelation.load(access_info.db_id, who.id) val relation = UserRelation.load(access_info.db_id, who.id)
Styler.setFollowIcon( Styler.setFollowIcon(
@ -1175,14 +1174,16 @@ internal class ItemViewHolder(
private fun showStatus(status : TootStatus, colorBg : Int = 0) { private fun showStatus(status : TootStatus, colorBg : Int = 0) {
val filteredWord = status.filteredWord val filteredWord = status.filteredWord
if(filteredWord != null ) { if(filteredWord != null) {
showMessageHolder(TootMessageHolder( showMessageHolder(
if(Pref.bpShowFilteredWord(activity.pref)){ TootMessageHolder(
"${activity.getString(R.string.filtered)} / $filteredWord" if(Pref.bpShowFilteredWord(activity.pref)) {
}else{ "${activity.getString(R.string.filtered)} / $filteredWord"
activity.getString(R.string.filtered) } else {
} activity.getString(R.string.filtered)
)) }
)
)
return return
} }
@ -1368,26 +1369,11 @@ internal class ItemViewHolder(
makeReactionsView(status) makeReactionsView(status)
buttons_for_status?.bind(status, (item as? TootNotification)) buttons_for_status?.bind(status, (item as? TootNotification))
var sb :StringBuilder? = null
fun prepareSb() :StringBuilder{ var sb : StringBuilder? = null
var x = sb
if( x == null){
x = StringBuilder()
sb = x
}else{
x.append(", ")
}
return x
}
val language = status.language fun prepareSb() : StringBuilder =
if( language != null && sb?.append(", ") ?: StringBuilder().also { sb = it }
(column.type == ColumnType.CONVERSATION || Pref.bpShowLanguage(activity.pref))
){
prepareSb().append(activity.getString(R.string.language_is,language))
}
val application = status.application val application = status.application
if(application != null && if(application != null &&
@ -1396,13 +1382,14 @@ internal class ItemViewHolder(
prepareSb().append(activity.getString(R.string.application_is, application.name ?: "")) prepareSb().append(activity.getString(R.string.application_is, application.name ?: ""))
} }
if(sb != null) { val language = status.language
tvApplication.visibility = View.VISIBLE if(language != null &&
tvApplication.text = sb (column.type == ColumnType.CONVERSATION || Pref.bpShowLanguage(activity.pref))
}else{ ) {
tvApplication.visibility = View.GONE prepareSb().append(activity.getString(R.string.language_is, language))
} }
tvApplication.vg(sb != null)?.text = sb
} }
private fun showInstanceTicker(who : TootAccount) { private fun showInstanceTicker(who : TootAccount) {

View File

@ -200,8 +200,8 @@ internal class StatusButtons(
// ブックマークボタン // ブックマークボタン
when { when {
!Pref.bpShowBookmarkButton(activity.pref) -> vg(btnBookmark,false) ! Pref.bpShowBookmarkButton(activity.pref) -> btnBookmark.vg(false)
activity.app_state.isBusyBookmark(access_info, status) -> setButton( activity.app_state.isBusyBookmark(access_info, status) -> setButton(
btnBookmark, btnBookmark,
false, false,
@ -242,16 +242,16 @@ internal class StatusButtons(
var optionalButtonFirst : View? = null var optionalButtonFirst : View? = null
var optionalButtonCount = 0 var optionalButtonCount = 0
fun showCustomShare(target : CustomShareTarget, b : ImageButton) { fun ImageButton.showCustomShare(target : CustomShareTarget) {
val (label, icon) = CustomShare.getCache(target) val (label, icon) = CustomShare.getCache(target)
?: error("showCustomShare: invalid target") ?: error("showCustomShare: invalid target")
if(vg(b, label != null || icon != null)) { vg(label != null || icon != null)?.apply {
b.isEnabled = true isEnabled = true
b.contentDescription = label ?: "?" contentDescription = label ?: "?"
b.setImageDrawable( setImageDrawable(
icon ?: createColoredDrawable( icon ?: createColoredDrawable(
activity, this@StatusButtons.activity,
R.drawable.ic_question, R.drawable.ic_question,
color_normal, color_normal,
Styler.boost_alpha Styler.boost_alpha
@ -259,18 +259,17 @@ internal class StatusButtons(
) )
++ optionalButtonCount ++ optionalButtonCount
if(optionalButtonFirst == null) { if(optionalButtonFirst == null) {
optionalButtonFirst = b optionalButtonFirst = this
} }
} }
} }
btnTranslate.vg(Pref.bpShowTranslateButton(activity.pref))
?.showCustomShare(CustomShareTarget.Translate)
if(vg(btnTranslate, Pref.bpShowTranslateButton(activity.pref))) { btnCustomShare1.showCustomShare(CustomShareTarget.CustomShare1)
showCustomShare(CustomShareTarget.Translate, btnTranslate) btnCustomShare2.showCustomShare(CustomShareTarget.CustomShare2)
} btnCustomShare3.showCustomShare(CustomShareTarget.CustomShare3)
showCustomShare(CustomShareTarget.CustomShare1, btnCustomShare1)
showCustomShare(CustomShareTarget.CustomShare2, btnCustomShare2)
showCustomShare(CustomShareTarget.CustomShare3, btnCustomShare3)
val lpConversation = btnConversation.layoutParams as? FlexboxLayout.LayoutParams val lpConversation = btnConversation.layoutParams as? FlexboxLayout.LayoutParams
val updateAdditionalButton : (btn : ImageButton) -> Unit val updateAdditionalButton : (btn : ImageButton) -> Unit

View File

@ -71,7 +71,7 @@ internal class ViewHolderHeaderProfile(
ivBackground = viewRoot.findViewById(R.id.ivBackground) ivBackground = viewRoot.findViewById(R.id.ivBackground)
llProfile = viewRoot.findViewById(R.id.llProfile) llProfile = viewRoot.findViewById(R.id.llProfile)
tvCreated = viewRoot.findViewById(R.id.tvCreated) tvCreated = viewRoot.findViewById(R.id.tvCreated)
tvLastStatusAt= viewRoot.findViewById(R.id.tvLastStatusAt) tvLastStatusAt = viewRoot.findViewById(R.id.tvLastStatusAt)
ivAvatar = viewRoot.findViewById(R.id.ivAvatar) ivAvatar = viewRoot.findViewById(R.id.ivAvatar)
tvDisplayName = viewRoot.findViewById(R.id.tvDisplayName) tvDisplayName = viewRoot.findViewById(R.id.tvDisplayName)
tvAcct = viewRoot.findViewById(R.id.tvAcct) tvAcct = viewRoot.findViewById(R.id.tvAcct)
@ -150,7 +150,7 @@ internal class ViewHolderHeaderProfile(
} }
val spacing = activity.timeline_spacing val spacing = activity.timeline_spacing
if( spacing != null) { if(spacing != null) {
tvMovedName.setLineSpacing(0f, spacing) tvMovedName.setLineSpacing(0f, spacing)
tvMoved.setLineSpacing(0f, spacing) tvMoved.setLineSpacing(0f, spacing)
} }
@ -200,7 +200,7 @@ internal class ViewHolderHeaderProfile(
if(who == null) { if(who == null) {
tvCreated.text = "" tvCreated.text = ""
vg(tvLastStatusAt,false) tvLastStatusAt.vg(false)
ivBackground.setImageDrawable(null) ivBackground.setImageDrawable(null)
ivAvatar.setImageDrawable(null) ivAvatar.setImageDrawable(null)
@ -223,7 +223,12 @@ internal class ViewHolderHeaderProfile(
tvCreated.text = tvCreated.text =
TootStatus.formatTime(tvCreated.context, (whoDetail ?: who).time_created_at, true) TootStatus.formatTime(tvCreated.context, (whoDetail ?: who).time_created_at, true)
who.setAccountExtra(access_info,tvLastStatusAt,invalidator = null,fromProfileHeader = true) who.setAccountExtra(
access_info,
tvLastStatusAt,
invalidator = null,
fromProfileHeader = true
)
ivBackground.setImageUrl( ivBackground.setImageUrl(
activity.pref, activity.pref,
@ -266,7 +271,7 @@ internal class ViewHolderHeaderProfile(
append(" ") append(" ")
val info = EmojiMap.sShortNameToEmojiInfo["lock"] val info = EmojiMap.sShortNameToEmojiInfo["lock"]
if(info != null) { if(info != null) {
appendSpan("locked",info.er.createSpan(activity)) appendSpan("locked", info.er.createSpan(activity))
} else { } else {
append("locked") append("locked")
} }
@ -317,14 +322,17 @@ internal class ViewHolderHeaderProfile(
append(s) append(s)
} }
} }
vg(tvMisskeyExtra, tvMisskeyExtra.text.isNotEmpty()) tvMisskeyExtra.vg(tvMisskeyExtra.text.isNotEmpty())
btnStatusCount.text = activity.getString(R.string.statuses) + "\n" + btnStatusCount.text =
(whoDetail?.statuses_count ?: who.statuses_count) "${activity.getString(R.string.statuses)}\n${whoDetail?.statuses_count
btnFollowing.text = activity.getString(R.string.following) + "\n" + ?: who.statuses_count}"
(whoDetail?.following_count ?: who.following_count) btnFollowing.text =
btnFollowers.text = activity.getString(R.string.followers) + "\n" + "${activity.getString(R.string.following)}\n${whoDetail?.following_count
(whoDetail?.followers_count ?: who.followers_count) ?: who.following_count}"
btnFollowers.text =
"${activity.getString(R.string.followers)}\n${whoDetail?.followers_count
?: who.followers_count}"
val relation = UserRelation.load(access_info.db_id, who.id) val relation = UserRelation.load(access_info.db_id, who.id)
Styler.setFollowIcon( Styler.setFollowIcon(

View File

@ -116,7 +116,7 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
init { init {
this.json = src this.json = src
var sv : String? var sv : String?
if(parser.serviceType == ServiceType.MISSKEY) { if(parser.serviceType == ServiceType.MISSKEY) {
@ -386,9 +386,9 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
fun setAccountExtra( fun setAccountExtra(
accessInfo : SavedAccount, accessInfo : SavedAccount,
tv : TextView, tv : TextView,
invalidator: NetworkEmojiInvalidator?, invalidator : NetworkEmojiInvalidator?,
fromProfileHeader : Boolean = false fromProfileHeader : Boolean = false
):SpannableStringBuilder? { ) : SpannableStringBuilder? {
val pref = App1.pref val pref = App1.pref
val context = tv.context val context = tv.context
@ -441,13 +441,13 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
} }
} }
if(vg(tv, sb != null)) { tv.vg(sb != null)
tv.text = sb ?.apply {
tv.movementMethod = MyLinkMovementMethod text = sb
invalidator?.register(sb) movementMethod = MyLinkMovementMethod
}else{ invalidator?.register(sb)
invalidator?.clear() }
} ?: invalidator?.clear()
return sb return sb
} }
@ -496,11 +496,10 @@ open class TootAccount(parser : TootParser, src : JSONObject) {
return "$user@$host" return "$user@$host"
} }
return null return null
} }
private fun parseSource(src : JSONObject?) : Source? { private fun parseSource(src : JSONObject?) : Source? {
src ?: return null src ?: return null
return try { return try {

View File

@ -59,8 +59,8 @@ object DlgCreateAccount {
).neatSpaces() ).neatSpaces()
val showReason = instanceInfo?.approval_required ?: false val showReason = instanceInfo?.approval_required ?: false
vg(tvReasonCaption, showReason) tvReasonCaption.vg(showReason)
vg(etReason, showReason) etReason.vg(showReason)
val listener : View.OnClickListener = View.OnClickListener { v -> val listener : View.OnClickListener = View.OnClickListener { v ->
when(v.id) { when(v.id) {

View File

@ -62,9 +62,9 @@ fun View.showKeyboard() {
// set visibility VISIBLE or GONE // set visibility VISIBLE or GONE
// return true if visible // return true if visible
fun vg(v : View, visible : Boolean) : Boolean { fun <T : View> T?.vg(visible : Boolean) : T? {
v.visibility = if(visible) View.VISIBLE else View.GONE this?.visibility = if(visible) View.VISIBLE else View.GONE
return visible return if(visible) this else null
} }
fun ViewGroup.generateLayoutParamsEx() : ViewGroup.LayoutParams? = fun ViewGroup.generateLayoutParamsEx() : ViewGroup.LayoutParams? =