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