Package com.aliucord

Object Utils

  • All Implemented Interfaces:

    
    public class Utils
    
                        

    Utility class that holds miscellaneous Utilities

    • Constructor Detail

    • Method Detail

      • launchUrl

         final static Unit launchUrl(String url)

        Launches an URL in the user's preferred Browser

        Parameters:
        url - The url to launch
      • launchUrl

         final static Unit launchUrl(Uri url)

        Launches an URL in the user's preferred Browser

        Parameters:
        url - The url to launch
      • nestedChildAt

         final static <R extends Any> R nestedChildAt(ViewGroup root, Integer indices)

        Nested childAt. Used to turn nightmares like

        val layout = ((v.getChildAt(1) as ViewGroup).getChildAt(0) as ViewGroup).getChildAt(1) as LinearLayout

        into the much nicer

        val layout = Utils.nestedChildAt<LinearLayout>(v, 1, 0, 1)
        Parameters:
        root - The root that holds the children
        indices - Indices of the children.
      • launchFileExplorer

         final static Unit launchFileExplorer(File folder)

        Launches the file explorer in the specified folder. May not work on all Roms, will show an error with advice in that case.

        Parameters:
        folder - The folder to launch
      • pluralise

         final static String pluralise(Integer amount, String noun)

        Converts the singular term of the noun into plural.

        Parameters:
        amount - Amount of the noun.
        noun - The noun
      • showToast

        @JvmOverloads() final static Unit showToast(String message, Boolean showLonger)

        Send a toast from any Thread

        Parameters:
        message - Message to show.
        showLonger - Whether to show toast for an extended period of time.
      • showToast

        @Deprecated(message = "Use {@link #showToast(String, boolean)}", replaceWith = @ReplaceWith(imports = {}, expression = "showToast(message, showLonger)"))@JvmOverloads() final static Unit showToast(Context ctx, String message, Boolean showLonger)

        Send a toast from any Thread

        Parameters:
        ctx - Context
        message - Message to show.
        showLonger - Whether to show toast for an extended period of time.
      • getResId

         final static Integer getResId(String name, String type)

        Get resource id from discord package.

        Parameters:
        name - Name of the resource.
        type - Type of the resource.
      • createCommandChoice

         final static CommandChoice createCommandChoice(String name, String value)

        Creates a CommandChoice that can be used inside Command args

        Parameters:
        name - The name of the choice
        value - The value representing this choice
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default, List<Integer> channelTypes, List<CommandChoice> choices, List<ApplicationCommandOption> subCommandOptions, Boolean autocomplete)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
        channelTypes - Channel types this command is enabled in
        choices - List of choices the user may pick from
        subCommandOptions - List of command options if this argument is of type
        autocomplete - Whether autocomplete is enabled
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default, List<Integer> channelTypes, List<CommandChoice> choices, List<ApplicationCommandOption> subCommandOptions)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
        channelTypes - Channel types this command is enabled in
        choices - List of choices the user may pick from
        subCommandOptions - List of command options if this argument is of type
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default, List<Integer> channelTypes, List<CommandChoice> choices)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
        channelTypes - Channel types this command is enabled in
        choices - List of choices the user may pick from
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default, List<Integer> channelTypes)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
        channelTypes - Channel types this command is enabled in
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
      • createCommandOption

        @JvmOverloads() final static ApplicationCommandOption createCommandOption(String name)

        Creates a CommandOption that can be used for commands

        Parameters:
        name - The name of this argument
      • createCommandOption

         final static ApplicationCommandOption createCommandOption(ApplicationCommandType type, String name, String description, Integer descriptionRes, Boolean required, Boolean default, List<Integer> channelTypes, List<CommandChoice> choices, List<ApplicationCommandOption> subCommandOptions, Boolean autocomplete, Number minValue, Number maxValue)

        Creates a CommandOption that can be used for commands

        Parameters:
        type - The type of this argument
        name - The name of this argument
        description - The description of this argument
        descriptionRes - Optional ID of a string resource that will be used as description
        required - Whether this option is required
        default - Whether this option is the default selection (I think so at least I'm not 100% sure lol)
        channelTypes - Channel types this command is enabled in
        choices - List of choices the user may pick from
        subCommandOptions - List of command options if this argument is of type
        autocomplete - Whether autocomplete is enabled
        minValue - minValue for number type options
        maxValue - maxValue for number type options
      • buildClyde

         final static User buildClyde(String name, String avatarUrl)

        Builds Clyde User

        Parameters:
        name - Name of user
        avatarUrl - Avatar URL of user
      • createCheckedSetting

         final static CheckedSetting createCheckedSetting(Context context, CheckedSetting.ViewType type, CharSequence text, CharSequence subtext)

        Creates a checkable View.

        Parameters:
        context - Context
        type - CheckedSetting.ViewType of the checkable item.
        text - Title of the checkable item.
        subtext - Summary of the checkable item.
      • tintToTheme

         final static Drawable tintToTheme(Drawable drawable)

        Tints a Drawable to match the user's current theme. More specifically, tints the drawable to R.c.primary_light_600 if the user is using light theme, R.c.primary_dark_300 otherwise

        Make sure you call Drawable.mutate first or the drawable will change in the entire app.

        Parameters:
        drawable - Drawable
      • log

        @Deprecated(message = "Please stop abusing this method to log random junk then forget about it. It does not tell which plugin is logging stuff, so it is very hard to debug. Make your own Logger instance") final static Unit log(String msg)

        Logs a message on debug level.

        Parameters:
        msg - Message to log.