1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 17:02:21 -05:00

Code cleanup (Formatting)

This commit is contained in:
Sebastian Kaspari 2011-01-25 21:02:27 +01:00
parent 4edaa4436d
commit 0fb2338f9c
72 changed files with 833 additions and 775 deletions

View File

@ -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
{
@ -65,6 +65,7 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
/**
* On Click
*/
@Override
public void onClick(View v)
{
switch (v.getId()) {
@ -92,6 +93,7 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
/**
* On item clicked
*/
@Override
public void onItemClick(AdapterView<?> list, View item, int position, long id)
{
final String alias = adapter.getItem(position);
@ -101,6 +103,7 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
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
@ -115,14 +118,17 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
alert.show();
}
@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);
}

View File

@ -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
@ -88,6 +88,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI
/**
* On Click
*/
@Override
public void onClick(View v)
{
switch (v.getId()) {
@ -115,6 +116,7 @@ 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);
@ -124,6 +126,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI
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

View File

@ -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
@ -89,6 +89,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On
/**
* On Click
*/
@Override
public void onClick(View v)
{
switch (v.getId()) {
@ -121,6 +122,7 @@ 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);
@ -130,6 +132,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On
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

View File

@ -54,6 +54,7 @@ public class JoinActivity extends Activity implements OnClickListener
/**
* On click
*/
@Override
public void onClick(View v)
{
Intent intent = new Intent();

View File

@ -22,6 +22,20 @@ package org.yaaic.activity;
import java.util.ArrayList;
import org.yaaic.R;
import org.yaaic.Yaaic;
import org.yaaic.adapter.ServerListAdapter;
import org.yaaic.db.Database;
import org.yaaic.irc.IRCBinder;
import org.yaaic.irc.IRCService;
import org.yaaic.layout.NonScalingBackgroundDrawable;
import org.yaaic.listener.ServerListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
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;
@ -36,23 +50,9 @@ 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;
import android.widget.AdapterView.OnItemLongClickListener;
import org.yaaic.R;
import org.yaaic.Yaaic;
import org.yaaic.adapter.ServerListAdapter;
import org.yaaic.db.Database;
import org.yaaic.irc.IRCBinder;
import org.yaaic.irc.IRCService;
import org.yaaic.layout.NonScalingBackgroundDrawable;
import org.yaaic.listener.ServerListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
import org.yaaic.receiver.ServerReceiver;
/**
* List of servers
@ -121,6 +121,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* 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;
@ -161,6 +163,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* On long click
*/
@Override
public boolean onItemLongClick(AdapterView<?> l, View v, int position, long id)
{
final Server server = adapter.getItem(position);
@ -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
@ -231,6 +235,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* Options Menu (Menu Button pressed)
*/
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
@ -304,6 +309,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* On server status update
*/
@Override
public void onStatusUpdate()
{
adapter.loadServers();

View File

@ -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;
@ -73,6 +73,7 @@ public class UserActivity extends Activity implements OnClickListener
/**
* On button click
*/
@Override
public void onClick(View v)
{
Intent intent = new Intent();

View File

@ -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();

View File

@ -63,6 +63,7 @@ public class DeckAdapter extends BaseAdapter
/**
* 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,6 +84,7 @@ public class DeckAdapter extends BaseAdapter
/**
* Get id of item at position
*/
@Override
public long getItemId(int position)
{
return position;
@ -180,6 +183,7 @@ public class DeckAdapter extends BaseAdapter
/**
* Get view at given position
*/
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Conversation conversation = getItem(position);

View File

@ -38,8 +38,8 @@ import android.widget.TextView;
*/
public class MessageListAdapter extends BaseAdapter
{
private LinkedList<TextView> messages;
private Context context;
private final LinkedList<TextView> messages;
private final Context context;
/**
* Create a new MessageAdapter
@ -117,6 +117,7 @@ public class MessageListAdapter extends BaseAdapter
*
* @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);

View File

@ -65,6 +65,7 @@ public class ServerListAdapter extends BaseAdapter
/**
* Get number of items
*/
@Override
public int getCount()
{
int size = servers.size();
@ -82,6 +83,7 @@ public class ServerListAdapter extends BaseAdapter
*
* @param position
*/
@Override
public Server getItem(int position)
{
if (servers.size() == 0) {
@ -96,6 +98,7 @@ public class ServerListAdapter extends BaseAdapter
*
* @param position
*/
@Override
public long getItemId(int position)
{
if (servers.size() == 0) {
@ -112,6 +115,7 @@ public class ServerListAdapter extends BaseAdapter
* @param convertView
* @param parent
*/
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Server server = getItem(position);

View File

@ -22,8 +22,6 @@ 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,6 +53,8 @@ import org.yaaic.model.Conversation;
import org.yaaic.model.Message;
import org.yaaic.model.Server;
import android.content.Intent;
/**
* Parser for commands
*
@ -62,8 +62,8 @@ import org.yaaic.model.Server;
*/
public class CommandParser
{
private HashMap<String, BaseHandler> commands;
private HashMap<String, String> aliases;
private final HashMap<String, BaseHandler> commands;
private final HashMap<String, String> aliases;
private static CommandParser instance;
/**

View File

@ -31,7 +31,7 @@ import android.os.Binder;
*/
public class IRCBinder extends Binder
{
private IRCService service;
private final IRCService service;
/**
* Create a new binder for given service

View File

@ -31,9 +31,10 @@ import android.view.View;
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
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
@ -51,6 +52,7 @@ public class NonScalingBackgroundDrawable extends Drawable {
/**
* Draw the background drawable
*/
@Override
public void draw(Canvas canvas)
{
int left = (view.getWidth() / 2) - (drawable.getIntrinsicWidth() / 2);
@ -66,6 +68,7 @@ public class NonScalingBackgroundDrawable extends Drawable {
/**
* Get the opacity
*/
@Override
public int getOpacity()
{
return drawable.getOpacity();
@ -74,6 +77,7 @@ public class NonScalingBackgroundDrawable extends Drawable {
/**
* 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);

View File

@ -20,17 +20,17 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
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,8 +38,8 @@ 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
@ -56,6 +56,7 @@ public class ConversationClickListener implements OnItemClickListener
/**
* On conversation item clicked
*/
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
{
Conversation conversation = adapter.getItem(position);

View File

@ -20,6 +20,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.listener;
/**
* Listener for conversations
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public interface ConversationListener
{
public void onConversationMessage(String target);

View File

@ -20,15 +20,15 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
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,9 +36,9 @@ 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
@ -56,6 +56,7 @@ public class ConversationSelectedListener implements OnItemSelectedListener
/**
* On conversation selected/focused
*/
@Override
public void onItemSelected(AdapterView<?> deck, View view, int position, long id)
{
Conversation conversation = (Conversation) deck.getItemAtPosition(position);
@ -84,6 +85,7 @@ public class ConversationSelectedListener implements OnItemSelectedListener
/**
* On no conversation selected/focused
*/
@Override
public void onNothingSelected(AdapterView<?> deck)
{
titleView.setText(server.getTitle());

View File

@ -62,6 +62,7 @@ public class MessageClickListener implements OnItemClickListener
/**
* On message item clicked
*/
@Override
public void onItemClick(AdapterView<?> group, View view, int position, long id)
{
MessageListAdapter adapter = (MessageListAdapter) group.getAdapter();

View File

@ -35,7 +35,7 @@ import android.view.View.OnClickListener;
*/
public class SpeechClickListener implements OnClickListener
{
private Activity activity;
private final Activity activity;
/**
* Create a new listener for speech button
@ -51,6 +51,7 @@ public class SpeechClickListener implements OnClickListener
/**
* On Click on speech button
*/
@Override
public void onClick(View v)
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

View File

@ -44,9 +44,9 @@ public abstract class Conversation
public static final int HISTORY_SIZE = 30;
private LinkedList<Message> buffer;
private LinkedList<Message> history;
private String name;
private final LinkedList<Message> buffer;
private final LinkedList<Message> history;
private final String name;
private MessageListAdapter adapter;
private int status = 1;

View File

@ -33,7 +33,7 @@ import java.util.List;
public class Identity
{
private String nickname;
private List<String> aliases = new ArrayList<String>();
private final List<String> aliases = new ArrayList<String>();
private String ident;
private String realname;

View File

@ -64,11 +64,11 @@ public class Message {
};
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
@ -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);

View File

@ -40,6 +40,7 @@ public class Query extends Conversation
/**
* Get the type of this conversation
*/
@Override
public int getType()
{
return Conversation.TYPE_QUERY;

View File

@ -31,7 +31,7 @@ public class Scrollback
{
public static final int MAX_HISTORY = 10;
private LinkedList<String> messages;
private final LinkedList<String> messages;
private int pointer;
/**

View File

@ -42,7 +42,7 @@ public class Server
private boolean useSSL = false;
private Identity identity;
private LinkedHashMap<String, Conversation> conversations = new LinkedHashMap<String, Conversation>();
private final LinkedHashMap<String, Conversation> conversations = new LinkedHashMap<String, Conversation>();
private ArrayList<String> autoJoinChannels;
private ArrayList<String> connectCommands;

View File

@ -25,7 +25,8 @@ package org.yaaic.model;
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class Status {
public class Status
{
public static final int DISCONNECTED = 0;
public static final int CONNECTING = 1;
public static final int CONNECTED = 2;

View File

@ -20,14 +20,14 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
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,8 +35,8 @@ 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

View File

@ -33,7 +33,7 @@ import android.content.Intent;
*/
public class ServerReceiver extends BroadcastReceiver
{
private ServerListener listener;
private final ServerListener listener;
/**
* Create a new server receiver

View File

@ -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];

View File

@ -39,7 +39,7 @@ import android.view.View;
public class ConversationSwitcher extends View
{
private Server server;
private Paint paint;
private final Paint paint;
/**
* Create a new ConversationSwitcher
@ -70,6 +70,7 @@ public class ConversationSwitcher extends View
* @param widthMeasureSpec
* @param heightMeasureSpec
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 16);
@ -78,6 +79,7 @@ public class ConversationSwitcher extends View
/**
* On draw
*/
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);

View File

@ -38,7 +38,7 @@ import android.widget.ListView;
public class MessageListView extends ListView
{
private boolean delegate = true;
private View parent;
private final View parent;
private int parentWidth;
private int parentHeight;
@ -109,6 +109,7 @@ public class MessageListView extends ListView
*
* @return The MessageListAdapter
*/
@Override
public MessageListAdapter getAdapter()
{
return (MessageListAdapter) super.getAdapter();