mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-06 17:25:01 -05:00
Merge pull request #402 from emdete/remove_poormans_tostring
optimize string operations a bit
This commit is contained in:
commit
0ffdb03aa3
@ -106,8 +106,8 @@ public class PgpEngine {
|
||||
outputFile.getAbsolutePath(), options);
|
||||
int imageHeight = options.outHeight;
|
||||
int imageWidth = options.outWidth;
|
||||
message.setBody("" + outputFile.getSize() + ","
|
||||
+ imageWidth + "," + imageHeight);
|
||||
message.setBody(Long.toString(outputFile.getSize()) + ','
|
||||
+ imageWidth + ',' + imageHeight);
|
||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||
PgpEngine.this.mXmppConnectionService
|
||||
.updateMessage(message);
|
||||
|
@ -150,13 +150,13 @@ public class Message extends AbstractEntity {
|
||||
|
||||
public String getReadableBody(Context context) {
|
||||
if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) {
|
||||
return "" + context.getText(R.string.encrypted_message_received);
|
||||
return context.getText(R.string.encrypted_message_received).toString();
|
||||
} else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) {
|
||||
return "" + context.getText(R.string.encrypted_image_received);
|
||||
return context.getText(R.string.encrypted_image_received).toString();
|
||||
} else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
|
||||
return "" + context.getText(R.string.decryption_failed);
|
||||
return context.getText(R.string.decryption_failed).toString();
|
||||
} else if (type == TYPE_IMAGE) {
|
||||
return "" + context.getText(R.string.image_file);
|
||||
return context.getText(R.string.image_file).toString();
|
||||
} else {
|
||||
return body.trim();
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
|
||||
CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<Conversation>();
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
String[] selectionArgs = { "" + status };
|
||||
String[] selectionArgs = { Integer.toString(status) };
|
||||
Cursor cursor = db.rawQuery("select * from " + Conversation.TABLENAME
|
||||
+ " where " + Conversation.STATUS + " = ? order by "
|
||||
+ Conversation.CREATED + " desc", selectionArgs);
|
||||
@ -163,7 +163,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||
+ "=?", selectionArgs, null, null, Message.TIME_SENT
|
||||
+ " DESC", String.valueOf(limit));
|
||||
} else {
|
||||
String[] selectionArgs = { conversation.getUuid(), "" + timestamp };
|
||||
String[] selectionArgs = { conversation.getUuid(), Long.toString(timestamp) };
|
||||
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
|
||||
+ "=? and " + Message.TIME_SENT + "<?", selectionArgs,
|
||||
null, null, Message.TIME_SENT + " DESC",
|
||||
|
@ -180,7 +180,7 @@ public class FileBackend {
|
||||
long size = file.getSize();
|
||||
int width = scalledBitmap.getWidth();
|
||||
int height = scalledBitmap.getHeight();
|
||||
message.setBody("" + size + "," + width + "," + height);
|
||||
message.setBody(Long.toString(size) + ',' + width + ',' + height);
|
||||
return file;
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ImageCopyException(R.string.error_file_not_found);
|
||||
|
@ -146,10 +146,10 @@ public class Element {
|
||||
}
|
||||
|
||||
public void setAttribute(String name, long value) {
|
||||
this.setAttribute(name, "" + value);
|
||||
this.setAttribute(name, Long.toString(value));
|
||||
}
|
||||
|
||||
public void setAttribute(String name, int value) {
|
||||
this.setAttribute(name, "" + value);
|
||||
this.setAttribute(name, Integer.toString(value));
|
||||
}
|
||||
}
|
||||
|
@ -117,9 +117,9 @@ public class JingleCandidate {
|
||||
Element element = new Element("candidate");
|
||||
element.setAttribute("cid", this.getCid());
|
||||
element.setAttribute("host", this.getHost());
|
||||
element.setAttribute("port", "" + this.getPort());
|
||||
element.setAttribute("port", Integer.toString(this.getPort()));
|
||||
element.setAttribute("jid", this.getJid());
|
||||
element.setAttribute("priority", "" + this.getPriority());
|
||||
element.setAttribute("priority", Integer.toString(this.getPriority()));
|
||||
if (this.getType() == TYPE_DIRECT) {
|
||||
element.setAttribute("type", "direct");
|
||||
} else if (this.getType() == TYPE_PROXY) {
|
||||
|
@ -95,7 +95,7 @@ public class JingleConnection {
|
||||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||
int imageHeight = options.outHeight;
|
||||
int imageWidth = options.outWidth;
|
||||
message.setBody("" + file.getSize() + "," + imageWidth + ","
|
||||
message.setBody(Long.toString(file.getSize()) + ',' + imageWidth + ','
|
||||
+ imageHeight);
|
||||
mXmppConnectionService.databaseBackend.createMessage(message);
|
||||
mXmppConnectionService.markMessage(message,
|
||||
@ -302,7 +302,7 @@ public class JingleConnection {
|
||||
}
|
||||
if (supportedFile) {
|
||||
long size = Long.parseLong(fileSize.getContent());
|
||||
message.setBody("" + size);
|
||||
message.setBody(Long.toString(size));
|
||||
conversation.getMessages().add(message);
|
||||
if (size <= this.mJingleConnectionManager
|
||||
.getAutoAcceptFileSize()) {
|
||||
@ -630,7 +630,7 @@ public class JingleConnection {
|
||||
this.transportId = this.mJingleConnectionManager.nextRandomId();
|
||||
content.setTransportId(this.transportId);
|
||||
content.ibbTransport().setAttribute("block-size",
|
||||
"" + this.ibbBlockSize);
|
||||
Integer.toString(this.ibbBlockSize));
|
||||
packet.setContent(content);
|
||||
this.sendJinglePacket(packet);
|
||||
}
|
||||
@ -652,7 +652,7 @@ public class JingleConnection {
|
||||
Content content = new Content("initiator", "a-file-offer");
|
||||
content.setTransportId(this.transportId);
|
||||
content.ibbTransport().setAttribute("block-size",
|
||||
"" + this.ibbBlockSize);
|
||||
Integer.toString(this.ibbBlockSize));
|
||||
answer.setContent(content);
|
||||
this.sendJinglePacket(answer);
|
||||
return true;
|
||||
|
@ -59,7 +59,7 @@ public class JingleInbandTransport extends JingleTransport {
|
||||
Element open = iq.addChild("open", "http://jabber.org/protocol/ibb");
|
||||
open.setAttribute("sid", this.sessionId);
|
||||
open.setAttribute("stanza", "iq");
|
||||
open.setAttribute("block-size", "" + this.blockSize);
|
||||
open.setAttribute("block-size", Integer.toString(this.blockSize));
|
||||
|
||||
this.account.getXmppConnection().sendIqPacket(iq,
|
||||
new OnIqPacketReceived() {
|
||||
@ -134,8 +134,8 @@ public class JingleInbandTransport extends JingleTransport {
|
||||
iq.setTo(this.counterpart);
|
||||
Element data = iq.addChild("data",
|
||||
"http://jabber.org/protocol/ibb");
|
||||
data.setAttribute("seq", "" + this.seq);
|
||||
data.setAttribute("block-size", "" + this.blockSize);
|
||||
data.setAttribute("seq", Integer.toString(this.seq));
|
||||
data.setAttribute("block-size", Integer.toString(this.blockSize));
|
||||
data.setAttribute("sid", this.sessionId);
|
||||
data.setContent(base64);
|
||||
this.account.getXmppConnection().sendIqPacket(iq,
|
||||
|
@ -58,10 +58,10 @@ public class JingleSocks5Transport extends JingleTransport {
|
||||
byte[] reply = new byte[2];
|
||||
outputStream.write(login);
|
||||
inputStream.read(reply);
|
||||
final String connect = Character.toString('\u0005') + '\u0001' + '\u0000'
|
||||
+ '\u0003' + '\u0028' + destination + '\u0000'
|
||||
+ '\u0000';
|
||||
if (Arrays.equals(reply, expectedReply)) {
|
||||
String connect = "" + '\u0005' + '\u0001' + '\u0000'
|
||||
+ '\u0003' + '\u0028' + destination + '\u0000'
|
||||
+ '\u0000';
|
||||
outputStream.write(connect.getBytes());
|
||||
byte[] result = new byte[2];
|
||||
inputStream.read(result);
|
||||
|
@ -30,7 +30,7 @@ public class Content extends Element {
|
||||
"urn:xmpp:jingle:apps:file-transfer:3");
|
||||
Element offer = description.addChild("offer");
|
||||
Element file = offer.addChild("file");
|
||||
file.addChild("size").setContent("" + actualFile.getSize());
|
||||
file.addChild("size").setContent(Long.toString(actualFile.getSize()));
|
||||
if (otr) {
|
||||
file.addChild("name").setContent(actualFile.getName() + ".otr");
|
||||
} else {
|
||||
|
@ -7,7 +7,7 @@ public class AckPacket extends AbstractStanza {
|
||||
public AckPacket(int sequence, int smVersion) {
|
||||
super("a");
|
||||
this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
|
||||
this.setAttribute("h", "" + sequence);
|
||||
this.setAttribute("h", Integer.toString(sequence));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class ResumePacket extends AbstractStanza {
|
||||
super("resume");
|
||||
this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
|
||||
this.setAttribute("previd", id);
|
||||
this.setAttribute("h", "" + sequence);
|
||||
this.setAttribute("h", Integer.toString(sequence));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user