pull/32/head
kunfei 5 years ago
parent 2626205ccd
commit eb16c0ceaa
  1. 20
      app/src/main/java/io/legado/app/ui/widget/BadgeView.kt
  2. 3
      app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt
  3. 21
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt

@ -29,12 +29,6 @@ class BadgeView @JvmOverloads constructor(
defStyle: Int = android.R.attr.textViewStyle
) : AppCompatTextView(context, attrs, defStyle) {
/**
* @return Returns true if view is hidden on badge value 0 or null;
*/
/**
* @param hideOnNull the hideOnNull to set
*/
var isHideOnNull = true
set(hideOnNull) {
field = hideOnNull
@ -70,7 +64,12 @@ class BadgeView @JvmOverloads constructor(
val badgeMargin: IntArray
get() {
val params = layoutParams as LayoutParams
return intArrayOf(params.leftMargin, params.topMargin, params.rightMargin, params.bottomMargin)
return intArrayOf(
params.leftMargin,
params.topMargin,
params.rightMargin,
params.bottomMargin
)
}
init {
@ -154,7 +153,12 @@ class BadgeView @JvmOverloads constructor(
setBadgeMargin(dipMargin, dipMargin, dipMargin, dipMargin)
}
fun setBadgeMargin(leftDipMargin: Int, topDipMargin: Int, rightDipMargin: Int, bottomDipMargin: Int) {
fun setBadgeMargin(
leftDipMargin: Int,
topDipMargin: Int,
rightDipMargin: Int,
bottomDipMargin: Int
) {
val params = layoutParams as LayoutParams
params.leftMargin = dip2Px(leftDipMargin.toFloat())
params.topMargin = dip2Px(topDipMargin.toFloat())

@ -10,7 +10,8 @@ import android.widget.TextView
import io.legado.app.R
class KeyboardToolPop(context: Context, onClickListener: OnClickListener?) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
class KeyboardToolPop(context: Context, onClickListener: OnClickListener?) :
PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
init {
@SuppressLint("InflateParams")

@ -60,7 +60,8 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
displayHomeAsUp = a.getBoolean(R.styleable.TitleBar_displayHomeAsUp, true)
val navigationIcon = a.getDrawable(R.styleable.TitleBar_navigationIcon)
val navigationContentDescription = a.getText(R.styleable.TitleBar_navigationContentDescription)
val navigationContentDescription =
a.getText(R.styleable.TitleBar_navigationContentDescription)
val titleText = a.getString(R.styleable.TitleBar_title)
val subtitleText = a.getString(R.styleable.TitleBar_subtitle)
@ -71,7 +72,10 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
}
if (a.hasValue(R.styleable.TitleBar_titleTextAppearance)) {
this.setTitleTextAppearance(context, a.getResourceId(R.styleable.TitleBar_titleTextAppearance, 0))
this.setTitleTextAppearance(
context,
a.getResourceId(R.styleable.TitleBar_titleTextAppearance, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_titleTextColor)) {
@ -79,7 +83,10 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
}
if (a.hasValue(R.styleable.TitleBar_subtitleTextAppearance)) {
this.setSubtitleTextAppearance(context, a.getResourceId(R.styleable.TitleBar_subtitleTextAppearance, 0))
this.setSubtitleTextAppearance(
context,
a.getResourceId(R.styleable.TitleBar_subtitleTextAppearance, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_subtitleTextColor)) {
@ -177,7 +184,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
}
private fun attachToActivity() {
if(attachToActivity) {
if (attachToActivity) {
activity?.let {
it.setSupportActionBar(toolbar)
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp)
@ -191,7 +198,11 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
if (navigationIconTint != null) {
wrapDrawableTint(toolbar.navigationIcon, navigationIconTint, navigationIconTintMode)
} else {
wrapDrawableTint(toolbar.navigationIcon, ColorStateList.valueOf(primaryTextColor), navigationIconTintMode)
wrapDrawableTint(
toolbar.navigationIcon,
ColorStateList.valueOf(primaryTextColor),
navigationIconTintMode
)
}
}

Loading…
Cancel
Save