自分の行ったリアクションの背景に色をつける

This commit is contained in:
tateisu 2021-01-04 10:11:45 +09:00
parent 1902b58fc0
commit c2378f2d1d
35 changed files with 2848 additions and 2858 deletions

View File

@ -542,7 +542,7 @@ class ActAccountSetting : AsyncActivity(), View.OnClickListener,
tvUserCustom.backgroundColor = ac.color_bg tvUserCustom.backgroundColor = ac.color_bg
tvUserCustom.text = ac.nickname tvUserCustom.text = ac.nickname
tvUserCustom.textColor = ac.color_fg.notZero() tvUserCustom.textColor = ac.color_fg.notZero()
?: getAttributeColor(R.attr.colorTimeSmall) ?: attrColor(R.attr.colorTimeSmall)
} }
private fun saveUIToData() { private fun saveUIToData() {

View File

@ -373,7 +373,7 @@ class ActAppSetting : AsyncActivity(), ColorPickerDialogListener, View.OnClickLi
val margin_tb = dip(6) val margin_tb = dip(6)
setMargins(margin_lr, margin_tb, margin_lr, margin_tb) setMargins(margin_lr, margin_tb, margin_lr, margin_tb)
} }
setBackgroundColor(context.getAttributeColor(R.attr.colorSettingDivider)) setBackgroundColor(context.attrColor(R.attr.colorSettingDivider))
}) })
} }

View File

@ -200,7 +200,7 @@ class ActColumnList : AppCompatActivity() {
val type = ColumnType.parse(json.optInt(Column.KEY_TYPE)) val type = ColumnType.parse(json.optInt(Column.KEY_TYPE))
val acct_color_bg = json.optInt(Column.KEY_COLUMN_ACCESS_COLOR_BG, 0) val acct_color_bg = json.optInt(Column.KEY_COLUMN_ACCESS_COLOR_BG, 0)
val acct_color_fg = json.optInt(Column.KEY_COLUMN_ACCESS_COLOR, 0) val acct_color_fg = json.optInt(Column.KEY_COLUMN_ACCESS_COLOR, 0)
.notZero() ?: context.getAttributeColor(R.attr.colorColumnListItemText) .notZero() ?: context.attrColor(R.attr.colorColumnListItemText)
var bOldSelection : Boolean = false var bOldSelection : Boolean = false
fun setOldSelection(b : Boolean) { fun setOldSelection(b : Boolean) {
@ -274,7 +274,7 @@ class ActColumnList : AppCompatActivity() {
clickedView.findViewById<View>(R.id.ivBookmark).visibility clickedView.findViewById<View>(R.id.ivBookmark).visibility
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -172,7 +172,7 @@ class ActFavMute : AppCompatActivity() {
clickedView.findViewById<TextView>(R.id.tvName).text clickedView.findViewById<TextView>(R.id.tvName).text
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -142,7 +142,7 @@ class ActHighlightWordEdit
tvName.text = item.name tvName.text = item.name
tvName.setBackgroundColor(item.color_bg) // may 0 tvName.setBackgroundColor(item.color_bg) // may 0
tvName.textColor = item.color_fg.notZero() tvName.textColor = item.color_fg.notZero()
?: getAttributeColor(android.R.attr.textColorPrimary) ?: attrColor(android.R.attr.textColorPrimary)
} finally { } finally {
bBusy = false bBusy = false

View File

@ -160,7 +160,7 @@ class ActHighlightWordList : AppCompatActivity(), View.OnClickListener {
tvName.setBackgroundColor(item.color_bg) tvName.setBackgroundColor(item.color_bg)
tvName.setTextColor( tvName.setTextColor(
item.color_fg.notZero() item.color_fg.notZero()
?: getAttributeColor(android.R.attr.textColorPrimary) ?: attrColor(android.R.attr.textColorPrimary)
) )
btnSound.vg(item.sound_type != HighlightWord.SOUND_TYPE_NONE)?.apply { btnSound.vg(item.sound_type != HighlightWord.SOUND_TYPE_NONE)?.apply {
@ -219,7 +219,7 @@ class ActHighlightWordList : AppCompatActivity(), View.OnClickListener {
clickedView.findViewById<View>(R.id.ivSpeech).visibility clickedView.findViewById<View>(R.id.ivSpeech).visibility
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -240,7 +240,7 @@ class ActLanguageFilter : AsyncActivity(), View.OnClickListener {
getDesc(item), getDesc(item),
getString(if(item.allow) R.string.language_show else R.string.language_hide) getString(if(item.allow) R.string.language_show else R.string.language_hide)
) )
tv.textColor = getAttributeColor( tv.textColor = attrColor(
when(item.allow) { when(item.allow) {
true -> R.attr.colorContentText true -> R.attr.colorContentText
false -> R.attr.colorRegexFilterError false -> R.attr.colorRegexFilterError
@ -373,7 +373,7 @@ class ActLanguageFilter : AsyncActivity(), View.OnClickListener {
btnPresets.setEnabledColor( btnPresets.setEnabledColor(
activity, activity,
R.drawable.ic_edit, R.drawable.ic_edit,
activity.getAttributeColor(R.attr.colorVectorDrawable), activity.attrColor(R.attr.colorVectorDrawable),
false false
) )
} }

View File

@ -540,7 +540,7 @@ class ActMain : AsyncActivity(), View.OnClickListener,
ItemViewHolder.toot_color_direct_me = Pref.ipTootColorDirectMe(pref) ItemViewHolder.toot_color_direct_me = Pref.ipTootColorDirectMe(pref)
MyClickableSpan.showLinkUnderline = Pref.bpShowLinkUnderline(pref) MyClickableSpan.showLinkUnderline = Pref.bpShowLinkUnderline(pref)
MyClickableSpan.defaultLinkColor = Pref.ipLinkColor(pref).notZero() MyClickableSpan.defaultLinkColor = Pref.ipLinkColor(pref).notZero()
?: getAttributeColor(R.attr.colorLink) ?: attrColor(R.attr.colorLink)
CustomShare.reloadCache(this, pref) CustomShare.reloadCache(this, pref)
@ -2316,7 +2316,7 @@ class ActMain : AsyncActivity(), View.OnClickListener,
val footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref) val footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref)
val colorColumnStripBackground = footer_tab_bg_color.notZero() val colorColumnStripBackground = footer_tab_bg_color.notZero()
?: getAttributeColor(R.attr.colorColumnStripBackground) ?: attrColor(R.attr.colorColumnStripBackground)
svColumnStrip.setBackgroundColor(colorColumnStripBackground) svColumnStrip.setBackgroundColor(colorColumnStripBackground)
llQuickTootBar.setBackgroundColor(colorColumnStripBackground) llQuickTootBar.setBackgroundColor(colorColumnStripBackground)
@ -2325,7 +2325,7 @@ class ActMain : AsyncActivity(), View.OnClickListener,
?: colorColumnStripBackground ?: colorColumnStripBackground
val colorButtonFg = footer_button_fg_color.notZero() val colorButtonFg = footer_button_fg_color.notZero()
?: getAttributeColor(R.attr.colorRippleEffect) ?: attrColor(R.attr.colorRippleEffect)
btnMenu.backgroundDrawable = btnMenu.backgroundDrawable =
getAdaptiveRippleDrawableRound(this, colorButtonBg, colorButtonFg) getAdaptiveRippleDrawableRound(this, colorButtonBg, colorButtonFg)
@ -2338,7 +2338,7 @@ class ActMain : AsyncActivity(), View.OnClickListener,
val csl = ColorStateList.valueOf( val csl = ColorStateList.valueOf(
footer_button_fg_color.notZero() footer_button_fg_color.notZero()
?: getAttributeColor(R.attr.colorVectorDrawable) ?: attrColor(R.attr.colorVectorDrawable)
) )
btnToot.imageTintList = csl btnToot.imageTintList = csl
btnMenu.imageTintList = csl btnMenu.imageTintList = csl
@ -2351,7 +2351,7 @@ class ActMain : AsyncActivity(), View.OnClickListener,
vFooterDivider2.setBackgroundColor(c) vFooterDivider2.setBackgroundColor(c)
llColumnStrip.indicatorColor = footer_tab_indicator_color.notZero() llColumnStrip.indicatorColor = footer_tab_indicator_color.notZero()
?: getAttributeColor(R.attr.colorAccent) ?: attrColor(R.attr.colorAccent)
} }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////

View File

@ -8,7 +8,7 @@ import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import jp.juggler.subwaytooter.table.MutedApp import jp.juggler.subwaytooter.table.MutedApp
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import java.util.* import java.util.*
import com.woxthebox.draglistview.DragItem import com.woxthebox.draglistview.DragItem
import com.woxthebox.draglistview.DragItemAdapter import com.woxthebox.draglistview.DragItemAdapter
@ -170,7 +170,7 @@ class ActMutedApp : AppCompatActivity() {
clickedView.findViewById<TextView>(R.id.tvName).text clickedView.findViewById<TextView>(R.id.tvName).text
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -13,7 +13,7 @@ import com.woxthebox.draglistview.swipe.ListSwipeHelper
import com.woxthebox.draglistview.swipe.ListSwipeItem import com.woxthebox.draglistview.swipe.ListSwipeItem
import jp.juggler.subwaytooter.table.UserRelation import jp.juggler.subwaytooter.table.UserRelation
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import java.util.* import java.util.*
class ActMutedPseudoAccount : AppCompatActivity() { class ActMutedPseudoAccount : AppCompatActivity() {
@ -169,7 +169,7 @@ class ActMutedPseudoAccount : AppCompatActivity() {
clickedView.findViewById<TextView>(R.id.tvName).text clickedView.findViewById<TextView>(R.id.tvName).text
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -13,7 +13,7 @@ import com.woxthebox.draglistview.swipe.ListSwipeHelper
import com.woxthebox.draglistview.swipe.ListSwipeItem import com.woxthebox.draglistview.swipe.ListSwipeItem
import jp.juggler.subwaytooter.table.MutedWord import jp.juggler.subwaytooter.table.MutedWord
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import java.util.* import java.util.*
class ActMutedWord : AppCompatActivity() { class ActMutedWord : AppCompatActivity() {
@ -169,7 +169,7 @@ class ActMutedWord : AppCompatActivity() {
clickedView.findViewById<TextView>(R.id.tvName).text clickedView.findViewById<TextView>(R.id.tvName).text
dragView.findViewById<View>(R.id.item_layout) dragView.findViewById<View>(R.id.item_layout)
.setBackgroundColor(getAttributeColor(R.attr.list_item_bg_pressed_dragged)) .setBackgroundColor(attrColor(R.attr.list_item_bg_pressed_dragged))
} }
} }

View File

@ -180,7 +180,7 @@ class ActNickname : AppCompatActivity(), View.OnClickListener, ColorPickerDialog
private fun show() { private fun show() {
val s = etNickname.text.toString().trim { it <= ' ' } val s = etNickname.text.toString().trim { it <= ' ' }
tvPreview.text = s.notEmpty() ?: acctPretty tvPreview.text = s.notEmpty() ?: acctPretty
tvPreview.textColor = color_fg.notZero() ?: getAttributeColor(R.attr.colorTimeSmall) tvPreview.textColor = color_fg.notZero() ?: attrColor(R.attr.colorTimeSmall)
tvPreview.backgroundColor = color_bg tvPreview.backgroundColor = color_bg
} }

View File

@ -1414,7 +1414,7 @@ class ActPost : AsyncActivity(),
tvCharCount.text = remain.toString() tvCharCount.text = remain.toString()
tvCharCount.setTextColor( tvCharCount.setTextColor(
getAttributeColor( attrColor(
if (remain < 0) if (remain < 0)
R.attr.colorRegexFilterError R.attr.colorRegexFilterError
else else
@ -1496,7 +1496,7 @@ class ActPost : AsyncActivity(),
if (a == null) { if (a == null) {
btnAccount.text = getString(R.string.not_selected) btnAccount.text = getString(R.string.not_selected)
btnAccount.setTextColor(getAttributeColor(android.R.attr.textColorPrimary)) btnAccount.setTextColor(attrColor(android.R.attr.textColorPrimary))
btnAccount.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp) btnAccount.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp)
} else { } else {
@ -1516,7 +1516,7 @@ class ActPost : AsyncActivity(),
} }
btnAccount.textColor = ac.color_fg.notZero() btnAccount.textColor = ac.color_fg.notZero()
?: getAttributeColor(android.R.attr.textColorPrimary) ?: attrColor(android.R.attr.textColorPrimary)
} }
updateTextCount() updateTextCount()
updateFeaturedTags() updateFeaturedTags()

View File

@ -830,12 +830,12 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
val header_bg = when { val header_bg = when {
color_column_header_bg != 0 -> color_column_header_bg color_column_header_bg != 0 -> color_column_header_bg
else -> activity.getAttributeColor(R.attr.color_column_header) else -> activity.attrColor(R.attr.color_column_header)
} }
val header_fg = when { val header_fg = when {
color_column_header_fg != 0 -> color_column_header_fg color_column_header_fg != 0 -> color_column_header_fg
else -> activity.getAttributeColor(R.attr.colorColumnHeaderName) else -> activity.attrColor(R.attr.colorColumnHeaderName)
} }
llColumnHeader.background = getAdaptiveRippleDrawable(header_bg, header_fg) llColumnHeader.background = getAdaptiveRippleDrawable(header_bg, header_fg)
@ -866,12 +866,12 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
tvSampleAcct.setTextColor( tvSampleAcct.setTextColor(
color_column_acct.notZero() color_column_acct.notZero()
?: activity.getAttributeColor(R.attr.colorTimeSmall) ?: activity.attrColor(R.attr.colorTimeSmall)
) )
tvSampleContent.setTextColor( tvSampleContent.setTextColor(
color_column_text.notZero() color_column_text.notZero()
?: activity.getAttributeColor(R.attr.colorContentText) ?: activity.attrColor(R.attr.colorContentText)
) )
} }
@ -906,7 +906,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
val footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref) val footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref)
val colorColumnStripBackground = footer_tab_bg_color.notZero() val colorColumnStripBackground = footer_tab_bg_color.notZero()
?: activity.getAttributeColor(R.attr.colorColumnStripBackground) ?: activity.attrColor(R.attr.colorColumnStripBackground)
llFooterBG.setBackgroundColor(colorColumnStripBackground) llFooterBG.setBackgroundColor(colorColumnStripBackground)
@ -914,7 +914,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
?: colorColumnStripBackground ?: colorColumnStripBackground
val colorButtonFg = footer_button_fg_color.notZero() val colorButtonFg = footer_button_fg_color.notZero()
?: activity.getAttributeColor(R.attr.colorRippleEffect) ?: activity.attrColor(R.attr.colorRippleEffect)
ivFooterMenu.backgroundDrawable = ivFooterMenu.backgroundDrawable =
getAdaptiveRippleDrawableRound(activity, colorButtonBg, colorButtonFg) getAdaptiveRippleDrawableRound(activity, colorButtonBg, colorButtonFg)
@ -923,7 +923,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
val csl = ColorStateList.valueOf( val csl = ColorStateList.valueOf(
footer_button_fg_color.notZero() footer_button_fg_color.notZero()
?: activity.getAttributeColor(R.attr.colorVectorDrawable) ?: activity.attrColor(R.attr.colorVectorDrawable)
) )
ivFooterToot.imageTintList = csl ivFooterToot.imageTintList = csl
ivFooterMenu.imageTintList = csl ivFooterMenu.imageTintList = csl
@ -935,7 +935,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
vIndicator.setBackgroundColor( vIndicator.setBackgroundColor(
footer_tab_indicator_color.notZero() footer_tab_indicator_color.notZero()
?: activity.getAttributeColor(R.attr.colorAccent) ?: activity.attrColor(R.attr.colorAccent)
) )
} }

View File

@ -348,22 +348,22 @@ class Column(
fun reloadDefaultColor(activity: AppCompatActivity, pref: SharedPreferences) { fun reloadDefaultColor(activity: AppCompatActivity, pref: SharedPreferences) {
defaultColorHeaderBg = Pref.ipCcdHeaderBg(pref).notZero() defaultColorHeaderBg = Pref.ipCcdHeaderBg(pref).notZero()
?: activity.getAttributeColor(R.attr.color_column_header) ?: activity.attrColor(R.attr.color_column_header)
defaultColorHeaderName = Pref.ipCcdHeaderFg(pref).notZero() defaultColorHeaderName = Pref.ipCcdHeaderFg(pref).notZero()
?: activity.getAttributeColor(R.attr.colorColumnHeaderName) ?: activity.attrColor(R.attr.colorColumnHeaderName)
defaultColorHeaderPageNumber = Pref.ipCcdHeaderFg(pref).notZero() defaultColorHeaderPageNumber = Pref.ipCcdHeaderFg(pref).notZero()
?: activity.getAttributeColor(R.attr.colorColumnHeaderPageNumber) ?: activity.attrColor(R.attr.colorColumnHeaderPageNumber)
defaultColorContentBg = Pref.ipCcdContentBg(pref) defaultColorContentBg = Pref.ipCcdContentBg(pref)
// may zero // may zero
defaultColorContentAcct = Pref.ipCcdContentAcct(pref).notZero() defaultColorContentAcct = Pref.ipCcdContentAcct(pref).notZero()
?: activity.getAttributeColor(R.attr.colorTimeSmall) ?: activity.attrColor(R.attr.colorTimeSmall)
defaultColorContentText = Pref.ipCcdContentText(pref).notZero() defaultColorContentText = Pref.ipCcdContentText(pref).notZero()
?: activity.getAttributeColor(R.attr.colorContentText) ?: activity.attrColor(R.attr.colorContentText)
} }

View File

@ -720,7 +720,7 @@ class ColumnViewHolder(
val context = activity val context = activity
val announcementsBgColor = Pref.ipAnnouncementsBgColor(App1.pref).notZero() val announcementsBgColor = Pref.ipAnnouncementsBgColor(App1.pref).notZero()
?: context.getAttributeColor(R.attr.colorSearchFormBackground) ?: context.attrColor(R.attr.colorSearchFormBackground)
btnAnnouncementsCutout.apply { btnAnnouncementsCutout.apply {
color = announcementsBgColor color = announcementsBgColor
@ -733,7 +733,7 @@ class ColumnViewHolder(
} }
val searchBgColor = Pref.ipSearchBgColor(App1.pref).notZero() val searchBgColor = Pref.ipSearchBgColor(App1.pref).notZero()
?: context.getAttributeColor(R.attr.colorSearchFormBackground) ?: context.attrColor(R.attr.colorSearchFormBackground)
llSearch.apply { llSearch.apply {
backgroundColor = searchBgColor backgroundColor = searchBgColor
@ -1231,7 +1231,7 @@ class ColumnViewHolder(
tvColumnContext.text = ac.nickname tvColumnContext.text = ac.nickname
tvColumnContext.setTextColor( tvColumnContext.setTextColor(
ac.color_fg.notZero() ac.color_fg.notZero()
?: activity.getAttributeColor(R.attr.colorTimeSmall) ?: activity.attrColor(R.attr.colorTimeSmall)
) )
tvColumnContext.setBackgroundColor(ac.color_bg) tvColumnContext.setBackgroundColor(ac.color_bg)
@ -1585,10 +1585,10 @@ class ColumnViewHolder(
if (insideColumnSetting) { if (insideColumnSetting) {
svQuickFilter.setBackgroundColor(0) svQuickFilter.setBackgroundColor(0)
val colorFg = activity.getAttributeColor(R.attr.colorContentText) val colorFg = activity.attrColor(R.attr.colorContentText)
val colorBgSelected = colorFg.applyAlphaMultiplier(0.25f) val colorBgSelected = colorFg.applyAlphaMultiplier(0.25f)
val colorFgList = ColorStateList.valueOf(colorFg) val colorFgList = ColorStateList.valueOf(colorFg)
val colorBg = activity.getAttributeColor(R.attr.colorColumnSettingBackground) val colorBg = activity.attrColor(R.attr.colorColumnSettingBackground)
showQuickFilterButton = { btn, iconId, selected -> showQuickFilterButton = { btn, iconId, selected ->
btn.backgroundDrawable = btn.backgroundDrawable =
getAdaptiveRippleDrawableRound( getAdaptiveRippleDrawableRound(
@ -1720,7 +1720,7 @@ class ColumnViewHolder(
gravity = Gravity.END gravity = Gravity.END
startPadding = dip(4) startPadding = dip(4)
endPadding = dip(4) endPadding = dip(4)
textColor = context.getAttributeColor(R.attr.colorColumnHeaderAcct) textColor = context.attrColor(R.attr.colorColumnHeaderAcct)
textSize = 12f textSize = 12f
}.lparams(0, wrapContent) { }.lparams(0, wrapContent) {
@ -1729,7 +1729,7 @@ class ColumnViewHolder(
tvColumnStatus = textView { tvColumnStatus = textView {
gravity = Gravity.END gravity = Gravity.END
textColor = context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) textColor = context.attrColor(R.attr.colorColumnHeaderPageNumber)
textSize = 12f textSize = 12f
}.lparams(wrapContent, wrapContent) { }.lparams(wrapContent, wrapContent) {
@ -1738,7 +1738,7 @@ class ColumnViewHolder(
tvColumnIndex = textView { tvColumnIndex = textView {
gravity = Gravity.END gravity = Gravity.END
textColor = context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) textColor = context.attrColor(R.attr.colorColumnHeaderPageNumber)
textSize = 12f textSize = 12f
}.lparams(wrapContent, wrapContent) { }.lparams(wrapContent, wrapContent) {
@ -1842,7 +1842,7 @@ class ColumnViewHolder(
val paint = Paint().apply { val paint = Paint().apply {
isAntiAlias = true isAntiAlias = true
color = color =
context.getAttributeColor(R.attr.colorColumnSettingBackground) context.attrColor(R.attr.colorColumnSettingBackground)
} }
val path = Path() val path = Path()
addOutsideDrawer(this) { canvas, parent, view, left, top -> addOutsideDrawer(this) { canvas, parent, view, left, top ->
@ -1908,7 +1908,7 @@ class ColumnViewHolder(
maxHeight = dip(240) maxHeight = dip(240)
backgroundColor = backgroundColor =
context.getAttributeColor(R.attr.colorColumnSettingBackground) context.attrColor(R.attr.colorColumnSettingBackground)
llColumnSettingInside = verticalLayout { llColumnSettingInside = verticalLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
@ -1923,7 +1923,7 @@ class ColumnViewHolder(
label = textView { label = textView {
textColor = textColor =
context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) context.attrColor(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)
@ -1938,7 +1938,7 @@ class ColumnViewHolder(
label = textView { label = textView {
textColor = textColor =
context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) context.attrColor(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)
@ -1953,7 +1953,7 @@ class ColumnViewHolder(
label = textView { label = textView {
textColor = textColor =
context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) context.attrColor(R.attr.colorColumnHeaderPageNumber)
text = context.getString(R.string.hashtag_extra_none) text = context.getString(R.string.hashtag_extra_none)
}.lparams(matchParent, wrapContent) }.lparams(matchParent, wrapContent)
@ -2048,12 +2048,12 @@ class ColumnViewHolder(
label = textView { label = textView {
textColor = textColor =
context.getAttributeColor(R.attr.colorColumnHeaderPageNumber) context.attrColor(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 = context.getAttributeColor(R.attr.colorRegexFilterError) textColor = context.attrColor(R.attr.colorRegexFilterError)
}.lparams(0, wrapContent) { }.lparams(0, wrapContent) {
weight = 1f weight = 1f
startMargin = dip(4) startMargin = dip(4)
@ -2219,7 +2219,7 @@ class ColumnViewHolder(
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( imageTintList = ColorStateList.valueOf(
context.getAttributeColor(R.attr.colorVectorDrawable) context.attrColor(R.attr.colorVectorDrawable)
) )
}.lparams(dip(40), dip(40)) { }.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
@ -2230,7 +2230,7 @@ class ColumnViewHolder(
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( imageTintList = ColorStateList.valueOf(
context.getAttributeColor(R.attr.colorVectorDrawable) context.attrColor(R.attr.colorVectorDrawable)
) )
}.lparams(dip(40), dip(40)) { }.lparams(dip(40), dip(40)) {
startMargin = dip(4) startMargin = dip(4)
@ -2262,7 +2262,7 @@ class ColumnViewHolder(
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( imageTintList = ColorStateList.valueOf(
context.getAttributeColor( context.attrColor(
R.attr.colorVectorDrawable R.attr.colorVectorDrawable
) )
) )
@ -2680,8 +2680,8 @@ class ColumnViewHolder(
btn.background = if (reaction.me == true) { btn.background = if (reaction.me == true) {
getAdaptiveRippleDrawableRound( getAdaptiveRippleDrawableRound(
actMain, actMain,
actMain.getAttributeColor(R.attr.colorButtonBgCw), actMain.attrColor(R.attr.colorButtonBgCw),
actMain.getAttributeColor(R.attr.colorRippleEffect) actMain.attrColor(R.attr.colorRippleEffect)
) )
} else { } else {
ContextCompat.getDrawable(actMain, R.drawable.btn_bg_transparent_round6dp) ContextCompat.getDrawable(actMain, R.drawable.btn_bg_transparent_round6dp)

View File

@ -347,14 +347,14 @@ internal class DlgContextMenu(
val colorButtonAccent = val colorButtonAccent =
Pref.ipButtonFollowingColor(activity.pref).notZero() Pref.ipButtonFollowingColor(activity.pref).notZero()
?: activity.getAttributeColor(R.attr.colorImageButtonAccent) ?: activity.attrColor(R.attr.colorImageButtonAccent)
val colorButtonError = val colorButtonError =
Pref.ipButtonFollowRequestColor(activity.pref).notZero() Pref.ipButtonFollowRequestColor(activity.pref).notZero()
?: activity.getAttributeColor(R.attr.colorRegexFilterError) ?: activity.attrColor(R.attr.colorRegexFilterError)
val colorButtonNormal = val colorButtonNormal =
activity.getAttributeColor(R.attr.colorImageButton) activity.attrColor(R.attr.colorImageButton)
fun showRelation(relation : UserRelation) { fun showRelation(relation : UserRelation) {
@ -405,7 +405,7 @@ internal class DlgContextMenu(
ivFollowedBy.vg(false) ivFollowedBy.vg(false)
btnFollow.setImageResource(R.drawable.ic_follow_plus) btnFollow.setImageResource(R.drawable.ic_follow_plus)
btnFollow.imageTintList = btnFollow.imageTintList =
ColorStateList.valueOf(activity.getAttributeColor(R.attr.colorImageButton)) ColorStateList.valueOf(activity.attrColor(R.attr.colorImageButton))
btnNotificationFrom.visibility = View.GONE btnNotificationFrom.visibility = View.GONE
} else { } else {
@ -583,7 +583,7 @@ internal class DlgContextMenu(
R.drawable.ic_arrow_drop_down R.drawable.ic_arrow_drop_down
} }
val iconColor = activity.getAttributeColor(R.attr.colorTimeSmall) val iconColor = activity.attrColor(R.attr.colorTimeSmall)
val drawable = createColoredDrawable(activity, iconId, iconColor, 1f) val drawable = createColoredDrawable(activity, iconId, iconColor, 1f)
btn.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null) btn.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null)
} }

File diff suppressed because it is too large Load Diff

View File

@ -122,7 +122,7 @@ class SideMenuAdapter(
) )
setSpan( setSpan(
ForegroundColorSpan( ForegroundColorSpan(
appContext.getAttributeColor(R.attr.colorRegexFilterError) appContext.attrColor(R.attr.colorRegexFilterError)
), ),
start, length, start, length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
@ -362,7 +362,7 @@ class SideMenuAdapter(
} }
) )
private val iconColor = actMain.getAttributeColor(R.attr.colorTimeSmall) private val iconColor = actMain.attrColor(R.attr.colorTimeSmall)
override fun getCount() : Int = list.size override fun getCount() : Int = list.size
override fun getItem(position : Int) : Any = list[position] override fun getItem(position : Int) : Any = list[position]
@ -427,7 +427,7 @@ class SideMenuAdapter(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT FrameLayout.LayoutParams.MATCH_PARENT
) )
backgroundColor = actMain.getAttributeColor(R.attr.colorWindowBackground) backgroundColor = actMain.attrColor(R.attr.colorWindowBackground)
selector = StateListDrawable() selector = StateListDrawable()
divider = null divider = null
dividerHeight = 0 dividerHeight = 0

View File

@ -66,7 +66,7 @@ internal class StatusButtons(
private val color_normal = column.getContentColor() private val color_normal = column.getContentColor()
private val color_accent : Int private val color_accent : Int
get() = activity.getAttributeColor(R.attr.colorImageButtonAccent) get() = activity.attrColor(R.attr.colorImageButtonAccent)
init { init {
this.access_info = column.access_info this.access_info = column.access_info

View File

@ -18,7 +18,7 @@ import jp.juggler.subwaytooter.span.EmojiImageSpan
import jp.juggler.subwaytooter.span.createSpan import jp.juggler.subwaytooter.span.createSpan
import jp.juggler.subwaytooter.table.UserRelation import jp.juggler.subwaytooter.table.UserRelation
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import jp.juggler.util.notZero import jp.juggler.util.notZero
import jp.juggler.util.setIconDrawableId import jp.juggler.util.setIconDrawableId
import kotlin.math.max import kotlin.math.max
@ -30,7 +30,7 @@ object Styler {
fun defaultColorIcon(context : Context, iconId : Int) : Drawable? = fun defaultColorIcon(context : Context, iconId : Int) : Drawable? =
ContextCompat.getDrawable(context, iconId)?.also { ContextCompat.getDrawable(context, iconId)?.also {
it.setTint(context.getAttributeColor(R.attr.colorVectorDrawable)) it.setTint(context.attrColor(R.attr.colorVectorDrawable))
it.setTintMode(PorterDuff.Mode.SRC_IN) it.setTintMode(PorterDuff.Mode.SRC_IN)
} }
@ -123,7 +123,7 @@ object Styler {
val icon_id = getVisibilityIconId(isMisskeyData, visibility) val icon_id = getVisibilityIconId(isMisskeyData, visibility)
val sv = getVisibilityString(context, isMisskeyData, visibility) val sv = getVisibilityString(context, isMisskeyData, visibility)
val color = context.getAttributeColor(R.attr.colorVectorDrawable) val color = context.attrColor(R.attr.colorVectorDrawable)
val sb = SpannableStringBuilder() val sb = SpannableStringBuilder()
// アイコン部分 // アイコン部分
@ -160,11 +160,11 @@ object Styler {
) { ) {
fun colorAccent() = fun colorAccent() =
Pref.ipButtonFollowingColor(context.pref()).notZero() Pref.ipButtonFollowingColor(context.pref()).notZero()
?: context.getAttributeColor(R.attr.colorImageButtonAccent) ?: context.attrColor(R.attr.colorImageButtonAccent)
fun colorError() = fun colorError() =
Pref.ipButtonFollowRequestColor(context.pref()).notZero() Pref.ipButtonFollowRequestColor(context.pref()).notZero()
?: context.getAttributeColor(R.attr.colorRegexFilterError) ?: context.attrColor(R.attr.colorRegexFilterError)
// 被フォロー状態 // 被フォロー状態
when { when {

View File

@ -141,7 +141,7 @@ internal class ViewHolderHeaderProfile(
override fun showColor() { override fun showColor() {
llProfile.setBackgroundColor( llProfile.setBackgroundColor(
when(val c = column.column_bg_color) { when(val c = column.column_bg_color) {
0 -> activity.getAttributeColor(R.attr.colorProfileBackgroundMask) 0 -> activity.attrColor(R.attr.colorProfileBackgroundMask)
else -> - 0x40000000 or (0x00ffffff and c) else -> - 0x40000000 or (0x00ffffff and c)
} }
) )

View File

@ -26,7 +26,7 @@ import jp.juggler.subwaytooter.util.EmojiDecoder
//} //}
object MisskeyReaction { object MisskeyReaction {
private val oldReactions = mapOf( private val oldReactions = mapOf(
"like" to "\ud83d\udc4d", "like" to "\ud83d\udc4d",
"love" to "\u2665", "love" to "\u2665",
"laugh" to "\ud83d\ude06", "laugh" to "\ud83d\ude06",
@ -42,6 +42,20 @@ object MisskeyReaction {
private val reCustomEmoji = """\A:([^:]+):\z""".toRegex() private val reCustomEmoji = """\A:([^:]+):\z""".toRegex()
fun getAnotherExpression(reaction: String): String? {
val customCode = reCustomEmoji.find(reaction)?.groupValues?.elementAtOrNull(1) ?: return null
val cols = customCode.split("@")
val name = cols.elementAtOrNull(0)
val domain = cols.elementAtOrNull(1)
return if (domain == null) ":$name@.:" else if (domain == ".") ":$name:" else null
}
fun equals(a:String?,b:String?) = when {
a==null -> b==null
b==null -> false
else -> a ==b || getAnotherExpression(a) == b || a == getAnotherExpression(b)
}
fun toSpannableStringBuilder( fun toSpannableStringBuilder(
code: String, code: String,
options: DecodeOptions, options: DecodeOptions,

View File

@ -928,17 +928,7 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
return list return list
} }
private fun getAnotherReactionExpression(reaction:String):String{
// :reaction: => reaction
// :reaction@xxx: => reaction@xxx
val customCode = reaction.replace(":","")
// reaction => :reaction@.:
return if( customCode != reaction && !customCode.contains("@"))
":${customCode}@.:"
else
reaction
}
// return true if updated // return true if updated
fun increaseReaction(reaction: String?, byMe: Boolean, caller: String): Boolean { fun increaseReaction(reaction: String?, byMe: Boolean, caller: String): Boolean {
@ -962,16 +952,14 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
this.reactionCounts = map this.reactionCounts = map
} }
when (
val anotherExpression = getAnotherReactionExpression(reaction) val key = reaction.takeIf { map.containsKey(it) }
?: MisskeyReaction.getAnotherExpression(reaction)?.takeIf { map.containsKey(it) }
for( entry in map){ ) {
if( entry.key == reaction || entry.key == anotherExpression){ null -> map[reaction] = 1
map[entry.key] = entry.value +1 else -> map[key] = max(0, map[key]!! + 1)
return true
}
} }
map[reaction] = 1
return true return true
} }
} }
@ -998,15 +986,14 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
this.reactionCounts = map this.reactionCounts = map
} }
val anotherExpression = getAnotherReactionExpression(reaction) when (
val key = reaction.takeIf { map.containsKey(it) }
?: MisskeyReaction.getAnotherExpression(reaction)?.takeIf { map.containsKey(it) }
) {
null -> map[reaction] = 0
else -> map[key] = max(0, map[key]!! - 1)
}
for( entry in map){
if( entry.key == reaction || entry.key == anotherExpression){
map[entry.key] = max(0,entry.value -1)
return true
}
}
map[reaction] = 0
return true return true
} }
} }
@ -1214,34 +1201,34 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
fun formatTime(context: Context, t: Long, bAllowRelative: Boolean, onlyDate: Boolean = false): String { fun formatTime(context: Context, t: Long, bAllowRelative: Boolean, onlyDate: Boolean = false): String {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
var delta = now - t var delta = now - t
@StringRes val phraseId = if (delta >= 0) @StringRes val phraseId = if (delta >= 0)
R.string.relative_time_phrase_past R.string.relative_time_phrase_past
else else
R.string.relative_time_phrase_future R.string.relative_time_phrase_future
fun f(v: Long, unit1: Int, units: Int): String { fun f(v: Long, unit1: Int, units: Int): String {
val vi = v.toInt() val vi = v.toInt()
return context.getString( return context.getString(
phraseId, phraseId,
vi, vi,
context.getString(if (vi <= 1) unit1 else units) context.getString(if (vi <= 1) unit1 else units)
) )
} }
if( onlyDate) return when{ if (onlyDate) return when {
delta < 40 * 86400000L -> f( delta < 40 * 86400000L -> f(
delta / 86400000L, delta / 86400000L,
R.string.relative_time_unit_day1, R.string.relative_time_unit_day1,
R.string.relative_time_unit_days R.string.relative_time_unit_days
) )
else -> else ->
formatDate(t, date_format2, omitZeroSecond = false, omitYear = true) formatDate(t, date_format2, omitZeroSecond = false, omitYear = true)
} }
if (bAllowRelative && Pref.bpRelativeTimestamp(App1.pref)) { if (bAllowRelative && Pref.bpRelativeTimestamp(App1.pref)) {
delta = abs(delta) delta = abs(delta)
@ -1268,13 +1255,13 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
R.string.relative_time_unit_hours R.string.relative_time_unit_hours
) )
delta < 40 * 86400000L -> return f( delta < 40 * 86400000L -> return f(
delta / 86400000L, delta / 86400000L,
R.string.relative_time_unit_day1, R.string.relative_time_unit_day1,
R.string.relative_time_unit_days R.string.relative_time_unit_days
) )
} }
// fall back to absolute time // fall back to absolute time
} }
return formatDate(t, date_format, omitZeroSecond = false, omitYear = false) return formatDate(t, date_format, omitZeroSecond = false, omitYear = false)
@ -1299,8 +1286,8 @@ class TootStatus(parser: TootParser, src: JsonObject) : TimelineItem() {
val dateNow = format.format(Date()) val dateNow = format.format(Date())
val delm = dateNow.indexOf('-') val delm = dateNow.indexOf('-')
if (delm != -1 && if (delm != -1 &&
dateNow.substring(0, delm + 1) == dateTarget.substring(0,delm + 1) dateNow.substring(0, delm + 1) == dateTarget.substring(0, delm + 1)
) { ) {
dateTarget = dateTarget.substring(delm + 1) dateTarget = dateTarget.substring(delm + 1)
} }
} }

View File

@ -150,7 +150,7 @@ class DlgAppPicker(
activity, activity,
ivImage, ivImage,
R.drawable.ic_question, R.drawable.ic_question,
color = activity.getAttributeColor(R.attr.colorVectorDrawable), color = activity.attrColor(R.attr.colorVectorDrawable),
alphaMultiplier = 1f alphaMultiplier = 1f
) )
} }

View File

@ -134,7 +134,7 @@ class DlgListMember(
this.list_owner = a this.list_owner = a
if(a == null) { if(a == null) {
btnListOwner.setText(R.string.not_selected) btnListOwner.setText(R.string.not_selected)
btnListOwner.setTextColor(activity.getAttributeColor( android.R.attr.textColorPrimary)) btnListOwner.setTextColor(activity.attrColor( android.R.attr.textColorPrimary))
btnListOwner.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp) btnListOwner.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp)
// //
@ -148,7 +148,7 @@ class DlgListMember(
btnListOwner.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp) btnListOwner.setBackgroundResource(R.drawable.btn_bg_transparent_round6dp)
} }
btnListOwner.textColor = ac.color_fg.notZero() btnListOwner.textColor = ac.color_fg.notZero()
?: activity.getAttributeColor( android.R.attr.textColorPrimary) ?: activity.attrColor( android.R.attr.textColorPrimary)
} }
loadLists() loadLists()

View File

@ -269,7 +269,7 @@ class EmojiPicker(
setTypeface(typeface, Typeface.BOLD) setTypeface(typeface, Typeface.BOLD)
textColor = this@EmojiPicker.activity.getAttributeColor(R.attr.colorContentText) textColor = this@EmojiPicker.activity.attrColor(R.attr.colorContentText)
textSize = 16f // SP単位 textSize = 16f // SP単位
text = when(val name = it.key) { text = when(val name = it.key) {

View File

@ -149,7 +149,7 @@ fun Activity.openCustomTab(url: String?, pref:SharedPreferences = pref()) {
CustomTabsIntent.Builder() CustomTabsIntent.Builder()
.setDefaultColorSchemeParams( .setDefaultColorSchemeParams(
CustomTabColorSchemeParams.Builder() CustomTabColorSchemeParams.Builder()
.setToolbarColor(getAttributeColor(R.attr.colorPrimary)) .setToolbarColor(attrColor(R.attr.colorPrimary))
.build() .build()
) )
.setShowTitle(true) .setShowTitle(true)

View File

@ -10,7 +10,7 @@ import jp.juggler.subwaytooter.R
import jp.juggler.subwaytooter.api.entity.TootStatus import jp.juggler.subwaytooter.api.entity.TootStatus
import jp.juggler.subwaytooter.table.SavedAccount import jp.juggler.subwaytooter.table.SavedAccount
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import jp.juggler.util.showToast import jp.juggler.util.showToast
import jp.juggler.util.systemService import jp.juggler.util.systemService
@ -71,7 +71,7 @@ object CustomShare {
label = label =
"${context.getString(R.string.copy_to_clipboard)}(${context.getString(R.string.app_name)})" "${context.getString(R.string.copy_to_clipboard)}(${context.getString(R.string.app_name)})"
icon = ContextCompat.getDrawable(context, R.drawable.ic_copy)?.mutate()?.apply { icon = ContextCompat.getDrawable(context, R.drawable.ic_copy)?.mutate()?.apply {
setTint(context.getAttributeColor(R.attr.colorVectorDrawable)) setTint(context.attrColor(R.attr.colorVectorDrawable))
setTintMode(PorterDuff.Mode.SRC_IN) setTintMode(PorterDuff.Mode.SRC_IN)
} }
} else { } else {

View File

@ -19,7 +19,7 @@ import jp.juggler.subwaytooter.api.entity.Acct
import jp.juggler.subwaytooter.view.MyEditText import jp.juggler.subwaytooter.view.MyEditText
import jp.juggler.util.LogCategory import jp.juggler.util.LogCategory
import jp.juggler.util.asciiPattern import jp.juggler.util.asciiPattern
import jp.juggler.util.getAttributeColor import jp.juggler.util.attrColor
import jp.juggler.util.groupEx import jp.juggler.util.groupEx
import java.util.* import java.util.*
import kotlin.math.min import kotlin.math.min
@ -97,7 +97,7 @@ internal class PopupAutoCompleteAcct(
run { run {
val v = activity.layoutInflater val v = activity.layoutInflater
.inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView .inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView
v.setTextColor(activity.getAttributeColor(android.R.attr.textColorPrimary)) v.setTextColor(activity.attrColor(android.R.attr.textColorPrimary))
v.setText(R.string.close) v.setText(R.string.close)
v.setOnClickListener { acct_popup.dismiss() } v.setOnClickListener { acct_popup.dismiss() }
llItems.addView(v) llItems.addView(v)
@ -107,7 +107,7 @@ internal class PopupAutoCompleteAcct(
if(picker_caption != null && picker_callback != null) { if(picker_caption != null && picker_callback != null) {
val v = activity.layoutInflater val v = activity.layoutInflater
.inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView .inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView
v.setTextColor(activity.getAttributeColor(android.R.attr.textColorPrimary)) v.setTextColor(activity.attrColor(android.R.attr.textColorPrimary))
v.text = picker_caption v.text = picker_caption
v.setOnClickListener { v.setOnClickListener {
acct_popup.dismiss() acct_popup.dismiss()
@ -125,7 +125,7 @@ internal class PopupAutoCompleteAcct(
val acct = acct_list[i] val acct = acct_list[i]
val v = activity.layoutInflater val v = activity.layoutInflater
.inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView .inflate(R.layout.lv_spinner_dropdown, llItems, false) as CheckedTextView
v.setTextColor(activity.getAttributeColor(android.R.attr.textColorPrimary)) v.setTextColor(activity.attrColor(android.R.attr.textColorPrimary))
v.text = acct v.text = acct
if(acct is Spannable) { if(acct is Spannable) {
NetworkEmojiInvalidator(handler, v).register(acct) NetworkEmojiInvalidator(handler, v).register(acct)

View File

@ -893,7 +893,7 @@ class PostHelper(
sb.append(item.alias) sb.append(item.alias)
sb.append(": → ") sb.append(": → ")
sb.setSpan( sb.setSpan(
ForegroundColorSpan(activity.getAttributeColor(R.attr.colorTimeSmall)), ForegroundColorSpan(activity.attrColor(R.attr.colorTimeSmall)),
start, start,
sb.length, sb.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE Spanned.SPAN_EXCLUSIVE_EXCLUSIVE

View File

@ -7,7 +7,7 @@ import android.graphics.Rect
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import jp.juggler.subwaytooter.R import jp.juggler.subwaytooter.R
import jp.juggler.util.getAttributeDrawable import jp.juggler.util.attrDrawable
class ListDivider(context : Context) : RecyclerView.ItemDecoration() { class ListDivider(context : Context) : RecyclerView.ItemDecoration() {
@ -18,7 +18,7 @@ class ListDivider(context : Context) : RecyclerView.ItemDecoration() {
var marginH : Int = 0 var marginH : Int = 0
} }
private val drawable = getAttributeDrawable(context, R.attr.colorSettingDivider) private val drawable = context.attrDrawable( R.attr.colorSettingDivider)
private val paint = Paint() private val paint = Paint()
private val rect = Rect() private val rect = Rect()

View File

@ -7,7 +7,7 @@ import android.graphics.Rect
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import jp.juggler.subwaytooter.R import jp.juggler.subwaytooter.R
import jp.juggler.util.getAttributeDrawable import jp.juggler.util.attrDrawable
class TabletColumnDivider(context : Context) : RecyclerView.ItemDecoration() { class TabletColumnDivider(context : Context) : RecyclerView.ItemDecoration() {
@ -19,7 +19,7 @@ class TabletColumnDivider(context : Context) : RecyclerView.ItemDecoration() {
var barWidth : Int = 0 var barWidth : Int = 0
} }
private val drawable = getAttributeDrawable(context, R.attr.colorSettingDivider) private val drawable = context.attrDrawable( R.attr.colorSettingDivider)
private val paint = Paint() private val paint = Paint()
private val rect = Rect() private val rect = Rect()

View File

@ -5,6 +5,7 @@ import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.TypedArray
import android.graphics.Color import android.graphics.Color
import android.graphics.ColorFilter import android.graphics.ColorFilter
import android.graphics.PorterDuff import android.graphics.PorterDuff
@ -37,40 +38,25 @@ fun Int.applyAlphaMultiplier(alphaMultiplier : Float? = null) : Int {
} }
} }
fun Context.getAttributeColor(attrId : Int) : Int { fun Context.attrColor(attrId : Int) : Int {
val a = theme.obtainStyledAttributes(intArrayOf(attrId)) val a = theme.obtainStyledAttributes(intArrayOf(attrId))
val color = a.getColor(0, Color.BLACK) val color = a.getColor(0, Color.BLACK)
a.recycle() a.recycle()
return color return color
} }
fun getAttributeDrawable(context : Context, attrId : Int) : Drawable { fun<T> TypedArray.use(block:(TypedArray)->T):T =
try{ block(this) }finally{ recycle() }
fun getAttributeResourceId(context : Context, attrId : Int) : Int {
val theme = context.theme fun Context.getAttributeResourceId( attrId : Int) =
val a = theme.obtainStyledAttributes(intArrayOf(attrId)) theme.obtainStyledAttributes(intArrayOf(attrId))
val resourceId = a.getResourceId(0, 0) .use{ it.getResourceId(0, 0) }
a.recycle() .notZero() ?: error("missing resource id. attr_id=0x${attrId.toString(16)}")
if(resourceId == 0)
throw RuntimeException( fun Context.attrDrawable( attrId : Int) : Drawable {
String.format( val drawableId = getAttributeResourceId( attrId)
Locale.JAPAN, return ContextCompat.getDrawable(this, drawableId)
"attr not defined.attr_id=0x%x", ?: error("getDrawable failed. drawableId=0x${drawableId.toString(16)}")
attrId
)
)
return resourceId
}
val drawableId = getAttributeResourceId(context, attrId)
val d = ContextCompat.getDrawable(context, drawableId)
return d ?: throw RuntimeException(
String.format(
Locale.JAPAN,
"getDrawable failed. drawableId=0x%x",
drawableId
)
)
} }
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////

View File

@ -108,10 +108,10 @@ fun Context.setSwitchColor(
pref : SharedPreferences, pref : SharedPreferences,
root : View? root : View?
) { ) {
val colorBg = getAttributeColor(R.attr.colorWindowBackground) val colorBg = attrColor(R.attr.colorWindowBackground)
val colorOn = Pref.ipSwitchOnColor(pref) val colorOn = Pref.ipSwitchOnColor(pref)
val colorOff = /* Pref.ipSwitchOffColor(pref).notZero() ?: */ val colorOff = /* Pref.ipSwitchOffColor(pref).notZero() ?: */
getAttributeColor(android.R.attr.colorPrimary) attrColor(android.R.attr.colorPrimary)
val colorDisabled = mixColor(colorBg, colorOff) val colorDisabled = mixColor(colorBg, colorOff)
@ -207,7 +207,7 @@ fun AppCompatActivity.setStatusBarColor(forceDark : Boolean = false) {
var c = when { var c = when {
forceDark -> Color.BLACK forceDark -> Color.BLACK
else -> Pref.ipStatusBarColor(App1.pref).notZero() else -> Pref.ipStatusBarColor(App1.pref).notZero()
?: getAttributeColor(R.attr.colorPrimaryDark) ?: attrColor(R.attr.colorPrimaryDark)
} }
statusBarColor = c or Color.BLACK statusBarColor = c or Color.BLACK