From 861e319aebf5eef77108f3993fd7b392138729da Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 6 Nov 2022 11:26:24 +0100 Subject: [PATCH] add the notification bell UI --- .../extensions/SetupNotificationBell.kt | 18 ++++++++ .../ui/adapters/SubscriptionChannelAdapter.kt | 10 ++++- .../libretube/ui/fragments/ChannelFragment.kt | 3 ++ .../github/libretube/util/PreferenceHelper.kt | 2 +- app/src/main/res/drawable/ic_bell.xml | 10 +++++ .../res/layout/channel_subscription_row.xml | 24 +++++++---- app/src/main/res/layout/fragment_channel.xml | 42 ++++++++----------- app/src/main/res/values/style.xml | 11 +++++ 8 files changed, 83 insertions(+), 37 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/extensions/SetupNotificationBell.kt create mode 100644 app/src/main/res/drawable/ic_bell.xml diff --git a/app/src/main/java/com/github/libretube/extensions/SetupNotificationBell.kt b/app/src/main/java/com/github/libretube/extensions/SetupNotificationBell.kt new file mode 100644 index 000000000..8cd60a5d4 --- /dev/null +++ b/app/src/main/java/com/github/libretube/extensions/SetupNotificationBell.kt @@ -0,0 +1,18 @@ +package com.github.libretube.extensions + +import android.util.Log +import com.github.libretube.R +import com.github.libretube.util.PreferenceHelper +import com.google.android.material.button.MaterialButton + +fun MaterialButton.setupNotificationBell(channelId: String) { + var isIgnorable = PreferenceHelper.isChannelNotificationIgnorable(channelId) + Log.e(channelId, isIgnorable.toString()) + setIconResource(if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification) + + setOnClickListener { + isIgnorable = !isIgnorable + PreferenceHelper.toggleIgnorableNotificationChannel(channelId) + setIconResource(if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification) + } +} diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt index 029131b03..2fe7277f7 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt @@ -5,14 +5,17 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.api.SubscriptionHelper +import com.github.libretube.api.obj.Subscription import com.github.libretube.databinding.ChannelSubscriptionRowBinding +import com.github.libretube.extensions.setupNotificationBell import com.github.libretube.extensions.toID import com.github.libretube.ui.viewholders.SubscriptionChannelViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper -class SubscriptionChannelAdapter(private val subscriptions: MutableList) : - RecyclerView.Adapter() { +class SubscriptionChannelAdapter( + private val subscriptions: MutableList +) : RecyclerView.Adapter() { override fun getItemCount(): Int { return subscriptions.size @@ -32,6 +35,9 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList + + diff --git a/app/src/main/res/layout/channel_subscription_row.xml b/app/src/main/res/layout/channel_subscription_row.xml index 2fefef887..b82b9a477 100644 --- a/app/src/main/res/layout/channel_subscription_row.xml +++ b/app/src/main/res/layout/channel_subscription_row.xml @@ -1,5 +1,5 @@ - + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index f3197e338..afbb9e879 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -45,24 +45,18 @@ android:layout_weight="1" android:orientation="vertical"> - - - - - + android:layout_gravity="start" + android:layout_marginTop="3.5dp" + android:drawablePadding="3dp" + android:ellipsize="end" + android:maxLines="1" + android:textSize="16sp" + android:textStyle="bold" + tools:text="Channel Name" /> + + + + \ No newline at end of file