diff --git a/src/org/yaaic/command/BaseHandler.java b/src/org/yaaic/command/BaseHandler.java index 68fb302..5728209 100644 --- a/src/org/yaaic/command/BaseHandler.java +++ b/src/org/yaaic/command/BaseHandler.java @@ -25,6 +25,8 @@ import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Base class for commands * @@ -53,9 +55,10 @@ public abstract class BaseHandler /** * Get the description for this command * + * @param context The current context. Needed for getting string resources * @return */ - public abstract String getDescription(); + public abstract String getDescription(Context context); /** * Merge params to a string diff --git a/src/org/yaaic/command/handler/AMsgHandler.java b/src/org/yaaic/command/handler/AMsgHandler.java index 819c8d6..3221a8f 100644 --- a/src/org/yaaic/command/handler/AMsgHandler.java +++ b/src/org/yaaic/command/handler/AMsgHandler.java @@ -22,6 +22,7 @@ package org.yaaic.command.handler; import java.util.Collection; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -30,6 +31,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -69,7 +71,7 @@ public class AMsgHandler extends BaseHandler } } } else { - throw new CommandException("Invalid number of params"); + throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } @@ -86,8 +88,8 @@ public class AMsgHandler extends BaseHandler * Description of /amsg */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Send a message to all channels"; + return context.getString(R.string.command_desc_amsg); } } diff --git a/src/org/yaaic/command/handler/AwayHandler.java b/src/org/yaaic/command/handler/AwayHandler.java index acea6f0..a4f037c 100644 --- a/src/org/yaaic/command/handler/AwayHandler.java +++ b/src/org/yaaic/command/handler/AwayHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /away [] * @@ -48,9 +51,9 @@ public class AwayHandler extends BaseHandler * Get description of /away */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Sets you away"; + return context.getString(R.string.command_desc_away); } /** diff --git a/src/org/yaaic/command/handler/CloseHandler.java b/src/org/yaaic/command/handler/CloseHandler.java index 05b42f1..29f7415 100644 --- a/src/org/yaaic/command/handler/CloseHandler.java +++ b/src/org/yaaic/command/handler/CloseHandler.java @@ -20,6 +20,7 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -27,6 +28,7 @@ import org.yaaic.model.Broadcast; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -78,8 +80,8 @@ public class CloseHandler extends BaseHandler * Description of /close */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Closes the current window"; + return context.getString(R.string.command_desc_close); } } diff --git a/src/org/yaaic/command/handler/DCCHandler.java b/src/org/yaaic/command/handler/DCCHandler.java index b57af6f..52c907d 100644 --- a/src/org/yaaic/command/handler/DCCHandler.java +++ b/src/org/yaaic/command/handler/DCCHandler.java @@ -22,6 +22,7 @@ package org.yaaic.command.handler; import java.io.File; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -30,6 +31,8 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /dcc SEND * @@ -81,8 +84,8 @@ public class DCCHandler extends BaseHandler * Description of /dcc */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Send a file to a user"; + return context.getString(R.string.command_desc_dcc); } } diff --git a/src/org/yaaic/command/handler/DeopHandler.java b/src/org/yaaic/command/handler/DeopHandler.java index 27a8c11..bfe12fe 100644 --- a/src/org/yaaic/command/handler/DeopHandler.java +++ b/src/org/yaaic/command/handler/DeopHandler.java @@ -20,21 +20,24 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** - * Command: /voice + * Command: /deop * * @author Sebastian Kaspari */ public class DeopHandler extends BaseHandler { /** - * Execute /voice + * Execute /deop */ @Override public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException @@ -51,20 +54,20 @@ public class DeopHandler extends BaseHandler } /** - * Usage of /voice + * Usage of /deop */ @Override public String getUsage() { - return "/voice "; + return "/deop "; } /** - * Description of /voice + * Description of /deop */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Give a user voice status"; + return context.getString(R.string.command_desc_deop); } } diff --git a/src/org/yaaic/command/handler/DevoiceHandler.java b/src/org/yaaic/command/handler/DevoiceHandler.java index 605131b..7b1090e 100644 --- a/src/org/yaaic/command/handler/DevoiceHandler.java +++ b/src/org/yaaic/command/handler/DevoiceHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /devoice * @@ -63,8 +66,8 @@ public class DevoiceHandler extends BaseHandler * Description of /devoice */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Remove voice status from a user"; + return context.getString(R.string.command_desc_devoice); } } diff --git a/src/org/yaaic/command/handler/EchoHandler.java b/src/org/yaaic/command/handler/EchoHandler.java index 687e328..843dc2f 100644 --- a/src/org/yaaic/command/handler/EchoHandler.java +++ b/src/org/yaaic/command/handler/EchoHandler.java @@ -20,6 +20,7 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -28,6 +29,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -71,8 +73,8 @@ public class EchoHandler extends BaseHandler * Description of /echo */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Print text to window"; + return context.getString(R.string.command_desc_echo); } } diff --git a/src/org/yaaic/command/handler/HelpHandler.java b/src/org/yaaic/command/handler/HelpHandler.java index cbe7921..2a177a4 100644 --- a/src/org/yaaic/command/handler/HelpHandler.java +++ b/src/org/yaaic/command/handler/HelpHandler.java @@ -23,6 +23,7 @@ package org.yaaic.command.handler; import java.util.HashMap; import java.util.Set; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.command.CommandParser; import org.yaaic.exception.CommandException; @@ -32,6 +33,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -83,7 +85,7 @@ public class HelpHandler extends BaseHandler break; } } - commandList.append("/" + command.toString() + alias + " - "+commands.get(command).getDescription() + "\n"); + commandList.append("/" + command.toString() + alias + " - "+commands.get(command).getDescription(service) + "\n"); } Message message = new Message(commandList.toString()); @@ -114,7 +116,7 @@ public class HelpHandler extends BaseHandler HashMap commands = cp.getCommands(); if (commands.containsKey(command)) { - Message message = new Message("Help of /" + command + "\n" + commands.get(command).getUsage() + "\n" + commands.get(command).getDescription() + "\n"); + Message message = new Message("Help of /" + command + "\n" + commands.get(command).getUsage() + "\n" + commands.get(command).getDescription(service) + "\n"); message.setColor(Message.COLOR_YELLOW); conversation.addMessage(message); @@ -143,8 +145,8 @@ public class HelpHandler extends BaseHandler * Description of /help */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Lists all available commands"; + return context.getString(R.string.command_desc_help); } } diff --git a/src/org/yaaic/command/handler/JoinHandler.java b/src/org/yaaic/command/handler/JoinHandler.java index ea2fb55..f1c9fd2 100644 --- a/src/org/yaaic/command/handler/JoinHandler.java +++ b/src/org/yaaic/command/handler/JoinHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /join [] * @@ -61,8 +64,8 @@ public class JoinHandler extends BaseHandler * Description of /join */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Join a channel"; + return context.getString(R.string.command_desc_join); } } diff --git a/src/org/yaaic/command/handler/KickHandler.java b/src/org/yaaic/command/handler/KickHandler.java index a7e273f..533e538 100644 --- a/src/org/yaaic/command/handler/KickHandler.java +++ b/src/org/yaaic/command/handler/KickHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /kick * @@ -65,8 +68,8 @@ public class KickHandler extends BaseHandler * Description of /kick */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Kicks a user"; + return context.getString(R.string.command_desc_kick); } } diff --git a/src/org/yaaic/command/handler/MeHandler.java b/src/org/yaaic/command/handler/MeHandler.java index 5bd7d88..ea41531 100644 --- a/src/org/yaaic/command/handler/MeHandler.java +++ b/src/org/yaaic/command/handler/MeHandler.java @@ -29,6 +29,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -82,8 +83,8 @@ public class MeHandler extends BaseHandler * Description of /me */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Perform an action"; + return context.getString(R.string.command_desc_me); } } diff --git a/src/org/yaaic/command/handler/ModeHandler.java b/src/org/yaaic/command/handler/ModeHandler.java index 017a220..3e2f9c4 100644 --- a/src/org/yaaic/command/handler/ModeHandler.java +++ b/src/org/yaaic/command/handler/ModeHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /mode * @@ -63,8 +66,8 @@ public class ModeHandler extends BaseHandler * Description of /mode */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Change channel modes"; + return context.getString(R.string.command_desc_mode); } } diff --git a/src/org/yaaic/command/handler/MsgHandler.java b/src/org/yaaic/command/handler/MsgHandler.java index 3e3886d..fbf7c75 100644 --- a/src/org/yaaic/command/handler/MsgHandler.java +++ b/src/org/yaaic/command/handler/MsgHandler.java @@ -20,6 +20,7 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -28,6 +29,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -81,8 +83,8 @@ public class MsgHandler extends BaseHandler * Description of /msg */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Send a message to a channel or user"; + return context.getString(R.string.command_desc_msg); } } diff --git a/src/org/yaaic/command/handler/NamesHandler.java b/src/org/yaaic/command/handler/NamesHandler.java index 13694b4..03c6c80 100644 --- a/src/org/yaaic/command/handler/NamesHandler.java +++ b/src/org/yaaic/command/handler/NamesHandler.java @@ -21,6 +21,7 @@ along with Yaaic. If not, see . package org.yaaic.command.handler; import org.jibble.pircbot.User; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -29,6 +30,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -84,8 +86,8 @@ public class NamesHandler extends BaseHandler * Description of /names */ @Override - public String getDescription() + public String getDescription(Context context) { - return "lists all users in channel"; + return context.getString(R.string.command_desc_names); } } diff --git a/src/org/yaaic/command/handler/NickHandler.java b/src/org/yaaic/command/handler/NickHandler.java index e24d13e..99860b8 100644 --- a/src/org/yaaic/command/handler/NickHandler.java +++ b/src/org/yaaic/command/handler/NickHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /nick * @@ -59,8 +62,8 @@ public class NickHandler extends BaseHandler * Description of /nick */ @Override - public String getDescription() + public String getDescription(Context context) { - return "change own nickname"; + return context.getString(R.string.command_desc_nick); } } diff --git a/src/org/yaaic/command/handler/NoticeHandler.java b/src/org/yaaic/command/handler/NoticeHandler.java index 7a9ea94..507bb0b 100644 --- a/src/org/yaaic/command/handler/NoticeHandler.java +++ b/src/org/yaaic/command/handler/NoticeHandler.java @@ -29,6 +29,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -79,8 +80,8 @@ public class NoticeHandler extends BaseHandler * Description of /notice */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Send a notice to an other user"; + return context.getString(R.string.command_desc_notice); } } diff --git a/src/org/yaaic/command/handler/OpHandler.java b/src/org/yaaic/command/handler/OpHandler.java index f19cac3..94810cd 100644 --- a/src/org/yaaic/command/handler/OpHandler.java +++ b/src/org/yaaic/command/handler/OpHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /deop * @@ -63,8 +66,8 @@ public class OpHandler extends BaseHandler * Description of /deop */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Give a user operator status"; + return context.getString(R.string.command_desc_op); } } diff --git a/src/org/yaaic/command/handler/PartHandler.java b/src/org/yaaic/command/handler/PartHandler.java index c3b1905..3e211b3 100644 --- a/src/org/yaaic/command/handler/PartHandler.java +++ b/src/org/yaaic/command/handler/PartHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /part [] * @@ -67,8 +70,8 @@ public class PartHandler extends BaseHandler * Description of /part */ @Override - public String getDescription() + public String getDescription(Context context) { - return "leave the current channel"; + return context.getString(R.string.command_desc_part); } } diff --git a/src/org/yaaic/command/handler/QueryHandler.java b/src/org/yaaic/command/handler/QueryHandler.java index 1c24354..7355b65 100644 --- a/src/org/yaaic/command/handler/QueryHandler.java +++ b/src/org/yaaic/command/handler/QueryHandler.java @@ -20,6 +20,7 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -28,6 +29,7 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Query; import org.yaaic.model.Server; +import android.content.Context; import android.content.Intent; /** @@ -84,8 +86,8 @@ public class QueryHandler extends BaseHandler * Description of /query */ @Override - public String getDescription() + public String getDescription(Context context) { - return "opens a private chat with a user"; + return context.getString(R.string.command_desc_query); } } diff --git a/src/org/yaaic/command/handler/QuitHandler.java b/src/org/yaaic/command/handler/QuitHandler.java index 8e6b9c5..e22a1d4 100644 --- a/src/org/yaaic/command/handler/QuitHandler.java +++ b/src/org/yaaic/command/handler/QuitHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /quit [] * @@ -59,8 +62,8 @@ public class QuitHandler extends BaseHandler * Description of /quit */ @Override - public String getDescription() + public String getDescription(Context context) { - return "disconnect from server"; + return context.getString(R.string.command_desc_quit); } } diff --git a/src/org/yaaic/command/handler/RawHandler.java b/src/org/yaaic/command/handler/RawHandler.java index 2a0842e..520a425 100644 --- a/src/org/yaaic/command/handler/RawHandler.java +++ b/src/org/yaaic/command/handler/RawHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /raw * @@ -62,8 +65,8 @@ public class RawHandler extends BaseHandler * Description of /raw */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Send a raw line to the server"; + return context.getString(R.string.command_desc_raw); } } diff --git a/src/org/yaaic/command/handler/TopicHandler.java b/src/org/yaaic/command/handler/TopicHandler.java index 64aeee2..91a232e 100644 --- a/src/org/yaaic/command/handler/TopicHandler.java +++ b/src/org/yaaic/command/handler/TopicHandler.java @@ -20,6 +20,7 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; @@ -27,6 +28,8 @@ import org.yaaic.model.Channel; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /topic [] * @@ -70,8 +73,8 @@ public class TopicHandler extends BaseHandler * Description of /topic */ @Override - public String getDescription() + public String getDescription(Context context) { - return "show or change the current topic"; + return context.getString(R.string.command_desc_topic); } } diff --git a/src/org/yaaic/command/handler/VoiceHandler.java b/src/org/yaaic/command/handler/VoiceHandler.java index 959e82f..a4cb872 100644 --- a/src/org/yaaic/command/handler/VoiceHandler.java +++ b/src/org/yaaic/command/handler/VoiceHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /voice * @@ -63,8 +66,8 @@ public class VoiceHandler extends BaseHandler * Description of /voice */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Give a user voice status"; + return context.getString(R.string.command_desc_voice); } } diff --git a/src/org/yaaic/command/handler/WhoisHandler.java b/src/org/yaaic/command/handler/WhoisHandler.java index f1ca101..50d0a89 100644 --- a/src/org/yaaic/command/handler/WhoisHandler.java +++ b/src/org/yaaic/command/handler/WhoisHandler.java @@ -20,12 +20,15 @@ along with Yaaic. If not, see . */ package org.yaaic.command.handler; +import org.yaaic.R; import org.yaaic.command.BaseHandler; import org.yaaic.exception.CommandException; import org.yaaic.irc.IRCService; import org.yaaic.model.Conversation; import org.yaaic.model.Server; +import android.content.Context; + /** * Command: /whois * @@ -52,9 +55,9 @@ public class WhoisHandler extends BaseHandler * Get description of /whois */ @Override - public String getDescription() + public String getDescription(Context context) { - return "Get information about a user"; + return context.getString(R.string.command_desc_whois); } /**