Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ object Authors {
val Nyako = Author("nyakowint", 118437263754395652L)
val Juby210 = Author("Juby210", 324622488644616195L)
val LampDelivery = Author("LampDelivery", 650805815623680030L)
val Ty = Author("Ty", 487443883127472129L)
val miaaaa0a = Author("miaaaa0a", 435750383491481602L)
val Vendicated = Author("Vendicated", 343383572805058560L)
val mantikafasi = Author("mantikafasi", 287555395151593473L)
val Ty = Author("Ty", 487443883127472129L)
val Cloudburst = Author("Cloudburst", 295186738085756929L)
val HalalKing = Author("HalalKing", 261634919980204033L)
val Accelerator = Author("Accelerator", 150234173024501762L)
val Vendicated = Author("Vendicated", 343383572805058560L)
val Derlan = Author("Derlan", 821545900807028757L)
}

Expand Down
13 changes: 13 additions & 0 deletions plugins/AutoShowSpoilers/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import com.aliucord.gradle.repo.Authors
import com.aliucord.gradle.repo.author

plugins {
id("com.aliucord.plugins-repo")
}

version = "1.1.0"
description = "Automatically clicks on spoilers for you"

aliucord {
author(Authors.Nyako)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package me.aniimalz.plugins

import android.content.Context
import com.aliucord.annotations.AliucordPlugin
import com.aliucord.entities.Plugin
import com.aliucord.patcher.InsteadHook
import com.aliucord.patcher.after
import com.discord.simpleast.core.node.Node
import com.discord.utilities.textprocessing.MessagePreprocessor
import com.discord.utilities.textprocessing.node.SpoilerNode
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemAttachment
import com.discord.widgets.chat.list.entries.AttachmentEntry

@AliucordPlugin
class AutoShowSpoilers : Plugin() {
override fun start(ctx: Context) {
patcher.after<MessagePreprocessor>("processNode", Node::class.java) {
val node = it.args[0]
if (node !is SpoilerNode<*>) return@after
node.updateState(spoilers.size, true)
}
patcher.after<SpoilerNode<*>>("isRevealed") { this.isRevealed = true }

// Embed spoiler patch
with(WidgetChatListAdapterItemAttachment.Model::class.java) {
val rev = getDeclaredMethod("isSpoilerEmbedRevealed", AttachmentEntry::class.java)
rev.apply { isAccessible = true }
patcher.patch(rev, InsteadHook { return@InsteadHook true })
}
}

override fun stop(ctx: Context) {
patcher.unpatchAll()
}
}
13 changes: 13 additions & 0 deletions plugins/ChannelLocker/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import com.aliucord.gradle.repo.Authors
import com.aliucord.gradle.repo.author

plugins {
id("com.aliucord.plugins-repo")
}

version = "1.0.3"
description = "Lets you lock channels so you cant type in them anymore"

aliucord {
author(Authors.Nyako)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package me.aniimalz.plugins

import android.content.Context
import android.view.Gravity
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.aliucord.utils.DimenUtils.dpToPx
import com.lytefast.flexinput.R

@Suppress("Deprecation")
class ChannelCard(ctx: Context?) : LinearLayout(ctx) {
val name: TextView
val delete: com.aliucord.views.ToolbarButton

init {
orientation = HORIZONTAL
gravity = Gravity.CENTER_VERTICAL
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
name = TextView(ctx, null, 0, R.i.UiKit_Settings_Item_Icon)
val buttons = LinearLayout(ctx)
buttons.orientation = HORIZONTAL
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
params.marginEnd = dpToPx(16)
buttons.layoutParams = params
buttons.setHorizontalGravity(Gravity.END)
buttons.setVerticalGravity(Gravity.CENTER_VERTICAL)
delete = com.aliucord.views.ToolbarButton(ctx)
delete.setImageDrawable(ContextCompat.getDrawable(ctx!!, R.e.ic_close_primary_200_24dp))
buttons.addView(delete)
addView(name)
addView(buttons)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package me.aniimalz.plugins

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.aliucord.PluginManager
import com.aliucord.Utils
import com.aliucord.Utils.getResId
import com.aliucord.fragments.SettingsPage
import com.discord.utilities.color.ColorCompat
import com.lytefast.flexinput.R
import java.util.*

class ChannelListAdapter(
page: SettingsPage,
private val channels: MutableMap<String, Long>
) :
RecyclerView.Adapter<ChannelListAdapter.ChannelListHolder>() {
inner class ChannelListHolder(private val adapter: ChannelListAdapter, val item: ChannelCard) :
RecyclerView.ViewHolder(item), View.OnClickListener {
override fun onClick(view: View) {
adapter.onClick()
}

}

private val ctx: Context? = page.context
override fun getItemCount(): Int {
return ArrayList(channels.keys).size
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChannelListHolder {
return ChannelListHolder(this, ChannelCard(ctx))
}

@SuppressLint("NotifyDataSetChanged")
override fun onBindViewHolder(holder: ChannelListHolder, position: Int) {
val name = ArrayList(channels.keys)[position]
holder.item.name.text = name
holder.item.delete.setOnClickListener {
channels.remove(name)
PluginManager.plugins["ChannelLocker"]!!.settings.setObject("channels", channels)
notifyDataSetChanged()
Utils.showToast("Channel removed: unlocked")
}
val icon =
ContextCompat.getDrawable(ctx!!, getResId("ic_text_channel_white_24dp", "drawable"))!!
.mutate()
icon.setTint(ColorCompat.getThemedColor(ctx, R.b.colorInteractiveNormal))
holder.item.name.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
}

fun onClick() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
package me.aniimalz.plugins

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.aliucord.Constants
import com.aliucord.Utils
import com.aliucord.annotations.AliucordPlugin
import com.aliucord.api.CommandsAPI
import com.aliucord.entities.Plugin
import com.aliucord.patcher.Hook
import com.aliucord.patcher.InsteadHook
import com.aliucord.patcher.after
import com.aliucord.utils.DimenUtils
import com.aliucord.utils.ReflectUtils
import com.aliucord.wrappers.ChannelWrapper.Companion.id
import com.aliucord.wrappers.ChannelWrapper.Companion.name
import com.discord.databinding.WidgetChannelsListItemActionsBinding
import com.discord.databinding.WidgetChatInputBinding
import com.discord.utilities.color.ColorCompat
import com.discord.widgets.channels.list.WidgetChannelsListItemChannelActions
import com.discord.widgets.chat.input.ChatInputViewModel
import com.discord.widgets.chat.input.WidgetChatInput
import com.google.gson.reflect.TypeToken
import com.lytefast.flexinput.R
import java.util.*

@AliucordPlugin
class ChannelLocker : Plugin() {
init {
settingsTab = SettingsTab(
PluginSettings::class.java,
SettingsTab.Type.PAGE
).withArgs(settings)
}


@SuppressLint("SetTextI18n")
override fun start(ctx: Context) {
val icon = Utils.tintToTheme(
ContextCompat.getDrawable(
Utils.appContext,
R.e.ic_lock_dark_a60_24dp
)
) // diamong makes me husk
val channelLockId = View.generateViewId()
val channels = settings.getObject(
"channels", HashMap<String, Long>(), TypeToken.getParameterized(
HashMap::class.java, String::class.javaObjectType, Long::class.javaObjectType
).type
)

commands.registerCommand(
"lockchannel",
"Use this to lock the channel so you cannot type in it anymore"
) {
if (channels.containsValue(it.channelId)) return@registerCommand CommandsAPI.CommandResult(
"Channel is already locked! how did you do this lol",
null,
false
)
channels[it.currentChannel.name] = it.channelId
settings.setObject("channels", channels)
CommandsAPI.CommandResult("Channel has been locked!", null, false)
}


val bindingMethod = WidgetChatInput::class.java.getDeclaredMethod("getBinding")
.apply { isAccessible = true }
patcher.after<WidgetChatInput>(
"configureChatGuard", ChatInputViewModel.ViewState.Loaded::class.java
) {
val loaded = it.args[0] as ChatInputViewModel.ViewState.Loaded

if (channels.containsValue(loaded.channelId) && !loaded.shouldShowVerificationGate) {
val binding = bindingMethod(it.thisObject) as WidgetChatInputBinding

val gateButtonText = binding.root.findViewById<TextView>(
Utils.getResId(
"chat_input_member_verification_guard_text",
"id"
)
)
val chatWrap = binding.root.findViewById<LinearLayout>(
Utils.getResId(
"chat_input_wrap",
"id"
)
)
val gateButtonImage = binding.root.findViewById<ImageView>(
Utils.getResId(
"chat_input_member_verification_guard_icon",
"id"
)
)
val gateButtonArrow = binding.root.findViewById<ImageView>(
Utils.getResId(
"chat_input_member_verification_guard_action",
"id"
)
)
val gateButtonLayout = binding.root.findViewById<RelativeLayout>(
Utils.getResId(
"guard_member_verification",
"id"
)
)

gateButtonLayout.visibility = View.VISIBLE
chatWrap.visibility = View.GONE

gateButtonImage.setImageResource(R.e.ic_channel_text_locked)
gateButtonText.text =
"Channel is locked"
gateButtonArrow.setImageResource(R.e.ic_check_white_24dp)
val pd = DimenUtils.defaultPadding
gateButtonArrow.setPadding(pd, pd, pd, pd)
gateButtonArrow.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
gateButtonArrow.setOnLongClickListener {
channels.remove(loaded.channel.name)
settings.setObject("channels", channels)

gateButtonLayout.visibility = View.GONE
chatWrap.visibility = View.VISIBLE
return@setOnLongClickListener true
}
gateButtonArrow.setOnClickListener {
InsteadHook.DO_NOTHING
}
gateButtonArrow.visibility =
if (settings.getBool("showUnlock", true)) View.VISIBLE else View.GONE
}
}


// just adding stupid buttons to channel settings and channel list actions

patcher.patch(
WidgetChannelsListItemChannelActions::class.java, "configureUI", arrayOf<Class<*>>(
WidgetChannelsListItemChannelActions.Model::class.java
), Hook {
val model = it.args[0] as WidgetChannelsListItemChannelActions.Model
val actions = it.thisObject as WidgetChannelsListItemChannelActions
try {
val binding = ReflectUtils.invokeMethod(
actions,
"getBinding"
) as WidgetChannelsListItemActionsBinding?
val root = (binding?.root as ViewGroup).getChildAt(0) as ViewGroup
TextView(root.context, null, 0, R.i.UiKit_Settings_Item_Icon).apply {
text =
if (!channels.containsValue(model.channel.id)) "Lock Channel" else "Unlock Channel"
setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
id = channelLockId
typeface = ResourcesCompat.getFont(
Utils.appContext,
Constants.Fonts.whitney_medium
)
setOnClickListener {
if (channels.containsValue(model.channel.id)) {
channels.remove(model.channel.name)
actions.dismiss()
Utils.showToast("Channel unlocked")
settings.setObject("channels", channels)
return@setOnClickListener
}
channels[model.channel.name] = model.channel.id
actions.dismiss()
Utils.showToast("Channel locked")
settings.setObject("channels", channels)
}
root.addView(this)
}
icon?.setTint(
ColorCompat.getThemedColor(
root.context,
R.b.colorInteractiveNormal
)
)
} catch (e: Throwable) {
logger.error("Error adding lock button to channel actions", e)
}
})
}

override fun stop(ctx: Context) {
patcher.unpatchAll()
commands.unregisterAll()
}
}
Loading