1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-02-07 06:04:23 +01:00
This commit is contained in:
tateisu 2019-10-05 22:27:12 +09:00
parent 86efd2a62b
commit 2919953707
6 changed files with 221 additions and 203 deletions

View File

@ -33,7 +33,7 @@ import java.util.regex.Pattern
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
class ColumnViewHolder( class ColumnViewHolder(
val activity : ActMain, val activity : ActMain,
parent:ViewGroup parent : ViewGroup
) : View.OnClickListener, ) : View.OnClickListener,
SwipyRefreshLayout.OnRefreshListener, SwipyRefreshLayout.OnRefreshListener,
CompoundButton.OnCheckedChangeListener, View.OnLongClickListener { CompoundButton.OnCheckedChangeListener, View.OnLongClickListener {
@ -69,7 +69,6 @@ class ColumnViewHolder(
lateinit var listLayoutManager : LinearLayoutManager lateinit var listLayoutManager : LinearLayoutManager
private lateinit var llColumnHeader : View private lateinit var llColumnHeader : View
private lateinit var tvColumnIndex : TextView private lateinit var tvColumnIndex : TextView
private lateinit var tvColumnStatus : TextView private lateinit var tvColumnStatus : TextView
@ -253,7 +252,8 @@ class ColumnViewHolder(
tvLoading.setOnTouchListener(ErrorFlickListener(activity)) tvLoading.setOnTouchListener(ErrorFlickListener(activity))
} }
val viewRoot : View = inflate(activity,parent) val viewRoot : View = inflate(activity, parent)
init { init {
viewRoot.scan { v -> viewRoot.scan { v ->
@ -266,7 +266,7 @@ class ColumnViewHolder(
log.trace(ex) log.trace(ex)
} }
} }
if(Pref.bpShareViewPool(activity.pref)) { if(Pref.bpShareViewPool(activity.pref)) {
@ -279,8 +279,6 @@ class ColumnViewHolder(
// animator.supportsChangeAnimations = false // animator.supportsChangeAnimations = false
// } // }
btnListAdd.setOnClickListener(this) btnListAdd.setOnClickListener(this)
etListName.setOnEditorActionListener { _, actionId, _ -> etListName.setOnEditorActionListener { _, actionId, _ ->
@ -310,7 +308,7 @@ class ColumnViewHolder(
btnColumnClose.setOnLongClickListener(this) btnColumnClose.setOnLongClickListener(this)
btnDeleteNotification.setOnClickListener(this) btnDeleteNotification.setOnClickListener(this)
btnColor.setOnClickListener(this) btnColor.setOnClickListener(this)
refreshLayout.setOnRefreshListener(this) refreshLayout.setOnRefreshListener(this)
refreshLayout.setDistanceToTriggerSync((0.5f + 20f * activity.density).toInt()) refreshLayout.setDistanceToTriggerSync((0.5f + 20f * activity.density).toInt())
@ -559,30 +557,30 @@ class ColumnViewHolder(
val bAllowFilter = column.canStatusFilter() val bAllowFilter = column.canStatusFilter()
llColumnSetting.visibility = View.GONE llColumnSetting.visibility = View.GONE
cbDontCloseColumn.isCheckedEx = column.dont_close
cbWithAttachment.isCheckedEx = column.with_attachment cbDontCloseColumn.isCheckedNoAnime = column.dont_close
cbWithHighlight.isCheckedEx = column.with_highlight cbWithAttachment.isCheckedNoAnime = column.with_attachment
cbDontShowBoost.isCheckedEx = column.dont_show_boost cbWithHighlight.isCheckedNoAnime = column.with_highlight
cbDontShowFollow.isCheckedEx = column.dont_show_follow cbDontShowBoost.isCheckedNoAnime = column.dont_show_boost
cbDontShowFavourite.isCheckedEx = column.dont_show_favourite cbDontShowFollow.isCheckedNoAnime = column.dont_show_follow
cbDontShowReply.isCheckedEx = column.dont_show_reply cbDontShowFavourite.isCheckedNoAnime = column.dont_show_favourite
cbDontShowReaction.isCheckedEx = column.dont_show_reaction cbDontShowReply.isCheckedNoAnime = column.dont_show_reply
cbDontShowVote.isCheckedEx = column.dont_show_vote cbDontShowReaction.isCheckedNoAnime = column.dont_show_reaction
cbDontShowNormalToot.isCheckedEx = column.dont_show_normal_toot cbDontShowVote.isCheckedNoAnime = column.dont_show_vote
cbInstanceLocal.isCheckedEx = column.instance_local cbDontShowNormalToot.isCheckedNoAnime = column.dont_show_normal_toot
cbDontStreaming.isCheckedEx = column.dont_streaming cbInstanceLocal.isCheckedNoAnime = column.instance_local
cbDontAutoRefresh.isCheckedEx = column.dont_auto_refresh cbDontStreaming.isCheckedNoAnime = column.dont_streaming
cbHideMediaDefault.isCheckedEx = column.hide_media_default cbDontAutoRefresh.isCheckedNoAnime = column.dont_auto_refresh
cbSystemNotificationNotRelated.isCheckedEx = column.system_notification_not_related cbHideMediaDefault.isCheckedNoAnime = column.hide_media_default
cbEnableSpeech.isCheckedEx = column.enable_speech cbSystemNotificationNotRelated.isCheckedNoAnime = column.system_notification_not_related
cbOldApi.isCheckedEx = column.use_old_api cbEnableSpeech.isCheckedNoAnime = column.enable_speech
cbOldApi.isCheckedNoAnime = column.use_old_api
etRegexFilter.setText(column.regex_text) etRegexFilter.setText(column.regex_text)
etSearch.setText(column.search_query) etSearch.setText(column.search_query)
cbResolve.isCheckedEx = column.search_resolve cbResolve.isCheckedNoAnime = column.search_resolve
vg(cbWithAttachment, bAllowFilter) vg(cbWithAttachment, bAllowFilter)
vg(cbWithHighlight, bAllowFilter) vg(cbWithHighlight, bAllowFilter)
@ -593,7 +591,7 @@ class ColumnViewHolder(
vg(cbDontShowReply, column.canFilterReply()) vg(cbDontShowReply, column.canFilterReply())
vg(cbDontShowNormalToot, column.canFilterNormalToot()) vg(cbDontShowNormalToot, column.canFilterNormalToot())
vg(cbDontShowReaction, isNotificationColumn && column.isMisskey) vg(cbDontShowReaction, isNotificationColumn && column.isMisskey)
vg(cbDontShowVote, isNotificationColumn ) vg(cbDontShowVote, isNotificationColumn)
vg(cbDontShowFavourite, isNotificationColumn && ! column.isMisskey) vg(cbDontShowFavourite, isNotificationColumn && ! column.isMisskey)
vg(cbDontShowFollow, isNotificationColumn) vg(cbDontShowFollow, isNotificationColumn)
@ -610,10 +608,10 @@ class ColumnViewHolder(
vg(btnDeleteNotification, column.isNotificationColumn) vg(btnDeleteNotification, column.isNotificationColumn)
if( vg(llSearch, column.isSearchColumn) ){ if(vg(llSearch, column.isSearchColumn)) {
vg(btnSearchClear,Pref.bpShowSearchClear(activity.pref)) vg(btnSearchClear, Pref.bpShowSearchClear(activity.pref))
} }
vg(llListList, column.type == ColumnType.LIST_LIST) vg(llListList, column.type == ColumnType.LIST_LIST)
vg(cbResolve, column.type == ColumnType.SEARCH) vg(cbResolve, column.type == ColumnType.SEARCH)
@ -773,7 +771,7 @@ class ColumnViewHolder(
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private fun loadBackgroundImage(iv : ImageView, url : String?) { private fun loadBackgroundImage(iv : ImageView, url : String?) {
try { try {
if(url == null || url.isEmpty() || Pref.bpDontShowColumnBackgroundImage(activity.pref) ) { if(url == null || url.isEmpty() || Pref.bpDontShowColumnBackgroundImage(activity.pref)) {
// 指定がないなら閉じる // 指定がないなら閉じる
closeBitmaps() closeBitmaps()
return return
@ -994,7 +992,7 @@ class ColumnViewHolder(
if(column.isSearchColumn) { if(column.isSearchColumn) {
etSearch.hideKeyboard() etSearch.hideKeyboard()
etSearch.setText(column.search_query) etSearch.setText(column.search_query)
cbResolve.isCheckedEx = column.search_resolve cbResolve.isCheckedNoAnime = column.search_resolve
} }
refreshLayout.isRefreshing = false refreshLayout.isRefreshing = false
column.startLoading() column.startLoading()
@ -1426,12 +1424,12 @@ class ColumnViewHolder(
try { try {
listView.stopScroll() listView.stopScroll()
} catch(ex : Throwable) { } catch(ex : Throwable) {
log.e(ex,"stopScroll failed.") log.e(ex, "stopScroll failed.")
} }
try { try {
listLayoutManager.scrollToPositionWithOffset(0, 0) listLayoutManager.scrollToPositionWithOffset(0, 0)
} catch(ex : Throwable) { } catch(ex : Throwable) {
log.e(ex,"scrollToPositionWithOffset failed.") log.e(ex, "scrollToPositionWithOffset failed.")
} }
} }
@ -1561,28 +1559,27 @@ class ColumnViewHolder(
) )
} }
private fun inflate(activity : ActMain, parent : ViewGroup) = with(activity.UI {}) {
private fun inflate(activity : ActMain,parent:ViewGroup) = with(activity.UI {}) {
val b = Benchmark(log, "Item-Inflate", 40L) val b = Benchmark(log, "Item-Inflate", 40L)
var label: TextView? = null var label : TextView? = null
val rv = verticalLayout { val rv = verticalLayout {
// トップレベルのViewGroupのlparamsはイニシャライザ内部に置くしかないみたい // トップレベルのViewGroupのlparamsはイニシャライザ内部に置くしかないみたい
val lp = parent.generateLayoutParamsEx() val lp = parent.generateLayoutParamsEx()
if( lp != null){ if(lp != null) {
lp.width = matchParent lp.width = matchParent
lp.height = matchParent lp.height = matchParent
if( lp is ViewGroup.MarginLayoutParams){ if(lp is ViewGroup.MarginLayoutParams) {
lp.marginStart = dip(8) lp.marginStart = dip(8)
lp.marginEnd = dip(8) lp.marginEnd = dip(8)
lp.topMargin = dip(2f) lp.topMargin = dip(2f)
lp.bottomMargin = dip(1f) lp.bottomMargin = dip(1f)
} }
layoutParams =lp layoutParams = lp
} }
llColumnHeader = verticalLayout { llColumnHeader = verticalLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
background = ContextCompat.getDrawable(context,R.drawable.bg_column_header) background = ContextCompat.getDrawable(context, R.drawable.bg_column_header)
startPadding = dip(12) startPadding = dip(12)
endPadding = dip(12) endPadding = dip(12)
topPadding = dip(3) topPadding = dip(3)
@ -1592,38 +1589,38 @@ class ColumnViewHolder(
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
gravity = Gravity.BOTTOM gravity = Gravity.BOTTOM
tvColumnContext = textView{ tvColumnContext = textView {
gravity = Gravity.END gravity = Gravity.END
startPadding = dip(4) startPadding = dip(4)
endPadding = dip(4) endPadding = dip(4)
textColor= getAttributeColor(context,R.attr.colorColumnHeaderAcct) textColor = getAttributeColor(context, R.attr.colorColumnHeaderAcct)
textSize = 12f textSize = 12f
}.lparams(0, wrapContent){ }.lparams(0, wrapContent) {
weight = 1f weight = 1f
} }
tvColumnStatus= textView{ tvColumnStatus = textView {
gravity = Gravity.END gravity = Gravity.END
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber) textColor = getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
textSize = 12f textSize = 12f
}.lparams(wrapContent, wrapContent){ }.lparams(wrapContent, wrapContent) {
marginStart = dip(12) marginStart = dip(12)
} }
tvColumnIndex = textView{ tvColumnIndex = textView {
gravity = Gravity.END gravity = Gravity.END
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber) textColor = getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
textSize = 12f textSize = 12f
}.lparams(wrapContent, wrapContent){ }.lparams(wrapContent, wrapContent) {
marginStart = dip(4) marginStart = dip(4)
} }
} }
linearLayout { linearLayout {
lparams(matchParent, wrapContent){ lparams(matchParent, wrapContent) {
topMargin = dip(0) topMargin = dip(0)
} }
@ -1639,14 +1636,15 @@ class ColumnViewHolder(
endMargin = dip(4) endMargin = dip(4)
} }
tvColumnName = textView{ tvColumnName = textView {
}.lparams(dip(0), wrapContent) { }.lparams(dip(0), wrapContent) {
weight =1f weight = 1f
} }
btnColumnSetting = imageButton { btnColumnSetting = imageButton {
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent) background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
contentDescription = context.getString(R.string.setting) contentDescription = context.getString(R.string.setting)
setImageResource(R.drawable.ic_tune) setImageResource(R.drawable.ic_tune)
padding = dip(8) padding = dip(8)
@ -1657,7 +1655,8 @@ class ColumnViewHolder(
} }
btnColumnReload = imageButton { btnColumnReload = imageButton {
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent) background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
contentDescription = context.getString(R.string.reload) contentDescription = context.getString(R.string.reload)
setImageResource(R.drawable.ic_refresh) setImageResource(R.drawable.ic_refresh)
padding = dip(8) padding = dip(8)
@ -1670,7 +1669,8 @@ class ColumnViewHolder(
} }
btnColumnClose = imageButton { btnColumnClose = imageButton {
background = ContextCompat.getDrawable(context,R.drawable.btn_bg_transparent) background =
ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent)
contentDescription = context.getString(R.string.close_column) contentDescription = context.getString(R.string.close_column)
setImageResource(R.drawable.ic_close) setImageResource(R.drawable.ic_close)
padding = dip(8) padding = dip(8)
@ -1684,7 +1684,7 @@ class ColumnViewHolder(
} }
} // end of column header } // end of column header
llColumnSetting = maxHeightScrollView{ llColumnSetting = maxHeightScrollView {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
isScrollbarFadingEnabled = false isScrollbarFadingEnabled = false
maxHeight = dip(240) maxHeight = dip(240)
@ -1692,276 +1692,293 @@ class ColumnViewHolder(
llColumnSettingInside = verticalLayout { llColumnSettingInside = verticalLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
backgroundColor = getAttributeColor(context,R.attr.colorColumnSettingBackground) backgroundColor =
getAttributeColor(context, R.attr.colorColumnSettingBackground)
startPadding = dip(12) startPadding = dip(12)
endPadding = dip(12) endPadding = dip(12)
topPadding = dip(3) topPadding = dip(3)
bottomPadding =dip(3) bottomPadding = dip(3)
llHashtagExtra = verticalLayout { llHashtagExtra = verticalLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
label = textView{ label = textView {
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber) textColor =
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.hashtag_extra_any) text = context.getString(R.string.hashtag_extra_any)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
etHashtagExtraAny = editText{ etHashtagExtraAny = editText {
id = View.generateViewId() id = View.generateViewId()
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
maxLines = 1 maxLines = 1
setHorizontallyScrolling(true) setHorizontallyScrolling(true)
isHorizontalScrollBarEnabled = true isHorizontalScrollBarEnabled = true
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
label?.labelFor = etHashtagExtraAny.id label?.labelFor = etHashtagExtraAny.id
label = textView { label = textView {
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber) textColor =
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.hashtag_extra_all) text = context.getString(R.string.hashtag_extra_all)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
etHashtagExtraAll = editText{ etHashtagExtraAll = editText {
id = View.generateViewId() id = View.generateViewId()
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
maxLines = 1 maxLines = 1
setHorizontallyScrolling(true) setHorizontallyScrolling(true)
isHorizontalScrollBarEnabled = true isHorizontalScrollBarEnabled = true
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
label?.labelFor = etHashtagExtraAll.id label?.labelFor = etHashtagExtraAll.id
label = textView {
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.hashtag_extra_none)
}.lparams(matchParent,wrapContent)
etHashtagExtraNone = editText{ label = textView {
textColor =
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.hashtag_extra_none)
}.lparams(matchParent, wrapContent)
etHashtagExtraNone = editText {
id = View.generateViewId() id = View.generateViewId()
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
maxLines = 1 maxLines = 1
setHorizontallyScrolling(true) setHorizontallyScrolling(true)
isHorizontalScrollBarEnabled = true isHorizontalScrollBarEnabled = true
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
label?.labelFor = etHashtagExtraNone.id label?.labelFor = etHashtagExtraNone.id
} // end of hashtag extra } // end of hashtag extra
cbDontCloseColumn = checkBox { cbDontCloseColumn = checkBox {
text = context.getString(R.string.dont_close_column) text = context.getString(R.string.dont_close_column)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbWithAttachment = checkBox { cbWithAttachment = checkBox {
text = context.getString(R.string.with_attachment) text = context.getString(R.string.with_attachment)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbWithHighlight = checkBox { cbWithHighlight = checkBox {
text = context.getString(R.string.with_highlight) text = context.getString(R.string.with_highlight)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowBoost = checkBox { cbDontShowBoost = checkBox {
text = context.getString(R.string.dont_show_boost) text = context.getString(R.string.dont_show_boost)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowFavourite = checkBox { cbDontShowFavourite = checkBox {
text = context.getString(R.string.dont_show_favourite) text = context.getString(R.string.dont_show_favourite)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowFollow = checkBox { cbDontShowFollow = checkBox {
text = context.getString(R.string.dont_show_follow) text = context.getString(R.string.dont_show_follow)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowReply = checkBox { cbDontShowReply = checkBox {
text = context.getString(R.string.dont_show_reply) text = context.getString(R.string.dont_show_reply)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowReaction = checkBox { cbDontShowReaction = checkBox {
text = context.getString(R.string.dont_show_reaction) text = context.getString(R.string.dont_show_reaction)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowVote = checkBox { cbDontShowVote = checkBox {
text = context.getString(R.string.dont_show_vote) text = context.getString(R.string.dont_show_vote)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontShowNormalToot = checkBox { cbDontShowNormalToot = checkBox {
text = context.getString(R.string.dont_show_normal_toot) text = context.getString(R.string.dont_show_normal_toot)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbInstanceLocal = checkBox { cbInstanceLocal = checkBox {
text = context.getString(R.string.instance_local) text = context.getString(R.string.instance_local)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontStreaming = checkBox { cbDontStreaming = checkBox {
text = context.getString(R.string.dont_use_streaming_api) text = context.getString(R.string.dont_use_streaming_api)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbDontAutoRefresh = checkBox { cbDontAutoRefresh = checkBox {
text = context.getString(R.string.dont_refresh_on_activity_resume) text = context.getString(R.string.dont_refresh_on_activity_resume)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbHideMediaDefault = checkBox { cbHideMediaDefault = checkBox {
text = context.getString(R.string.hide_media_default) text = context.getString(R.string.hide_media_default)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbSystemNotificationNotRelated = checkBox { cbSystemNotificationNotRelated = checkBox {
text = context.getString(R.string.system_notification_not_related) text = context.getString(R.string.system_notification_not_related)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbEnableSpeech = checkBox { cbEnableSpeech = checkBox {
text = context.getString(R.string.enable_speech) text = context.getString(R.string.enable_speech)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
cbOldApi = checkBox { cbOldApi = checkBox {
text = context.getString(R.string.use_old_api) text = context.getString(R.string.use_old_api)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
llRegexFilter = linearLayout { llRegexFilter = linearLayout {
lparams(matchParent,wrapContent) lparams(matchParent, wrapContent)
label = textView{ label = textView {
textColor= getAttributeColor(context,R.attr.colorColumnHeaderPageNumber) textColor =
getAttributeColor(context, R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.regex_filter) text = context.getString(R.string.regex_filter)
}.lparams(wrapContent,wrapContent) }.lparams(wrapContent, wrapContent)
tvRegexFilterError = textView{ tvRegexFilterError = textView {
textColor= getAttributeColor(context,R.attr.colorRegexFilterError) textColor = getAttributeColor(context, R.attr.colorRegexFilterError)
}.lparams(0,wrapContent){ }.lparams(0, wrapContent) {
weight=1f weight = 1f
startMargin = dip(4) startMargin = dip(4)
} }
} }
etRegexFilter = editText{ etRegexFilter = editText {
id = View.generateViewId() id = View.generateViewId()
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
maxLines = 1 maxLines = 1
setHorizontallyScrolling(true) setHorizontallyScrolling(true)
isHorizontalScrollBarEnabled = true isHorizontalScrollBarEnabled = true
}.lparams(matchParent, wrapContent)
}.lparams(matchParent,wrapContent) label?.labelFor = etRegexFilter.id
label?.labelFor =etRegexFilter.id
btnDeleteNotification = button{ btnDeleteNotification = button {
isAllCaps = false isAllCaps = false
text = context.getString(R.string.notification_delete) text = context.getString(R.string.notification_delete)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
btnColor = button{ btnColor = button {
isAllCaps = false isAllCaps = false
text = context.getString(R.string.color_and_background) text = context.getString(R.string.color_and_background)
}.lparams(matchParent,wrapContent) }.lparams(matchParent, wrapContent)
} }
} // end of column setting scroll view } // end of column setting scroll view
llSearch = verticalLayout { llSearch = verticalLayout {
lparams(matchParent,wrapContent) lparams(matchParent, wrapContent)
backgroundColor = getAttributeColor(context,R.attr.colorSearchFormBackground) backgroundColor = getAttributeColor(context, R.attr.colorSearchFormBackground)
startPadding=dip(12) startPadding = dip(12)
endPadding=dip(12) endPadding = dip(12)
topPadding=dip(3) topPadding = dip(3)
bottomPadding=dip(3) bottomPadding = dip(3)
linearLayout { linearLayout {
lparams(matchParent,wrapContent) lparams(matchParent, wrapContent)
isBaselineAligned=false isBaselineAligned = false
gravity = Gravity.CENTER gravity = Gravity.CENTER
etSearch = editText{ etSearch = editText {
id = View.generateViewId() id = View.generateViewId()
imeOptions = EditorInfo.IME_ACTION_SEARCH imeOptions = EditorInfo.IME_ACTION_SEARCH
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
maxLines = 1 maxLines = 1
}.lparams(0, wrapContent){ }.lparams(0, wrapContent) {
weight=1f weight = 1f
} }
btnSearchClear = imageButton{ btnSearchClear = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.clear) contentDescription = context.getString(R.string.clear)
imageResource = R.drawable.ic_close imageResource = R.drawable.ic_close
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable)) imageTintList = ColorStateList.valueOf(
}.lparams(dip(40),dip(40)){ getAttributeColor(
context,
R.attr.colorVectorDrawable
)
)
}.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
} }
btnSearch = imageButton{ btnSearch = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.search) contentDescription = context.getString(R.string.search)
imageResource = R.drawable.ic_search imageResource = R.drawable.ic_search
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable)) imageTintList = ColorStateList.valueOf(
}.lparams(dip(40),dip(40)){ getAttributeColor(
context,
R.attr.colorVectorDrawable
)
)
}.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
} }
} }
cbResolve = checkBox { cbResolve = checkBox {
text = context.getString(R.string.resolve_non_local_account) text = context.getString(R.string.resolve_non_local_account)
}.lparams(wrapContent,wrapContent) // チェックボックスの余白はタッチ判定外 }.lparams(wrapContent, wrapContent) // チェックボックスの余白はタッチ判定外
} // end of search bar } // end of search bar
llListList = linearLayout { llListList = linearLayout {
lparams(matchParent,wrapContent) lparams(matchParent, wrapContent)
startPadding=dip(12) startPadding = dip(12)
endPadding=dip(12) endPadding = dip(12)
topPadding=dip(3) topPadding = dip(3)
bottomPadding=dip(3) bottomPadding = dip(3)
backgroundColor = getAttributeColor(context,R.attr.colorSearchFormBackground) backgroundColor = getAttributeColor(context, R.attr.colorSearchFormBackground)
isBaselineAligned = false isBaselineAligned = false
gravity = Gravity.CENTER gravity = Gravity.CENTER
etListName = editText{ etListName = editText {
hint = context.getString(R.string.list_create_hint) hint = context.getString(R.string.list_create_hint)
imeOptions = EditorInfo.IME_ACTION_SEND imeOptions = EditorInfo.IME_ACTION_SEND
inputType = InputType.TYPE_CLASS_TEXT inputType = InputType.TYPE_CLASS_TEXT
}.lparams(0,wrapContent){ }.lparams(0, wrapContent) {
weight= 1f weight = 1f
} }
btnListAdd = imageButton { btnListAdd = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.add) contentDescription = context.getString(R.string.add)
imageResource = R.drawable.ic_add imageResource = R.drawable.ic_add
imageTintList = ColorStateList.valueOf(getAttributeColor(context,R.attr.colorVectorDrawable)) imageTintList = ColorStateList.valueOf(
}.lparams(dip(40),dip(40)){ getAttributeColor(
context,
R.attr.colorVectorDrawable
)
)
}.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
} }
} // end of list list header } // end of list list header
svQuickFilter = horizontalScrollView { svQuickFilter = horizontalScrollView {
lparams(matchParent,wrapContent) lparams(matchParent, wrapContent)
isFillViewport = true isFillViewport = true
linearLayout { linearLayout {
lparams(matchParent,dip(40)) lparams(matchParent, dip(40))
btnQuickFilterAll = button{ btnQuickFilterAll = button {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
minWidthCompat = dip(40) minWidthCompat = dip(40)
startPadding = dip(4) startPadding = dip(4)
@ -1969,80 +1986,80 @@ class ColumnViewHolder(
isAllCaps = false isAllCaps = false
stateListAnimator = null stateListAnimator = null
text = context.getString(R.string.all) text = context.getString(R.string.all)
}.lparams(wrapContent,matchParent){ }.lparams(wrapContent, matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterMention = imageButton{ btnQuickFilterMention = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.mention2) contentDescription = context.getString(R.string.mention2)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterFavourite = imageButton{ btnQuickFilterFavourite = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.favourite) contentDescription = context.getString(R.string.favourite)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterBoost = imageButton{ btnQuickFilterBoost = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.boost) contentDescription = context.getString(R.string.boost)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterFollow = imageButton{ btnQuickFilterFollow = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.follow) contentDescription = context.getString(R.string.follow)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterReaction = imageButton{ btnQuickFilterReaction = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.reaction) contentDescription = context.getString(R.string.reaction)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
btnQuickFilterVote = imageButton{ btnQuickFilterVote = imageButton {
backgroundResource = R.drawable.btn_bg_transparent backgroundResource = R.drawable.btn_bg_transparent
contentDescription = context.getString(R.string.vote_polls) contentDescription = context.getString(R.string.vote_polls)
}.lparams(dip(40),matchParent){ }.lparams(dip(40), matchParent) {
margin = 0 margin = 0
} }
} }
} // end of notification quick filter bar } // end of notification quick filter bar
flColumnBackground = frameLayout{ flColumnBackground = frameLayout {
ivColumnBackgroundImage = imageView{ ivColumnBackgroundImage = imageView {
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
scaleType = ImageView.ScaleType.CENTER_CROP scaleType = ImageView.ScaleType.CENTER_CROP
visibility = View.GONE visibility = View.GONE
}.lparams(matchParent,matchParent) }.lparams(matchParent, matchParent)
tvLoading = textView{ tvLoading = textView {
gravity = Gravity.CENTER gravity = Gravity.CENTER
}.lparams(matchParent,matchParent) }.lparams(matchParent, matchParent)
refreshLayout = swipyRefreshLayout{ refreshLayout = swipyRefreshLayout {
lparams(matchParent,matchParent) lparams(matchParent, matchParent)
direction = SwipyRefreshLayoutDirection.BOTH direction = SwipyRefreshLayoutDirection.BOTH
// スタイルで指定しないとAndroid 6 で落ちる… // スタイルで指定しないとAndroid 6 で落ちる…
listView = recyclerView{ listView = recyclerView {
listLayoutManager = LinearLayoutManager(activity) listLayoutManager = LinearLayoutManager(activity)
layoutManager = listLayoutManager layoutManager = listLayoutManager
}.lparams(matchParent,matchParent){ }.lparams(matchParent, matchParent) {
} }
} }
@ -2052,34 +2069,34 @@ class ColumnViewHolder(
foregroundGravity = Gravity.BOTTOM foregroundGravity = Gravity.BOTTOM
backgroundResource = R.drawable.bg_refresh_error backgroundResource = R.drawable.bg_refresh_error
startPadding=dip(6) startPadding = dip(6)
endPadding=dip(6) endPadding = dip(6)
topPadding=dip(3) topPadding = dip(3)
bottomPadding=dip(3) bottomPadding = dip(3)
ivRefreshError = imageView{ ivRefreshError = imageView {
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
scaleType = ImageView.ScaleType.FIT_CENTER scaleType = ImageView.ScaleType.FIT_CENTER
imageResource = R.drawable.ic_error imageResource = R.drawable.ic_error
imageTintList = ColorStateList.valueOf(Color.RED) imageTintList = ColorStateList.valueOf(Color.RED)
}.lparams(dip(24),dip(24)){ }.lparams(dip(24), dip(24)) {
gravity = Gravity.START or Gravity.CENTER_VERTICAL gravity = Gravity.START or Gravity.CENTER_VERTICAL
startMargin = dip(4) startMargin = dip(4)
} }
tvRefreshError = textView{ tvRefreshError = textView {
textColor = Color.WHITE textColor = Color.WHITE
}.lparams(matchParent, wrapContent){ }.lparams(matchParent, wrapContent) {
gravity = Gravity.TOP or Gravity.START gravity = Gravity.TOP or Gravity.START
startMargin =dip(32) startMargin = dip(32)
} }
}.lparams(matchParent, wrapContent){ }.lparams(matchParent, wrapContent) {
margin = dip(6) margin = dip(6)
} }
}.lparams(matchParent,0){ }.lparams(matchParent, 0) {
weight = 1f weight = 1f
} }
} }

View File

@ -1170,7 +1170,7 @@ class PollingWorker private constructor(contextArg : Context) {
if(array != null) { if(array != null) {
try { try {
for(i in array.length() - 1 downTo 0) { for(i in array.length() - 1 downTo 0) {
update_sub( array.optJSONObject(i) ?: continue) update_sub(array.optJSONObject(i) ?: continue)
} }
} catch(ex : JSONException) { } catch(ex : JSONException) {
log.trace(ex) log.trace(ex)

View File

@ -10,33 +10,33 @@ import jp.juggler.subwaytooter.R
// Anko Layout中にカスタムビューを指定する為に拡張関数を定義する // Anko Layout中にカスタムビューを指定する為に拡張関数を定義する
inline fun ViewManager.myNetworkImageView(init: MyNetworkImageView.() -> Unit): MyNetworkImageView { inline fun ViewManager.myNetworkImageView(init : MyNetworkImageView.() -> Unit) : MyNetworkImageView {
return ankoView({ MyNetworkImageView(it) }, theme = 0, init = init) return ankoView({ MyNetworkImageView(it) }, theme = 0, init = init)
} }
inline fun ViewManager.myTextView(init: MyTextView.() -> Unit) : MyTextView { inline fun ViewManager.myTextView(init : MyTextView.() -> Unit) : MyTextView {
return ankoView({ MyTextView(it) }, theme = 0, init = init) return ankoView({ MyTextView(it) }, theme = 0, init = init)
} }
inline fun ViewManager.trendTagHistoryView(init : TagHistoryView.() -> Unit) : TagHistoryView {
inline fun ViewManager.trendTagHistoryView(init: TagHistoryView.() -> Unit): TagHistoryView {
return ankoView({ TagHistoryView(it) }, theme = 0, init = init) return ankoView({ TagHistoryView(it) }, theme = 0, init = init)
} }
inline fun ViewManager.blurhashView(init: BlurhashView.() -> Unit): BlurhashView { inline fun ViewManager.blurhashView(init : BlurhashView.() -> Unit) : BlurhashView {
return ankoView({ BlurhashView(it) }, theme = 0, init = init) return ankoView({ BlurhashView(it) }, theme = 0, init = init)
} }
inline fun ViewManager.maxHeightScrollView(init : MaxHeightScrollView.() -> Unit) : MaxHeightScrollView {
inline fun ViewManager.maxHeightScrollView(init: MaxHeightScrollView.() -> Unit): MaxHeightScrollView {
return ankoView({ MaxHeightScrollView(it) }, theme = 0, init = init) return ankoView({ MaxHeightScrollView(it) }, theme = 0, init = init)
} }
inline fun ViewManager.swipyRefreshLayout(init: SwipyRefreshLayout.() -> Unit): SwipyRefreshLayout { inline fun ViewManager.swipyRefreshLayout(init : SwipyRefreshLayout.() -> Unit) : SwipyRefreshLayout {
return ankoView({ SwipyRefreshLayout(it) }, theme = 0, init = init) return ankoView({ SwipyRefreshLayout(it) }, theme = 0, init = init)
} }
inline fun ViewManager.recyclerView(init: RecyclerView.() -> Unit): RecyclerView { inline fun ViewManager.recyclerView(init : RecyclerView.() -> Unit) : RecyclerView {
return ankoView({ RecyclerView(ContextThemeWrapper(it, R.style.recycler_view_with_scroll_bar)) }, theme = 0, init = init) return ankoView({
RecyclerView(ContextThemeWrapper(it, R.style.recycler_view_with_scroll_bar))
}, theme = 0, init = init)
} }

View File

@ -15,9 +15,9 @@ class ScrollPosition {
val isHead : Boolean val isHead : Boolean
get() = adapterIndex == 0 && offset >= 0 get() = adapterIndex == 0 && offset >= 0
override fun toString() : String ="ScrlPos($adapterIndex,$offset)" override fun toString() : String = "ScrlPos($adapterIndex,$offset)"
constructor(adapterIndex : Int =0) { constructor(adapterIndex : Int = 0) {
this.adapterIndex = adapterIndex this.adapterIndex = adapterIndex
this.offset = 0 this.offset = 0
} }
@ -25,13 +25,15 @@ class ScrollPosition {
constructor(holder : ColumnViewHolder) { constructor(holder : ColumnViewHolder) {
val layoutManager = holder.listLayoutManager val layoutManager = holder.listLayoutManager
val findPosition = layoutManager.findFirstVisibleItemPosition() val findPosition = layoutManager.findFirstVisibleItemPosition()
if(findPosition == androidx.recyclerview.widget.RecyclerView.NO_POSITION) { if(findPosition == RecyclerView.NO_POSITION) {
adapterIndex = 0 adapterIndex = 0
offset = 0 offset = 0
} else { } else {
adapterIndex = findPosition adapterIndex = findPosition
val firstItemView = layoutManager.findViewByPosition(findPosition) val firstItemView = layoutManager.findViewByPosition(findPosition)
offset = (firstItemView?.top ?: 0) - (((firstItemView?.layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin)?:0) offset = (firstItemView?.top
?: 0) - (((firstItemView?.layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin)
?: 0)
} }
} }

View File

@ -67,26 +67,24 @@ fun vg(v : View, visible : Boolean) : Boolean {
return visible return visible
} }
fun ViewGroup.generateLayoutParamsEx() : ViewGroup.LayoutParams? =
fun ViewGroup.generateLayoutParamsEx():ViewGroup.LayoutParams?=
try { try {
val parser = resources.getLayout(R.layout.generate_params) val parser = resources.getLayout(R.layout.generate_params)
// Skip everything until the view tag. // Skip everything until the view tag.
while(true){ while(true) {
val token = parser.nextToken() val token = parser.nextToken()
if(token == XmlPullParser.START_TAG) break if(token == XmlPullParser.START_TAG) break
} }
generateLayoutParams(parser) generateLayoutParams(parser)
} catch (ex:Throwable) { } catch(ex : Throwable) {
log.e(ex,"generateLayoutParamsEx failed") log.e(ex, "generateLayoutParamsEx failed")
null null
} }
// isChecked with skipping animation // isChecked with skipping animation
var CompoundButton.isCheckedEx :Boolean var CompoundButton.isCheckedNoAnime : Boolean
get() = isChecked get() = isChecked
set(value){ set(value) {
isChecked = value isChecked = value
jumpDrawablesToCurrentState() jumpDrawablesToCurrentState()
} }

View File

@ -68,7 +68,8 @@
<item name="colorRippleEffect">@color/Dark_colorRippleEffect</item> <item name="colorRippleEffect">@color/Dark_colorRippleEffect</item>
<item name="colorButtonSelected">@color/Dark_colorButtonSelected</item> <item name="colorButtonSelected">@color/Dark_colorButtonSelected</item>
<item name="colorReplyBackground">@color/Dark_colorReplyBackground</item> <item name="colorReplyBackground">@color/Dark_colorReplyBackground</item>
<item name="colorColumnListDeleteBackground">@color/Dark_colorColumnListDeleteBackground</item> <item name="colorColumnListDeleteBackground">@color/Dark_colorColumnListDeleteBackground
</item>
<item name="colorColumnListDeleteText">@color/Dark_colorColumnListDeleteText</item> <item name="colorColumnListDeleteText">@color/Dark_colorColumnListDeleteText</item>
<item name="colorColumnListDragHandleBackground"> <item name="colorColumnListDragHandleBackground">
@color/Dark_colorColumnListDragHandleBackground @color/Dark_colorColumnListDragHandleBackground
@ -110,9 +111,9 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="setting_group_header"> <style name="setting_group_header">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
@ -150,6 +151,7 @@
<item name="android:paddingStart">12dp</item> <item name="android:paddingStart">12dp</item>
</style> </style>
<style name="setting_row_label"> <style name="setting_row_label">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
@ -229,7 +231,7 @@
<item name="android:imeOptions">actionDone</item> <item name="android:imeOptions">actionDone</item>
</style> </style>
<style name="recycler_view_with_scroll_bar" > <style name="recycler_view_with_scroll_bar">
<item name="android:clipToPadding">false</item> <item name="android:clipToPadding">false</item>
<item name="android:fadeScrollbars">false</item> <item name="android:fadeScrollbars">false</item>
<item name="android:padding">0dp</item> <item name="android:padding">0dp</item>
@ -238,5 +240,4 @@
</style> </style>
</resources> </resources>