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

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.ipEventBgColorQuote, R.string.quote_renote)
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) {
@ -903,6 +915,11 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
colorOpaque(Pref.ipNavigationBarColor, R.string.navigation_bar_color) {
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) {

View File

@ -108,6 +108,7 @@ class ColumnViewHolder(
private lateinit var btnAnnouncementsBadge : ImageView
private lateinit var btnAnnouncements : ImageButton
private lateinit var btnAnnouncementsCutout : Paint
private lateinit var btnColumnSetting : ImageButton
private lateinit var btnColumnReload : ImageButton
private lateinit var btnColumnClose : ImageButton
@ -710,6 +711,41 @@ class ColumnViewHolder(
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()
showContent(reason = "onPageCreate", reset = true)
@ -1749,9 +1785,8 @@ class ColumnViewHolder(
padding = dip(8)
scaleType = ImageView.ScaleType.FIT_CENTER
val paint = Paint().apply {
btnAnnouncementsCutout = Paint().apply {
isAntiAlias = true
color = getAttributeColor(context, R.attr.colorSearchFormBackground)
}
val path = Path()
addOutsideDrawer(this) { canvas, parent, view, left, top ->
@ -1768,7 +1803,7 @@ class ColumnViewHolder(
path.lineTo(triBottomRight, triBottom)
path.lineTo(triBottomLeft, triBottom)
path.lineTo(triTopX, triTopY)
canvas.drawPath(path, paint)
canvas.drawPath(path, btnAnnouncementsCutout)
}
}
}.lparams(dip(40), dip(40))
@ -2060,14 +2095,6 @@ class ColumnViewHolder(
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 paddingH = (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) {
topMargin = dip(1)
}
val pad_lr = dip(6)
pad_tb = dip(2)
val pad_tb = dip(2)
setPadding(pad_lr, pad_tb, pad_lr, pad_tb)
scrollBarStyle = View.SCROLLBARS_OUTSIDE_OVERLAY
@ -2168,11 +2196,6 @@ class ColumnViewHolder(
llSearch = verticalLayout {
lparams(matchParent, wrapContent)
backgroundColor = getAttributeColor(context, R.attr.colorSearchFormBackground)
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
linearLayout {
lparams(matchParent, wrapContent)
@ -2227,16 +2250,9 @@ class ColumnViewHolder(
llListList = linearLayout {
lparams(matchParent, wrapContent)
startPadding = dip(12)
endPadding = dip(12)
topPadding = dip(3)
bottomPadding = dip(3)
backgroundColor = getAttributeColor(context, R.attr.colorSearchFormBackground)
isBaselineAligned = false
gravity = Gravity.CENTER
etListName = editText {
hint = context.getString(R.string.list_create_hint)
imeOptions = EditorInfo.IME_ACTION_SEND

View File

@ -338,7 +338,19 @@ internal class DlgContextMenu(
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) {
// 被フォロー状態
// Styler.setFollowIconとは異なり細かい状態を表示しない
ivFollowedBy.vg(relation.followed_by)
@ -352,37 +364,30 @@ internal class DlgContextMenu(
else -> R.drawable.ic_follow_plus
}
)
btnFollow.imageTintList = ColorStateList.valueOf(
getAttributeColor(
activity,
when {
relation.getRequested(who) -> R.attr.colorRegexFilterError
relation.getFollowing(who) -> R.attr.colorImageButtonAccent
else -> R.attr.colorImageButton
}
)
when {
relation.getRequested(who) -> colorButtonError
relation.getFollowing(who) -> colorButtonAccent
else -> colorButtonNormal
}
)
// ミュート状態
btnMute.imageTintList = ColorStateList.valueOf(
getAttributeColor(
activity,
when(relation.muting) {
true -> R.attr.colorImageButtonAccent
else -> R.attr.colorImageButton
}
)
when(relation.muting) {
true -> colorButtonAccent
else -> colorButtonNormal
}
)
// ブロック状態
btnBlock.imageTintList = ColorStateList.valueOf(
getAttributeColor(
activity,
when(relation.blocking) {
true -> R.attr.colorImageButtonAccent
else -> R.attr.colorImageButton
}
)
when(relation.blocking) {
true -> colorButtonAccent
else -> colorButtonNormal
}
)
}

View File

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

View File

@ -488,6 +488,12 @@ object Pref {
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 ipNavigationBarColor = IntPref("NavigationBarColor", 0)
@ -513,6 +519,13 @@ object Pref {
val ipCcdContentAcct = IntPref("ipCcdContentAcct", 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)
// const val TTCS_WEEKLY = 0
// const val TTCS_DAILY = 1

View File

@ -85,8 +85,8 @@ internal class StatusButtons(
btnCustomShare1.setOnLongClickListener(this)
btnCustomShare2.setOnLongClickListener(this)
btnCustomShare3.setOnLongClickListener(this)
btnMore.setOnClickListener(this)
btnConversation.setOnClickListener(this)
btnConversation.setOnLongClickListener(this)
@ -103,6 +103,8 @@ internal class StatusButtons(
this.status = status
this.notification = notification
val pref = activity.pref
setIconDrawableId(
activity,
btnConversation,
@ -110,6 +112,7 @@ internal class StatusButtons(
color = color_normal,
alphaMultiplier = Styler.boost_alpha
)
setIconDrawableId(
activity,
btnMore,
@ -118,20 +121,6 @@ internal class StatusButtons(
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(
btnReply,
true,
@ -157,28 +146,31 @@ internal class StatusButtons(
// マストドンではDirectはブーストできない (Misskeyはできる)
(! access_info.isMisskey && status.visibility.order <= TootVisibility.DirectSpecified.order) ->
setButton(
btnBoost,
false,
color_accent,
R.drawable.ic_mail,
"",
activity.getString(R.string.boost)
)
btnBoost,
false,
color_accent,
R.drawable.ic_mail,
"",
activity.getString(R.string.boost)
)
activity.app_state.isBusyBoost(access_info, status) ->
setButton(
btnBoost,
false,
color_normal,
R.drawable.ic_refresh,
"?",
activity.getString(R.string.boost)
)
btnBoost,
false,
color_normal,
R.drawable.ic_refresh,
"?",
activity.getString(R.string.boost)
)
else -> setButton(
btnBoost,
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,
when(val boosts_count = status.reblogs_count) {
null -> ""
@ -228,7 +220,10 @@ internal class StatusButtons(
else -> setButton(
btnFavourite,
true,
if(status.favourited) color_accent else color_normal,
if(status.favourited)
Pref.ipButtonFavoritedColor(pref).notZero() ?: color_accent
else
color_normal,
fav_icon_drawable,
when(val favourites_count = status.favourites_count) {
null -> ""
@ -261,7 +256,10 @@ internal class StatusButtons(
else -> setButton(
btnBookmark,
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,
activity.getString(R.string.bookmark)
)
@ -474,13 +472,12 @@ internal class StatusButtons(
Action_Toot.replyFromAnotherAccount(activity, access_info, status)
}
btnQuote ->if(! access_info.isPseudo) {
Action_Toot.reply(activity, access_info, status,quote = true)
btnQuote -> if(! access_info.isPseudo) {
Action_Toot.reply(activity, access_info, status, quote = true)
} else {
Action_Toot.replyFromAnotherAccount(activity, access_info, status,quote = true)
Action_Toot.replyFromAnotherAccount(activity, access_info, status, quote = true)
}
btnBoost -> {
if(access_info.isPseudo) {
Action_Toot.boostFromAnotherAccount(activity, access_info, status)
@ -678,8 +675,8 @@ internal class StatusButtons(
activity, access_info, status
)
btnQuote ->Action_Toot.replyFromAnotherAccount(
activity, access_info, status ,quote = true
btnQuote -> Action_Toot.replyFromAnotherAccount(
activity, access_info, status, quote = true
)
btnFollow2 -> Action_Follow.followFromAnotherAccount(
@ -696,7 +693,7 @@ internal class StatusButtons(
CustomShareTarget.CustomShare1
)
btnCustomShare2 ->shareUrl(
btnCustomShare2 -> shareUrl(
status,
CustomShareTarget.CustomShare2
)
@ -716,7 +713,7 @@ internal class StatusButtons(
) {
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
, alphaMultiplier : Float
) {
fun colorAccent() =
Pref.ipButtonFollowingColor(Pref.pref(context)).notZero()
?: getAttributeColor(context, R.attr.colorImageButtonAccent)
fun colorError() = getAttributeColor(context, R.attr.colorRegexFilterError)
fun colorAccent() = getAttributeColor(context, R.attr.colorImageButtonAccent)
fun colorError() =
Pref.ipButtonFollowRequestColor(Pref.pref(context)).notZero()
?: getAttributeColor(context, R.attr.colorRegexFilterError)
// 被フォロー状態
when {

View File

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

View File

@ -1021,4 +1021,10 @@
<string name="yes">はい</string>
<string name="no">いいえ</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>

View File

@ -1026,4 +1026,10 @@
<string name="yes">Yes</string>
<string name="no">No</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>