「アプリ設定/色」にいくつかの項目を追加

This commit is contained in:
tateisu 2020-06-25 03:46:18 +09:00
parent c03a5ff731
commit a114315042
10 changed files with 170 additions and 100 deletions

View File

@ -745,6 +745,18 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
colorAlpha(Pref.ipEventBgColorReaction, R.string.reaction) colorAlpha(Pref.ipEventBgColorReaction, R.string.reaction)
colorAlpha(Pref.ipEventBgColorQuote, R.string.quote_renote) colorAlpha(Pref.ipEventBgColorQuote, R.string.quote_renote)
colorAlpha(Pref.ipEventBgColorVote, R.string.vote_polls) colorAlpha(Pref.ipEventBgColorVote, R.string.vote_polls)
colorAlpha(
Pref.ipConversationMainTootBgColor,
R.string.conversation_main_toot_background_color
)
}
group(R.string.button_accent_color) {
colorAlpha(Pref.ipButtonBoostedColor, R.string.boost)
colorAlpha(Pref.ipButtonFavoritedColor, R.string.favourites)
colorAlpha(Pref.ipButtonBookmarkedColor, R.string.bookmarks)
colorAlpha(Pref.ipButtonFollowingColor, R.string.follow)
colorAlpha(Pref.ipButtonFollowRequestColor, R.string.follow_request)
} }
group(R.string.column_color_default) { group(R.string.column_color_default) {
@ -903,6 +915,11 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
colorOpaque(Pref.ipNavigationBarColor, R.string.navigation_bar_color) { colorOpaque(Pref.ipNavigationBarColor, R.string.navigation_bar_color) {
changed = { App1.setStatusBarColor(this) } changed = { App1.setStatusBarColor(this) }
} }
colorOpaque(Pref.ipSearchBgColor, R.string.search_bar_background_color)
colorAlpha(Pref.ipAnnouncementsBgColor, R.string.announcement_background_color)
colorAlpha(Pref.ipVerifiedLinkBgColor, R.string.verified_link_background_color)
colorAlpha(Pref.ipVerifiedLinkFgColor, R.string.verified_link_foreground_color)
} }
section(R.string.performance) { section(R.string.performance) {

View File

@ -108,6 +108,7 @@ class ColumnViewHolder(
private lateinit var btnAnnouncementsBadge : ImageView private lateinit var btnAnnouncementsBadge : ImageView
private lateinit var btnAnnouncements : ImageButton private lateinit var btnAnnouncements : ImageButton
private lateinit var btnAnnouncementsCutout : Paint
private lateinit var btnColumnSetting : ImageButton private lateinit var btnColumnSetting : ImageButton
private lateinit var btnColumnReload : ImageButton private lateinit var btnColumnReload : ImageButton
private lateinit var btnColumnClose : ImageButton private lateinit var btnColumnClose : ImageButton
@ -710,6 +711,41 @@ class ColumnViewHolder(
lastAnnouncementShown = - 1L lastAnnouncementShown = - 1L
fun dip(dp : Int) : Int = (activity.density * dp + 0.5f).toInt()
val context = activity
val announcementsBgColor = Pref.ipAnnouncementsBgColor(activity.pref).notZero()
?: getAttributeColor(context, R.attr.colorSearchFormBackground)
btnAnnouncementsCutout.apply {
color = announcementsBgColor
}
llAnnouncementsBox.apply {
background = createRoundDrawable( dip(6).toFloat(), announcementsBgColor )
val pad_tb = dip(2)
setPadding(0, pad_tb, 0, pad_tb)
}
val searchBgColor = Pref.ipSearchBgColor(activity.pref).notZero()
?: getAttributeColor(context, R.attr.colorSearchFormBackground)
llSearch.apply {
backgroundColor = searchBgColor
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
}
llListList.apply {
backgroundColor = searchBgColor
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
}
showColumnColor() showColumnColor()
showContent(reason = "onPageCreate", reset = true) showContent(reason = "onPageCreate", reset = true)
@ -1749,9 +1785,8 @@ class ColumnViewHolder(
padding = dip(8) padding = dip(8)
scaleType = ImageView.ScaleType.FIT_CENTER scaleType = ImageView.ScaleType.FIT_CENTER
val paint = Paint().apply { btnAnnouncementsCutout = Paint().apply {
isAntiAlias = true isAntiAlias = true
color = getAttributeColor(context, R.attr.colorSearchFormBackground)
} }
val path = Path() val path = Path()
addOutsideDrawer(this) { canvas, parent, view, left, top -> addOutsideDrawer(this) { canvas, parent, view, left, top ->
@ -1768,7 +1803,7 @@ class ColumnViewHolder(
path.lineTo(triBottomRight, triBottom) path.lineTo(triBottomRight, triBottom)
path.lineTo(triBottomLeft, triBottom) path.lineTo(triBottomLeft, triBottom)
path.lineTo(triTopX, triTopY) path.lineTo(triTopX, triTopY)
canvas.drawPath(path, paint) canvas.drawPath(path, btnAnnouncementsCutout)
} }
} }
}.lparams(dip(40), dip(40)) }.lparams(dip(40), dip(40))
@ -2060,14 +2095,6 @@ class ColumnViewHolder(
bottomMargin = dip(2) bottomMargin = dip(2)
} }
background = createRoundDrawable(
dip(6).toFloat(),
getAttributeColor(context, R.attr.colorSearchFormBackground)
)
var pad_tb = dip(2)
setPadding(0, pad_tb, 0, pad_tb)
val buttonHeight = ActMain.boostButtonSize val buttonHeight = ActMain.boostButtonSize
val paddingH = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt() val paddingH = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt()
val paddingV = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt() val paddingV = (buttonHeight.toFloat() * 0.1f + 0.5f).toInt()
@ -2131,8 +2158,9 @@ class ColumnViewHolder(
lparams(matchParent, wrapContent) { lparams(matchParent, wrapContent) {
topMargin = dip(1) topMargin = dip(1)
} }
val pad_lr = dip(6) val pad_lr = dip(6)
pad_tb = dip(2) val pad_tb = dip(2)
setPadding(pad_lr, pad_tb, pad_lr, pad_tb) setPadding(pad_lr, pad_tb, pad_lr, pad_tb)
scrollBarStyle = View.SCROLLBARS_OUTSIDE_OVERLAY scrollBarStyle = View.SCROLLBARS_OUTSIDE_OVERLAY
@ -2168,11 +2196,6 @@ class ColumnViewHolder(
llSearch = verticalLayout { llSearch = verticalLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
backgroundColor = getAttributeColor(context, R.attr.colorSearchFormBackground)
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
linearLayout { linearLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
@ -2227,16 +2250,9 @@ class ColumnViewHolder(
llListList = linearLayout { llListList = linearLayout {
lparams(matchParent, wrapContent) lparams(matchParent, wrapContent)
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
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

View File

@ -338,7 +338,19 @@ internal class DlgContextMenu(
llNotification.vg(notification != null) llNotification.vg(notification != null)
val colorButtonAccent =
Pref.ipButtonFollowingColor(activity.pref).notZero()
?: getAttributeColor(activity, R.attr.colorImageButtonAccent)
val colorButtonError =
Pref.ipButtonFollowRequestColor(activity.pref).notZero()
?: getAttributeColor(activity, R.attr.colorRegexFilterError)
val colorButtonNormal =
getAttributeColor(activity, R.attr.colorImageButton)
fun showRelation(relation : UserRelation) { fun showRelation(relation : UserRelation) {
// 被フォロー状態 // 被フォロー状態
// Styler.setFollowIconとは異なり細かい状態を表示しない // Styler.setFollowIconとは異なり細かい状態を表示しない
ivFollowedBy.vg(relation.followed_by) ivFollowedBy.vg(relation.followed_by)
@ -352,37 +364,30 @@ internal class DlgContextMenu(
else -> R.drawable.ic_follow_plus else -> R.drawable.ic_follow_plus
} }
) )
btnFollow.imageTintList = ColorStateList.valueOf( btnFollow.imageTintList = ColorStateList.valueOf(
getAttributeColor( when {
activity, relation.getRequested(who) -> colorButtonError
when { relation.getFollowing(who) -> colorButtonAccent
relation.getRequested(who) -> R.attr.colorRegexFilterError else -> colorButtonNormal
relation.getFollowing(who) -> R.attr.colorImageButtonAccent }
else -> R.attr.colorImageButton
}
)
) )
// ミュート状態 // ミュート状態
btnMute.imageTintList = ColorStateList.valueOf( btnMute.imageTintList = ColorStateList.valueOf(
getAttributeColor( when(relation.muting) {
activity, true -> colorButtonAccent
when(relation.muting) { else -> colorButtonNormal
true -> R.attr.colorImageButtonAccent }
else -> R.attr.colorImageButton
}
)
) )
// ブロック状態 // ブロック状態
btnBlock.imageTintList = ColorStateList.valueOf( btnBlock.imageTintList = ColorStateList.valueOf(
getAttributeColor( when(relation.blocking) {
activity, true -> colorButtonAccent
when(relation.blocking) { else -> colorButtonNormal
true -> R.attr.colorImageButtonAccent }
else -> R.attr.colorImageButton
}
)
) )
} }

View File

@ -1226,12 +1226,12 @@ internal class ItemViewHolder(
llStatus.visibility = View.VISIBLE llStatus.visibility = View.VISIBLE
if(status.conversation_main) { if(status.conversation_main) {
this.viewRoot.setBackgroundColor(
(getAttributeColor( val conversationMainBgColor = Pref.ipConversationMainTootBgColor(activity.pref).notZero()
activity, ?: (getAttributeColor(activity,R.attr.colorImageButtonAccent) and 0xffffff) or 0x20000000
R.attr.colorImageButtonAccent
) and 0xffffff) or 0x20000000 this.viewRoot.setBackgroundColor( conversationMainBgColor )
)
} else { } else {
val c = colorBg.notZero() val c = colorBg.notZero()

View File

@ -488,6 +488,12 @@ object Pref {
val ipSwitchOnColor = IntPref("SwitchOnColor", Color.BLACK or 0x0080ff) val ipSwitchOnColor = IntPref("SwitchOnColor", Color.BLACK or 0x0080ff)
val ipButtonBoostedColor = IntPref("ButtonBoostedColor", 0)
val ipButtonFavoritedColor = IntPref("ButtonFavoritedColor", 0)
val ipButtonBookmarkedColor = IntPref("ButtonBookmarkedColor", 0)
val ipButtonFollowingColor = IntPref("ButtonFollowingColor", 0)
val ipButtonFollowRequestColor = IntPref("ButtonFollowRequestColor", 0)
val ipStatusBarColor = IntPref("StatusBarColor", 0) val ipStatusBarColor = IntPref("StatusBarColor", 0)
val ipNavigationBarColor = IntPref("NavigationBarColor", 0) val ipNavigationBarColor = IntPref("NavigationBarColor", 0)
@ -513,6 +519,13 @@ object Pref {
val ipCcdContentAcct = IntPref("ipCcdContentAcct", 0) val ipCcdContentAcct = IntPref("ipCcdContentAcct", 0)
val ipCcdContentText = IntPref("ipCcdContentText", 0) val ipCcdContentText = IntPref("ipCcdContentText", 0)
val ipSearchBgColor = IntPref("SearchBgColor", 0)
val ipAnnouncementsBgColor = IntPref("AnnouncementsBgColor", 0)
val ipConversationMainTootBgColor = IntPref("ConversationMainTootBgColor", 0)
val ipVerifiedLinkBgColor = IntPref("VerifiedLinkBgColor", 0)
val ipVerifiedLinkFgColor = IntPref("VerifiedLinkFgColor", 0)
// val ipTrendTagCountShowing = IntPref("TrendTagCountShowing", 0) // val ipTrendTagCountShowing = IntPref("TrendTagCountShowing", 0)
// const val TTCS_WEEKLY = 0 // const val TTCS_WEEKLY = 0
// const val TTCS_DAILY = 1 // const val TTCS_DAILY = 1

View File

@ -85,8 +85,8 @@ internal class StatusButtons(
btnCustomShare1.setOnLongClickListener(this) btnCustomShare1.setOnLongClickListener(this)
btnCustomShare2.setOnLongClickListener(this) btnCustomShare2.setOnLongClickListener(this)
btnCustomShare3.setOnLongClickListener(this) btnCustomShare3.setOnLongClickListener(this)
btnMore.setOnClickListener(this) btnMore.setOnClickListener(this)
btnConversation.setOnClickListener(this) btnConversation.setOnClickListener(this)
btnConversation.setOnLongClickListener(this) btnConversation.setOnLongClickListener(this)
@ -103,6 +103,8 @@ internal class StatusButtons(
this.status = status this.status = status
this.notification = notification this.notification = notification
val pref = activity.pref
setIconDrawableId( setIconDrawableId(
activity, activity,
btnConversation, btnConversation,
@ -110,6 +112,7 @@ internal class StatusButtons(
color = color_normal, color = color_normal,
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
setIconDrawableId( setIconDrawableId(
activity, activity,
btnMore, btnMore,
@ -118,20 +121,6 @@ internal class StatusButtons(
alphaMultiplier = Styler.boost_alpha alphaMultiplier = Styler.boost_alpha
) )
// val a = (((color_normal ushr 24)/255f) * 0.7f)
// setIconDrawableId で色を指定するとアルファ値も反映されるらしい
// btnConversation.alpha = a
// btnMore.alpha = a
//
// btnReply.alpha = a
// btnBoost.alpha = a
// btnFavourite.alpha = a
// btnFollow2.alpha = a
// ivFollowedBy2.alpha = a
setButton( setButton(
btnReply, btnReply,
true, true,
@ -157,28 +146,31 @@ internal class StatusButtons(
// マストドンではDirectはブーストできない (Misskeyはできる) // マストドンではDirectはブーストできない (Misskeyはできる)
(! access_info.isMisskey && status.visibility.order <= TootVisibility.DirectSpecified.order) -> (! access_info.isMisskey && status.visibility.order <= TootVisibility.DirectSpecified.order) ->
setButton( setButton(
btnBoost, btnBoost,
false, false,
color_accent, color_accent,
R.drawable.ic_mail, R.drawable.ic_mail,
"", "",
activity.getString(R.string.boost) activity.getString(R.string.boost)
) )
activity.app_state.isBusyBoost(access_info, status) -> activity.app_state.isBusyBoost(access_info, status) ->
setButton( setButton(
btnBoost, btnBoost,
false, false,
color_normal, color_normal,
R.drawable.ic_refresh, R.drawable.ic_refresh,
"?", "?",
activity.getString(R.string.boost) activity.getString(R.string.boost)
) )
else -> setButton( else -> setButton(
btnBoost, btnBoost,
true, true,
if(status.reblogged) color_accent else color_normal, if(status.reblogged)
Pref.ipButtonBoostedColor(pref).notZero() ?: color_accent
else
color_normal,
R.drawable.ic_repeat, R.drawable.ic_repeat,
when(val boosts_count = status.reblogs_count) { when(val boosts_count = status.reblogs_count) {
null -> "" null -> ""
@ -228,7 +220,10 @@ internal class StatusButtons(
else -> setButton( else -> setButton(
btnFavourite, btnFavourite,
true, true,
if(status.favourited) color_accent else color_normal, if(status.favourited)
Pref.ipButtonFavoritedColor(pref).notZero() ?: color_accent
else
color_normal,
fav_icon_drawable, fav_icon_drawable,
when(val favourites_count = status.favourites_count) { when(val favourites_count = status.favourites_count) {
null -> "" null -> ""
@ -261,7 +256,10 @@ internal class StatusButtons(
else -> setButton( else -> setButton(
btnBookmark, btnBookmark,
true, true,
if(status.bookmarked) color_accent else color_normal, if(status.bookmarked)
Pref.ipButtonBookmarkedColor(pref).notZero() ?: color_accent
else
color_normal,
R.drawable.ic_bookmark, R.drawable.ic_bookmark,
activity.getString(R.string.bookmark) activity.getString(R.string.bookmark)
) )
@ -474,13 +472,12 @@ internal class StatusButtons(
Action_Toot.replyFromAnotherAccount(activity, access_info, status) Action_Toot.replyFromAnotherAccount(activity, access_info, status)
} }
btnQuote ->if(! access_info.isPseudo) { btnQuote -> if(! access_info.isPseudo) {
Action_Toot.reply(activity, access_info, status,quote = true) Action_Toot.reply(activity, access_info, status, quote = true)
} else { } else {
Action_Toot.replyFromAnotherAccount(activity, access_info, status,quote = true) Action_Toot.replyFromAnotherAccount(activity, access_info, status, quote = true)
} }
btnBoost -> { btnBoost -> {
if(access_info.isPseudo) { if(access_info.isPseudo) {
Action_Toot.boostFromAnotherAccount(activity, access_info, status) Action_Toot.boostFromAnotherAccount(activity, access_info, status)
@ -678,8 +675,8 @@ internal class StatusButtons(
activity, access_info, status activity, access_info, status
) )
btnQuote ->Action_Toot.replyFromAnotherAccount( btnQuote -> Action_Toot.replyFromAnotherAccount(
activity, access_info, status ,quote = true activity, access_info, status, quote = true
) )
btnFollow2 -> Action_Follow.followFromAnotherAccount( btnFollow2 -> Action_Follow.followFromAnotherAccount(
@ -696,7 +693,7 @@ internal class StatusButtons(
CustomShareTarget.CustomShare1 CustomShareTarget.CustomShare1
) )
btnCustomShare2 ->shareUrl( btnCustomShare2 -> shareUrl(
status, status,
CustomShareTarget.CustomShare2 CustomShareTarget.CustomShare2
) )
@ -716,7 +713,7 @@ internal class StatusButtons(
) { ) {
val url = status.url ?: status.uri ?: return val url = status.url ?: status.uri ?: return
CustomShare.invoke(activity,url,target) CustomShare.invoke(activity, url, target)
} }
} }

View File

@ -156,9 +156,13 @@ object Styler {
, defaultColor : Int , defaultColor : Int
, alphaMultiplier : Float , alphaMultiplier : Float
) { ) {
fun colorAccent() =
Pref.ipButtonFollowingColor(Pref.pref(context)).notZero()
?: getAttributeColor(context, R.attr.colorImageButtonAccent)
fun colorError() = getAttributeColor(context, R.attr.colorRegexFilterError) fun colorError() =
fun colorAccent() = getAttributeColor(context, R.attr.colorImageButtonAccent) Pref.ipButtonFollowRequestColor(Pref.pref(context)).notZero()
?: getAttributeColor(context, R.attr.colorRegexFilterError)
// 被フォロー状態 // 被フォロー状態
when { when {

View File

@ -414,8 +414,11 @@ internal class ViewHolderHeaderProfile(
valueText.append(TootStatus.formatTime(activity, item.verified_at, false)) valueText.append(TootStatus.formatTime(activity, item.verified_at, false))
val end = valueText.length val end = valueText.length
val linkFgColor = Pref.ipVerifiedLinkFgColor(activity.pref).notZero()
?: (Color.BLACK or 0x7fbc99)
valueText.setSpan( valueText.setSpan(
ForegroundColorSpan(Color.BLACK or 0x7fbc99) ForegroundColorSpan(linkFgColor)
, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE , start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
) )
} }
@ -431,7 +434,10 @@ internal class ViewHolderHeaderProfile(
valueView.movementMethod = MyLinkMovementMethod valueView.movementMethod = MyLinkMovementMethod
if(item.verified_at > 0L) { if(item.verified_at > 0L) {
valueView.setBackgroundColor(0x337fbc99) val linkBgColor = Pref.ipVerifiedLinkBgColor(activity.pref).notZero()
?: (0x337fbc99)
valueView.setBackgroundColor(linkBgColor)
} }
llFields.addView(valueView) llFields.addView(valueView)
@ -465,7 +471,7 @@ internal class ViewHolderHeaderProfile(
tvMovedName.text = movedRef.decoded_display_name tvMovedName.text = movedRef.decoded_display_name
moved_name_invalidator.register(movedRef.decoded_display_name) moved_name_invalidator.register(movedRef.decoded_display_name)
setAcct(tvMovedAcct, access_info,moved) setAcct(tvMovedAcct, access_info, moved)
val relation = UserRelation.load(access_info.db_id, moved.id) val relation = UserRelation.load(access_info.db_id, moved.id)
Styler.setFollowIcon( Styler.setFollowIcon(
@ -479,8 +485,8 @@ internal class ViewHolderHeaderProfile(
) )
} }
private fun setAcct(tv : TextView,accessInfo:SavedAccount,who:TootAccount) { private fun setAcct(tv : TextView, accessInfo : SavedAccount, who : TootAccount) {
val ac = AcctColor.load(accessInfo,who) val ac = AcctColor.load(accessInfo, who)
tv.text = when { tv.text = when {
AcctColor.hasNickname(ac) -> ac.nickname AcctColor.hasNickname(ac) -> ac.nickname
Pref.bpShortAcctLocalUser(App1.pref) -> "@${who.acct.pretty}" Pref.bpShortAcctLocalUser(App1.pref) -> "@${who.acct.pretty}"

View File

@ -1021,4 +1021,10 @@
<string name="yes">はい</string> <string name="yes">はい</string>
<string name="no">いいえ</string> <string name="no">いいえ</string>
<string name="muted_quote">ミュートされた引用</string> <string name="muted_quote">ミュートされた引用</string>
<string name="button_accent_color">ボタン強調色</string>
<string name="search_bar_background_color">検索バーの背景色 (アプリ再起動が必要)</string>
<string name="announcement_background_color">告知の背景色 (アプリ再起動が必要)</string>
<string name="conversation_main_toot_background_color">会話ビューのメイン投稿の背景色</string>
<string name="verified_link_background_color">認証済みリンクの背景色 (アプリ再起動が必要)</string>
<string name="verified_link_foreground_color">認証済みリンクの文字色 (アプリ再起動が必要)</string>
</resources> </resources>

View File

@ -1026,4 +1026,10 @@
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="no">No</string> <string name="no">No</string>
<string name="muted_quote">Muted quote</string> <string name="muted_quote">Muted quote</string>
<string name="button_accent_color">Button accent color</string>
<string name="search_bar_background_color">Search bar background color (app restart required)</string>
<string name="announcement_background_color">Announcements background color (app restart required)</string>
<string name="conversation_main_toot_background_color">Conversation main toot background color</string>
<string name="verified_link_background_color">Verified link background color (app restart required)</string>
<string name="verified_link_foreground_color">Verified link foreground color (app restart required)</string>
</resources> </resources>