update TitleBar

pull/32/head
Administrator 5 years ago
parent 16b4932a01
commit f8c9393405
  1. 31
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  2. 25
      app/src/main/res/layout/activity_book_source.xml
  3. 154
      app/src/main/res/values/attrs.xml

@ -86,6 +86,37 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
this.setSubtitleTextColor(a.getColor(R.styleable.TitleBar_subtitleTextColor, -0x1)) this.setSubtitleTextColor(a.getColor(R.styleable.TitleBar_subtitleTextColor, -0x1))
} }
if (a.hasValue(R.styleable.TitleBar_contentInsetLeft)
|| a.hasValue(R.styleable.TitleBar_contentInsetRight)
) {
this.setContentInsetsAbsolute(
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetLeft, 0),
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetRight, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetStart)
|| a.hasValue(R.styleable.TitleBar_contentInsetEnd)
) {
this.setContentInsetsRelative(
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetStart, 0),
a.getDimensionPixelSize(R.styleable.TitleBar_contentInsetEnd, 0)
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetStartWithNavigation)) {
this.contentInsetStartWithNavigation = a.getDimensionPixelOffset(
R.styleable.TitleBar_contentInsetStartWithNavigation, 0
)
}
if (a.hasValue(R.styleable.TitleBar_contentInsetEndWithActions)) {
this.contentInsetEndWithActions = a.getDimensionPixelOffset(
R.styleable.TitleBar_contentInsetEndWithActions, 0
)
}
if (!titleText.isNullOrBlank()) { if (!titleText.isNullOrBlank()) {
this.title = titleText this.title = titleText
} }

@ -1,20 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar <io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:displayHomeAsUp="true" app:contentInsetStartWithNavigation="0dp"
app:title="@string/book_source" /> app:displayHomeAsUp="true"
app:title="@string/book_source"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>

@ -2,109 +2,115 @@
<resources> <resources>
<declare-styleable name="TitleBar"> <declare-styleable name="TitleBar">
<attr name="title" /> <attr name="title"/>
<attr name="subtitle" /> <attr name="subtitle"/>
<attr name="titleTextAppearance" /> <attr name="titleTextAppearance"/>
<attr name="titleTextColor" /> <attr name="titleTextColor"/>
<attr name="subtitleTextAppearance" /> <attr name="subtitleTextAppearance"/>
<attr name="subtitleTextColor" /> <attr name="subtitleTextColor"/>
<attr name="attachToActivity" format="boolean" /> <attr name="contentInsetEnd"/>
<attr name="displayHomeAsUp" format="boolean" /> <attr name="contentInsetEndWithActions"/>
<attr name="navigationIcon" format="reference" /> <attr name="contentInsetStart"/>
<attr name="fitStatusBar" format="boolean" /> <attr name="contentInsetStartWithNavigation"/>
<attr name="fitNavigationBar" format="boolean" /> <attr name="contentInsetLeft"/>
<attr name="navigationContentDescription" format="reference|string" /> <attr name="contentInsetRight"/>
<attr name="navigationIconTint" format="color|reference" /> <attr name="attachToActivity" format="boolean"/>
<attr name="displayHomeAsUp" format="boolean"/>
<attr name="navigationIcon" format="reference"/>
<attr name="fitStatusBar" format="boolean"/>
<attr name="fitNavigationBar" format="boolean"/>
<attr name="navigationContentDescription" format="reference|string"/>
<attr name="navigationIconTint" format="color|reference"/>
<attr name="navigationIconTintMode" format="enum"> <attr name="navigationIconTintMode" format="enum">
<enum name="clear" value="0" /> <enum name="clear" value="0"/>
<enum name="src" value="1" /> <enum name="src" value="1"/>
<enum name="dst" value="2" /> <enum name="dst" value="2"/>
<enum name="src_over" value="3" /> <enum name="src_over" value="3"/>
<enum name="dst_over" value="4" /> <enum name="dst_over" value="4"/>
<enum name="src_in" value="5" /> <enum name="src_in" value="5"/>
<enum name="dst_in" value="6" /> <enum name="dst_in" value="6"/>
<enum name="src_out" value="7" /> <enum name="src_out" value="7"/>
<enum name="dst_out" value="8" /> <enum name="dst_out" value="8"/>
<enum name="src_atop" value="9" /> <enum name="src_atop" value="9"/>
<enum name="dst_atop" value="10" /> <enum name="dst_atop" value="10"/>
<enum name="xor" value="11" /> <enum name="xor" value="11"/>
<enum name="darken" value="16" /> <enum name="darken" value="16"/>
<enum name="lighten" value="17" /> <enum name="lighten" value="17"/>
<enum name="multiply" value="13" /> <enum name="multiply" value="13"/>
<enum name="screen" value="14" /> <enum name="screen" value="14"/>
<enum name="add" value="12" /> <enum name="add" value="12"/>
<enum name="overlay" value="15" /> <enum name="overlay" value="15"/>
</attr> </attr>
</declare-styleable> </declare-styleable>
<attr name="titleBarStyle" format="reference" /> <attr name="titleBarStyle" format="reference"/>
<declare-styleable name="DynamicFrameLayout"> <declare-styleable name="DynamicFrameLayout">
<attr name="errorSrc" format="reference" /> <attr name="errorSrc" format="reference"/>
<attr name="emptySrc" format="reference" /> <attr name="emptySrc" format="reference"/>
<attr name="errorActionDescription" format="string|reference" /> <attr name="errorActionDescription" format="string|reference"/>
<attr name="emptyActionDescription" format="string|reference" /> <attr name="emptyActionDescription" format="string|reference"/>
<attr name="emptyDescription" format="string|reference" /> <attr name="emptyDescription" format="string|reference"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="RefreshProgressBar"> <declare-styleable name="RefreshProgressBar">
<attr name="max_progress" format="integer" /> <attr name="max_progress" format="integer"/>
<attr name="dur_progress" format="integer" /> <attr name="dur_progress" format="integer"/>
<attr name="second_dur_progress" format="dimension" /> <attr name="second_dur_progress" format="dimension"/>
<attr name="second_max_progress" format="dimension" /> <attr name="second_max_progress" format="dimension"/>
<attr name="bg_color" format="color" /> <attr name="bg_color" format="color"/>
<attr name="second_color" format="color" /> <attr name="second_color" format="color"/>
<attr name="font_color" format="color" /> <attr name="font_color" format="color"/>
<attr name="speed" format="dimension" /> <attr name="speed" format="dimension"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="SmoothCheckBox"> <declare-styleable name="SmoothCheckBox">
<attr name="duration" format="integer" /> <attr name="duration" format="integer"/>
<attr name="stroke_width" format="dimension" /> <attr name="stroke_width" format="dimension"/>
<attr name="color_tick" format="color" /> <attr name="color_tick" format="color"/>
<attr name="color_checked" format="color" /> <attr name="color_checked" format="color"/>
<attr name="color_unchecked" format="color" /> <attr name="color_unchecked" format="color"/>
<attr name="color_unchecked_stroke" format="color" /> <attr name="color_unchecked_stroke" format="color"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="NumberPickerPreference"> <declare-styleable name="NumberPickerPreference">
<attr name="MinValue" format="integer" /> <attr name="MinValue" format="integer"/>
<attr name="MaxValue" format="integer" /> <attr name="MaxValue" format="integer"/>
<attr name="android:summary" /> <attr name="android:summary"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="RefreshLayout"> <declare-styleable name="RefreshLayout">
<attr name="layout_refresh_empty" format="reference" /> <attr name="layout_refresh_empty" format="reference"/>
<attr name="layout_refresh_error" format="reference" /> <attr name="layout_refresh_error" format="reference"/>
<attr name="layout_refresh_loading" format="reference" /> <attr name="layout_refresh_loading" format="reference"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="FastScroller"> <declare-styleable name="FastScroller">
<attr name="fadeScrollbar" format="boolean" /> <attr name="fadeScrollbar" format="boolean"/>
<attr name="showBubble" format="boolean" /> <attr name="showBubble" format="boolean"/>
<attr name="showTrack" format="boolean" /> <attr name="showTrack" format="boolean"/>
<attr name="trackColor" format="color" /> <attr name="trackColor" format="color"/>
<attr name="handleColor" format="color" /> <attr name="handleColor" format="color"/>
<attr name="bubbleColor" format="color" /> <attr name="bubbleColor" format="color"/>
<attr name="bubbleTextColor" format="color" /> <attr name="bubbleTextColor" format="color"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="FilletImageView"> <declare-styleable name="FilletImageView">
<attr name="radius" format="dimension" /> <attr name="radius" format="dimension"/>
<attr name="left_top_radius" format="dimension" /> <attr name="left_top_radius" format="dimension"/>
<attr name="right_top_radius" format="dimension" /> <attr name="right_top_radius" format="dimension"/>
<attr name="right_bottom_radius" format="dimension" /> <attr name="right_bottom_radius" format="dimension"/>
<attr name="left_bottom_radius" format="dimension" /> <attr name="left_bottom_radius" format="dimension"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="IconListPreference"> <declare-styleable name="IconListPreference">
<attr name="icons" format="reference" /> <attr name="icons" format="reference"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="RotateLoading"> <declare-styleable name="RotateLoading">
<attr name="loading_width" format="dimension" /> <attr name="loading_width" format="dimension"/>
<attr name="loading_color" format="color" /> <attr name="loading_color" format="color"/>
<attr name="shadow_position" format="integer" /> <attr name="shadow_position" format="integer"/>
<attr name="loading_speed" format="integer" /> <attr name="loading_speed" format="integer"/>
</declare-styleable> </declare-styleable>
</resources> </resources>
Loading…
Cancel
Save