|
34 | 34 | import android.support.v7.app.AlertDialog; |
35 | 35 | import android.text.Editable; |
36 | 36 | import android.text.InputType; |
| 37 | +import android.text.SpannableString; |
37 | 38 | import android.text.TextUtils; |
38 | 39 | import android.text.TextWatcher; |
| 40 | +import android.text.method.LinkMovementMethod; |
| 41 | +import android.text.util.Linkify; |
39 | 42 | import android.view.LayoutInflater; |
40 | 43 | import android.view.View; |
41 | 44 | import android.view.WindowManager; |
|
45 | 48 | import android.widget.CompoundButton.OnCheckedChangeListener; |
46 | 49 | import android.widget.EditText; |
47 | 50 | import android.widget.ImageView; |
| 51 | +import android.widget.TextView; |
48 | 52 |
|
49 | 53 | import java.net.MalformedURLException; |
50 | 54 | import java.net.URL; |
@@ -375,14 +379,17 @@ protected void onPostExecute(final Integer versionCode) { |
375 | 379 | mDialogLogin.dismiss(); |
376 | 380 |
|
377 | 381 | if(versionCode == -1 && exception_message.equals("Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject")) { |
378 | | - if(isAdded()) |
| 382 | + if(isAdded()) { |
379 | 383 | ShowAlertDialog(getString(R.string.login_dialog_title_error), getString(R.string.login_dialog_text_not_compatible), getActivity()); |
| 384 | + } |
380 | 385 | } else if(versionCode == -1) { |
381 | | - if(isAdded()) |
| 386 | + if(isAdded()) { |
382 | 387 | ShowAlertDialog(getString(R.string.login_dialog_title_error), exception_message, getActivity()); |
| 388 | + } |
383 | 389 | } else if(versionCode == 0){ |
384 | | - if(isAdded()) |
385 | | - ShowAlertDialog(getString(R.string.login_dialog_title_error), getString(R.string.login_dialog_text_something_went_wrong), getActivity()); |
| 390 | + if(isAdded()) { |
| 391 | + ShowAlertDialog(getString(R.string.login_dialog_title_error), getString(R.string.login_dialog_text_zero_version_code), getActivity()); |
| 392 | + } |
386 | 393 | } else { |
387 | 394 | //Reset Database |
388 | 395 | DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getActivity()); |
@@ -414,10 +421,18 @@ protected void onCancelled() { |
414 | 421 |
|
415 | 422 | public static void ShowAlertDialog(String title, String text, Activity activity) |
416 | 423 | { |
417 | | - AlertDialog.Builder aDialog = new AlertDialog.Builder(activity); |
418 | | - aDialog.setTitle(title); |
419 | | - aDialog.setMessage(text); |
420 | | - aDialog.setPositiveButton(activity.getString(android.R.string.ok) , null); |
421 | | - aDialog.create().show(); |
| 424 | + // Linkify the message |
| 425 | + final SpannableString s = new SpannableString(text); |
| 426 | + Linkify.addLinks(s, Linkify.ALL); |
| 427 | + |
| 428 | + AlertDialog aDialog = new AlertDialog.Builder(activity) |
| 429 | + .setTitle(title) |
| 430 | + .setMessage(s) |
| 431 | + .setPositiveButton(activity.getString(android.R.string.ok) , null) |
| 432 | + .create(); |
| 433 | + aDialog.show(); |
| 434 | + |
| 435 | + // Make the textview clickable. Must be called after show() |
| 436 | + ((TextView)aDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); |
422 | 437 | } |
423 | 438 | } |
0 commit comments