@@ -27,12 +27,9 @@ protected void onCreate(Bundle savedInstanceState) { |
27 | 27 |
|
28 | 28 | mTextView = (TextView) findViewById(R.id.log_textView); |
29 | 29 | mTextView.setMovementMethod(new ScrollingMovementMethod()); |
30 | | - interceptLog(); |
31 | 30 |
|
32 | 31 | // the Normal Usage |
33 | | - View view = findViewById(R.id.usage_normal); |
34 | | - assert view != null; |
35 | | - view.setOnClickListener(new View.OnClickListener() { |
| 32 | + findViewById(R.id.usage_normal).setOnClickListener(new View.OnClickListener() { |
36 | 33 | @Override |
37 | 34 | public void onClick(View v) { |
38 | 35 | log("---- Normal Usage ---------------------------------------------------"); |
@@ -58,39 +55,8 @@ public void onClick(View v) { |
58 | 55 | } |
59 | 56 | }); |
60 | 57 |
|
61 | | - // the Normal Usage |
62 | | - view = findViewById(R.id.usage_low_iteration); |
63 | | - assert view != null; |
64 | | - view.setOnClickListener(new View.OnClickListener() { |
65 | | - @Override |
66 | | - public void onClick(View v) { |
67 | | - log("---- Low Iteration Usage --------------------------------------------"); |
68 | | - // Low iteration is equals the default but faster once it uses only 1 iteration instead of 65536 |
69 | | - Encryption encryption = Encryption.getLowIteration("SomeKey", "SomeSalt", new byte[16]); |
70 | | - |
71 | | - String secretText = "Low iteration is faster but may you will prefer an async approach with a big iteration count"; |
72 | | - |
73 | | - // the method encryptOrNull will encrypt your text and if some error occurs will return null |
74 | | - // if you want handle the errors you can call the encrypt method directly |
75 | | - String encrypted = encryption.encryptOrNull(secretText); |
76 | | - |
77 | | - // just printing to see the text and the encrypted string |
78 | | - log("This is our secret text: " + secretText); |
79 | | - log("And this is our encrypted text: " + encrypted); |
80 | | - |
81 | | - // now you can send the encrypted text by network or save in disk securely or do wherever |
82 | | - // that you want, but remember encrypt is not all, we need decrypt too, so lets go do it |
83 | | - String decrypted = encryption.decryptOrNull(encrypted); |
84 | | - |
85 | | - // the decrypted text should be equals the encrypted |
86 | | - log("And finally this is our decrypted text: " + decrypted); |
87 | | - } |
88 | | - }); |
89 | | - |
90 | 58 | // a Customized Usage |
91 | | - view = findViewById(R.id.usage_customized); |
92 | | - assert view != null; |
93 | | - view.setOnClickListener(new View.OnClickListener() { |
| 59 | + findViewById(R.id.usage_customized).setOnClickListener(new View.OnClickListener() { |
94 | 60 | @Override |
95 | 61 | public void onClick(View v) { |
96 | 62 | log("---- Customized Usage -----------------------------------------------"); |
@@ -132,9 +98,7 @@ public void onClick(View v) { |
132 | 98 | }); |
133 | 99 |
|
134 | 100 | // an Async Usage |
135 | | - view = findViewById(R.id.usage_async); |
136 | | - assert view != null; |
137 | | - view.setOnClickListener(new View.OnClickListener() { |
| 101 | + findViewById(R.id.usage_async).setOnClickListener(new View.OnClickListener() { |
138 | 102 | @Override |
139 | 103 | public void onClick(View v) { |
140 | 104 | log("---- Async Usage ----------------------------------------------------"); |
@@ -165,30 +129,6 @@ public void onError(Exception e) { |
165 | 129 | }); |
166 | 130 | } |
167 | 131 |
|
168 | | - /** |
169 | | - * By default Encryption do not log, but you can intercept logs |
170 | | - */ |
171 | | - private void interceptLog() { |
172 | | - // you can intercept logs and sed direct to System.out with: |
173 | | - Logger.enableDefaultLog(); |
174 | | - |
175 | | - // you can turn off the log too, by default the log is off |
176 | | - Logger.disableLog(); |
177 | | - |
178 | | - // you can also intercept the log and do wherever you want |
179 | | - Logger.setLogDelegate(new Logger.EncryptionLogDelegate() { |
180 | | - @Override |
181 | | - public void log(String message, Exception e) { |
182 | | - MainActivity.this.log("this is an exception log: " + message + ", " + e); |
183 | | - } |
184 | | - |
185 | | - @Override |
186 | | - public void log(String message) { |
187 | | - MainActivity.this.log("this is a normal log: " + message); |
188 | | - } |
189 | | - }); |
190 | | - } |
191 | | - |
192 | 132 | private void log(final String message) { |
193 | 133 | Log.d(TAG, message); |
194 | 134 |
|
|