|
18 | 18 | */
|
19 | 19 | public class Misc {
|
20 | 20 | public static void showDonate(Activity context) {
|
21 |
| - AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.Theme_AppCompat_DayNight_Dialog_Alert) |
22 |
| - .setTitle(R.string.donate_dialog_title) |
23 |
| - .setMessage(R.string.donate_dialog_content) |
24 |
| - .setPositiveButton(R.string.donate_dialog_yes, (dialog, which) -> { |
25 |
| - // show chooser dialog |
| 21 | + final String alipay = context.getResources().getString(R.string.donate_alipay); |
| 22 | + final String[] items = {alipay, "PayPal", "Bitcoin"}; |
26 | 23 |
|
27 |
| - final String alipay = context.getResources().getString(R.string.donate_alipay); |
28 |
| - final String[] items = {alipay, "Paypal", "Bitcoin"}; |
| 24 | + AlertDialog chooseDialog = new AlertDialog.Builder(context, R.style.Theme_AppCompat_DayNight_Dialog_Alert) |
| 25 | + .setTitle(R.string.donate_choose_title) |
| 26 | + .setItems(items, (dialog1, which1) -> { |
| 27 | + dialog1.dismiss(); |
| 28 | + if (which1 == 0) { |
| 29 | + if (!AlipayZeroSdk.hasInstalledAlipayClient(context)) { |
| 30 | + Toast.makeText(context, R.string.prompt_alipay_not_found, Toast.LENGTH_SHORT).show(); |
| 31 | + return; |
| 32 | + } |
| 33 | + AlipayZeroSdk.startAlipayClient(context, "FKX016770URBZGZSR37U37"); |
| 34 | + } else if (which1 == 1) { |
| 35 | + try { |
| 36 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 37 | + t.setData(Uri.parse("https://paypal.me/virtualxposed")); |
| 38 | + context.startActivity(t); |
| 39 | + } catch (Throwable ignored) { |
| 40 | + ignored.printStackTrace(); |
| 41 | + } |
| 42 | + } else if (which1 == 2) { |
| 43 | + final String address = "39Wst8oL74pRP2vKPkPihH6RFQF4hWoBqU"; |
29 | 44 |
|
30 |
| - AlertDialog chooseDialog = new AlertDialog.Builder(context, R.style.Theme_AppCompat_DayNight_Dialog_Alert) |
31 |
| - .setTitle(R.string.donate_choose_title) |
32 |
| - .setItems(items, (dialog1, which1) -> { |
33 |
| - dialog1.dismiss(); |
34 |
| - if (which1 == 0) { |
35 |
| - if (!AlipayZeroSdk.hasInstalledAlipayClient(context)) { |
36 |
| - Toast.makeText(context, R.string.prompt_alipay_not_found, Toast.LENGTH_SHORT).show(); |
37 |
| - return; |
38 |
| - } |
39 |
| - AlipayZeroSdk.startAlipayClient(context, "FKX016770URBZGZSR37U37"); |
40 |
| - } else if (which1 == 1) { |
41 |
| - try { |
42 |
| - Intent t = new Intent(Intent.ACTION_VIEW); |
43 |
| - t.setData(Uri.parse("https://paypal.me/virtualxposed")); |
44 |
| - context.startActivity(t); |
45 |
| - } catch (Throwable ignored) { |
46 |
| - ignored.printStackTrace(); |
47 |
| - } |
48 |
| - } else if (which1 == 2) { |
49 |
| - final String address = "39Wst8oL74pRP2vKPkPihH6RFQF4hWoBqU"; |
50 |
| - |
51 |
| - try { |
52 |
| - ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); |
53 |
| - if (clipboardManager != null) { |
54 |
| - clipboardManager.setPrimaryClip(ClipData.newPlainText(null, address)); |
55 |
| - } |
56 |
| - Toast.makeText(context, context.getResources().getString(R.string.donate_bitconins_tips), Toast.LENGTH_SHORT).show(); |
57 |
| - } catch (Throwable ignored) { |
58 |
| - ignored.printStackTrace(); |
59 |
| - } |
60 |
| - } |
61 |
| - }) |
62 |
| - .create(); |
63 |
| - chooseDialog.show(); |
| 45 | + try { |
| 46 | + ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); |
| 47 | + if (clipboardManager != null) { |
| 48 | + clipboardManager.setPrimaryClip(ClipData.newPlainText(null, address)); |
| 49 | + } |
| 50 | + Toast.makeText(context, context.getResources().getString(R.string.donate_bitconins_tips), Toast.LENGTH_SHORT).show(); |
| 51 | + } catch (Throwable ignored) { |
| 52 | + ignored.printStackTrace(); |
| 53 | + } |
| 54 | + } |
64 | 55 | })
|
65 |
| - .setNegativeButton(R.string.donate_dialog_no, ((dialog, which) -> { |
66 |
| - Intent intent = new Intent(); |
67 |
| - intent.setAction(Intent.ACTION_VIEW); |
68 |
| - intent.addCategory(Intent.CATEGORY_BROWSABLE); |
69 |
| - intent.setData(Uri.parse("https://github.com/android-hacker/VirtualXposed")); |
70 |
| - context.startActivity(intent); |
71 |
| - })) |
72 | 56 | .create();
|
73 |
| - try { |
74 |
| - alertDialog.show(); |
75 |
| - } catch (Throwable ignored) { |
76 |
| - // BadTokenException. |
77 |
| - } |
| 57 | + chooseDialog.show(); |
78 | 58 | }
|
79 | 59 | }
|
0 commit comments