Skip to content

Commit

Permalink
#3
Browse files Browse the repository at this point in the history
  • Loading branch information
C10udburst committed Oct 8, 2021
1 parent 4e0a750 commit 2552245
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion EditWebhooks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "1.0.4"
version = "1.0.5"
description = "Edit Webhooks."
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import com.aliucord.plugins.ui.WebhookList
class EditWebhooks : Plugin() {
@SuppressLint("SetTextI18n")
override fun start(context: Context) {
val iconLeft = ContextCompat.getDrawable(context, R.d.ic_qr_code_24dp)
val iconLeft = ContextCompat.getDrawable(context, R.d.ic_send_24dp)
val iconRight = ContextCompat.getDrawable(context, R.d.icon_carrot)
val editWebooksId = View.generateViewId()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ class WebhookList(val channel: Channel) : SettingsPage() {
override fun onViewBound(view: View) {
super.onViewBound(view)
setActionBarTitle(channel.m())
val context = requireContext()

fetchList()
}

public fun fetchList() {
val context = requireContext()
Utils.threadPool.execute {
val list = Http.Request("https://discord.com/api/v9/channels/%d/webhooks".format(channel.h()), "GET")
.setHeader("Authorization", ReflectUtils.getField(StoreStream.getAuthentication(), "authToken") as String?)
Expand All @@ -44,6 +48,7 @@ class WebhookList(val channel: Channel) : SettingsPage() {


Utils.mainThread.post {
clear()
val shape = ShapeDrawable(RectShape())
.apply {
setTint(Color.TRANSPARENT)
Expand All @@ -59,7 +64,7 @@ class WebhookList(val channel: Channel) : SettingsPage() {

val recyclerView = RecyclerView(context)
.apply {
adapter = WebhookRecyclerAdapter(list.toList(), parentFragmentManager)
adapter = WebhookRecyclerAdapter(list.toList(), this@WebhookList)
layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
addItemDecoration(decoration)
}
Expand Down Expand Up @@ -97,5 +102,6 @@ class WebhookList(val channel: Channel) : SettingsPage() {
.setHeader("Accept", "*/*")
.executeWithJson(WebhookRequest(name))
Utils.showToast(context, "Webhook created")
fetchList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ import com.discord.api.message.attachment.MessageAttachment
import com.discord.utilities.SnowflakeUtils
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemAttachment

class WebhookMenu(private val webhook: Webhook) : AppBottomSheet() {

import com.aliucord.plugins.ui.WebhookList

class WebhookMenu(
private val webhook: Webhook,
private val parent: WebhookList
) : AppBottomSheet() {

override fun getContentViewResId() = 0

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, bundle: Bundle?): View {
Expand Down Expand Up @@ -105,6 +109,7 @@ class WebhookMenu(private val webhook: Webhook) : AppBottomSheet() {
.setHeader("Accept", "*/*")
.execute()
Utils.showToast(context, "Webhook deleted")
parent.fetchList()
dismiss()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import androidx.recyclerview.widget.RecyclerView
import android.widget.TextView
import com.lytefast.flexinput.R
import com.aliucord.plugins.utils.Webhook
import androidx.fragment.app.FragmentManager
import com.aliucord.Utils
import android.view.LayoutInflater
import android.widget.RelativeLayout
import com.discord.utilities.icon.IconUtils
import com.discord.utilities.color.ColorCompat
import com.aliucord.plugins.ui.WebhookList

class WebhookRecyclerAdapter(
private val webhooks: List<Webhook>,
private val fragmentManager: FragmentManager
private val parent: WebhookList
) : RecyclerView.Adapter<ViewHolder>() {

private val layoutId = Utils.getResId("widget_user_profile_adapter_item_server", "layout")
Expand All @@ -39,6 +39,6 @@ class WebhookRecyclerAdapter(
}

fun onClick(position: Int) = webhooks.elementAt(position).let {
WebhookMenu(it).show(Utils.appActivity.supportFragmentManager, it.name)
WebhookMenu(it, parent).show(parent.parentFragmentManager, it.name)
}
}
2 changes: 1 addition & 1 deletion SendEmbeds/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "1.1.0"
version = "1.1.1"
description = "Send embed messages with /embed or with a button."
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SendEmbeds : Plugin() {
}

override fun start(context: Context) {
val icon = ContextCompat.getDrawable(context, R.d.ic_qr_code_24dp)
val icon = ContextCompat.getDrawable(context, R.d.ic_embed_white_24dp)
Utils.tintToTheme(icon).setAlpha(0x99);

commands.registerCommand(
Expand Down

0 comments on commit 2552245

Please sign in to comment.