|
| 1 | +/* |
| 2 | + * QNotified - An Xposed module for QQ/TIM |
| 3 | + * Copyright (C) 2019-2022 [email protected] |
| 4 | + * https://github.com/ferredoxin/QNotified |
| 5 | + * |
| 6 | + * This software is non-free but opensource software: you can redistribute it |
| 7 | + * and/or modify it under the terms of the GNU Affero General Public License |
| 8 | + * as published by the Free Software Foundation; either |
| 9 | + * version 3 of the License, or any later version and our eula as published |
| 10 | + * by ferredoxin. |
| 11 | + * |
| 12 | + * This software is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + * Affero General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Affero General Public License |
| 18 | + * and eula along with this software. If not, see |
| 19 | + * <https://www.gnu.org/licenses/> |
| 20 | + * <https://github.com/ferredoxin/QNotified/blob/master/LICENSE.md>. |
| 21 | + */ |
| 22 | + |
| 23 | +package cc.ioctl.hook; |
| 24 | + |
| 25 | +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
| 26 | +import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; |
| 27 | +import static nil.nadph.qnotified.ui.ViewBuilder.newLinearLayoutParams; |
| 28 | +import static nil.nadph.qnotified.util.Utils.dip2px; |
| 29 | + |
| 30 | +import android.app.AlertDialog; |
| 31 | +import android.content.Context; |
| 32 | +import android.content.Intent; |
| 33 | +import android.widget.EditText; |
| 34 | +import android.widget.LinearLayout; |
| 35 | +import androidx.core.view.ViewCompat; |
| 36 | +import nil.nadph.qnotified.ui.CustomDialog; |
| 37 | +import nil.nadph.qnotified.ui.drawable.HighContrastBorder; |
| 38 | +import nil.nadph.qnotified.util.Toasts; |
| 39 | + |
| 40 | +public class CheckCommonGroup { |
| 41 | + |
| 42 | + public static void onClick(Context ctx) { |
| 43 | + CustomDialog dialog = CustomDialog.createFailsafe(ctx); |
| 44 | + EditText editText = new EditText(ctx); |
| 45 | + editText.setTextSize(16); |
| 46 | + int _5 = dip2px(ctx, 5); |
| 47 | + editText.setPadding(_5, _5, _5, _5); |
| 48 | + ViewCompat.setBackground(editText, new HighContrastBorder()); |
| 49 | + LinearLayout linearLayout = new LinearLayout(ctx); |
| 50 | + linearLayout |
| 51 | + .addView(editText, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, _5 * 2)); |
| 52 | + AlertDialog alertDialog = (AlertDialog) dialog.setTitle("输入对方QQ号") |
| 53 | + .setView(linearLayout) |
| 54 | + .setCancelable(true) |
| 55 | + .setPositiveButton("打开QQ号", null) |
| 56 | + .setNegativeButton("取消", null) |
| 57 | + .create(); |
| 58 | + alertDialog.show(); |
| 59 | + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE) |
| 60 | + .setOnClickListener(v -> { |
| 61 | + String text = editText.getText().toString(); |
| 62 | + if (text.equals("")) { |
| 63 | + Toasts.error(ctx, "请输入QQ号"); |
| 64 | + return; |
| 65 | + } |
| 66 | + long uin = 0; |
| 67 | + try { |
| 68 | + uin = Long.parseLong(text); |
| 69 | + } catch (NumberFormatException ignored) { |
| 70 | + } |
| 71 | + if (uin < 10000) { |
| 72 | + Toasts.error(ctx, "请输入有效的QQ号"); |
| 73 | + return; |
| 74 | + } |
| 75 | + alertDialog.dismiss(); |
| 76 | + Class<?> browser = null; |
| 77 | + try { |
| 78 | + browser = Class |
| 79 | + .forName("com.tencent.mobileqq.activity.QQBrowserDelegationActivity"); |
| 80 | + Intent intent = new Intent(ctx, browser); |
| 81 | + intent.putExtra("fling_action_key", 2); |
| 82 | + intent.putExtra("fling_code_key", ctx.hashCode()); |
| 83 | + intent.putExtra("useDefBackText", true); |
| 84 | + intent.putExtra("param_force_internal_browser", true); |
| 85 | + intent.putExtra("url", "https://ti.qq.com/friends/recall?uin=" + uin); |
| 86 | + ctx.startActivity(intent); |
| 87 | + } catch (ClassNotFoundException e) { |
| 88 | + e.printStackTrace(); |
| 89 | + } |
| 90 | + }); |
| 91 | + } |
| 92 | + |
| 93 | +} |
0 commit comments