diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt b/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt index 31bed7c6..7f0efe3c 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt @@ -74,6 +74,16 @@ class ActAppSettingChild : AppCompatActivity() internal const val COLOR_DIALOG_ID_COLUMN_ACCT = 15 internal const val COLOR_DIALOG_ID_COLUMN_TEXT = 16 + internal const val COLOR_DIALOG_ID_EVENT_BG_BOOST = 17 + internal const val COLOR_DIALOG_ID_EVENT_BG_FAVOURITE = 18 + internal const val COLOR_DIALOG_ID_EVENT_BG_FOLLOW = 19 + internal const val COLOR_DIALOG_ID_EVENT_BG_MENTION = 20 + internal const val COLOR_DIALOG_ID_EVENT_BG_UNFOLLOW = 21 + internal const val COLOR_DIALOG_ID_EVENT_BG_REACTION = 22 + internal const val COLOR_DIALOG_ID_EVENT_BG_QUOTE = 23 + internal const val COLOR_DIALOG_ID_EVENT_BG_VOTE = 24 + internal const val COLOR_DIALOG_ID_EVENT_BG_FOLLOWREQUEST = 25 + internal const val REQUEST_CODE_TIMELINE_FONT = 1 internal const val REQUEST_CODE_TIMELINE_FONT_BOLD = 2 @@ -112,6 +122,16 @@ class ActAppSettingChild : AppCompatActivity() private var toot_color_direct_me : Int = 0 private var link_color : Int = 0 + private var event_bg_color_boost : Int = 0 + private var event_bg_color_favourite : Int = 0 + private var event_bg_color_follow : Int = 0 + private var event_bg_color_mention : Int = 0 + private var event_bg_color_unfollow : Int = 0 + private var event_bg_color_reaction : Int = 0 + private var event_bg_color_quote : Int = 0 + private var event_bg_color_vote : Int = 0 + private var event_bg_color_follow_request : Int = 0 + private var color_column_header_bg : Int = 0 private var color_column_header_fg : Int = 0 private var color_column_bg : Int = 0 @@ -340,6 +360,24 @@ class ActAppSettingChild : AppCompatActivity() , R.id.btnCcdContentTextEdit , R.id.btnCcdContentTextReset , R.id.btnInstanceTickerCopyright + , R.id.btnBackgroundColorBoostEdit + , R.id.btnBackgroundColorBoostReset + , R.id.btnBackgroundColorFavouritesEdit + , R.id.btnBackgroundColorFavouritesReset + , R.id.btnBackgroundColorFollowEdit + , R.id.btnBackgroundColorFollowReset + , R.id.btnBackgroundColorMentionEdit + , R.id.btnBackgroundColorMentionReset + , R.id.btnBackgroundColorUnfollowEdit + , R.id.btnBackgroundColorUnfollowReset + , R.id.btnBackgroundColorReactionEdit + , R.id.btnBackgroundColorReactionReset + , R.id.btnBackgroundColorQuotedEdit + , R.id.btnBackgroundColorQuotedReset + , R.id.btnBackgroundColorVotedEdit + , R.id.btnBackgroundColorVotedReset + , R.id.btnBackgroundColorFollowRequestedEdit + , R.id.btnBackgroundColorFollowRequestedReset ).forEach { findViewById(it)?.setOnClickListener(this) } @@ -512,6 +550,16 @@ class ActAppSettingChild : AppCompatActivity() toot_color_direct_me = Pref.ipTootColorDirectMe(pref) link_color = Pref.ipLinkColor(pref) + event_bg_color_boost = Pref.ipEventBgColorBoost(pref) + event_bg_color_favourite = Pref.ipEventBgColorFavourite(pref) + event_bg_color_follow = Pref.ipEventBgColorFollow(pref) + event_bg_color_mention = Pref.ipEventBgColorMention(pref) + event_bg_color_unfollow = Pref.ipEventBgColorUnfollow(pref) + event_bg_color_reaction = Pref.ipEventBgColorReaction(pref) + event_bg_color_quote = Pref.ipEventBgColorQuote(pref) + event_bg_color_vote = Pref.ipEventBgColorVote(pref) + event_bg_color_follow_request = Pref.ipEventBgColorFollowRequest(pref) + color_column_header_bg = Pref.ipCcdHeaderBg(pref) color_column_header_fg = Pref.ipCcdHeaderFg(pref) color_column_bg = Pref.ipCcdContentBg(pref) @@ -652,6 +700,8 @@ class ActAppSettingChild : AppCompatActivity() e.put(sp, value) } + fun put(sp : IntPref, value : Int) = e.put(sp, value) + putIf(hasFooterColorUi, Pref.ipFooterButtonBgColor, footer_button_bg_color) putIf(hasFooterColorUi, Pref.ipFooterButtonFgColor, footer_button_fg_color) putIf(hasFooterColorUi, Pref.ipFooterTabBgColor, footer_tab_bg_color) @@ -660,10 +710,24 @@ class ActAppSettingChild : AppCompatActivity() putIf(hasListDividerColorUi, Pref.ipListDividerColor, list_divider_color) - putIf(hasTootBackgroundColorUi, Pref.ipTootColorUnlisted, toot_color_unlisted) - putIf(hasTootBackgroundColorUi, Pref.ipTootColorFollower, toot_color_follower) - putIf(hasTootBackgroundColorUi, Pref.ipTootColorDirectUser, toot_color_direct_user) - putIf(hasTootBackgroundColorUi, Pref.ipTootColorDirectMe, toot_color_direct_me) + if(hasTootBackgroundColorUi) { + put(Pref.ipTootColorUnlisted, toot_color_unlisted) + put(Pref.ipTootColorFollower, toot_color_follower) + put(Pref.ipTootColorDirectUser, toot_color_direct_user) + put(Pref.ipTootColorDirectMe, toot_color_direct_me) + + put(Pref.ipEventBgColorBoost, event_bg_color_boost) + put(Pref.ipEventBgColorFavourite, event_bg_color_favourite) + put(Pref.ipEventBgColorFollow, event_bg_color_follow) + put(Pref.ipEventBgColorMention, event_bg_color_mention) + put(Pref.ipEventBgColorUnfollow, event_bg_color_unfollow) + put(Pref.ipEventBgColorReaction, event_bg_color_reaction) + put(Pref.ipEventBgColorQuote, event_bg_color_quote) + put(Pref.ipEventBgColorVote, event_bg_color_vote) + put(Pref.ipEventBgColorFollowRequest, event_bg_color_follow_request) + } + + putIf(hasLinkColorUi, Pref.ipLinkColor, link_color) @@ -950,6 +1014,106 @@ class ActAppSettingChild : AppCompatActivity() this@ActAppSettingChild, "https://wee.jp/mastodon/" ) + + R.id.btnBackgroundColorBoostEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_BOOST, + event_bg_color_boost, + true + ) + + R.id.btnBackgroundColorBoostReset -> { + event_bg_color_boost = 0 + saveUIToData() + } + + R.id.btnBackgroundColorFavouritesEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_FAVOURITE, + event_bg_color_favourite, + true + ) + + R.id.btnBackgroundColorFavouritesReset -> { + event_bg_color_favourite = 0 + saveUIToData() + } + + R.id.btnBackgroundColorFollowEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_FOLLOW, + event_bg_color_follow, + true + ) + + R.id.btnBackgroundColorFollowReset -> { + event_bg_color_follow = 0 + saveUIToData() + } + + R.id.btnBackgroundColorMentionEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_MENTION, + event_bg_color_mention, + true + ) + + R.id.btnBackgroundColorMentionReset -> { + event_bg_color_mention = 0 + saveUIToData() + } + + R.id.btnBackgroundColorUnfollowEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_UNFOLLOW, + event_bg_color_unfollow, + true + ) + + R.id.btnBackgroundColorUnfollowReset -> { + event_bg_color_unfollow = 0 + saveUIToData() + } + + R.id.btnBackgroundColorReactionEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_REACTION, + event_bg_color_reaction, + true + ) + + R.id.btnBackgroundColorReactionReset -> { + event_bg_color_reaction = 0 + saveUIToData() + } + + R.id.btnBackgroundColorQuotedEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_QUOTE, + event_bg_color_quote, + true + ) + + R.id.btnBackgroundColorQuotedReset -> { + event_bg_color_quote = 0 + saveUIToData() + } + + R.id.btnBackgroundColorVotedEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_VOTE, + event_bg_color_vote, + true + ) + + R.id.btnBackgroundColorVotedReset -> { + event_bg_color_vote = 0 + saveUIToData() + } + + R.id.btnBackgroundColorFollowRequestedEdit -> openColorPicker( + COLOR_DIALOG_ID_EVENT_BG_FOLLOWREQUEST, + event_bg_color_follow_request, + true + ) + + R.id.btnBackgroundColorFollowRequestedReset -> { + event_bg_color_follow_request = 0 + saveUIToData() + } + } } @@ -1083,6 +1247,52 @@ class ActAppSettingChild : AppCompatActivity() saveUIToData() showColumnSample() } + + COLOR_DIALOG_ID_EVENT_BG_BOOST -> { + event_bg_color_boost = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_FAVOURITE -> { + event_bg_color_favourite = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_FOLLOW -> { + event_bg_color_follow = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_MENTION -> { + event_bg_color_mention = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_UNFOLLOW -> { + event_bg_color_unfollow = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_REACTION -> { + event_bg_color_reaction = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_QUOTE -> { + event_bg_color_quote = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_VOTE -> { + event_bg_color_vote = colorAlpha + saveUIToData() + } + + COLOR_DIALOG_ID_EVENT_BG_FOLLOWREQUEST -> { + event_bg_color_follow_request = colorAlpha + saveUIToData() + } + } } @@ -1351,16 +1561,16 @@ class ActAppSettingChild : AppCompatActivity() // GMT数字を指定するタイプのタイムゾーンは無視する。ただしGMT-12:00の1項目だけは残す // 3文字のIDは曖昧な場合があるので非推奨 // '/' を含まないIDは列挙しない - if(! when{ - ! tz.id.contains('/') -> false - tz.id == "Etc/GMT+12" -> true - tz.id.startsWith("Etc/") -> false - else-> true - }) continue + if(! when { + ! tz.id.contains('/') -> false + tz.id == "Etc/GMT+12" -> true + tz.id.startsWith("Etc/") -> false + else -> true + }) continue var offset = tz.rawOffset.toLong() val caption = when(offset) { - 0L -> String.format("(UTC\u00B100:00) %s %s",tz.id, tz.displayName) + 0L -> String.format("(UTC\u00B100:00) %s %s", tz.id, tz.displayName) else -> { @@ -1377,18 +1587,18 @@ class ActAppSettingChild : AppCompatActivity() - String.format(format, hours, minutes,tz.id, tz.displayName) + String.format(format, hours, minutes, tz.id, tz.displayName) } } - if( null == list.find{ it.caption == caption } ){ + if(null == list.find { it.caption == caption }) { list.add(Item(id, caption, tz.rawOffset)) } } - + list.sortWith(Comparator { a, b -> - (a.offset - b.offset).notZero() ?: a.caption.compareTo( b.caption) + (a.offset - b.offset).notZero() ?: a.caption.compareTo(b.caption) }) - + list.add(0, Item("", getString(R.string.device_timezone), 0)) } diff --git a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt index 52711fa9..d476f2f8 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.kt @@ -5,7 +5,6 @@ import android.content.res.ColorStateList import android.graphics.Typeface import android.os.SystemClock import android.support.v4.content.ContextCompat -import android.support.v4.view.ViewCompat import android.support.v7.app.AlertDialog import android.support.v7.widget.RecyclerView import android.text.Spannable @@ -475,7 +474,8 @@ internal class ItemViewHolder( item.accountRef, item.time_created_at, R.drawable.ic_repeat, - R.string.display_name_boosted_by + R.string.display_name_boosted_by, + colorBg = Pref.ipEventBgColorBoost(activity.pref) ) showStatusOrReply(item.reblog) } @@ -773,7 +773,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, if(access_info.isNicoru(n_account)) R.drawable.ic_nicoru else R.drawable.ic_star, - R.string.display_name_favourited_by + R.string.display_name_favourited_by, + colorBg = Pref.ipEventBgColorFavourite(activity.pref) ) if(n_status != null) { showNotificationStatus(n_status) @@ -785,7 +786,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_repeat, - R.string.display_name_boosted_by + R.string.display_name_boosted_by, + colorBg = Pref.ipEventBgColorBoost(activity.pref) ) if(n_status != null) { showNotificationStatus(n_status) @@ -799,7 +801,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_repeat, - R.string.display_name_boosted_by + R.string.display_name_boosted_by, + colorBg = Pref.ipEventBgColorBoost(activity.pref) ) if(n_status != null) { showNotificationStatus(n_status) @@ -812,7 +815,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_follow_plus, - R.string.display_name_followed_by + R.string.display_name_followed_by, + colorBg = Pref.ipEventBgColorFollow(activity.pref) ) showAccount(n_accountRef) } @@ -824,7 +828,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_follow_cross, - R.string.display_name_unfollowed_by + R.string.display_name_unfollowed_by, + colorBg = Pref.ipEventBgColorUnfollow(activity.pref) ) showAccount(n_accountRef) } @@ -845,7 +850,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_reply, - R.string.display_name_mentioned_by + R.string.display_name_mentioned_by, + colorBg = Pref.ipEventBgColorMention(activity.pref) ) } } @@ -861,8 +867,9 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_question, // not used - R.string.display_name_reaction_by - , reactionDrawableId = reaction?.btnDrawableId + R.string.display_name_reaction_by, + colorBg = Pref.ipEventBgColorReaction(activity.pref), + reactionDrawableId = reaction?.btnDrawableId ) if(n_status != null) { showNotificationStatus(n_status) @@ -874,7 +881,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_repeat, - R.string.display_name_quoted_by + R.string.display_name_quoted_by, + colorBg = Pref.ipEventBgColorQuote(activity.pref) ) if(n_status != null) { showNotificationStatus(n_status) @@ -886,7 +894,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_vote, - R.string.display_name_voted_by + R.string.display_name_voted_by, + colorBg = Pref.ipEventBgColorVote(activity.pref) ) if(n_status != null) { showNotificationStatus(n_status) @@ -898,7 +907,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_follow_wait, - R.string.display_name_follow_request_by + R.string.display_name_follow_request_by, + colorBg = Pref.ipEventBgColorFollowRequest(activity.pref) ) boostedAction = { activity.addColumn( @@ -914,7 +924,8 @@ internal class ItemViewHolder( n_accountRef, n.time_created_at, R.drawable.ic_question, - R.string.unknown_notification_from + R.string.unknown_notification_from, + colorBg = 0 ) if(n_status != null) { showNotificationStatus(n_status) @@ -1041,6 +1052,7 @@ internal class ItemViewHolder( time : Long, iconId : Int, string_id : Int, + colorBg : Int, reactionDrawableId : Int? = null ) { boost_account = whoRef @@ -1066,6 +1078,12 @@ internal class ItemViewHolder( ) } + if( colorBg == 0) { + llBoosted.backgroundResource = R.drawable.btn_bg_transparent + }else{ + llBoosted.backgroundDrawable = getAdaptiveRippleDrawable(normalColor = colorBg, pressedColor = content_color) + } + boost_time = time llBoosted.visibility = View.VISIBLE showStatusTime(activity, tvBoostedTime, who, time = time) @@ -2597,8 +2615,7 @@ internal class ItemViewHolder( lparams(matchParent, wrapContent) { bottomMargin = dip(6) } - - background = ContextCompat.getDrawable(context, R.drawable.btn_bg_transparent) + backgroundResource = R.drawable.btn_bg_transparent gravity = Gravity.CENTER_VERTICAL ivBoosted = imageView { diff --git a/app/src/main/java/jp/juggler/subwaytooter/Pref.kt b/app/src/main/java/jp/juggler/subwaytooter/Pref.kt index 41b231b4..6c172515 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/Pref.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/Pref.kt @@ -420,6 +420,16 @@ object Pref { val ipTootColorDirectUser = IntPref("ipTootColorDirectUser", 0) val ipTootColorDirectMe = IntPref("ipTootColorDirectMe", 0) + val ipEventBgColorBoost = IntPref("EventBgColorBoost", 0) + val ipEventBgColorFavourite = IntPref("EventBgColorFavourite", 0) + val ipEventBgColorFollow = IntPref("EventBgColorFollow", 0) + val ipEventBgColorMention = IntPref("EventBgColorMention", 0) + val ipEventBgColorUnfollow = IntPref("EventBgColorUnfollow", 0) + val ipEventBgColorReaction = IntPref("EventBgColorReaction", 0) + val ipEventBgColorQuote = IntPref("EventBgColorQuote", 0) + val ipEventBgColorVote = IntPref("EventBgColorVote", 0) + val ipEventBgColorFollowRequest = IntPref("EventBgColorFollowRequest", 0) + val ipCcdHeaderBg = IntPref("ipCcdHeaderBg", 0) val ipCcdHeaderFg = IntPref("ipCcdHeaderFg", 0) val ipCcdContentBg = IntPref("ipCcdContentBg", 0) diff --git a/app/src/main/res/layout/act_app_setting_color.xml b/app/src/main/res/layout/act_app_setting_color.xml index 322413fd..6d0b18bb 100644 --- a/app/src/main/res/layout/act_app_setting_color.xml +++ b/app/src/main/res/layout/act_app_setting_color.xml @@ -11,8 +11,8 @@ android:clipToPadding="false" android:fillViewport="true" - android:paddingBottom="128dp" android:paddingTop="12dp" + android:paddingBottom="128dp" android:scrollbarStyle="outsideOverlay" tools:ignore="TooManyViews,UseCompoundDrawables,UselessParent,Autofill" @@ -154,7 +154,6 @@ - + + + + + + + + + + +