Skip to content

Commit aca0862

Browse files
author
Devendra
committed
formatting android files
1 parent fad6e15 commit aca0862

3 files changed

Lines changed: 41 additions & 40 deletions

File tree

‎android/src/com/pubnub/api/Pubnub.java‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public class Pubnub extends PubnubCoreShared {
3030
* @param ssl_on
3131
* SSL on ?
3232
*/
33-
public Pubnub(String publish_key, String subscribe_key, String secret_key,
34-
String cipher_key, boolean ssl_on) {
33+
public Pubnub(String publish_key, String subscribe_key, String secret_key, String cipher_key, boolean ssl_on) {
3534
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
3635
}
3736

@@ -47,8 +46,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
4746
* @param ssl_on
4847
* SSL on ?
4948
*/
50-
public Pubnub(String publish_key, String subscribe_key, String secret_key,
51-
boolean ssl_on) {
49+
public Pubnub(String publish_key, String subscribe_key, String secret_key, boolean ssl_on) {
5250
super(publish_key, subscribe_key, secret_key, "", ssl_on);
5351
}
5452

@@ -95,32 +93,31 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key, Strin
9593
}
9694

9795
/**
98-
*
99-
* Constructor for Pubnub Class
100-
*
101-
* @param publish_key
102-
* Publish Key
103-
* @param subscribe_key
104-
* Subscribe Key
105-
* @param secret_key
106-
* Secret Key
107-
* @param cipher_key
108-
* Cipher Key
109-
* @param ssl_on
110-
* SSL enabled ?
111-
* @param initialization_vector
112-
* Initialization vector
113-
*/
96+
*
97+
* Constructor for Pubnub Class
98+
*
99+
* @param publish_key
100+
* Publish Key
101+
* @param subscribe_key
102+
* Subscribe Key
103+
* @param secret_key
104+
* Secret Key
105+
* @param cipher_key
106+
* Cipher Key
107+
* @param ssl_on
108+
* SSL enabled ?
109+
* @param initialization_vector
110+
* Initialization vector
111+
*/
114112

115-
public Pubnub(String publish_key, String subscribe_key,
116-
String secret_key, String cipher_key, boolean ssl_on, String initialization_vector) {
113+
public Pubnub(String publish_key, String subscribe_key, String secret_key, String cipher_key, boolean ssl_on,
114+
String initialization_vector) {
117115
super(publish_key, subscribe_key, secret_key, cipher_key, ssl_on, initialization_vector);
118116
}
119117

120118
protected String getUserAgent() {
121-
return "(Android " + android.os.Build.VERSION.RELEASE +
122-
"; " + android.os.Build.MODEL +
123-
" Build) PubNub-Java/Android/" + VERSION;
119+
return "(Android " + android.os.Build.VERSION.RELEASE + "; " + android.os.Build.MODEL
120+
+ " Build) PubNub-Java/Android/" + VERSION;
124121
}
125122

126123
}

‎android/srcCrypto/com/pubnub/api/PubnubCryptoCore.java‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.pubnub.api;
22

3-
43
import java.io.*;
54
import java.security.InvalidAlgorithmParameterException;
65
import java.security.InvalidKeyException;
@@ -33,28 +32,31 @@ abstract class PubnubCryptoCore {
3332
public PubnubCryptoCore(String CIPHER_KEY) {
3433
this.CIPHER_KEY = CIPHER_KEY;
3534
}
35+
3636
public PubnubCryptoCore(String CIPHER_KEY, String initialization_vector) {
37-
if (initialization_vector != null) this.IV = initialization_vector;
37+
if (initialization_vector != null)
38+
this.IV = initialization_vector;
3839
this.CIPHER_KEY = CIPHER_KEY;
3940
}
4041

4142
public void InitCiphers() throws PubnubException {
42-
if (INIT) return;
43+
if (INIT)
44+
return;
4345
try {
4446

45-
keyBytes = new String(hexEncode(sha256(this.CIPHER_KEY.getBytes("UTF-8"))),
46-
"UTF-8").substring(0, 32).toLowerCase().getBytes("UTF-8");
47+
keyBytes = new String(hexEncode(sha256(this.CIPHER_KEY.getBytes("UTF-8"))), "UTF-8").substring(0, 32)
48+
.toLowerCase().getBytes("UTF-8");
4749
ivBytes = IV.getBytes("UTF-8");
4850
INIT = true;
4951
} catch (UnsupportedEncodingException e) {
5052
throw new PubnubException(newCryptoError(11, e.toString()));
5153
}
5254
}
5355

54-
5556
public static byte[] hexEncode(byte[] input) throws PubnubException {
5657
StringBuffer result = new StringBuffer();
57-
for (byte byt : input) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
58+
for (byte byt : input)
59+
result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
5860
try {
5961
return result.toString().getBytes("UTF-8");
6062
} catch (UnsupportedEncodingException e) {
@@ -66,7 +68,7 @@ private static PubnubError newCryptoError(int code, String message) {
6668
return PubnubError.getErrorObject(PubnubError.PNERROBJ_CRYPTO_ERROR, code, message);
6769
}
6870

69-
public String encrypt(String input) throws PubnubException {
71+
public String encrypt(String input) throws PubnubException {
7072
try {
7173
InitCiphers();
7274
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
@@ -100,7 +102,7 @@ public String encrypt(String input) throws PubnubException {
100102
* @return String
101103
* @throws PubnubException
102104
*/
103-
public String decrypt(String cipher_text) throws PubnubException {
105+
public String decrypt(String cipher_text) throws PubnubException {
104106
try {
105107
InitCiphers();
106108
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
@@ -109,8 +111,8 @@ public String decrypt(String cipher_text) throws PubnubException {
109111
cipher.init(Cipher.DECRYPT_MODE, newKey, ivSpec);
110112
return new String(cipher.doFinal(Base64Encoder.decode(cipher_text)), "UTF-8");
111113
} catch (IllegalArgumentException e) {
112-
throw new PubnubException(newCryptoError(111, e.toString()));
113-
} catch (UnsupportedEncodingException e) {
114+
throw new PubnubException(newCryptoError(111, e.toString()));
115+
} catch (UnsupportedEncodingException e) {
114116
throw new PubnubException(newCryptoError(112, e.toString()));
115117
} catch (IllegalBlockSizeException e) {
116118
throw new PubnubException(newCryptoError(113, e.toString()));
@@ -127,13 +129,11 @@ public String decrypt(String cipher_text) throws PubnubException {
127129
}
128130
}
129131

130-
131132
public static byte[] hexStringToByteArray(String s) {
132133
int len = s.length();
133134
byte[] data = new byte[len / 2];
134135
for (int i = 0; i < len; i += 2) {
135-
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character
136-
.digit(s.charAt(i + 1), 16));
136+
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
137137
}
138138
return data;
139139
}

‎android/srcLogging/com/pubnub/api/Logger.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
public class Logger extends AbstractLogger {
66
Class _class;
7+
78
public Logger(Class _class) {
89
super();
910
this._class = _class;
@@ -12,13 +13,16 @@ public Logger(Class _class) {
1213
protected void nativeDebug(String s) {
1314
Log.d(_class.getName(), s);
1415
}
16+
1517
protected void nativeVerbose(String s) {
1618
Log.v(_class.getName(), s);
1719
}
20+
1821
protected void nativeError(String s) {
1922
Log.e(_class.getName(), s);
2023
}
24+
2125
protected void nativeInfo(String s) {
22-
Log.i(_class.getName(), s );
26+
Log.i(_class.getName(), s);
2327
}
2428
}

0 commit comments

Comments
 (0)