|
1 | 1 | package io.virtualapp.home; |
2 | 2 |
|
3 | 3 | import android.app.Activity; |
| 4 | +import android.app.AlertDialog; |
| 5 | +import android.content.ComponentName; |
4 | 6 | import android.content.Context; |
5 | 7 | import android.content.Intent; |
| 8 | +import android.content.pm.PackageManager; |
6 | 9 | import android.database.Cursor; |
7 | 10 | import android.graphics.drawable.ColorDrawable; |
8 | 11 | import android.net.Uri; |
@@ -78,6 +81,77 @@ public void onSaveInstanceState(Bundle outState) { |
78 | 81 | mAdapter.saveInstanceState(outState); |
79 | 82 | } |
80 | 83 |
|
| 84 | + private void whatIsTaiChi() { |
| 85 | + AlertDialog alertDialog = new AlertDialog.Builder(getContext()) |
| 86 | + .setTitle(R.string.what_is_exp) |
| 87 | + .setMessage(R.string.exp_tips) |
| 88 | + .setPositiveButton(R.string.exp_introduce_title, (dialog, which) -> { |
| 89 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 90 | + t.setData(Uri.parse("https://www.coolapk.com/apk/me.weishu.exp")); |
| 91 | + startActivity(t); |
| 92 | + }).setNegativeButton(R.string.about_donate_title, (dialog, which) -> { |
| 93 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 94 | + t.setData(Uri.parse("https://vxposed.com/donate.html")); |
| 95 | + startActivity(t); |
| 96 | + }) |
| 97 | + .create(); |
| 98 | + try { |
| 99 | + alertDialog.show(); |
| 100 | + } catch (Throwable ignored) { |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + private void chooseInstallWay(Runnable runnable, String path) { |
| 105 | + AlertDialog alertDialog = new AlertDialog.Builder(getContext()) |
| 106 | + .setTitle(R.string.install_choose_way) |
| 107 | + .setMessage(R.string.install_choose_content) |
| 108 | + .setPositiveButton(R.string.install_choose_taichi, (dialog, which) -> { |
| 109 | + PackageManager packageManager = getActivity().getPackageManager(); |
| 110 | + try { |
| 111 | + packageManager.getPackageInfo("me.weishu.exp", 0); |
| 112 | + Intent intent = new Intent(); |
| 113 | + intent.setComponent(new ComponentName("me.weishu.exp", "me.weishu.exp.ui.MainActivity")); |
| 114 | + intent.putExtra("path", path); |
| 115 | + startActivity(intent); |
| 116 | + } catch (PackageManager.NameNotFoundException e) { |
| 117 | + AlertDialog showInstallDialog = new AlertDialog.Builder(getContext()) |
| 118 | + .setTitle(android.R.string.dialog_alert_title) |
| 119 | + .setMessage(R.string.install_taichi_not_exist) |
| 120 | + .setPositiveButton(R.string.install_go_to_install_exp, (dialog1, which1) -> { |
| 121 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 122 | + t.setData(Uri.parse("https://www.coolapk.com/apk/me.weishu.exp")); |
| 123 | + startActivity(t); |
| 124 | + }) |
| 125 | + .create(); |
| 126 | + showInstallDialog.show(); |
| 127 | + } catch (Throwable e) { |
| 128 | + AlertDialog showInstallDialog = new AlertDialog.Builder(getContext()) |
| 129 | + .setTitle(android.R.string.dialog_alert_title) |
| 130 | + .setMessage(R.string.install_taichi_while_old_version) |
| 131 | + .setPositiveButton(R.string.install_go_latest_exp, (dialog1, which1) -> { |
| 132 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 133 | + t.setData(Uri.parse("https://www.coolapk.com/apk/me.weishu.exp")); |
| 134 | + startActivity(t); |
| 135 | + }) |
| 136 | + .create(); |
| 137 | + showInstallDialog.show(); |
| 138 | + } |
| 139 | + finishActivity(); |
| 140 | + }).setNegativeButton("VirtualXposed", (dialog, which) -> { |
| 141 | + if (runnable != null) { |
| 142 | + runnable.run(); |
| 143 | + } |
| 144 | + finishActivity(); |
| 145 | + }).setNeutralButton(R.string.what_is_exp, ((dialog, which) -> { |
| 146 | + whatIsTaiChi(); |
| 147 | + })) |
| 148 | + .create(); |
| 149 | + try { |
| 150 | + alertDialog.show(); |
| 151 | + } catch (Throwable ignored) { |
| 152 | + } |
| 153 | + } |
| 154 | + |
81 | 155 | @Override |
82 | 156 | public void onViewCreated(View view, Bundle savedInstanceState) { |
83 | 157 | mRecyclerView = (DragSelectRecyclerView) view.findViewById(R.id.select_app_recycler_view); |
@@ -120,8 +194,7 @@ public boolean isSelectable(int position) { |
120 | 194 | dataList.add(new AppInfoLite(info.packageName, info.path, info.fastOpen, info.disableMultiVersion)); |
121 | 195 | } |
122 | 196 |
|
123 | | - Installd.startInstallerActivity(getActivity(), dataList); |
124 | | - getActivity().finish(); |
| 197 | + chooseInstallWay(() -> Installd.startInstallerActivity(getActivity(), dataList), dataList.get(0).path); |
125 | 198 | }); |
126 | 199 | mSelectFromExternal.setOnClickListener(v -> { |
127 | 200 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
@@ -172,9 +245,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { |
172 | 245 | if (path == null) { |
173 | 246 | return; |
174 | 247 | } |
175 | | - Installd.handleRequestFromFile(getActivity(), path); |
176 | 248 |
|
177 | | - getActivity().finish(); |
| 249 | + chooseInstallWay(() -> Installd.handleRequestFromFile(getActivity(), path), path); |
178 | 250 | } |
179 | 251 |
|
180 | 252 | public static String getPath(Context context, Uri uri) { |
|
0 commit comments