18
18
import android .view .View ;
19
19
import android .widget .TextView ;
20
20
21
- import com .nowsecure .android .vts .BuildConfig ;
21
+ import com .afollestad .materialdialogs .DialogAction ;
22
+ import com .afollestad .materialdialogs .MaterialDialog ;
22
23
import com .nowsecure .android .vts .R ;
23
24
24
- import org .json .JSONArray ;
25
25
import org .json .JSONException ;
26
26
import org .json .JSONObject ;
27
27
@@ -60,7 +60,7 @@ protected void onCreate(Bundle savedInstanceState) {
60
60
getSupportActionBar ().setTitle (R .string .app_name );
61
61
62
62
if (savedInstanceState != null && savedInstanceState .containsKey (SERIALIZABLE_RESULTS )) {
63
- testResults = (ArrayList <VulnerabilityTestResult >) savedInstanceState .getSerializable (SERIALIZABLE_RESULTS );
63
+ testResults = (ArrayList <VulnerabilityTestResult >) savedInstanceState .getSerializable (SERIALIZABLE_RESULTS );
64
64
} else {
65
65
testResults = new ArrayList <>();
66
66
}
@@ -95,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState) {
95
95
tvBuildSDK .setText (devInfo .getBuildSDK ());
96
96
97
97
StringBuilder sb = new StringBuilder ();
98
- for (String s : devInfo .getSupportedABIS ()){
98
+ for (String s : devInfo .getSupportedABIS ()) {
99
99
sb .append (s );
100
100
sb .append (" " );
101
101
}
@@ -134,7 +134,7 @@ public void onClick(View v) {
134
134
}
135
135
136
136
}).show ();
137
-
137
+
138
138
return true ;
139
139
}
140
140
@@ -146,7 +146,7 @@ public void onClick(View v) {
146
146
intent .setType ("text/plain" );
147
147
intent .putExtra (Intent .EXTRA_SUBJECT , "Android VTS Results" );
148
148
intent .putExtra (Intent .EXTRA_TEXT , json .toString (4 ));
149
- } else if (itemId == R .id .menu_share_results ) {
149
+ } else if (itemId == R .id .menu_share_results ) {
150
150
Uri formUri = new ShareViaGoogleForm (json ).buildUri ();
151
151
intent = new Intent (Intent .ACTION_VIEW , formUri );
152
152
}
@@ -177,10 +177,59 @@ public void finished(final List<VulnerabilityTestResult> results) {
177
177
178
178
emptyView .setVisibility (View .GONE );
179
179
recyclerAdapter .updateResults (results );
180
+
181
+ showScanResume (results );
180
182
}
181
183
}).execute ();
182
184
}
183
185
186
+ private void showScanResume (final List <VulnerabilityTestResult > results ) {
187
+ int numberOfFailed = 0 ;
188
+
189
+ for (VulnerabilityTestResult result : results ) {
190
+ if (result .getException () != null ) {
191
+ continue ;
192
+ }
193
+
194
+ if (result .isVulnerable ()) {
195
+ numberOfFailed ++;
196
+ }
197
+ }
198
+
199
+ MaterialDialog .Builder dialogBuilder = new MaterialDialog .Builder (this )
200
+ .title (R .string .scan_details )
201
+ .customView (R .layout .dialog_scan_details_layout , true )
202
+ .positiveText (R .string .dismiss );
203
+
204
+ if (numberOfFailed > 0 ) {
205
+ dialogBuilder .negativeText (R .string .my_device_is_vulnerable_info )
206
+ .onNegative (new MaterialDialog .SingleButtonCallback () {
207
+ @ Override
208
+ public void onClick (MaterialDialog materialDialog , DialogAction dialogAction ) {
209
+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://www.nowsecure.com/blog/2015/11/18/my-device-is-vulnerable-now-what/" ));
210
+ startActivity (browserIntent );
211
+ }
212
+ });
213
+ }
214
+
215
+ View view = dialogBuilder .show ().getCustomView ();
216
+
217
+ TextView state = (TextView ) view .findViewById (R .id .scan_details_device_state );
218
+ if (numberOfFailed > 0 ) {
219
+ state .setText (R .string .scan_details_vulnerable_message );
220
+ state .setTextColor (getResources ().getColor (R .color .red ));
221
+ } else {
222
+ state .setText (R .string .scan_details_secure_message );
223
+ state .setTextColor (getResources ().getColor (R .color .green ));
224
+ }
225
+
226
+ TextView numberOfTests = (TextView ) view .findViewById (R .id .scan_details_number_tests );
227
+ numberOfTests .setText (String .valueOf (results .size ()));
228
+
229
+ TextView numberOfFailedTests = (TextView ) view .findViewById (R .id .scan_details_failed_tests );
230
+ numberOfFailedTests .setText (String .valueOf (numberOfFailed ));
231
+ }
232
+
184
233
@ Override
185
234
public void onConfigurationChanged (Configuration newConfig ) {
186
235
super .onConfigurationChanged (newConfig );
0 commit comments