pull/168/head
Koitharu 4 years ago
parent 36634ecca1
commit 730d664b91
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -36,8 +36,7 @@ class ListItemTextView @JvmOverloads constructor(
init { init {
context.withStyledAttributes(attrs, R.styleable.ListItemTextView, defStyleAttr) { context.withStyledAttributes(attrs, R.styleable.ListItemTextView, defStyleAttr) {
val itemRippleColor = getColorStateList(R.styleable.ListItemTextView_rippleColor) val itemRippleColor = getRippleColor(context)
?: getRippleColorFallback(context)
val shape = createShapeDrawable(this) val shape = createShapeDrawable(this)
background = RippleDrawable( background = RippleDrawable(
RippleUtils.sanitizeRippleDrawableColor(itemRippleColor), RippleUtils.sanitizeRippleDrawableColor(itemRippleColor),
@ -108,7 +107,7 @@ class ListItemTextView @JvmOverloads constructor(
ta.getResourceId(R.styleable.ListItemTextView_shapeAppearanceOverlay, 0), ta.getResourceId(R.styleable.ListItemTextView_shapeAppearanceOverlay, 0),
).build() ).build()
val shapeDrawable = MaterialShapeDrawable(shapeAppearance) val shapeDrawable = MaterialShapeDrawable(shapeAppearance)
shapeDrawable.fillColor = ta.getColorStateList(R.styleable.ListItemTextView_backgroundTint) shapeDrawable.fillColor = ta.getColorStateList(R.styleable.ListItemTextView_backgroundFillColor)
return InsetDrawable( return InsetDrawable(
shapeDrawable, shapeDrawable,
ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetLeft, 0), ta.getDimensionPixelOffset(R.styleable.ListItemTextView_android_insetLeft, 0),
@ -118,7 +117,7 @@ class ListItemTextView @JvmOverloads constructor(
) )
} }
private fun getRippleColorFallback(context: Context): ColorStateList { private fun getRippleColor(context: Context): ColorStateList {
return context.getThemeColorStateList(android.R.attr.colorControlHighlight) return context.getThemeColorStateList(android.R.attr.colorControlHighlight)
?: ColorStateList.valueOf(Color.TRANSPARENT) ?: ColorStateList.valueOf(Color.TRANSPARENT)
} }

@ -28,7 +28,7 @@ class FavouriteCategoriesBottomSheet :
BaseBottomSheet<DialogFavoriteCategoriesBinding>(), BaseBottomSheet<DialogFavoriteCategoriesBinding>(),
OnListItemClickListener<MangaCategoryItem>, OnListItemClickListener<MangaCategoryItem>,
CategoriesEditDelegate.CategoriesEditCallback, CategoriesEditDelegate.CategoriesEditCallback,
Toolbar.OnMenuItemClickListener { Toolbar.OnMenuItemClickListener, View.OnClickListener {
private val viewModel by viewModel<MangaCategoriesViewModel> { private val viewModel by viewModel<MangaCategoriesViewModel> {
parametersOf(requireNotNull(arguments?.getParcelableArrayList<ParcelableManga>(KEY_MANGA_LIST)).map { it.manga }) parametersOf(requireNotNull(arguments?.getParcelableArrayList<ParcelableManga>(KEY_MANGA_LIST)).map { it.manga })
@ -46,6 +46,7 @@ class FavouriteCategoriesBottomSheet :
adapter = MangaCategoriesAdapter(this) adapter = MangaCategoriesAdapter(this)
binding.recyclerViewCategories.adapter = adapter binding.recyclerViewCategories.adapter = adapter
binding.toolbar.setOnMenuItemClickListener(this) binding.toolbar.setOnMenuItemClickListener(this)
binding.itemCreate.setOnClickListener(this)
viewModel.content.observe(viewLifecycleOwner, this::onContentChanged) viewModel.content.observe(viewLifecycleOwner, this::onContentChanged)
viewModel.onError.observe(viewLifecycleOwner, ::onError) viewModel.onError.observe(viewLifecycleOwner, ::onError)
@ -58,14 +59,20 @@ class FavouriteCategoriesBottomSheet :
override fun onMenuItemClick(item: MenuItem): Boolean { override fun onMenuItemClick(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
R.id.action_create -> { R.id.action_done -> {
startActivity(FavouritesCategoryEditActivity.newIntent(requireContext())) dismiss()
true true
} }
else -> false else -> false
} }
} }
override fun onClick(v: View) {
when (v.id) {
R.id.item_create -> startActivity(FavouritesCategoryEditActivity.newIntent(requireContext()))
}
}
override fun onItemClick(item: MangaCategoryItem, view: View) { override fun onItemClick(item: MangaCategoryItem, view: View) {
viewModel.setChecked(item.id, !item.isChecked) viewModel.setChecked(item.id, !item.isChecked)
} }

@ -9,6 +9,7 @@ import androidx.core.view.updatePadding
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import org.koin.android.ext.android.get import org.koin.android.ext.android.get
import org.koin.androidx.viewmodel.ext.android.sharedViewModel import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.BaseFragment import org.koitharu.kotatsu.base.ui.BaseFragment
import org.koitharu.kotatsu.databinding.FragmentSearchSuggestionBinding import org.koitharu.kotatsu.databinding.FragmentSearchSuggestionBinding
import org.koitharu.kotatsu.main.ui.AppBarOwner import org.koitharu.kotatsu.main.ui.AppBarOwner
@ -43,11 +44,10 @@ class SearchSuggestionFragment :
override fun onWindowInsetsChanged(insets: Insets) { override fun onWindowInsetsChanged(insets: Insets) {
val headerHeight = (activity as? AppBarOwner)?.appBar?.measureHeight() ?: insets.top val headerHeight = (activity as? AppBarOwner)?.appBar?.measureHeight() ?: insets.top
val extraPadding = resources.getDimensionPixelOffset(R.dimen.list_spacing)
binding.root.updatePadding( binding.root.updatePadding(
top = headerHeight, top = headerHeight + extraPadding,
// left = insets.left, bottom = insets.bottom + extraPadding,
// right = insets.right,
bottom = insets.bottom,
) )
} }

@ -5,13 +5,14 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="@dimen/list_spacing">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
app:menu="@menu/opt_favourites_bs" app:menu="@menu/opt_config"
app:title="@string/add_to_favourites" /> app:title="@string/add_to_favourites" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -20,9 +21,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:overScrollMode="never" android:overScrollMode="never"
android:paddingBottom="@dimen/list_spacing"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_checkable_new" /> tools:listitem="@layout/item_checkable_new" />
<TextView
android:id="@+id/item_create"
style="?listItemTextViewStyle"
android:layout_width="match_parent"
android:layout_height="?android:listPreferredItemHeightSmall"
android:background="?selectableItemBackground"
android:paddingStart="?android:listPreferredItemPaddingStart"
android:paddingEnd="?android:listPreferredItemPaddingEnd"
android:text="@string/create_category"
android:textAppearance="?attr/textAppearanceButton" />
</LinearLayout> </LinearLayout>

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<org.koitharu.kotatsu.base.ui.widgets.ListItemTextView <org.koitharu.kotatsu.base.ui.widgets.ListItemTextView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?android:listPreferredItemHeightSmall" android:layout_height="?android:listPreferredItemHeightSmall"
@ -9,5 +8,4 @@
android:paddingStart="?android:listPreferredItemPaddingStart" android:paddingStart="?android:listPreferredItemPaddingStart"
android:paddingEnd="?android:listPreferredItemPaddingEnd" android:paddingEnd="?android:listPreferredItemPaddingEnd"
android:textAppearance="?attr/textAppearanceButton" android:textAppearance="?attr/textAppearanceButton"
app:rippleColor="?colorSecondaryContainer"
tools:text="@tools:sample/full_names" /> tools:text="@tools:sample/full_names" />

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_create"
android:icon="@drawable/ic_list_add"
android:title="@string/add_new_category"
android:titleCondensed="@string/add"
app:showAsAction="ifRoom|withText" />
</menu>

@ -3,5 +3,6 @@
<style name="ThemeOverlay.Kotatsu.BottomSheetDialog" parent="ThemeOverlay.Material3.DayNight.BottomSheetDialog"> <style name="ThemeOverlay.Kotatsu.BottomSheetDialog" parent="ThemeOverlay.Material3.DayNight.BottomSheetDialog">
<item name="android:navigationBarColor">@color/navigation_bar_scrim</item> <item name="android:navigationBarColor">@color/navigation_bar_scrim</item>
<item name="android:windowLightNavigationBar">@bool/light_navigation_bar</item> <item name="android:windowLightNavigationBar">@bool/light_navigation_bar</item>
<item name="colorControlHighlight">?colorSecondary</item>
</style> </style>
</resources> </resources>

@ -26,8 +26,7 @@
<declare-styleable name="ListItemTextView"> <declare-styleable name="ListItemTextView">
<attr name="shapeAppearance" /> <attr name="shapeAppearance" />
<attr name="shapeAppearanceOverlay" /> <attr name="shapeAppearanceOverlay" />
<attr name="backgroundTint" /> <attr name="backgroundFillColor" format="color" />
<attr name="rippleColor" />
<attr name="checkedDrawableStart" format="reference" /> <attr name="checkedDrawableStart" format="reference" />
<attr name="checkedDrawableEnd" format="reference" /> <attr name="checkedDrawableEnd" format="reference" />
<attr name="android:insetTop" /> <attr name="android:insetTop" />

@ -24,6 +24,7 @@
<style name="ThemeOverlay.Kotatsu.BottomSheetDialog" parent="ThemeOverlay.Material3.DayNight.BottomSheetDialog"> <style name="ThemeOverlay.Kotatsu.BottomSheetDialog" parent="ThemeOverlay.Material3.DayNight.BottomSheetDialog">
<item name="android:statusBarColor">@color/dim</item> <item name="android:statusBarColor">@color/dim</item>
<item name="colorControlHighlight">?colorSecondary</item>
</style> </style>
<!-- Widget styles --> <!-- Widget styles -->
@ -86,7 +87,7 @@
<style name="Widget.Kotatsu.ListItemTextView" parent=""> <style name="Widget.Kotatsu.ListItemTextView" parent="">
<item name="android:textColor">@color/list_item_text_color</item> <item name="android:textColor">@color/list_item_text_color</item>
<item name="backgroundTint">@color/list_item_background_color</item> <item name="backgroundFillColor">@color/list_item_background_color</item>
<item name="checkedDrawableStart">@drawable/ic_check</item> <item name="checkedDrawableStart">@drawable/ic_check</item>
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.NavigationView.Item</item> <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.NavigationView.Item</item>
<item name="android:gravity">center_vertical|start</item> <item name="android:gravity">center_vertical|start</item>

Loading…
Cancel
Save