From 0fb2338f9c100ce6d7e1e3d4c0fe42a1ea41d9e9 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Tue, 25 Jan 2011 21:02:27 +0100 Subject: [PATCH] Code cleanup (Formatting) --- application/src/org/yaaic/Yaaic.java | 38 +-- .../src/org/yaaic/activity/AboutActivity.java | 6 +- .../org/yaaic/activity/AddAliasActivity.java | 138 ++++++----- .../yaaic/activity/AddChannelActivity.java | 27 +- .../yaaic/activity/AddCommandsActivity.java | 33 +-- .../src/org/yaaic/activity/JoinActivity.java | 5 +- .../org/yaaic/activity/MessageActivity.java | 6 +- .../org/yaaic/activity/ServersActivity.java | 98 ++++---- .../org/yaaic/activity/SettingsActivity.java | 4 +- .../src/org/yaaic/activity/UserActivity.java | 15 +- .../src/org/yaaic/activity/UsersActivity.java | 7 +- .../src/org/yaaic/adapter/DeckAdapter.java | 52 ++-- .../org/yaaic/adapter/MessageListAdapter.java | 36 +-- .../org/yaaic/adapter/ServerListAdapter.java | 32 +-- .../src/org/yaaic/command/BaseHandler.java | 14 +- .../src/org/yaaic/command/CommandParser.java | 40 +-- .../yaaic/command/handler/AMsgHandler.java | 14 +- .../yaaic/command/handler/AwayHandler.java | 2 +- .../yaaic/command/handler/CloseHandler.java | 10 +- .../org/yaaic/command/handler/DCCHandler.java | 12 +- .../yaaic/command/handler/DeopHandler.java | 8 +- .../yaaic/command/handler/DevoiceHandler.java | 8 +- .../yaaic/command/handler/EchoHandler.java | 8 +- .../yaaic/command/handler/HelpHandler.java | 26 +- .../yaaic/command/handler/JoinHandler.java | 4 +- .../yaaic/command/handler/KickHandler.java | 8 +- .../org/yaaic/command/handler/MeHandler.java | 14 +- .../yaaic/command/handler/ModeHandler.java | 8 +- .../org/yaaic/command/handler/MsgHandler.java | 14 +- .../yaaic/command/handler/NamesHandler.java | 16 +- .../yaaic/command/handler/NickHandler.java | 8 +- .../yaaic/command/handler/NoticeHandler.java | 12 +- .../org/yaaic/command/handler/OpHandler.java | 8 +- .../yaaic/command/handler/PartHandler.java | 8 +- .../yaaic/command/handler/QueryHandler.java | 14 +- .../yaaic/command/handler/QuitHandler.java | 6 +- .../org/yaaic/command/handler/RawHandler.java | 6 +- .../yaaic/command/handler/TopicHandler.java | 8 +- .../yaaic/command/handler/VoiceHandler.java | 8 +- .../yaaic/command/handler/WhoisHandler.java | 4 +- .../src/org/yaaic/db/AliasConstants.java | 6 +- .../src/org/yaaic/db/ChannelConstants.java | 6 +- .../src/org/yaaic/db/CommandConstants.java | 6 +- application/src/org/yaaic/db/Database.java | 234 +++++++++--------- .../src/org/yaaic/db/IdentityConstants.java | 8 +- .../src/org/yaaic/db/ServerConstants.java | 6 +- .../org/yaaic/exception/CommandException.java | 4 +- .../yaaic/exception/ValidationException.java | 4 +- application/src/org/yaaic/irc/IRCBinder.java | 16 +- .../layout/NonScalingBackgroundDrawable.java | 23 +- .../listener/ConversationClickListener.java | 29 +-- .../yaaic/listener/ConversationListener.java | 7 +- .../ConversationSelectedListener.java | 34 +-- .../yaaic/listener/MessageClickListener.java | 15 +- .../org/yaaic/listener/ServerListener.java | 2 +- .../yaaic/listener/SpeechClickListener.java | 13 +- .../src/org/yaaic/model/Broadcast.java | 16 +- application/src/org/yaaic/model/Channel.java | 8 +- .../src/org/yaaic/model/Conversation.java | 48 ++-- application/src/org/yaaic/model/Extra.java | 8 +- application/src/org/yaaic/model/Identity.java | 20 +- application/src/org/yaaic/model/Message.java | 90 +++---- application/src/org/yaaic/model/Query.java | 5 +- .../src/org/yaaic/model/Scrollback.java | 26 +- application/src/org/yaaic/model/Server.java | 88 +++---- .../src/org/yaaic/model/ServerInfo.java | 4 +- application/src/org/yaaic/model/Status.java | 7 +- .../yaaic/receiver/ConversationReceiver.java | 24 +- .../org/yaaic/receiver/ServerReceiver.java | 8 +- .../src/org/yaaic/ssl/NaiveTrustManager.java | 5 +- .../org/yaaic/view/ConversationSwitcher.java | 26 +- .../src/org/yaaic/view/MessageListView.java | 27 +- 72 files changed, 833 insertions(+), 775 deletions(-) diff --git a/application/src/org/yaaic/Yaaic.java b/application/src/org/yaaic/Yaaic.java index d850b9a..7392c38 100644 --- a/application/src/org/yaaic/Yaaic.java +++ b/application/src/org/yaaic/Yaaic.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic; import java.util.ArrayList; @@ -36,11 +36,11 @@ import android.content.Context; */ public class Yaaic { - public static Yaaic instance; - + public static Yaaic instance; + private HashMap servers; - private boolean serversLoaded = false; - + private boolean serversLoaded = false; + /** * Private constructor, you may want to use static getInstance() */ @@ -48,7 +48,7 @@ public class Yaaic { servers = new HashMap(); } - + /** * Load servers from database * @@ -60,12 +60,12 @@ public class Yaaic Database db = new Database(context); servers = db.getServers(); db.close(); - - //context.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); + + // context.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE)); serversLoaded = true; } } - + /** * Get global Yaaic instance * @@ -74,12 +74,12 @@ public class Yaaic public static Yaaic getInstance() { if (instance == null) { - instance = new Yaaic(); + instance = new Yaaic(); } - + return instance; } - + /** * Get server by id * @@ -89,7 +89,7 @@ public class Yaaic { return servers.get(serverId); } - + /** * Remove server with given unique id from list * @@ -99,7 +99,7 @@ public class Yaaic { servers.remove(serverId); } - + /** * Set servers * @@ -109,7 +109,7 @@ public class Yaaic { this.servers = servers; } - + /** * Add server to list */ @@ -119,7 +119,7 @@ public class Yaaic servers.put(server.getId(), server); } } - + /** * Update a server in list */ @@ -127,7 +127,7 @@ public class Yaaic { servers.put(server.getId(), server); } - + /** * Get list of servers * @@ -136,12 +136,12 @@ public class Yaaic public ArrayList getServersAsArrayList() { ArrayList serverList = new ArrayList(); - + Set mKeys = servers.keySet(); for (int key : mKeys) { serverList.add(servers.get(key)); } - + return serverList; } } diff --git a/application/src/org/yaaic/activity/AboutActivity.java b/application/src/org/yaaic/activity/AboutActivity.java index 0e4b897..88cc18f 100644 --- a/application/src/org/yaaic/activity/AboutActivity.java +++ b/application/src/org/yaaic/activity/AboutActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import org.yaaic.R; @@ -40,9 +40,9 @@ public class AboutActivity extends Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + requestWindowFeature(Window.FEATURE_NO_TITLE); - + setContentView(R.layout.about); } } diff --git a/application/src/org/yaaic/activity/AddAliasActivity.java b/application/src/org/yaaic/activity/AddAliasActivity.java index 6a40288..3edbc46 100644 --- a/application/src/org/yaaic/activity/AddAliasActivity.java +++ b/application/src/org/yaaic/activity/AddAliasActivity.java @@ -13,14 +13,14 @@ import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; +import android.view.Window; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; -import android.widget.AdapterView.OnItemClickListener; public class AddAliasActivity extends Activity implements OnClickListener, OnItemClickListener, TextWatcher { @@ -35,18 +35,18 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - + setContentView(R.layout.aliasadd); - + aliasInput = (EditText) findViewById(R.id.alias); aliasInput.addTextChangedListener(this); - + adapter = new ArrayAdapter(this, R.layout.aliasitem); - + ListView list = (ListView) findViewById(R.id.aliases); list.setAdapter(adapter); list.setOnItemClickListener(this); - + addButton = (Button) findViewById(R.id.add); addButton.setOnClickListener(this); ((Button) findViewById(R.id.cancel)).setOnClickListener(this); @@ -56,74 +56,80 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte okButton.setEnabled(false); aliases = getIntent().getExtras().getStringArrayList(Extra.ALIASES); - + for (String alias : aliases) { adapter.add(alias); } } - + /** * On Click */ - public void onClick(View v) - { - switch (v.getId()) { - case R.id.add: - String alias = aliasInput.getText().toString().trim(); - aliases.add(alias); - adapter.add(alias); - aliasInput.setText(""); - okButton.setEnabled(true); - break; - case R.id.cancel: - setResult(RESULT_CANCELED); - finish(); - break; - case R.id.ok: - // Get list and return as result - Intent intent = new Intent(); - intent.putExtra(Extra.ALIASES, aliases); - setResult(RESULT_OK, intent); - finish(); - break; - } - } + @Override + public void onClick(View v) + { + switch (v.getId()) { + case R.id.add: + String alias = aliasInput.getText().toString().trim(); + aliases.add(alias); + adapter.add(alias); + aliasInput.setText(""); + okButton.setEnabled(true); + break; + case R.id.cancel: + setResult(RESULT_CANCELED); + finish(); + break; + case R.id.ok: + // Get list and return as result + Intent intent = new Intent(); + intent.putExtra(Extra.ALIASES, aliases); + setResult(RESULT_OK, intent); + finish(); + break; + } + } - /** - * On item clicked - */ - public void onItemClick(AdapterView list, View item, int position, long id) - { - final String alias = adapter.getItem(position); - - String[] items = { getResources().getString(R.string.action_remove) }; - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(alias); - builder.setItems(items, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int item) { - switch (item) { - case 0: // Remove - adapter.remove(alias); - aliases.remove(alias); - okButton.setEnabled(true); - break; - } - } - }); - AlertDialog alert = builder.create(); - alert.show(); - } + /** + * On item clicked + */ + @Override + public void onItemClick(AdapterView list, View item, int position, long id) + { + final String alias = adapter.getItem(position); - public void afterTextChanged(Editable s) { - // Do nothing. - } + String[] items = { getResources().getString(R.string.action_remove) }; - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - // Do nothing. - } + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(alias); + builder.setItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + switch (item) { + case 0: // Remove + adapter.remove(alias); + aliases.remove(alias); + okButton.setEnabled(true); + break; + } + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } - public void onTextChanged(CharSequence s, int start, int before, int count) { - addButton.setEnabled(aliasInput.getText().length() > 0); - } + @Override + public void afterTextChanged(Editable s) { + // Do nothing. + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + // Do nothing. + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + addButton.setEnabled(aliasInput.getText().length() > 0); + } } diff --git a/application/src/org/yaaic/activity/AddChannelActivity.java b/application/src/org/yaaic/activity/AddChannelActivity.java index 76f5f0b..aa6abb6 100644 --- a/application/src/org/yaaic/activity/AddChannelActivity.java +++ b/application/src/org/yaaic/activity/AddChannelActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import java.util.ArrayList; @@ -31,14 +31,14 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; +import android.view.Window; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; -import android.widget.AdapterView.OnItemClickListener; /** * Adding auto join channels to a server @@ -51,7 +51,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI private ArrayAdapter adapter; private ArrayList channels; private Button okButton; - + /** * On create */ @@ -60,17 +60,17 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - + setContentView(R.layout.channeladd); - + channelInput = (EditText) findViewById(R.id.channel); - + adapter = new ArrayAdapter(this, R.layout.channelitem); - + ListView list = (ListView) findViewById(R.id.channels); list.setAdapter(adapter); list.setOnItemClickListener(this); - + ((Button) findViewById(R.id.add)).setOnClickListener(this); ((Button) findViewById(R.id.cancel)).setOnClickListener(this); @@ -79,7 +79,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI okButton.setEnabled(false); channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS); - + for (String channel : channels) { adapter.add(channel); } @@ -88,6 +88,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI /** * On Click */ + @Override public void onClick(View v) { switch (v.getId()) { @@ -115,15 +116,17 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI /** * On item clicked */ + @Override public void onItemClick(AdapterView list, View item, int position, long id) { final String channel = adapter.getItem(position); - + String[] items = { getResources().getString(R.string.action_remove) }; - + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(channel); builder.setItems(items, new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: // Remove diff --git a/application/src/org/yaaic/activity/AddCommandsActivity.java b/application/src/org/yaaic/activity/AddCommandsActivity.java index 435872c..6bcb263 100644 --- a/application/src/org/yaaic/activity/AddCommandsActivity.java +++ b/application/src/org/yaaic/activity/AddCommandsActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import java.util.ArrayList; @@ -31,14 +31,14 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; +import android.view.Window; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; -import android.widget.AdapterView.OnItemClickListener; /** * Adding commands (to execute after connect) to a server @@ -51,7 +51,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On private ArrayAdapter adapter; private ArrayList commands; private Button okButton; - + /** * On create */ @@ -60,17 +60,17 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - + setContentView(R.layout.commandadd); - + commandInput = (EditText) findViewById(R.id.command); - + adapter = new ArrayAdapter(this, R.layout.commanditem); - + ListView list = (ListView) findViewById(R.id.commands); list.setAdapter(adapter); list.setOnItemClickListener(this); - + ((Button) findViewById(R.id.add)).setOnClickListener(this); ((Button) findViewById(R.id.ok)).setOnClickListener(this); ((Button) findViewById(R.id.cancel)).setOnClickListener(this); @@ -78,9 +78,9 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On okButton = (Button) findViewById(R.id.ok); okButton.setOnClickListener(this); okButton.setEnabled(false); - + commands = getIntent().getExtras().getStringArrayList(Extra.COMMANDS); - + for (String command : commands) { adapter.add(command); } @@ -89,16 +89,17 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On /** * On Click */ + @Override public void onClick(View v) { switch (v.getId()) { case R.id.add: String command = commandInput.getText().toString().trim(); - + if (!command.startsWith("/")) { command = "/" + command; } - + commands.add(command); adapter.add(command); commandInput.setText("/"); @@ -121,15 +122,17 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On /** * On item clicked */ + @Override public void onItemClick(AdapterView list, View item, int position, long id) { final String command = adapter.getItem(position); - + String[] items = { getResources().getString(R.string.action_remove) }; - + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(command); builder.setItems(items, new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: // Remove diff --git a/application/src/org/yaaic/activity/JoinActivity.java b/application/src/org/yaaic/activity/JoinActivity.java index 5f32715..dd51a94 100644 --- a/application/src/org/yaaic/activity/JoinActivity.java +++ b/application/src/org/yaaic/activity/JoinActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import org.yaaic.R; @@ -47,13 +47,14 @@ public class JoinActivity extends Activity implements OnClickListener super.onCreate(savedInstanceState); setContentView(R.layout.join); - + ((Button) findViewById(R.id.join)).setOnClickListener(this); } /** * On click */ + @Override public void onClick(View v) { Intent intent = new Intent(); diff --git a/application/src/org/yaaic/activity/MessageActivity.java b/application/src/org/yaaic/activity/MessageActivity.java index 7e2b0d0..1b7cbdd 100644 --- a/application/src/org/yaaic/activity/MessageActivity.java +++ b/application/src/org/yaaic/activity/MessageActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import org.yaaic.R; @@ -42,10 +42,10 @@ public class MessageActivity extends Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.message); - + ((TextView) findViewById(R.id.message)).setText( getIntent().getExtras().getString(Extra.MESSAGE) ); diff --git a/application/src/org/yaaic/activity/ServersActivity.java b/application/src/org/yaaic/activity/ServersActivity.java index 64bd837..a35e9b7 100644 --- a/application/src/org/yaaic/activity/ServersActivity.java +++ b/application/src/org/yaaic/activity/ServersActivity.java @@ -17,29 +17,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import java.util.ArrayList; -import android.app.AlertDialog; -import android.app.ListActivity; -import android.content.ComponentName; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.Toast; -import android.widget.AdapterView.OnItemLongClickListener; - import org.yaaic.R; import org.yaaic.Yaaic; import org.yaaic.adapter.ServerListAdapter; @@ -54,6 +36,24 @@ import org.yaaic.model.Server; import org.yaaic.model.Status; import org.yaaic.receiver.ServerReceiver; +import android.app.AlertDialog; +import android.app.ListActivity; +import android.content.ComponentName; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.IBinder; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemLongClickListener; +import android.widget.ListView; +import android.widget.Toast; + /** * List of servers * @@ -64,7 +64,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, private ServerReceiver receiver; private ServerListAdapter adapter; private ListView list; - + /** * On create */ @@ -73,10 +73,10 @@ public class ServersActivity extends ListActivity implements ServiceConnection, { super.onCreate(savedInstanceState); setContentView(R.layout.servers); - + adapter = new ServerListAdapter(); setListAdapter(adapter); - + list = getListView(); list.setOnItemLongClickListener(this); list.setBackgroundDrawable(new NonScalingBackgroundDrawable(this, list, R.drawable.background)); @@ -89,7 +89,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, public void onResume() { super.onResume(); - + // Start and connect to service Intent intent = new Intent(this, IRCService.class); intent.setAction(IRCService.ACTION_BACKGROUND); @@ -98,10 +98,10 @@ public class ServersActivity extends ListActivity implements ServiceConnection, receiver = new ServerReceiver(this); registerReceiver(receiver, new IntentFilter(Broadcast.SERVER_UPDATE)); - + adapter.loadServers(); } - + /** * On pause */ @@ -109,18 +109,19 @@ public class ServersActivity extends ListActivity implements ServiceConnection, public void onPause() { super.onPause(); - + if (binder != null && binder.getService() != null) { binder.getService().checkServiceStatus(); } - + unbindService(this); unregisterReceiver(receiver); } - + /** * Service connected to Activity */ + @Override public void onServiceConnected(ComponentName name, IBinder service) { binder = (IRCBinder) service; @@ -129,6 +130,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, /** * Service disconnected from Activity */ + @Override public void onServiceDisconnected(ComponentName name) { binder = null; @@ -140,36 +142,37 @@ public class ServersActivity extends ListActivity implements ServiceConnection, @Override protected void onListItemClick(ListView l, View v, int position, long id) { Server server = adapter.getItem(position); - + if (server == null) { // "Add server" was selected startActivityForResult(new Intent(this, AddServerActivity.class), 0); return; } - + Intent intent = new Intent(this, ConversationActivity.class); - + if (server.getStatus() == Status.DISCONNECTED) { server.setStatus(Status.PRE_CONNECTING); intent.putExtra("connect", true); - } - + } + intent.putExtra("serverId", server.getId()); startActivity(intent); } - + /** * On long click */ + @Override public boolean onItemLongClick(AdapterView l, View v, int position, long id) { final Server server = adapter.getItem(position); - + if (server == null) { // "Add server" view selected return true; } - + final CharSequence[] items = { getString(R.string.connect), getString(R.string.disconnect), @@ -180,6 +183,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(server.getTitle()); builder.setItems(items, new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: // Connect @@ -208,7 +212,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, alert.show(); return true; } - + /** * Start activity to edit server with given id * @@ -217,7 +221,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, private void editServer(int serverId) { Server server = Yaaic.getInstance().getServerById(serverId); - + if (server.getStatus() != Status.DISCONNECTED) { Toast.makeText(this, getResources().getString(R.string.disconnect_before_editing), Toast.LENGTH_SHORT).show(); } @@ -227,18 +231,19 @@ public class ServersActivity extends ListActivity implements ServiceConnection, startActivityForResult(intent, 0); } } - + /** * Options Menu (Menu Button pressed) */ + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - + // inflate from xml MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.servers, menu); - + return true; } @@ -270,7 +275,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, binder.getService().stopForegroundCompat(R.string.app_name); finish(); } - + return true; } @@ -285,7 +290,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, adapter.loadServers(); } } - + /** * Delete server * @@ -296,7 +301,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection, Database db = new Database(this); db.removeServerById(serverId); db.close(); - + Yaaic.getInstance().removeServerById(serverId); adapter.loadServers(); } @@ -304,14 +309,15 @@ public class ServersActivity extends ListActivity implements ServiceConnection, /** * On server status update */ + @Override public void onStatusUpdate() { adapter.loadServers(); - + if (adapter.getCount() > 2) { // Hide background if there are servers in the list list.setBackgroundDrawable(null); } } - + } \ No newline at end of file diff --git a/application/src/org/yaaic/activity/SettingsActivity.java b/application/src/org/yaaic/activity/SettingsActivity.java index 360e5e1..8276c73 100644 --- a/application/src/org/yaaic/activity/SettingsActivity.java +++ b/application/src/org/yaaic/activity/SettingsActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import org.yaaic.R; @@ -39,7 +39,7 @@ public class SettingsActivity extends PreferenceActivity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + addPreferencesFromResource(R.xml.preferences); } } diff --git a/application/src/org/yaaic/activity/UserActivity.java b/application/src/org/yaaic/activity/UserActivity.java index 678c5a1..227cf14 100644 --- a/application/src/org/yaaic/activity/UserActivity.java +++ b/application/src/org/yaaic/activity/UserActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import org.yaaic.R; @@ -27,9 +27,9 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; +import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; -import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.Button; import android.widget.TextView; @@ -42,7 +42,7 @@ import android.widget.TextView; public class UserActivity extends Activity implements OnClickListener { private String nickname; - + /** * On create */ @@ -51,28 +51,29 @@ public class UserActivity extends Activity implements OnClickListener { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - + nickname = getIntent().getStringExtra(Extra.USER); setContentView(R.layout.user); - + // Use full width LayoutParams params = getWindow().getAttributes(); params.width = WindowManager.LayoutParams.FILL_PARENT; getWindow().setAttributes(params); - + ((Button) findViewById(R.id.op)).setOnClickListener(this); ((Button) findViewById(R.id.deop)).setOnClickListener(this); ((Button) findViewById(R.id.voice)).setOnClickListener(this); ((Button) findViewById(R.id.devoice)).setOnClickListener(this); ((Button) findViewById(R.id.kick)).setOnClickListener(this); ((Button) findViewById(R.id.ban)).setOnClickListener(this); - + ((TextView) findViewById(R.id.nickname)).setText(nickname); } /** * On button click */ + @Override public void onClick(View v) { Intent intent = new Intent(); diff --git a/application/src/org/yaaic/activity/UsersActivity.java b/application/src/org/yaaic/activity/UsersActivity.java index 626a171..7e9db59 100644 --- a/application/src/org/yaaic/activity/UsersActivity.java +++ b/application/src/org/yaaic/activity/UsersActivity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.activity; import java.util.Arrays; @@ -49,9 +49,9 @@ public class UsersActivity extends ListActivity implements OnItemClickListener { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - + setContentView(R.layout.users); - + final String[] users = getIntent().getExtras().getStringArray(Extra.USERS); getListView().setOnItemClickListener(this); @@ -64,6 +64,7 @@ public class UsersActivity extends ListActivity implements OnItemClickListener /** * On user selected */ + @Override public void onItemClick(AdapterView list, View item, int position, long id) { Intent intent = new Intent(); diff --git a/application/src/org/yaaic/adapter/DeckAdapter.java b/application/src/org/yaaic/adapter/DeckAdapter.java index ac99059..5f4da0d 100644 --- a/application/src/org/yaaic/adapter/DeckAdapter.java +++ b/application/src/org/yaaic/adapter/DeckAdapter.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.adapter; import java.util.LinkedList; @@ -43,7 +43,7 @@ public class DeckAdapter extends BaseAdapter private LinkedList conversations; private MessageListView currentView; private String currentChannel; - + /** * Create a new DeckAdapter instance */ @@ -51,7 +51,7 @@ public class DeckAdapter extends BaseAdapter { conversations = new LinkedList(); } - + /** * Clear conversations */ @@ -59,10 +59,11 @@ public class DeckAdapter extends BaseAdapter { conversations = new LinkedList(); } - + /** * Get number of item */ + @Override public int getCount() { return conversations.size(); @@ -71,6 +72,7 @@ public class DeckAdapter extends BaseAdapter /** * Get item at position */ + @Override public Conversation getItem(int position) { if (position >= 0 && position < conversations.size()) { @@ -82,13 +84,14 @@ public class DeckAdapter extends BaseAdapter /** * Get id of item at position */ + @Override public long getItemId(int position) { return position; } - + /** - * Add an item + * Add an item * * @param channel Name of the channel * @param view The view object @@ -96,10 +99,10 @@ public class DeckAdapter extends BaseAdapter public void addItem(Conversation conversation) { conversations.add(conversation); - + notifyDataSetChanged(); } - + /** * Get an item by the channel's name * @@ -111,16 +114,16 @@ public class DeckAdapter extends BaseAdapter // Optimization - cache field lookups int mSize = conversations.size(); LinkedList mItems = this.conversations; - + for (int i = 0; i < mSize; i++) { if (mItems.get(i).getName().equalsIgnoreCase(name)) { return i; } } - + return -1; } - + /** * Remove an item * @@ -129,13 +132,13 @@ public class DeckAdapter extends BaseAdapter public void removeItem(String target) { int position = getPositionByName(target); - + if (position != -1) { conversations.remove(position); notifyDataSetChanged(); } } - + /** * Set single channel view * @@ -146,7 +149,7 @@ public class DeckAdapter extends BaseAdapter currentChannel = channel; currentView = current; } - + /** * Get single channel view * @@ -156,7 +159,7 @@ public class DeckAdapter extends BaseAdapter { return currentView; } - + /** * Get name of channel (single channel view) * @@ -166,9 +169,9 @@ public class DeckAdapter extends BaseAdapter { return currentChannel; } - + /** - * Has the view been switched to single channel view? + * Has the view been switched to single channel view? * * @return view true if view is in single channel view, false otherwise */ @@ -176,16 +179,17 @@ public class DeckAdapter extends BaseAdapter { return currentView != null; } - + /** * Get view at given position */ + @Override public View getView(int position, View convertView, ViewGroup parent) { Conversation conversation = getItem(position); return renderConversation(conversation, parent); } - + /** * Render a conversation view (MessageListView) * @@ -197,21 +201,21 @@ public class DeckAdapter extends BaseAdapter { MessageListView list = new MessageListView(parent.getContext(), parent); list.setOnItemClickListener(MessageClickListener.getInstance()); - + MessageListAdapter adapter = conversation.getMessageListAdapter(); if (adapter == null) { adapter = new MessageListAdapter(conversation, parent.getContext()); conversation.setMessageListAdapter(adapter); } - + list.setAdapter(adapter); - + list.setDivider(null); list.setLayoutParams(new Gallery.LayoutParams( parent.getWidth() / 100 * 85, parent.getHeight() )); - + list.setBackgroundResource(R.layout.rounded); list.setCacheColorHint(0xee000000); list.setPadding(5, 5, 5, 5); @@ -219,7 +223,7 @@ public class DeckAdapter extends BaseAdapter list.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_INSET); list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL); list.setSelection(list.getAdapter().getCount() - 1); // scroll to bottom - + return list; } } diff --git a/application/src/org/yaaic/adapter/MessageListAdapter.java b/application/src/org/yaaic/adapter/MessageListAdapter.java index b4a5c3d..bbc2019 100644 --- a/application/src/org/yaaic/adapter/MessageListAdapter.java +++ b/application/src/org/yaaic/adapter/MessageListAdapter.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.adapter; import java.util.LinkedList; @@ -38,9 +38,9 @@ import android.widget.TextView; */ public class MessageListAdapter extends BaseAdapter { - private LinkedList messages; - private Context context; - + private final LinkedList messages; + private final Context context; + /** * Create a new MessageAdapter * @@ -50,26 +50,26 @@ public class MessageListAdapter extends BaseAdapter public MessageListAdapter(Conversation conversation, Context context) { LinkedList messages = new LinkedList(); - + // Render channel name as first message in channel if (conversation.getType() != Conversation.TYPE_SERVER) { Message header = new Message(conversation.getName()); header.setColor(Message.COLOR_RED); messages.add(header.renderTextView(context)); } - + // Optimization - cache field lookups LinkedList mHistory = conversation.getHistory(); int mSize = mHistory.size(); - + for (int i = 0; i < mSize; i++) { messages.add(mHistory.get(i).renderTextView(context)); } - + // XXX: We don't want to clear the buffer, we want to add only // buffered messages that are not already added (history) conversation.clearBuffer(); - + this.messages = messages; this.context = context; } @@ -82,14 +82,14 @@ public class MessageListAdapter extends BaseAdapter public void addMessage(Message message) { messages.add(message.renderTextView(context)); - + if (messages.size() > Conversation.HISTORY_SIZE) { messages.remove(0); } - + notifyDataSetChanged(); } - + /** * Add a list of messages to the list * @@ -100,23 +100,24 @@ public class MessageListAdapter extends BaseAdapter LinkedList mMessages = this.messages; Context mContext = this.context; int mSize = messages.size(); - + for (int i = mSize - 1; i > -1; i--) { mMessages.add(messages.get(i).renderTextView(mContext)); - + if (mMessages.size() > Conversation.HISTORY_SIZE) { mMessages.remove(0); } } - + notifyDataSetChanged(); } - + /** * Get number of items * * @return */ + @Override public int getCount() { return messages.size(); @@ -128,6 +129,7 @@ public class MessageListAdapter extends BaseAdapter * @param position * @return */ + @Override public TextView getItem(int position) { return messages.get(position); @@ -139,6 +141,7 @@ public class MessageListAdapter extends BaseAdapter * @param position * @return */ + @Override public long getItemId(int position) { return position; @@ -152,6 +155,7 @@ public class MessageListAdapter extends BaseAdapter * @param parent * @return */ + @Override public View getView(int position, View convertView, ViewGroup parent) { return getItem(position); diff --git a/application/src/org/yaaic/adapter/ServerListAdapter.java b/application/src/org/yaaic/adapter/ServerListAdapter.java index 70981ca..2ba1b63 100644 --- a/application/src/org/yaaic/adapter/ServerListAdapter.java +++ b/application/src/org/yaaic/adapter/ServerListAdapter.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.adapter; import java.util.ArrayList; @@ -42,7 +42,7 @@ import android.widget.TextView; public class ServerListAdapter extends BaseAdapter { private ArrayList servers; - + /** * Create a new adapter for server lists */ @@ -50,7 +50,7 @@ public class ServerListAdapter extends BaseAdapter { loadServers(); } - + /** * Load servers from database * @@ -61,19 +61,20 @@ public class ServerListAdapter extends BaseAdapter servers = Yaaic.getInstance().getServersAsArrayList(); notifyDataSetChanged(); } - + /** * Get number of items */ + @Override public int getCount() { int size = servers.size(); - + // Display "Add server" item if (size == 0) { return 1; } - + return size; } @@ -82,12 +83,13 @@ public class ServerListAdapter extends BaseAdapter * * @param position */ + @Override public Server getItem(int position) { if (servers.size() == 0) { return null; // No server object for the "add server" view } - + return servers.get(position); } @@ -96,12 +98,13 @@ public class ServerListAdapter extends BaseAdapter * * @param position */ + @Override public long getItemId(int position) { if (servers.size() == 0) { return 0; } - + return getItem(position).getId(); } @@ -112,24 +115,25 @@ public class ServerListAdapter extends BaseAdapter * @param convertView * @param parent */ + @Override public View getView(int position, View convertView, ViewGroup parent) { Server server = getItem(position); - + LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - + if (server == null) { // Return "Add server" view return inflater.inflate(R.layout.addserveritem, null); } - + View v = inflater.inflate(R.layout.serveritem, null); - + ((TextView) v.findViewById(R.id.title)).setText(server.getTitle()); ((TextView) v.findViewById(R.id.host)).setText(server.getIdentity().getNickname() + " @ " + server.getHost() + " : " + server.getPort()); - + ((ImageView) v.findViewById(R.id.status)).setImageResource(server.getStatusIcon()); - + return v; } } diff --git a/application/src/org/yaaic/command/BaseHandler.java b/application/src/org/yaaic/command/BaseHandler.java index 908f838..48137de 100644 --- a/application/src/org/yaaic/command/BaseHandler.java +++ b/application/src/org/yaaic/command/BaseHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command; import org.yaaic.exception.CommandException; @@ -44,14 +44,14 @@ public abstract class BaseHandler * @throws CommandException if command couldn't be executed */ public abstract void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException; - + /** * Get the usage description for this command * * @return The usage description */ public abstract String getUsage(); - + /** * Get the description for this command * @@ -59,7 +59,7 @@ public abstract class BaseHandler * @return */ public abstract String getDescription(Context context); - + /** * Merge params to a string * @@ -69,7 +69,7 @@ public abstract class BaseHandler { return mergeParams(params, 1); } - + /** * Merge params to a string * @@ -79,12 +79,12 @@ public abstract class BaseHandler public static String mergeParams(String[] params, int position) { StringBuffer buffer = new StringBuffer(); - + for (; position < params.length; position++) { buffer.append(params[position]); buffer.append(" "); } - + return buffer.toString().trim(); } } diff --git a/application/src/org/yaaic/command/CommandParser.java b/application/src/org/yaaic/command/CommandParser.java index a467b26..f204fe2 100644 --- a/application/src/org/yaaic/command/CommandParser.java +++ b/application/src/org/yaaic/command/CommandParser.java @@ -17,13 +17,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command; import java.util.HashMap; -import android.content.Intent; - import org.yaaic.command.handler.AMsgHandler; import org.yaaic.command.handler.AwayHandler; import org.yaaic.command.handler.CloseHandler; @@ -55,15 +53,17 @@ import org.yaaic.model.Conversation; import org.yaaic.model.Message; import org.yaaic.model.Server; +import android.content.Intent; + /** * Parser for commands - * + * * @author Sebastian Kaspari */ public class CommandParser { - private HashMap commands; - private HashMap aliases; + private final HashMap commands; + private final HashMap aliases; private static CommandParser instance; /** @@ -72,7 +72,7 @@ public class CommandParser private CommandParser() { commands = new HashMap(); - + // Commands commands.put("nick", new NickHandler()); commands.put("join", new JoinHandler()); @@ -98,9 +98,9 @@ public class CommandParser commands.put("msg", new MsgHandler()); commands.put("quote", new RawHandler()); commands.put("amsg", new AMsgHandler()); - + aliases = new HashMap(); - + // Aliases aliases.put("j","join"); aliases.put("q", "query"); @@ -108,7 +108,7 @@ public class CommandParser aliases.put("raw", "quote"); aliases.put("w", "whois"); } - + /** * Get the global CommandParser instance * @@ -119,10 +119,10 @@ public class CommandParser if (instance == null) { instance = new CommandParser(); } - + return instance; } - + /** * Get the commands HashMap * @@ -132,7 +132,7 @@ public class CommandParser { return commands; } - + /** * Get the command aliases HashMap * @@ -142,7 +142,7 @@ public class CommandParser { return aliases; } - + /** * Is the given command a valid client command? * @@ -153,7 +153,7 @@ public class CommandParser { return commands.containsKey(command.toLowerCase()) || aliases.containsKey(command.toLowerCase()); } - + /** * Handle a client command * @@ -180,11 +180,11 @@ public class CommandParser Message errorMessage = new Message(type + ": " + e.getMessage()); errorMessage.setColor(Message.COLOR_RED); conversation.addMessage(errorMessage); - + // XXX:I18N - How to get a context here? (command_syntax) Message usageMessage = new Message("Syntax: " + command.getUsage()); conversation.addMessage(usageMessage); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), @@ -195,7 +195,7 @@ public class CommandParser } } } - + /** * Handle a server command * @@ -215,7 +215,7 @@ public class CommandParser service.getConnection(server.getId()).sendRawLineViaQueue(type.toUpperCase()); } } - + /** * Parse the given line * @@ -226,7 +226,7 @@ public class CommandParser line = line.trim().substring(1); // cut the slash String[] params = line.split(" "); String type = params[0]; - + if (isClientCommand(type)) { handleClientCommand(type, params, server, conversation, service); } else { diff --git a/application/src/org/yaaic/command/handler/AMsgHandler.java b/application/src/org/yaaic/command/handler/AMsgHandler.java index 96074ed..aa72f97 100644 --- a/application/src/org/yaaic/command/handler/AMsgHandler.java +++ b/application/src/org/yaaic/command/handler/AMsgHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import java.util.Collection; @@ -47,26 +47,26 @@ public class AMsgHandler extends BaseHandler * Execute /amsg */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 1) { String text = BaseHandler.mergeParams(params); - + Collection mConversations = server.getConversations(); for (Conversation currentConversation : mConversations) { if (currentConversation.getType() == Conversation.TYPE_CHANNEL) { Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text); currentConversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), currentConversation.getName() ); - + service.sendBroadcast(intent); - + service.getConnection(server.getId()).sendMessage(currentConversation.getName(), text); } } @@ -74,7 +74,7 @@ public class AMsgHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /amsg */ diff --git a/application/src/org/yaaic/command/handler/AwayHandler.java b/application/src/org/yaaic/command/handler/AwayHandler.java index b5f3ac7..0ea9ece 100644 --- a/application/src/org/yaaic/command/handler/AwayHandler.java +++ b/application/src/org/yaaic/command/handler/AwayHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; diff --git a/application/src/org/yaaic/command/handler/CloseHandler.java b/application/src/org/yaaic/command/handler/CloseHandler.java index 0482536..ed6727c 100644 --- a/application/src/org/yaaic/command/handler/CloseHandler.java +++ b/application/src/org/yaaic/command/handler/CloseHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -44,19 +44,19 @@ public class CloseHandler extends BaseHandler * Execute /close */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() == Conversation.TYPE_SERVER) { throw new CommandException(service.getString(R.string.close_server_window)); } - + if (params.length == 1) { if (conversation.getType() == Conversation.TYPE_CHANNEL) { service.getConnection(server.getId()).partChannel(conversation.getName()); } if (conversation.getType() == Conversation.TYPE_QUERY) { server.removeConversation(conversation.getName()); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_REMOVE, server.getId(), @@ -66,7 +66,7 @@ public class CloseHandler extends BaseHandler } } } - + /** * Usage of /close */ diff --git a/application/src/org/yaaic/command/handler/DCCHandler.java b/application/src/org/yaaic/command/handler/DCCHandler.java index 0089ea8..7f5508b 100644 --- a/application/src/org/yaaic/command/handler/DCCHandler.java +++ b/application/src/org/yaaic/command/handler/DCCHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import java.io.File; @@ -46,7 +46,7 @@ public class DCCHandler extends BaseHandler * Execute /dcc */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 4) { if (!params[1].equalsIgnoreCase("SEND")) { @@ -56,13 +56,13 @@ public class DCCHandler extends BaseHandler if (!file.exists()) { throw new CommandException(service.getString(R.string.dcc_file_not_found, params[3])); } - + service.getConnection(server.getId()).dccSendFile(file, params[2], 60000); - + Message message = new Message(service.getString(R.string.dcc_waiting_accept, params[2])); message.setColor(Message.COLOR_GREY); conversation.addMessage(message); - + service.sendBroadcast( Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName()) ); @@ -70,7 +70,7 @@ public class DCCHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /dcc */ diff --git a/application/src/org/yaaic/command/handler/DeopHandler.java b/application/src/org/yaaic/command/handler/DeopHandler.java index 65c8375..3147cbc 100644 --- a/application/src/org/yaaic/command/handler/DeopHandler.java +++ b/application/src/org/yaaic/command/handler/DeopHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,19 +40,19 @@ public class DeopHandler extends BaseHandler * Execute /deop */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + if (params.length == 2) { service.getConnection(server.getId()).deOp(conversation.getName(), params[1]); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /deop */ diff --git a/application/src/org/yaaic/command/handler/DevoiceHandler.java b/application/src/org/yaaic/command/handler/DevoiceHandler.java index 60f2f0e..ba2422e 100644 --- a/application/src/org/yaaic/command/handler/DevoiceHandler.java +++ b/application/src/org/yaaic/command/handler/DevoiceHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,19 +40,19 @@ public class DevoiceHandler extends BaseHandler * Execute /devoice */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + if (params.length == 2) { service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /devoice */ diff --git a/application/src/org/yaaic/command/handler/EchoHandler.java b/application/src/org/yaaic/command/handler/EchoHandler.java index e29c70d..d5bc6b3 100644 --- a/application/src/org/yaaic/command/handler/EchoHandler.java +++ b/application/src/org/yaaic/command/handler/EchoHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -43,12 +43,12 @@ public class EchoHandler extends BaseHandler * Execute /echo */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 1) { Message message = new Message(BaseHandler.mergeParams(params)); conversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), @@ -59,7 +59,7 @@ public class EchoHandler extends BaseHandler throw new CommandException(service.getString(R.string.text_missing)); } } - + /** * Usage of /echo */ diff --git a/application/src/org/yaaic/command/handler/HelpHandler.java b/application/src/org/yaaic/command/handler/HelpHandler.java index 4fd1361..6181d9e 100644 --- a/application/src/org/yaaic/command/handler/HelpHandler.java +++ b/application/src/org/yaaic/command/handler/HelpHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import java.util.HashMap; @@ -37,7 +37,7 @@ import android.content.Context; import android.content.Intent; /** - * Command: /help + * Command: /help * * @author Karol Gliniecki * @author Sebastian Kaspari @@ -51,14 +51,14 @@ public class HelpHandler extends BaseHandler public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 2) { - showCommandDetails(service, server, conversation, params[1]); + showCommandDetails(service, server, conversation, params[1]); } else if (params.length == 1) { showAllCommands(service, server, conversation); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Show all available commands * @@ -69,16 +69,16 @@ public class HelpHandler extends BaseHandler private void showAllCommands(IRCService service, Server server, Conversation conversation) { CommandParser cp = CommandParser.getInstance(); - + StringBuffer commandList = new StringBuffer(service.getString(R.string.available_commands)); commandList.append("\n"); - + HashMap commands = cp.getCommands(); HashMap aliases = cp.getAliases(); Set commandKeys = commands.keySet(); Set aliasesKeys = aliases.keySet(); - + for (Object command : commandKeys) { String alias = ""; for (Object aliasCommand : aliasesKeys) { @@ -89,17 +89,17 @@ public class HelpHandler extends BaseHandler } commandList.append("/" + command.toString() + alias + " - "+commands.get(command).getDescription(service) + "\n"); } - + Message message = new Message(commandList.toString()); message.setColor(Message.COLOR_YELLOW); conversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName() ); - + service.sendBroadcast(intent); } @@ -116,19 +116,19 @@ public class HelpHandler extends BaseHandler { CommandParser cp = CommandParser.getInstance(); HashMap commands = cp.getCommands(); - + if (commands.containsKey(command)) { // XXX:I18N - String building salad :) 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); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName() ); - + service.sendBroadcast(intent); } else { throw new CommandException(service.getString(R.string.unknown_command, command)); diff --git a/application/src/org/yaaic/command/handler/JoinHandler.java b/application/src/org/yaaic/command/handler/JoinHandler.java index f4ee999..68a09a6 100644 --- a/application/src/org/yaaic/command/handler/JoinHandler.java +++ b/application/src/org/yaaic/command/handler/JoinHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -50,7 +50,7 @@ public class JoinHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /join */ diff --git a/application/src/org/yaaic/command/handler/KickHandler.java b/application/src/org/yaaic/command/handler/KickHandler.java index 415afa1..ebef2c6 100644 --- a/application/src/org/yaaic/command/handler/KickHandler.java +++ b/application/src/org/yaaic/command/handler/KickHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -42,19 +42,19 @@ public class KickHandler extends BaseHandler * Execute /kick */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + if (params.length == 2) { service.getConnection(server.getId()).kick(conversation.getName(), params[1]); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /kick */ diff --git a/application/src/org/yaaic/command/handler/MeHandler.java b/application/src/org/yaaic/command/handler/MeHandler.java index 1ccde6c..84dc8d8 100644 --- a/application/src/org/yaaic/command/handler/MeHandler.java +++ b/application/src/org/yaaic/command/handler/MeHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -43,33 +43,33 @@ public class MeHandler extends BaseHandler * Execute /me */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() == Conversation.TYPE_SERVER) { throw new CommandException(service.getString(R.string.only_usable_from_channel_or_query)); } - + if (params.length > 1) { String action = BaseHandler.mergeParams(params); String nickname = service.getConnection(server.getId()).getNick(); - + Message message = new Message(nickname + " " + action); message.setIcon(R.drawable.action); server.getConversation(conversation.getName()).addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName() ); service.sendBroadcast(intent); - + service.getConnection(server.getId()).sendAction(conversation.getName(), action); } else { throw new CommandException(service.getString(R.string.text_missing)); } } - + /** * Usage of /me */ diff --git a/application/src/org/yaaic/command/handler/ModeHandler.java b/application/src/org/yaaic/command/handler/ModeHandler.java index c09f06f..a436167 100644 --- a/application/src/org/yaaic/command/handler/ModeHandler.java +++ b/application/src/org/yaaic/command/handler/ModeHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -42,17 +42,17 @@ public class ModeHandler extends BaseHandler * Execute /mode */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 2) { String modes = BaseHandler.mergeParams(params, 2); - + service.getConnection(server.getId()).setMode(params[1], modes); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /mode */ diff --git a/application/src/org/yaaic/command/handler/MsgHandler.java b/application/src/org/yaaic/command/handler/MsgHandler.java index 2c9514e..1b18393 100644 --- a/application/src/org/yaaic/command/handler/MsgHandler.java +++ b/application/src/org/yaaic/command/handler/MsgHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -45,31 +45,31 @@ public class MsgHandler extends BaseHandler * Execute /msg */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 2) { String text = BaseHandler.mergeParams(params, 2); service.getConnection(server.getId()).sendMessage(params[1], text); - + Conversation targetConversation = server.getConversation(params[1]); - + if (targetConversation != null) { Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text); targetConversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), targetConversation.getName() ); - + service.sendBroadcast(intent); } } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /msg */ diff --git a/application/src/org/yaaic/command/handler/NamesHandler.java b/application/src/org/yaaic/command/handler/NamesHandler.java index 83736fe..2ff0688 100644 --- a/application/src/org/yaaic/command/handler/NamesHandler.java +++ b/application/src/org/yaaic/command/handler/NamesHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.jibble.pircbot.User; @@ -35,7 +35,7 @@ import android.content.Intent; /** * Command: /names - * Lists all users currently in the selected channel + * Lists all users currently in the selected channel * * @author Sebastian Kaspari */ @@ -45,14 +45,14 @@ public class NamesHandler extends BaseHandler * Execute /names */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + StringBuffer userList = new StringBuffer(service.getString(R.string.message_users_on_chan, conversation.getName())); - + User[] mUsers = service.getConnection(server.getId()).getUsers(conversation.getName()); int mSize = mUsers.length; for (int i = 0; i < mSize; i++) { @@ -60,11 +60,11 @@ public class NamesHandler extends BaseHandler userList.append(mUsers[i].getPrefix()); userList.append(mUsers[i].getNick()); } - + Message message = new Message(userList.toString()); message.setColor(Message.COLOR_YELLOW); conversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), @@ -72,7 +72,7 @@ public class NamesHandler extends BaseHandler ); service.sendBroadcast(intent); } - + /** * Usage of /names */ diff --git a/application/src/org/yaaic/command/handler/NickHandler.java b/application/src/org/yaaic/command/handler/NickHandler.java index f628e77..3d20db7 100644 --- a/application/src/org/yaaic/command/handler/NickHandler.java +++ b/application/src/org/yaaic/command/handler/NickHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,7 +40,7 @@ public class NickHandler extends BaseHandler * Execute /nick */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 2) { service.getConnection(server.getId()).changeNick(params[1]); @@ -48,7 +48,7 @@ public class NickHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /nick */ @@ -57,7 +57,7 @@ public class NickHandler extends BaseHandler { return "/nick "; } - + /** * Description of /nick */ diff --git a/application/src/org/yaaic/command/handler/NoticeHandler.java b/application/src/org/yaaic/command/handler/NoticeHandler.java index 9fa5144..024a4a9 100644 --- a/application/src/org/yaaic/command/handler/NoticeHandler.java +++ b/application/src/org/yaaic/command/handler/NoticeHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -45,28 +45,28 @@ public class NoticeHandler extends BaseHandler * Execute /notice */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 2) { String text = BaseHandler.mergeParams(params); - + Message message = new Message(">" + params[1] + "< " + text); message.setIcon(R.drawable.info); conversation.addMessage(message); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName() ); service.sendBroadcast(intent); - + service.getConnection(server.getId()).sendNotice(params[1], text); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /notice */ diff --git a/application/src/org/yaaic/command/handler/OpHandler.java b/application/src/org/yaaic/command/handler/OpHandler.java index 16c7da3..e495ca0 100644 --- a/application/src/org/yaaic/command/handler/OpHandler.java +++ b/application/src/org/yaaic/command/handler/OpHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,19 +40,19 @@ public class OpHandler extends BaseHandler * Execute /deop */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + if (params.length == 2) { service.getConnection(server.getId()).op(conversation.getName(), params[1]); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /deop */ diff --git a/application/src/org/yaaic/command/handler/PartHandler.java b/application/src/org/yaaic/command/handler/PartHandler.java index 92974d8..6918a64 100644 --- a/application/src/org/yaaic/command/handler/PartHandler.java +++ b/application/src/org/yaaic/command/handler/PartHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -42,13 +42,13 @@ public class PartHandler extends BaseHandler * Execute /part */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 1) { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + service.getConnection(server.getId()).partChannel(conversation.getName()); } else if (params.length == 2) { service.getConnection(server.getId()).partChannel(params[1]); @@ -56,7 +56,7 @@ public class PartHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /part */ diff --git a/application/src/org/yaaic/command/handler/QueryHandler.java b/application/src/org/yaaic/command/handler/QueryHandler.java index 2fe1526..7623908 100644 --- a/application/src/org/yaaic/command/handler/QueryHandler.java +++ b/application/src/org/yaaic/command/handler/QueryHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -45,23 +45,23 @@ public class QueryHandler extends BaseHandler * Execute /query */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 2) { // Simple validation if (params[1].startsWith("#")) { throw new CommandException(service.getString(R.string.query_to_channel)); } - + Conversation query = server.getConversation(params[1]); - + if (query != null) { throw new CommandException(service.getString(R.string.query_exists)); } - + query = new Query(params[1]); server.addConversationl(query); - + Intent intent = Broadcast.createConversationIntent( Broadcast.CONVERSATION_NEW, server.getId(), @@ -72,7 +72,7 @@ public class QueryHandler extends BaseHandler throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /query */ diff --git a/application/src/org/yaaic/command/handler/QuitHandler.java b/application/src/org/yaaic/command/handler/QuitHandler.java index 26518fd..525db8f 100644 --- a/application/src/org/yaaic/command/handler/QuitHandler.java +++ b/application/src/org/yaaic/command/handler/QuitHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,7 +40,7 @@ public class QuitHandler extends BaseHandler * Execute /quit */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length == 1) { service.getConnection(server.getId()).quitServer(); @@ -48,7 +48,7 @@ public class QuitHandler extends BaseHandler service.getConnection(server.getId()).quitServer(BaseHandler.mergeParams(params)); } } - + /** * Usage of /quit */ diff --git a/application/src/org/yaaic/command/handler/RawHandler.java b/application/src/org/yaaic/command/handler/RawHandler.java index 5b280d0..857fb16 100644 --- a/application/src/org/yaaic/command/handler/RawHandler.java +++ b/application/src/org/yaaic/command/handler/RawHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -42,7 +42,7 @@ public class RawHandler extends BaseHandler * Execute /raw */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (params.length > 1) { String line = BaseHandler.mergeParams(params); @@ -51,7 +51,7 @@ public class RawHandler extends BaseHandler throw new CommandException(service.getString(R.string.line_missing)); } } - + /** * Usage of /raw */ diff --git a/application/src/org/yaaic/command/handler/TopicHandler.java b/application/src/org/yaaic/command/handler/TopicHandler.java index 5c33c96..d368477 100644 --- a/application/src/org/yaaic/command/handler/TopicHandler.java +++ b/application/src/org/yaaic/command/handler/TopicHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -48,9 +48,9 @@ public class TopicHandler extends BaseHandler if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + Channel channel = (Channel) conversation; - + if (params.length == 1) { // Show topic service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false); @@ -59,7 +59,7 @@ public class TopicHandler extends BaseHandler service.getConnection(server.getId()).setTopic(channel.getName(), BaseHandler.mergeParams(params)); } } - + /** * Usage of /topic */ diff --git a/application/src/org/yaaic/command/handler/VoiceHandler.java b/application/src/org/yaaic/command/handler/VoiceHandler.java index 7e2418f..2872a1b 100644 --- a/application/src/org/yaaic/command/handler/VoiceHandler.java +++ b/application/src/org/yaaic/command/handler/VoiceHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -40,19 +40,19 @@ public class VoiceHandler extends BaseHandler * Execute /voice */ @Override - public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException + public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException { if (conversation.getType() != Conversation.TYPE_CHANNEL) { throw new CommandException(service.getString(R.string.only_usable_from_channel)); } - + if (params.length == 2) { service.getConnection(server.getId()).voice(conversation.getName(), params[1]); } else { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } } - + /** * Usage of /voice */ diff --git a/application/src/org/yaaic/command/handler/WhoisHandler.java b/application/src/org/yaaic/command/handler/WhoisHandler.java index 5a06bec..130c144 100644 --- a/application/src/org/yaaic/command/handler/WhoisHandler.java +++ b/application/src/org/yaaic/command/handler/WhoisHandler.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.command.handler; import org.yaaic.R; @@ -47,7 +47,7 @@ public class WhoisHandler extends BaseHandler if (params.length != 2) { throw new CommandException(service.getString(R.string.invalid_number_of_params)); } - + service.getConnection(server.getId()).sendRawLineViaQueue("WHOIS " + params[1]); } diff --git a/application/src/org/yaaic/db/AliasConstants.java b/application/src/org/yaaic/db/AliasConstants.java index 7aee246..89a01b9 100644 --- a/application/src/org/yaaic/db/AliasConstants.java +++ b/application/src/org/yaaic/db/AliasConstants.java @@ -5,15 +5,15 @@ import android.provider.BaseColumns; public class AliasConstants implements BaseColumns { public static final String TABLE_NAME = "aliases"; - + // fields public static final String ALIAS = "alias"; public static final String IDENTITY = "identity"; - + public static final String[] ALL = { _ID, ALIAS, IDENTITY, }; - + } diff --git a/application/src/org/yaaic/db/ChannelConstants.java b/application/src/org/yaaic/db/ChannelConstants.java index 7b9dc1f..93cb088 100644 --- a/application/src/org/yaaic/db/ChannelConstants.java +++ b/application/src/org/yaaic/db/ChannelConstants.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.db; import android.provider.BaseColumns; @@ -30,12 +30,12 @@ import android.provider.BaseColumns; public interface ChannelConstants extends BaseColumns { public static final String TABLE_NAME = "channels"; - + // fields public static final String NAME = "name"; public static final String PASSWORD = "password"; public static final String SERVER = "server"; - + /** * All fields of the table */ diff --git a/application/src/org/yaaic/db/CommandConstants.java b/application/src/org/yaaic/db/CommandConstants.java index d5f42a8..d328224 100644 --- a/application/src/org/yaaic/db/CommandConstants.java +++ b/application/src/org/yaaic/db/CommandConstants.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.db; import android.provider.BaseColumns; @@ -30,11 +30,11 @@ import android.provider.BaseColumns; public interface CommandConstants extends BaseColumns { public static final String TABLE_NAME = "commands"; - + // fields public static final String COMMAND = "command"; public static final String SERVER = "server"; - + /** * All fields of the table */ diff --git a/application/src/org/yaaic/db/Database.java b/application/src/org/yaaic/db/Database.java index 264a2a0..d2ea30e 100644 --- a/application/src/org/yaaic/db/Database.java +++ b/application/src/org/yaaic/db/Database.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.db; import java.util.ArrayList; @@ -35,7 +35,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; /** - * Database Helper for the servers and channels tables + * Database Helper for the servers and channels tables * * @author Sebastian Kaspari */ @@ -43,7 +43,7 @@ public class Database extends SQLiteOpenHelper { private static final String DATABASE_NAME = "servers.db"; private static final int DATABASE_VERSION = 4; - + /** * Create a new helper for database access * @@ -53,7 +53,7 @@ public class Database extends SQLiteOpenHelper { super(context, DATABASE_NAME, null, DATABASE_VERSION); } - + /** * Create all needed tables on first start */ @@ -61,41 +61,41 @@ public class Database extends SQLiteOpenHelper public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + ServerConstants.TABLE_NAME + " ( " - + ServerConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + ServerConstants.TITLE + " TEXT NOT NULL, " - + ServerConstants.HOST + " TEXT NOT NULL, " - + ServerConstants.PORT + " INTEGER, " - + ServerConstants.PASSWORD + " TEXT, " - + ServerConstants.AUTOCONNECT + " BOOLEAN, " // XXX: Does SQLLite support boolean? - + ServerConstants.USE_SSL + " BOOLEAN, " - + ServerConstants.CHARSET + " TEXT, " - + ServerConstants.IDENTITY + " INTEGER" - + ");" + + ServerConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + ServerConstants.TITLE + " TEXT NOT NULL, " + + ServerConstants.HOST + " TEXT NOT NULL, " + + ServerConstants.PORT + " INTEGER, " + + ServerConstants.PASSWORD + " TEXT, " + + ServerConstants.AUTOCONNECT + " BOOLEAN, " // XXX: Does SQLLite support boolean? + + ServerConstants.USE_SSL + " BOOLEAN, " + + ServerConstants.CHARSET + " TEXT, " + + ServerConstants.IDENTITY + " INTEGER" + + ");" ); - + db.execSQL("CREATE TABLE " + ChannelConstants.TABLE_NAME + " (" - + ChannelConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + ChannelConstants.NAME + " TEXT NOT NULL, " - + ChannelConstants.PASSWORD + " TEXT, " - + ChannelConstants.SERVER + " INTEGER" - + ");" + + ChannelConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + ChannelConstants.NAME + " TEXT NOT NULL, " + + ChannelConstants.PASSWORD + " TEXT, " + + ChannelConstants.SERVER + " INTEGER" + + ");" ); - + db.execSQL("CREATE TABLE " + IdentityConstants.TABLE_NAME +" (" - + IdentityConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + IdentityConstants.NICKNAME + " TEXT NOT NULL," - + IdentityConstants.IDENT + " TEXT NOT NULL," - + IdentityConstants.REALNAME + " TEXT NOT NULL" - + ");" + + IdentityConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + IdentityConstants.NICKNAME + " TEXT NOT NULL," + + IdentityConstants.IDENT + " TEXT NOT NULL," + + IdentityConstants.REALNAME + " TEXT NOT NULL" + + ");" ); - + db.execSQL("CREATE TABLE " + CommandConstants.TABLE_NAME + " (" + CommandConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + CommandConstants.COMMAND + " TEXT NOT NULL, " + ChannelConstants.SERVER + " INTEGER" + ");" ); - + db.execSQL("CREATE TABLE " + AliasConstants.TABLE_NAME + " (" + AliasConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + AliasConstants.ALIAS + " TEXT NOT NULL, " @@ -103,7 +103,7 @@ public class Database extends SQLiteOpenHelper + ");" ); } - + /** * Migrate existing databases to */ @@ -111,20 +111,20 @@ public class Database extends SQLiteOpenHelper public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // XXX: Do not delete databases (release version) - + // db.execSQL("DROP TABLE IF EXISTS " + ServerConstants.TABLE_NAME + ";"); // db.execSQL("DROP TABLE IF EXISTS " + ChannelConstants.TABLE_NAME + ";"); // db.execSQL("DROP TABLE IF EXISTS " + IdentityConstants.TABLE_NAME + ";"); - + // onCreate(db); - + if (oldVersion == 1) { // Add charset field to server table db.execSQL("ALTER TABLE " + ServerConstants.TABLE_NAME + " ADD " + ServerConstants.CHARSET + " TEXT AFTER " + ServerConstants.USE_SSL + ";"); - + oldVersion = 2; // now do the updates for version 2 } - + if (oldVersion == 2) { // Add new commands table (copy&paste from onCreate()) db.execSQL("CREATE TABLE " + CommandConstants.TABLE_NAME + " (" @@ -133,10 +133,10 @@ public class Database extends SQLiteOpenHelper + ChannelConstants.SERVER + " INTEGER" + ");" ); - + oldVersion = 3; } - + if (oldVersion == 3) { db.execSQL("CREATE TABLE " + AliasConstants.TABLE_NAME + " (" + AliasConstants._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " @@ -146,9 +146,9 @@ public class Database extends SQLiteOpenHelper ); } } - + /** - * Add a new server to the database + * Add a new server to the database * * @param title Unique title of the server * @param host Hostname of the server @@ -161,7 +161,7 @@ public class Database extends SQLiteOpenHelper public long addServer(String title, String host, int port, String password, boolean autoConnect, boolean useSSL, long identityId, String charset) { ContentValues values = new ContentValues(); - + values.put(ServerConstants.TITLE, title); values.put(ServerConstants.HOST, host); values.put(ServerConstants.PORT, port); @@ -170,10 +170,10 @@ public class Database extends SQLiteOpenHelper values.put(ServerConstants.USE_SSL, useSSL); values.put(ServerConstants.IDENTITY, identityId); values.put(ServerConstants.CHARSET, charset); - + return this.getWritableDatabase().insert(ServerConstants.TABLE_NAME, null, values); } - + /** * Update the server record in the database * @@ -189,7 +189,7 @@ public class Database extends SQLiteOpenHelper public void updateServer(int serverId, String title, String host, int port, String password, boolean autoConnect, boolean useSSL, long identityId, String charset) { ContentValues values = new ContentValues(); - + values.put(ServerConstants.TITLE, title); values.put(ServerConstants.HOST, host); values.put(ServerConstants.PORT, port); @@ -198,7 +198,7 @@ public class Database extends SQLiteOpenHelper values.put(ServerConstants.USE_SSL, useSSL); values.put(ServerConstants.IDENTITY, identityId); values.put(ServerConstants.CHARSET, charset); - + this.getWritableDatabase().update( ServerConstants.TABLE_NAME, values, @@ -206,7 +206,7 @@ public class Database extends SQLiteOpenHelper null ); } - + /** * Add a channel to the database * @@ -217,14 +217,14 @@ public class Database extends SQLiteOpenHelper public void addChannel(int serverId, String name, String password) { ContentValues values = new ContentValues(); - + values.put(ChannelConstants.NAME, name); values.put(ChannelConstants.PASSWORD, password); values.put(ChannelConstants.SERVER, serverId); - + this.getWritableDatabase().insert(ChannelConstants.TABLE_NAME, null, values); } - + /** * Replace list of channels for the given server * @@ -239,13 +239,13 @@ public class Database extends SQLiteOpenHelper ChannelConstants.SERVER + " = " + serverId, null ); - + // Add new channels for (String channel : channels) { addChannel(serverId, channel, ""); } } - + /** * Get all commands to execute on connect * @@ -255,7 +255,7 @@ public class Database extends SQLiteOpenHelper public ArrayList getCommandsByServerId(int serverId) { ArrayList commands = new ArrayList(); - + Cursor cursor = this.getReadableDatabase().query( CommandConstants.TABLE_NAME, CommandConstants.ALL, @@ -265,17 +265,17 @@ public class Database extends SQLiteOpenHelper null, null ); - + while (cursor.moveToNext()) { String command = cursor.getString(cursor.getColumnIndex(CommandConstants.COMMAND)); commands.add(command); } - + cursor.close(); - + return commands; } - + /** * Add a command to a server * @@ -285,13 +285,13 @@ public class Database extends SQLiteOpenHelper public void addCommand(int serverId, String command) { ContentValues values = new ContentValues(); - + values.put(CommandConstants.COMMAND, command); values.put(CommandConstants.SERVER, serverId); - + this.getWritableDatabase().insert(CommandConstants.TABLE_NAME, null, values); } - + /** * Replace list of commands for the given server * @@ -306,13 +306,13 @@ public class Database extends SQLiteOpenHelper CommandConstants.SERVER + " = " + serverId, null ); - + // Add new commands for (String command : commands) { addCommand(serverId, command); } } - + /** * Get all servers from database * @@ -321,7 +321,7 @@ public class Database extends SQLiteOpenHelper public HashMap getServers() { HashMap servers = new HashMap(); - + Cursor cursor = this.getReadableDatabase().query( ServerConstants.TABLE_NAME, ServerConstants.ALL, @@ -331,20 +331,20 @@ public class Database extends SQLiteOpenHelper null, ServerConstants.TITLE + " ASC" ); - + while (cursor.moveToNext()) { Server server = populateServer(cursor); servers.put(server.getId(), server); } cursor.close(); - + return servers; } - + public Server getServerById(int serverId) { Server server = null; - + Cursor cursor = this.getReadableDatabase().query( ServerConstants.TABLE_NAME, ServerConstants.ALL, @@ -354,16 +354,16 @@ public class Database extends SQLiteOpenHelper null, ServerConstants.TITLE + " ASC" ); - + if (cursor.moveToNext()) { server = populateServer(cursor); } - + cursor.close(); - + return server; } - + /** * Check if the given server title is currently used * @@ -373,7 +373,7 @@ public class Database extends SQLiteOpenHelper public boolean isTitleUsed(String title) { boolean isTitleUsed = false; - + Cursor cursor = this.getReadableDatabase().query( ServerConstants.TABLE_NAME, ServerConstants.ALL, @@ -383,16 +383,16 @@ public class Database extends SQLiteOpenHelper null, null ); - + if (cursor.moveToNext()) { isTitleUsed = true; } - + cursor.close(); - + return isTitleUsed; } - + /** * Populate a server object from the given database cursor * @param cursor @@ -401,36 +401,36 @@ public class Database extends SQLiteOpenHelper private Server populateServer(Cursor cursor) { Server server = new Server(); - + server.setTitle(cursor.getString(cursor.getColumnIndex((ServerConstants.TITLE)))); server.setHost(cursor.getString(cursor.getColumnIndex((ServerConstants.HOST)))); server.setPort(cursor.getInt(cursor.getColumnIndex((ServerConstants.PORT)))); server.setPassword(cursor.getString(cursor.getColumnIndex(ServerConstants.PASSWORD))); server.setId(cursor.getInt(cursor.getColumnIndex((ServerConstants._ID)))); server.setCharset(cursor.getString(cursor.getColumnIndex(ServerConstants.CHARSET))); - + String useSSLvalue = cursor.getString(cursor.getColumnIndex(ServerConstants.USE_SSL)); if (useSSLvalue != null && useSSLvalue.equals("1")) { server.setUseSSL(true); } - + server.setStatus(Status.DISCONNECTED); - + // Load identity for server Identity identity = this.getIdentityById(cursor.getInt(cursor.getColumnIndex(ServerConstants.IDENTITY))); server.setIdentity(identity); - + // Load auto join channels ArrayList channels = this.getChannelsByServerId(server.getId()); server.setAutoJoinChannels(channels); - + // Load commands to execute after connect ArrayList commands = this.getCommandsByServerId(server.getId()); server.setConnectCommands(commands); - + return server; } - + /** * Get all servers with autoconnect enabled * @@ -448,7 +448,7 @@ public class Database extends SQLiteOpenHelper ServerConstants.TITLE + " ASC" ); } - + /** * Get all channels of server * @@ -458,7 +458,7 @@ public class Database extends SQLiteOpenHelper public ArrayList getChannelsByServerId(int serverId) { ArrayList channels = new ArrayList(); - + Cursor cursor = this.getReadableDatabase().query( ChannelConstants.TABLE_NAME, ChannelConstants.ALL, @@ -468,17 +468,17 @@ public class Database extends SQLiteOpenHelper null, ChannelConstants.NAME + " ASC" ); - + while (cursor.moveToNext()) { String channel = cursor.getString(cursor.getColumnIndex(ChannelConstants.NAME)); channels.add(channel); } - + cursor.close(); - + return channels; } - + /** * Remove server from database by unique id * @@ -493,19 +493,19 @@ public class Database extends SQLiteOpenHelper deleteAliases(identityId); this.getWritableDatabase().execSQL( "DELETE FROM " + IdentityConstants.TABLE_NAME + " WHERE " + IdentityConstants._ID + " = " + identityId + ";" - ); + ); } - + // Now delete the server entry this.getWritableDatabase().execSQL( "DELETE FROM " + ServerConstants.TABLE_NAME + " WHERE " + ServerConstants._ID + " = " + serverId + ";" ); } - + protected void setAliases(long identityId, List aliases) { deleteAliases(identityId); - + ContentValues values = new ContentValues(); for (String alias : aliases) { values.clear(); @@ -514,18 +514,18 @@ public class Database extends SQLiteOpenHelper getWritableDatabase().insert(AliasConstants.TABLE_NAME, null, values); } } - + protected void deleteAliases(long identityId) { getWritableDatabase().execSQL( "DELETE FROM " + AliasConstants.TABLE_NAME + " WHERE " + AliasConstants.IDENTITY + " = " + identityId ); } - + protected List getAliasesByIdentityId(long identityId) { List aliases = new ArrayList(); - + Cursor cursor = this.getReadableDatabase().query( AliasConstants.TABLE_NAME, AliasConstants.ALL, @@ -535,15 +535,15 @@ public class Database extends SQLiteOpenHelper null, null ); - + while (cursor.moveToNext()) { aliases.add(cursor.getString(cursor.getColumnIndex(AliasConstants.ALIAS))); } cursor.close(); - + return aliases; } - + /** * Add a new identity * @@ -556,18 +556,18 @@ public class Database extends SQLiteOpenHelper public long addIdentity(String nickname, String ident, String realname, List aliases) { ContentValues values = new ContentValues(); - + values.put(IdentityConstants.NICKNAME, nickname); values.put(IdentityConstants.IDENT, ident); values.put(IdentityConstants.REALNAME, realname); - + long identityId = this.getWritableDatabase().insert(IdentityConstants.TABLE_NAME, null, values); - + setAliases(identityId, aliases); - + return identityId; } - + /** * Update the identity with the given id * @@ -579,21 +579,21 @@ public class Database extends SQLiteOpenHelper public void updateIdentity(int identityId, String nickname, String ident, String realname, List aliases) { ContentValues values = new ContentValues(); - + values.put(IdentityConstants.NICKNAME, nickname); values.put(IdentityConstants.IDENT, ident); values.put(IdentityConstants.REALNAME, realname); - + this.getWritableDatabase().update( IdentityConstants.TABLE_NAME, values, IdentityConstants._ID + " = " + identityId, null ); - + setAliases(identityId, aliases); } - + /** * Get an identity by its id * @@ -603,7 +603,7 @@ public class Database extends SQLiteOpenHelper public Identity getIdentityById(int identityId) { Identity identity = null; - + Cursor cursor = this.getReadableDatabase().query( IdentityConstants.TABLE_NAME, IdentityConstants.ALL, @@ -613,22 +613,22 @@ public class Database extends SQLiteOpenHelper null, null ); - + if (cursor.moveToNext()) { identity = new Identity(); - + identity.setNickname(cursor.getString(cursor.getColumnIndex(IdentityConstants.NICKNAME))); identity.setIdent(cursor.getString(cursor.getColumnIndex(IdentityConstants.IDENT))); identity.setRealName(cursor.getString(cursor.getColumnIndex(IdentityConstants.REALNAME))); - + identity.setAliases(getAliasesByIdentityId(identityId)); } - + cursor.close(); - + return identity; } - + /** * Get a server by its id * @@ -638,7 +638,7 @@ public class Database extends SQLiteOpenHelper public int getIdentityIdByServerId(int serverId) { int identityId = -1; - + Cursor cursor = this.getReadableDatabase().query( ServerConstants.TABLE_NAME, ServerConstants.ALL, @@ -648,13 +648,13 @@ public class Database extends SQLiteOpenHelper null, null ); - + if (cursor.moveToNext()) { identityId = cursor.getInt(cursor.getColumnIndex(ServerConstants.IDENTITY)); } - + cursor.close(); - + return identityId; } } diff --git a/application/src/org/yaaic/db/IdentityConstants.java b/application/src/org/yaaic/db/IdentityConstants.java index a621e05..18df41c 100644 --- a/application/src/org/yaaic/db/IdentityConstants.java +++ b/application/src/org/yaaic/db/IdentityConstants.java @@ -17,25 +17,25 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.db; import android.provider.BaseColumns; /** * Constants for the identity table - * + * * @author Sebastian Kaspari */ public class IdentityConstants implements BaseColumns { public static final String TABLE_NAME = "identities"; - + // fields public static final String NICKNAME = "nickname"; public static final String IDENT = "ident"; public static final String REALNAME = "realname"; - + /** * All fields of the table */ diff --git a/application/src/org/yaaic/db/ServerConstants.java b/application/src/org/yaaic/db/ServerConstants.java index ab36b56..44619c5 100644 --- a/application/src/org/yaaic/db/ServerConstants.java +++ b/application/src/org/yaaic/db/ServerConstants.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.db; import android.provider.BaseColumns; @@ -30,7 +30,7 @@ import android.provider.BaseColumns; public interface ServerConstants extends BaseColumns { public static final String TABLE_NAME = "servers"; - + // fields public static final String TITLE = "title"; public static final String HOST = "host"; @@ -40,7 +40,7 @@ public interface ServerConstants extends BaseColumns public static final String USE_SSL = "useSSL"; public static final String CHARSET = "charset"; public static final String IDENTITY = "identity"; - + /** * All fields of the table */ diff --git a/application/src/org/yaaic/exception/CommandException.java b/application/src/org/yaaic/exception/CommandException.java index 6717670..8e27fbd 100644 --- a/application/src/org/yaaic/exception/CommandException.java +++ b/application/src/org/yaaic/exception/CommandException.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.exception; /** @@ -29,7 +29,7 @@ package org.yaaic.exception; public class CommandException extends Throwable { private static final long serialVersionUID = -8317993941455253288L; - + /** * Create a new CommandException object */ diff --git a/application/src/org/yaaic/exception/ValidationException.java b/application/src/org/yaaic/exception/ValidationException.java index ea6ad54..5e54ab0 100644 --- a/application/src/org/yaaic/exception/ValidationException.java +++ b/application/src/org/yaaic/exception/ValidationException.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.exception; /** @@ -28,7 +28,7 @@ package org.yaaic.exception; public class ValidationException extends Exception { private static final long serialVersionUID = 6951535205062761539L; - + /** * Create a new ValidationException with the given message * diff --git a/application/src/org/yaaic/irc/IRCBinder.java b/application/src/org/yaaic/irc/IRCBinder.java index c5b6c3f..a126dd6 100644 --- a/application/src/org/yaaic/irc/IRCBinder.java +++ b/application/src/org/yaaic/irc/IRCBinder.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.irc; import org.yaaic.model.Server; @@ -26,25 +26,25 @@ import android.os.Binder; /** * Binder for service communication - * + * * @author Sebastian Kaspari */ public class IRCBinder extends Binder { - private IRCService service; - + private final IRCService service; + /** - * Create a new binder for given service + * Create a new binder for given service * * @param service */ public IRCBinder(IRCService service) { super(); - + this.service = service; } - + /** * Connect to given server * @@ -54,7 +54,7 @@ public class IRCBinder extends Binder { service.connect(server); } - + /** * Get service associated with this service * @return diff --git a/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java b/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java index f2bfee3..94175fb 100644 --- a/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java +++ b/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.layout; import android.content.Context; @@ -31,10 +31,11 @@ import android.view.View; * * @author Sebastian Kaspari */ -public class NonScalingBackgroundDrawable extends Drawable { - private View view; - private Drawable drawable; - +public class NonScalingBackgroundDrawable extends Drawable +{ + private final View view; + private final Drawable drawable; + /** * Create a new non scaling background drawable * @@ -44,13 +45,14 @@ public class NonScalingBackgroundDrawable extends Drawable { */ public NonScalingBackgroundDrawable(Context context, View view, int resource) { - this.view = view; - this.drawable = context.getResources().getDrawable(resource); + this.view = view; + this.drawable = context.getResources().getDrawable(resource); } /** * Draw the background drawable */ + @Override public void draw(Canvas canvas) { int left = (view.getWidth() / 2) - (drawable.getIntrinsicWidth() / 2); @@ -59,21 +61,23 @@ public class NonScalingBackgroundDrawable extends Drawable { int bottom = top + drawable.getIntrinsicHeight(); drawable.setBounds(left, top, right, bottom); - + drawable.draw(canvas); } /** * Get the opacity */ + @Override public int getOpacity() { - return drawable.getOpacity(); + return drawable.getOpacity(); } /** * Set the alpha */ + @Override public void setAlpha(int alpha) { drawable.setAlpha(alpha); @@ -82,6 +86,7 @@ public class NonScalingBackgroundDrawable extends Drawable { /** * Set the color filter */ + @Override public void setColorFilter(ColorFilter cf) { drawable.setColorFilter(cf); diff --git a/application/src/org/yaaic/listener/ConversationClickListener.java b/application/src/org/yaaic/listener/ConversationClickListener.java index d7ee447f..57fab9c 100644 --- a/application/src/org/yaaic/listener/ConversationClickListener.java +++ b/application/src/org/yaaic/listener/ConversationClickListener.java @@ -17,20 +17,20 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.ViewSwitcher; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.TableLayout.LayoutParams; - import org.yaaic.adapter.DeckAdapter; import org.yaaic.model.Conversation; import org.yaaic.view.MessageListView; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; +import android.widget.TableLayout.LayoutParams; +import android.widget.ViewSwitcher; + /** * Listener for clicks on conversations * @@ -38,9 +38,9 @@ import org.yaaic.view.MessageListView; */ public class ConversationClickListener implements OnItemClickListener { - private DeckAdapter adapter; - private ViewSwitcher switcher; - + private final DeckAdapter adapter; + private final ViewSwitcher switcher; + /** * Create a new ConversationClickListener * @@ -52,19 +52,20 @@ public class ConversationClickListener implements OnItemClickListener this.adapter = adapter; this.switcher = switcher; } - + /** * On conversation item clicked */ + @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { Conversation conversation = adapter.getItem(position); - + MessageListView canvas = adapter.renderConversation(conversation, switcher); canvas.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); canvas.setDelegateTouchEvents(false); // Do not delegate - + adapter.setSwitched(conversation.getName(), canvas); switcher.addView(canvas); switcher.showNext(); diff --git a/application/src/org/yaaic/listener/ConversationListener.java b/application/src/org/yaaic/listener/ConversationListener.java index 199823f..a925c26 100644 --- a/application/src/org/yaaic/listener/ConversationListener.java +++ b/application/src/org/yaaic/listener/ConversationListener.java @@ -17,9 +17,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; +/** + * Listener for conversations + * + * @author Sebastian Kaspari + */ public interface ConversationListener { public void onConversationMessage(String target); diff --git a/application/src/org/yaaic/listener/ConversationSelectedListener.java b/application/src/org/yaaic/listener/ConversationSelectedListener.java index 60bb517..e3fb143 100644 --- a/application/src/org/yaaic/listener/ConversationSelectedListener.java +++ b/application/src/org/yaaic/listener/ConversationSelectedListener.java @@ -17,18 +17,18 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; -import android.view.View; -import android.widget.AdapterView; -import android.widget.TextView; -import android.widget.AdapterView.OnItemSelectedListener; - import org.yaaic.model.Conversation; import org.yaaic.model.Server; import org.yaaic.view.ConversationSwitcher; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.TextView; + /** * Listener for conversation selections * @@ -36,10 +36,10 @@ import org.yaaic.view.ConversationSwitcher; */ public class ConversationSelectedListener implements OnItemSelectedListener { - private Server server; - private TextView titleView; - private ConversationSwitcher switcher; - + private final Server server; + private final TextView titleView; + private final ConversationSwitcher switcher; + /** * Create a new ConversationSelectedListener * @@ -52,38 +52,40 @@ public class ConversationSelectedListener implements OnItemSelectedListener this.titleView = titleView; this.switcher = switcher; } - + /** * On conversation selected/focused */ + @Override public void onItemSelected(AdapterView deck, View view, int position, long id) { Conversation conversation = (Conversation) deck.getItemAtPosition(position); - + if (conversation != null && conversation.getType() != Conversation.TYPE_SERVER) { titleView.setText(server.getTitle() + " - " + conversation.getName()); } else { onNothingSelected(deck); } - + // Remember selection if (conversation != null) { Conversation previousConversation = server.getConversation(server.getSelectedConversation()); - + if (previousConversation != null) { previousConversation.setStatus(Conversation.STATUS_DEFAULT); } - + conversation.setStatus(Conversation.STATUS_SELECTED); server.setSelectedConversation(conversation.getName()); } switcher.invalidate(); } - + /** * On no conversation selected/focused */ + @Override public void onNothingSelected(AdapterView deck) { titleView.setText(server.getTitle()); diff --git a/application/src/org/yaaic/listener/MessageClickListener.java b/application/src/org/yaaic/listener/MessageClickListener.java index c4d1955..d5f8eb8 100644 --- a/application/src/org/yaaic/listener/MessageClickListener.java +++ b/application/src/org/yaaic/listener/MessageClickListener.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; import org.yaaic.activity.MessageActivity; @@ -37,16 +37,16 @@ import android.widget.AdapterView.OnItemClickListener; public class MessageClickListener implements OnItemClickListener { private static MessageClickListener instance; - + /** * Private constructor */ private MessageClickListener() { } - + /** - * Get global instance of message click listener + * Get global instance of message click listener * * @return */ @@ -55,17 +55,18 @@ public class MessageClickListener implements OnItemClickListener if (instance == null) { instance = new MessageClickListener(); } - + return instance; } - + /** * On message item clicked */ + @Override public void onItemClick(AdapterView group, View view, int position, long id) { MessageListAdapter adapter = (MessageListAdapter) group.getAdapter(); - + Intent intent = new Intent(group.getContext(), MessageActivity.class); intent.putExtra(Extra.MESSAGE, adapter.getItem(position).getText().toString()); group.getContext().startActivity(intent); diff --git a/application/src/org/yaaic/listener/ServerListener.java b/application/src/org/yaaic/listener/ServerListener.java index 6822e5b..68f02b4 100644 --- a/application/src/org/yaaic/listener/ServerListener.java +++ b/application/src/org/yaaic/listener/ServerListener.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; public interface ServerListener diff --git a/application/src/org/yaaic/listener/SpeechClickListener.java b/application/src/org/yaaic/listener/SpeechClickListener.java index 36a7401..48fd26b 100644 --- a/application/src/org/yaaic/listener/SpeechClickListener.java +++ b/application/src/org/yaaic/listener/SpeechClickListener.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.listener; import org.yaaic.activity.ConversationActivity; @@ -35,8 +35,8 @@ import android.view.View.OnClickListener; */ public class SpeechClickListener implements OnClickListener { - private Activity activity; - + private final Activity activity; + /** * Create a new listener for speech button * @@ -47,17 +47,18 @@ public class SpeechClickListener implements OnClickListener { this.activity = activity; } - + /** * On Click on speech button */ + @Override public void onClick(View v) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); - + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, ""); - + activity.startActivityForResult(intent, ConversationActivity.REQUEST_CODE_SPEECH); } } diff --git a/application/src/org/yaaic/model/Broadcast.java b/application/src/org/yaaic/model/Broadcast.java index 5373e0c..6ef2bd1 100644 --- a/application/src/org/yaaic/model/Broadcast.java +++ b/application/src/org/yaaic/model/Broadcast.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import android.content.Intent; @@ -30,11 +30,11 @@ import android.content.Intent; public abstract class Broadcast { public static final String SERVER_UPDATE = "org.yaaic.server.status"; - + public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message"; public static final String CONVERSATION_NEW = "org.yaaic.conversation.new"; public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove"; - + /** * Create an Intent for conversation broadcasting * @@ -46,13 +46,13 @@ public abstract class Broadcast public static Intent createConversationIntent(String broadcastType, int serverId, String conversationName) { Intent intent = new Intent(broadcastType); - + intent.putExtra(Extra.SERVER, serverId); intent.putExtra(Extra.CONVERSATION, conversationName); - + return intent; } - + /** * Create an Intent for server broadcasting * @@ -63,9 +63,9 @@ public abstract class Broadcast public static Intent createServerIntent(String broadcastType, int serverId) { Intent intent = new Intent(broadcastType); - + intent.putExtra(Extra.SERVER, serverId); - + return intent; } } diff --git a/application/src/org/yaaic/model/Channel.java b/application/src/org/yaaic/model/Channel.java index d580d28..a73d2d3 100644 --- a/application/src/org/yaaic/model/Channel.java +++ b/application/src/org/yaaic/model/Channel.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; /** @@ -39,7 +39,7 @@ public class Channel extends Conversation super(name); this.topic = ""; } - + /** * Get the type of this conversation */ @@ -48,7 +48,7 @@ public class Channel extends Conversation { return Conversation.TYPE_CHANNEL; } - + /** * Set the channel's topic * @@ -58,7 +58,7 @@ public class Channel extends Conversation { this.topic = topic; } - + /** * Get the topic of the channel * diff --git a/application/src/org/yaaic/model/Conversation.java b/application/src/org/yaaic/model/Conversation.java index aa2c81a..7241b05 100644 --- a/application/src/org/yaaic/model/Conversation.java +++ b/application/src/org/yaaic/model/Conversation.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import java.util.LinkedList; @@ -36,27 +36,27 @@ public abstract class Conversation public static final int TYPE_CHANNEL = 1; public static final int TYPE_QUERY = 2; public static final int TYPE_SERVER = 3; - + public static final int STATUS_DEFAULT = 1; public static final int STATUS_SELECTED = 2; public static final int STATUS_MESSAGE = 3; public static final int STATUS_HIGHLIGHT = 4; - + public static final int HISTORY_SIZE = 30; - - private LinkedList buffer; - private LinkedList history; - private String name; + + private final LinkedList buffer; + private final LinkedList history; + private final String name; private MessageListAdapter adapter; private int status = 1; - + /** * Get the type of conversation (channel, query, ..) * * @return See the constants: Conversation.TYPE_* */ public abstract int getType(); - + /** * Create a new conversation with the given name * @@ -68,7 +68,7 @@ public abstract class Conversation this.history = new LinkedList(); this.name = name.toLowerCase(); } - + /** * Get name of the conversation (channel, user) */ @@ -76,7 +76,7 @@ public abstract class Conversation { return name; } - + /** * Add a message to the channel */ @@ -84,12 +84,12 @@ public abstract class Conversation { buffer.add(0, message); history.add(message); - + if (history.size() > HISTORY_SIZE) { history.remove(0); } } - + /** * Get the history */ @@ -97,7 +97,7 @@ public abstract class Conversation { return history; } - + /** * Get message of the history at the given position * @@ -108,7 +108,7 @@ public abstract class Conversation { return history.get(position); } - + /** * Get last buffered message * @@ -120,7 +120,7 @@ public abstract class Conversation buffer.remove(buffer.size() - 1); return message; } - + /** * Get the buffer * @@ -130,7 +130,7 @@ public abstract class Conversation { return buffer; } - + /** * Does the channel have buffered messages? */ @@ -138,7 +138,7 @@ public abstract class Conversation { return buffer.size() > 0; } - + /** * Clear the message buffer */ @@ -146,7 +146,7 @@ public abstract class Conversation { buffer.clear(); } - + /** * Store the adapter of this conversation */ @@ -154,7 +154,7 @@ public abstract class Conversation { this.adapter = adapter; } - + /** * Get the MessageList Adapter of this conversation if known */ @@ -162,7 +162,7 @@ public abstract class Conversation { return adapter; } - + /** * Set status of conversation * @@ -174,15 +174,15 @@ public abstract class Conversation if (this.status == STATUS_SELECTED && status != STATUS_DEFAULT) { return; } - + // Highlight status can only be changed by selecting if (this.status == STATUS_HIGHLIGHT && status != STATUS_SELECTED) { return; } - + this.status = status; } - + /** * Get status of conversation * diff --git a/application/src/org/yaaic/model/Extra.java b/application/src/org/yaaic/model/Extra.java index 1e17eb6..f956006 100644 --- a/application/src/org/yaaic/model/Extra.java +++ b/application/src/org/yaaic/model/Extra.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; /** @@ -27,12 +27,12 @@ package org.yaaic.model; */ public class Extra { - public static final String SERVER = "server"; + public static final String SERVER = "server"; public static final String CONVERSATION = "conversation"; public static final String USERS = "users"; - + public static final String ALIASES = "aliases"; - public static final String CHANNELS = "channels"; + public static final String CHANNELS = "channels"; public static final String COMMANDS = "commands"; public static final String MESSAGE = "message"; public static final String USER = "user"; diff --git a/application/src/org/yaaic/model/Identity.java b/application/src/org/yaaic/model/Identity.java index e8c144b..9c373e3 100644 --- a/application/src/org/yaaic/model/Identity.java +++ b/application/src/org/yaaic/model/Identity.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import java.util.ArrayList; @@ -33,10 +33,10 @@ import java.util.List; public class Identity { private String nickname; - private List aliases = new ArrayList(); + private final List aliases = new ArrayList(); private String ident; private String realname; - + /** * Set the nickname of this identity * @@ -46,7 +46,7 @@ public class Identity { this.nickname = nickname; } - + /** * Get the nickname of this identity * @@ -56,16 +56,16 @@ public class Identity { return nickname; } - + public void setAliases(Collection aliases) { this.aliases.clear(); this.aliases.addAll(aliases); } - + public List getAliases() { return Collections.unmodifiableList(aliases); } - + /** * Set the ident of this identity * @@ -75,7 +75,7 @@ public class Identity { this.ident = ident; } - + /** * Get the ident of this identity * @@ -85,7 +85,7 @@ public class Identity { return ident; } - + /** * Set the real name of this identity * @@ -95,7 +95,7 @@ public class Identity { this.realname = realname; } - + /** * Get the real name of this identity * diff --git a/application/src/org/yaaic/model/Message.java b/application/src/org/yaaic/model/Message.java index 37b3cc1..804e3e2 100644 --- a/application/src/org/yaaic/model/Message.java +++ b/application/src/org/yaaic/model/Message.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import java.util.Date; @@ -37,39 +37,39 @@ import android.widget.TextView; * @author Sebastian Kaspari */ public class Message { - public static final int COLOR_GREEN = 0xFF458509; - public static final int COLOR_RED = 0xFFcc0000; - public static final int COLOR_BLUE = 0xFF729fcf; - public static final int COLOR_YELLOW = 0xFFbe9b01; - public static final int COLOR_GREY = 0xFFaaaaaa; - public static final int COLOR_DEFAULT = 0xFFeeeeee; - + public static final int COLOR_GREEN = 0xFF458509; + public static final int COLOR_RED = 0xFFcc0000; + public static final int COLOR_BLUE = 0xFF729fcf; + public static final int COLOR_YELLOW = 0xFFbe9b01; + public static final int COLOR_GREY = 0xFFaaaaaa; + public static final int COLOR_DEFAULT = 0xFFeeeeee; + public static final int[] colors = { - 0xFFffffff, //White - 0xFFffff00, //Yellow - 0xFFff00ff, //Fuchsia - 0xFFff0000, //Red - 0xFFc0c0c0, //Silver - 0xFF808080, //Gray - 0xFF808000, //Olive - 0xFF800080, //Purple - 0xFF800000, //Maroon - 0xFF00ffff, //Agua - 0xFF00ff00, //Lime - 0xFF008080, //Teal - 0xFF008000, //Green - 0xFF0000FF, //Blue - 0xFF000080, //Navy - 0xFF000000, //Black + 0xFFffffff, // White + 0xFFffff00, // Yellow + 0xFFff00ff, // Fuchsia + 0xFFff0000, // Red + 0xFFc0c0c0, // Silver + 0xFF808080, // Gray + 0xFF808000, // Olive + 0xFF800080, // Purple + 0xFF800000, // Maroon + 0xFF00ffff, // Agua + 0xFF00ff00, // Lime + 0xFF008080, // Teal + 0xFF008000, // Green + 0xFF0000FF, // Blue + 0xFF000080, // Navy + 0xFF000000, // Black }; private int icon = -1; - private String text; - private String sender; + private final String text; + private final String sender; private SpannableString canvas; private int color = -1; - private long timestamp; - + private final long timestamp; + /** * Create a new message without an icon * @@ -91,7 +91,7 @@ public class Message { this.sender = sender; this.timestamp = new Date().getTime(); } - + /** * Set the message's icon */ @@ -99,7 +99,7 @@ public class Message { { this.icon = icon; } - + /** * Get the message's icon * @@ -109,7 +109,7 @@ public class Message { { return icon; } - + /** * Get the text of this message * @@ -119,7 +119,7 @@ public class Message { { return text; } - + /** * Set the color of this message */ @@ -135,7 +135,9 @@ public class Message { private int getSenderColor() { /* It might be worth to use some hash table here */ - if (sender == null) return COLOR_DEFAULT; + if (sender == null) { + return COLOR_DEFAULT; + } int color = 0; for(int i = 0; i < sender.length(); i++){ color += sender.charAt(i); @@ -152,14 +154,14 @@ public class Message { public SpannableString render(Context context) { Settings settings = new Settings(context); - + if (canvas == null) { String prefix = icon != -1 && settings.showIcons() ? " " : ""; String nick = sender != null ? "<" + sender + "> " : ""; String timestamp = settings.showTimestamp() ? Message.generateTimestamp(this.timestamp, settings.use24hFormat()) : ""; - + canvas = new SpannableString(prefix + timestamp + nick + text); - + if (sender != null) { int start = (prefix + timestamp).length() + 1; int end = start + sender.length(); @@ -177,10 +179,10 @@ public class Message { canvas.setSpan(new ForegroundColorSpan(color), 0, canvas.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } - + return canvas; } - + /** * Render message as text view * @@ -191,17 +193,17 @@ public class Message { { // XXX: We should not read settings here ALWAYS for EVERY textview Settings settings = new Settings(context); - + TextView canvas = new TextView(context); - + canvas.setText(this.render(context)); canvas.setTextSize(settings.getFontSize()); canvas.setTypeface(Typeface.MONOSPACE); canvas.setTextColor(COLOR_DEFAULT); - + return canvas; } - + /** * Generate a timestamp * @@ -211,7 +213,7 @@ public class Message { public static String generateTimestamp(long timestamp, boolean use24hFormat) { Date date = new Date(timestamp); - + int hours = date.getHours(); int minutes = date.getMinutes(); @@ -221,7 +223,7 @@ public class Message { hours = 0; } } - + return "[" + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + "] "; } } diff --git a/application/src/org/yaaic/model/Query.java b/application/src/org/yaaic/model/Query.java index 167a25a..092b5e5 100644 --- a/application/src/org/yaaic/model/Query.java +++ b/application/src/org/yaaic/model/Query.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; /** @@ -36,10 +36,11 @@ public class Query extends Conversation { super(name); } - + /** * Get the type of this conversation */ + @Override public int getType() { return Conversation.TYPE_QUERY; diff --git a/application/src/org/yaaic/model/Scrollback.java b/application/src/org/yaaic/model/Scrollback.java index a4d5c8c..a426aa6 100644 --- a/application/src/org/yaaic/model/Scrollback.java +++ b/application/src/org/yaaic/model/Scrollback.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import java.util.LinkedList; @@ -30,10 +30,10 @@ import java.util.LinkedList; public class Scrollback { public static final int MAX_HISTORY = 10; - - private LinkedList messages; + + private final LinkedList messages; private int pointer; - + /** * Create a new scrollback object */ @@ -41,21 +41,21 @@ public class Scrollback { messages = new LinkedList(); } - + /** * Add a message to the history */ public void addMessage(String message) { messages.addLast(message); - + if (messages.size() > MAX_HISTORY) { messages.removeFirst(); } - + pointer = messages.size(); } - + /** * Go back in history * @@ -66,14 +66,14 @@ public class Scrollback if (pointer > 0) { pointer--; } - + if (messages.size() > 0) { return messages.get(pointer); } - + return null; } - + /** * Go forward in history * @@ -86,11 +86,11 @@ public class Scrollback } else { return ""; } - + if (messages.size() > 0) { return messages.get(pointer); } - + return null; } } diff --git a/application/src/org/yaaic/model/Server.java b/application/src/org/yaaic/model/Server.java index c8ebe67..e6ae6d5 100644 --- a/application/src/org/yaaic/model/Server.java +++ b/application/src/org/yaaic/model/Server.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; import java.util.ArrayList; @@ -41,14 +41,14 @@ public class Server private String charset; private boolean useSSL = false; private Identity identity; - - private LinkedHashMap conversations = new LinkedHashMap(); + + private final LinkedHashMap conversations = new LinkedHashMap(); private ArrayList autoJoinChannels; private ArrayList connectCommands; - + private int status = Status.DISCONNECTED; private String selected = ""; - + /** * Create a new server object */ @@ -57,7 +57,7 @@ public class Server conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo()); this.selected = ServerInfo.DEFAULT_NAME; } - + /** * Set the identity for this server * @@ -67,7 +67,7 @@ public class Server { this.identity = identity; } - + /** * Get the identity for this server * @@ -77,7 +77,7 @@ public class Server { return identity; } - + /** * Get unique id of server * @@ -87,7 +87,7 @@ public class Server { return id; } - + /** * Set unique id of server * @@ -97,7 +97,7 @@ public class Server { this.id = id; } - + /** * Set password of the server * @@ -107,7 +107,7 @@ public class Server { this.password = password; } - + /** * Get the password of the server * @@ -117,7 +117,7 @@ public class Server { return password; } - + /** * Get title of server * @@ -127,7 +127,7 @@ public class Server { return title; } - + /** * Set title of server * @@ -137,7 +137,7 @@ public class Server { this.title = title; } - + /** * Get hostname of server * @@ -147,7 +147,7 @@ public class Server { return host; } - + /** * Set hostname of server * @@ -157,7 +157,7 @@ public class Server { this.host = host; } - + /** * Get port of server * @@ -167,7 +167,7 @@ public class Server { return port; } - + /** * Set port of server * @@ -177,7 +177,7 @@ public class Server { this.port = port; } - + /** * Set the charset to be used for all messages sent to the server * @@ -187,7 +187,7 @@ public class Server { this.charset = charset; } - + /** * Get the charset to be used with this server * @@ -197,7 +197,7 @@ public class Server { return charset; } - + /** * Set if this connections needs to use ssl */ @@ -205,7 +205,7 @@ public class Server { this.useSSL = useSSL; } - + /** * Does this connection use SSL? * @@ -215,7 +215,7 @@ public class Server { return useSSL; } - + /** * Set connection status of server * @@ -225,7 +225,7 @@ public class Server { this.status = status; } - + /** * Get connection status of server * @@ -235,7 +235,7 @@ public class Server { return status; } - + /** * Set list of channels to auto join after connect * @@ -245,7 +245,7 @@ public class Server { this.autoJoinChannels = autoJoinChannels; } - + /** * Get list of channels to auto join after connect * @@ -255,7 +255,7 @@ public class Server { return autoJoinChannels; } - + /** * Set commands to execute after connect * @@ -265,7 +265,7 @@ public class Server { this.connectCommands = connectCommands; } - + /** * Get commands to execute after connect * @@ -275,17 +275,17 @@ public class Server { return connectCommands; } - + /** * Is disconnected? * - * @return true if the user is disconnected, false if the user is connected or currently connecting + * @return true if the user is disconnected, false if the user is connected or currently connecting */ public boolean isDisconnected() { return status == Status.DISCONNECTED; } - + /** * Is connected? * @@ -295,7 +295,7 @@ public class Server { return status == Status.CONNECTED; } - + /** * Get all conversations * @@ -305,7 +305,7 @@ public class Server { return conversations.values(); } - + /** * Get conversation by name */ @@ -313,7 +313,7 @@ public class Server { return conversations.get(name.toLowerCase()); } - + /** * Add a new conversation * @@ -323,7 +323,7 @@ public class Server { conversations.put(conversation.getName().toLowerCase(), conversation); } - + /** * Removes a conversation by name * @@ -333,19 +333,19 @@ public class Server { conversations.remove(name.toLowerCase()); } - + /** * Remove all conversations */ public void clearConversations() { conversations.clear(); - + // reset defaults conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo()); this.selected = ServerInfo.DEFAULT_NAME; } - + /** * Set name of currently selected conversation * @@ -355,9 +355,9 @@ public class Server { this.selected = selected; } - + /** - * Get name of currently selected conversation + * Get name of currently selected conversation * * @return The name of the selected conversation */ @@ -365,7 +365,7 @@ public class Server { return selected; } - + /** * Get names of the currently joined channels * @@ -375,16 +375,16 @@ public class Server { ArrayList channels = new ArrayList(); Collection mConversations = conversations.values(); - + for (Conversation conversation : mConversations) { if (conversation.getType() == Conversation.TYPE_CHANNEL) { channels.add(conversation.getName()); } } - + return channels; } - + /** * Get icon for current server status * @@ -401,7 +401,7 @@ public class Server case Status.CONNECTING: return R.drawable.connecting; } - + return R.drawable.connecting; } } diff --git a/application/src/org/yaaic/model/ServerInfo.java b/application/src/org/yaaic/model/ServerInfo.java index ebb26c0..99424b4 100644 --- a/application/src/org/yaaic/model/ServerInfo.java +++ b/application/src/org/yaaic/model/ServerInfo.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; /** @@ -28,7 +28,7 @@ package org.yaaic.model; public class ServerInfo extends Conversation { public static final String DEFAULT_NAME = ""; - + /** * Create a new ServerInfo object * diff --git a/application/src/org/yaaic/model/Status.java b/application/src/org/yaaic/model/Status.java index ff797b3..a351acd 100644 --- a/application/src/org/yaaic/model/Status.java +++ b/application/src/org/yaaic/model/Status.java @@ -17,15 +17,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.model; /** - * Helper class for server status constants + * Helper class for server status constants * * @author Sebastian Kaspari */ -public class Status { +public class Status +{ public static final int DISCONNECTED = 0; public static final int CONNECTING = 1; public static final int CONNECTED = 2; diff --git a/application/src/org/yaaic/receiver/ConversationReceiver.java b/application/src/org/yaaic/receiver/ConversationReceiver.java index 9bf9925..5bacba4 100644 --- a/application/src/org/yaaic/receiver/ConversationReceiver.java +++ b/application/src/org/yaaic/receiver/ConversationReceiver.java @@ -17,17 +17,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.receiver; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - import org.yaaic.listener.ConversationListener; import org.yaaic.model.Broadcast; import org.yaaic.model.Extra; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + /** * A channel receiver for receiving channel updates * @@ -35,14 +35,14 @@ import org.yaaic.model.Extra; */ public class ConversationReceiver extends BroadcastReceiver { - private ConversationListener listener; - private int serverId; - + private final ConversationListener listener; + private final int serverId; + /** * Create a new channel receiver - * + * * @param serverId Only listen on channels of this server - * @param listener + * @param listener */ public ConversationReceiver(int serverId, ConversationListener listener) { @@ -63,7 +63,7 @@ public class ConversationReceiver extends BroadcastReceiver if (serverId != this.serverId) { return; } - + String action = intent.getAction(); if (action.equals(Broadcast.CONVERSATION_MESSAGE)) { @@ -73,6 +73,6 @@ public class ConversationReceiver extends BroadcastReceiver } else if (action.equals(Broadcast.CONVERSATION_REMOVE)) { listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION)); } - + } } diff --git a/application/src/org/yaaic/receiver/ServerReceiver.java b/application/src/org/yaaic/receiver/ServerReceiver.java index 4fc1124..8ad5829 100644 --- a/application/src/org/yaaic/receiver/ServerReceiver.java +++ b/application/src/org/yaaic/receiver/ServerReceiver.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.receiver; import org.yaaic.listener.ServerListener; @@ -33,8 +33,8 @@ import android.content.Intent; */ public class ServerReceiver extends BroadcastReceiver { - private ServerListener listener; - + private final ServerListener listener; + /** * Create a new server receiver * @@ -51,6 +51,6 @@ public class ServerReceiver extends BroadcastReceiver @Override public void onReceive(Context context, Intent intent) { - listener.onStatusUpdate(); + listener.onStatusUpdate(); } } diff --git a/application/src/org/yaaic/ssl/NaiveTrustManager.java b/application/src/org/yaaic/ssl/NaiveTrustManager.java index 9d80dbc..6818538 100644 --- a/application/src/org/yaaic/ssl/NaiveTrustManager.java +++ b/application/src/org/yaaic/ssl/NaiveTrustManager.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.ssl; import java.security.cert.CertificateException; @@ -37,6 +37,7 @@ public class NaiveTrustManager implements X509TrustManager * * @throws CertificateException if not trusted */ + @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { // No Exception == Trust @@ -47,6 +48,7 @@ public class NaiveTrustManager implements X509TrustManager * * @throws CertificateException if not trusted */ + @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { // No Exception == Trust @@ -55,6 +57,7 @@ public class NaiveTrustManager implements X509TrustManager /** * Get accepted issuers */ + @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; diff --git a/application/src/org/yaaic/view/ConversationSwitcher.java b/application/src/org/yaaic/view/ConversationSwitcher.java index 514b26c..ab2b1e3 100644 --- a/application/src/org/yaaic/view/ConversationSwitcher.java +++ b/application/src/org/yaaic/view/ConversationSwitcher.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.view; import java.util.Collection; @@ -39,8 +39,8 @@ import android.view.View; public class ConversationSwitcher extends View { private Server server; - private Paint paint; - + private final Paint paint; + /** * Create a new ConversationSwitcher * @@ -49,11 +49,11 @@ public class ConversationSwitcher extends View public ConversationSwitcher(Context context, AttributeSet attributes) { super(context, attributes); - + paint = new Paint(); paint.setStyle(Paint.Style.STROKE); } - + /** * Set the server whos conversations should be displayed * @@ -63,37 +63,39 @@ public class ConversationSwitcher extends View { this.server = server; } - + /** * Measure the size of the view * * @param widthMeasureSpec * @param heightMeasureSpec */ + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 16); } - + /** * On draw */ + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - + if (server == null) { return; } Collection conversations = server.getConversations(); - + int i = 0; int width = getWidth(); int height = getHeight(); int circles = conversations.size(); int startX = (width / 2) - (((circles + 1) / 2) * 12); - + for (Conversation conversation : conversations) { switch (conversation.getStatus()) { case Conversation.STATUS_DEFAULT: @@ -109,10 +111,10 @@ public class ConversationSwitcher extends View paint.setColor(0xFFFFFFFF); break; } - + canvas.drawCircle(startX + 12 * i, height / 2, 4, paint); i++; } - + } } diff --git a/application/src/org/yaaic/view/MessageListView.java b/application/src/org/yaaic/view/MessageListView.java index d91160e..85f0dc7 100644 --- a/application/src/org/yaaic/view/MessageListView.java +++ b/application/src/org/yaaic/view/MessageListView.java @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Yaaic. If not, see . -*/ + */ package org.yaaic.view; import org.yaaic.adapter.MessageListAdapter; @@ -31,17 +31,17 @@ import android.widget.Gallery; import android.widget.ListView; /** - * A customized ListView for Messages + * A customized ListView for Messages * * @author Sebastian Kaspari */ public class MessageListView extends ListView { private boolean delegate = true; - private View parent; + private final View parent; private int parentWidth; private int parentHeight; - + /** * Create a new MessageListView * @@ -50,14 +50,14 @@ public class MessageListView extends ListView public MessageListView(Context context, View parent) { super(context); - + this.parent = parent; this.setOnItemClickListener(MessageClickListener.getInstance()); - + parentWidth = parent.getWidth(); parentHeight = parent.getHeight(); } - + /** * Should all touch events delegated? * @@ -67,7 +67,7 @@ public class MessageListView extends ListView { this.delegate = delegate; } - + /** * Handle touch screen motion events */ @@ -75,7 +75,7 @@ public class MessageListView extends ListView public boolean onTouchEvent(MotionEvent event) { if (delegate) { - // We delegate the touch events to the underlying view + // We delegate the touch events to the underlying view return false; } else { return super.onTouchEvent(event); @@ -90,25 +90,26 @@ public class MessageListView extends ListView { if (delegate && (parent.getWidth() != parentWidth || parent.getHeight() != parentHeight)) { // parent size changed, resizing this child too - + parentWidth = parent.getWidth(); parentHeight = parent.getHeight(); - + this.setLayoutParams(new Gallery.LayoutParams( parent.getWidth() / 100 * 85, parent.getHeight() )); } - + super.onDraw(canvas); } - + /** * Get the adapter of this MessageListView * (Helper to avoid casting) * * @return The MessageListAdapter */ + @Override public MessageListAdapter getAdapter() { return (MessageListAdapter) super.getAdapter();