mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-02-01 11:26:48 +01:00
ポップアップ背景色の設定を追加
This commit is contained in:
parent
8e33880dbc
commit
3df1fde938
@ -961,6 +961,7 @@ val appSettingRoot = AppSettingItem(null, SettingType.Section, R.string.app_sett
|
||||
}
|
||||
|
||||
colorOpaque(PrefI.ipSearchBgColor, R.string.search_bar_background_color)
|
||||
colorAlpha(PrefI.ipPopupBgColor, R.string.popup_background_color)
|
||||
colorAlpha(PrefI.ipAnnouncementsBgColor, R.string.announcement_background_color)
|
||||
colorAlpha(PrefI.ipVerifiedLinkBgColor, R.string.verified_link_background_color)
|
||||
colorAlpha(PrefI.ipVerifiedLinkFgColor, R.string.verified_link_foreground_color)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package jp.juggler.subwaytooter.itemviewholder
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.SystemClock
|
||||
import android.view.Gravity
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
@ -15,7 +15,11 @@ import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.entity.TootNotification
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.column.Column
|
||||
import jp.juggler.subwaytooter.databinding.ListItemPopupBinding
|
||||
import jp.juggler.subwaytooter.pref.PrefI
|
||||
import jp.juggler.util.LogCategory
|
||||
import jp.juggler.util.attrColor
|
||||
import jp.juggler.util.notZero
|
||||
import org.jetbrains.anko.matchParent
|
||||
import kotlin.math.max
|
||||
|
||||
@ -34,16 +38,14 @@ internal class StatusButtonsPopup(
|
||||
var lastPopupClose = 0L
|
||||
}
|
||||
|
||||
private val viewRoot: View
|
||||
private val views = ListItemPopupBinding.inflate(activity.layoutInflater)
|
||||
private val buttonsForStatus: StatusButtons
|
||||
private var window: PopupWindow? = null
|
||||
|
||||
init {
|
||||
@SuppressLint("InflateParams")
|
||||
this.viewRoot = activity.layoutInflater.inflate(R.layout.list_item_popup, null, false)
|
||||
val statusButtonsViewHolder = StatusButtonsViewHolder(activity, matchParent, 0f)
|
||||
viewRoot.findViewById<LinearLayout>(R.id.llBarPlaceHolder)
|
||||
.addView(statusButtonsViewHolder.viewRoot)
|
||||
views.llBarPlaceHolder.addView(statusButtonsViewHolder.viewRoot)
|
||||
this.buttonsForStatus = StatusButtons(
|
||||
activity,
|
||||
column,
|
||||
@ -72,7 +74,7 @@ internal class StatusButtonsPopup(
|
||||
|
||||
window.width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
window.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
window.contentView = viewRoot
|
||||
window.contentView = views.root
|
||||
window.setBackgroundDrawable(ColorDrawable(0x00000000))
|
||||
window.isTouchable = true
|
||||
window.isOutsideTouchable = true
|
||||
@ -91,16 +93,23 @@ internal class StatusButtonsPopup(
|
||||
buttonsForStatus.bind(status, notification)
|
||||
buttonsForStatus.closeWindow = window
|
||||
|
||||
val bgColor = PrefI.ipPopupBgColor.invoke(activity.pref)
|
||||
.notZero() ?: activity.attrColor(R.attr.colorStatusButtonsPopupBg)
|
||||
val bgColorState = ColorStateList.valueOf(bgColor)
|
||||
views.ivTriangleTop.backgroundTintList = bgColorState
|
||||
views.ivTriangleBottom.backgroundTintList = bgColorState
|
||||
views.llBarPlaceHolder.backgroundTintList = bgColorState
|
||||
|
||||
val density = activity.density
|
||||
fun Int.dp() = (this * density + 0.5f).toInt()
|
||||
|
||||
// popupの大きさ
|
||||
viewRoot.measure(
|
||||
views.root.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(listView.width, View.MeasureSpec.AT_MOST),
|
||||
View.MeasureSpec.makeMeasureSpec(listView.height, View.MeasureSpec.AT_MOST)
|
||||
)
|
||||
val popupWidth = viewRoot.measuredWidth
|
||||
val popupHeight = viewRoot.measuredHeight
|
||||
val popupWidth = views.root.measuredWidth
|
||||
val popupHeight = views.root.measuredHeight
|
||||
|
||||
val location = IntArray(2)
|
||||
|
||||
@ -126,8 +135,8 @@ internal class StatusButtonsPopup(
|
||||
if (popupY > clipBottom) popupY = clipBottom
|
||||
|
||||
// 画面の下側にあるならポップアップの吹き出しが下から出ているように見せる
|
||||
viewRoot.findViewById<View>(R.id.ivTriangleTop).visibility = View.GONE
|
||||
viewRoot.findViewById<View>(R.id.ivTriangleBottom).visibility = View.VISIBLE
|
||||
views.ivTriangleTop.visibility = View.GONE
|
||||
views.ivTriangleBottom.visibility = View.VISIBLE
|
||||
popupY -= popupHeight
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,7 @@ object PrefI {
|
||||
val ipConversationMainTootBgColor = IntPref("ConversationMainTootBgColor", 0)
|
||||
val ipVerifiedLinkBgColor = IntPref("VerifiedLinkBgColor", 0)
|
||||
val ipVerifiedLinkFgColor = IntPref("VerifiedLinkFgColor", 0)
|
||||
val ipPopupBgColor = IntPref("PopupBgColor", 0)
|
||||
|
||||
// val ipTrendTagCountShowing = IntPref("TrendTagCountShowing", 0)
|
||||
// const val TTCS_WEEKLY = 0
|
||||
|
@ -1,35 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivTriangleTop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/list_item_popup_triangle"
|
||||
android:importantForAccessibility="no"
|
||||
/>
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llBarPlaceHolder"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/list_item_popup_bg"
|
||||
android:backgroundTintMode="src_in"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/llBarPlaceHolder"
|
||||
/>
|
||||
tools:layout_height="100dp" />
|
||||
|
||||
<ImageView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivTriangleBottom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/list_item_popup_triangle_bottom"
|
||||
android:visibility="gone"
|
||||
android:importantForAccessibility="no"
|
||||
|
||||
/>
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
@ -1163,5 +1163,6 @@
|
||||
|
||||
<string name="permission_rational_media_access">端末上のデータにアクセスするには権限が必要です。</string>
|
||||
<string name="permission_denied_media_access">端末上のデータにアクセスする権限がありません。</string>
|
||||
<string name="popup_background_color">ポップアップ背景色</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1172,4 +1172,5 @@
|
||||
|
||||
<string name="permission_rational_media_access">Permission required to access the device\'s media data.</string>
|
||||
<string name="permission_denied_media_access">Missing app permission to access the device\'s media data.</string>
|
||||
<string name="popup_background_color">Popup background color</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user