Skip to content

Commit d6b7d09

Browse files
author
维术
committed
[Exposed-UI] do not show animation when app foreground.
1 parent 2279e97 commit d6b7d09

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

VirtualApp/app/src/main/java/io/virtualapp/delegate/MyAppRequestListener.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.virtualapp.delegate;
22

33
import android.content.Context;
4+
import android.content.res.Resources;
45
import android.widget.Toast;
56

67
import com.lody.virtual.client.core.InstallStrategy;
@@ -9,6 +10,8 @@
910

1011
import java.io.IOException;
1112

13+
import io.virtualapp.R;
14+
1215
/**
1316
* @author Lody
1417
*/
@@ -23,7 +26,8 @@ public MyAppRequestListener(Context context) {
2326

2427
@Override
2528
public void onRequestInstall(String path) {
26-
Toast.makeText(context, "Installing: " + path, Toast.LENGTH_SHORT).show();
29+
Resources resources = VirtualCore.get().getContext().getResources();
30+
Toast.makeText(context, resources.getString(R.string.installing_tips, path), Toast.LENGTH_SHORT).show();
2731
InstallResult res = VirtualCore.get().installPackage(path, InstallStrategy.UPDATE_IF_EXIST);
2832
if (res.isSuccess) {
2933
try {
@@ -32,12 +36,15 @@ public void onRequestInstall(String path) {
3236
e.printStackTrace();
3337
}
3438
if (res.isUpdate) {
35-
Toast.makeText(context, "Update: " + res.packageName + " success!", Toast.LENGTH_SHORT).show();
39+
Toast.makeText(context, resources.getString(R.string.update_success_tips, res.packageName),
40+
Toast.LENGTH_SHORT).show();
3641
} else {
37-
Toast.makeText(context, "Install: " + res.packageName + " success!", Toast.LENGTH_SHORT).show();
42+
Toast.makeText(context, resources.getString(R.string.install_success_tips),
43+
Toast.LENGTH_SHORT).show();
3844
}
3945
} else {
40-
Toast.makeText(context, "Install failed: " + res.error, Toast.LENGTH_SHORT).show();
46+
Toast.makeText(context, resources.getString(R.string.install_fail_tips, res.packageName, res.error),
47+
Toast.LENGTH_SHORT).show();
4148
}
4249
}
4350

VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ public class HomeActivity extends VActivity implements HomeContract.HomeView {
8181
private VirtualCore.PackageObserver mPackageObserver = new VirtualCore.PackageObserver() {
8282
@Override
8383
public void onPackageInstalled(String packageName) throws RemoteException {
84-
runOnUiThread(() -> mPresenter.dataChanged());
84+
if (!isForground) {
85+
runOnUiThread(() -> mPresenter.dataChanged());
86+
}
8587
}
8688

8789
@Override
8890
public void onPackageUninstalled(String packageName) throws RemoteException {
89-
runOnUiThread(() -> mPresenter.dataChanged());
91+
if (!isForground) {
92+
runOnUiThread(() -> mPresenter.dataChanged());
93+
}
9094
}
9195

9296
@Override
@@ -97,6 +101,7 @@ public void onPackageInstalledAsUser(int userId, String packageName) throws Remo
97101
public void onPackageUninstalledAsUser(int userId, String packageName) throws RemoteException {
98102
}
99103
};
104+
private boolean isForground = false;
100105
//endregion
101106

102107
public static void goHome(Context context) {
@@ -119,6 +124,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
119124
VirtualCore.get().registerObserver(mPackageObserver);
120125
}
121126

127+
@Override
128+
protected void onResume() {
129+
super.onResume();
130+
isForground = true;
131+
}
132+
133+
@Override
134+
protected void onStop() {
135+
super.onStop();
136+
isForground = false;
137+
}
138+
122139
@Override
123140
protected void onDestroy() {
124141
super.onDestroy();

VirtualApp/app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@
3030
\n遇到问题请详细描述你的机型,系统版本,ROM,操作流程,问题情况,如果是开发者,最好能提供Logcat日志;谢谢配合(简单的"用不了,有问题, 黑屏了"等等解决不了任何问题) 欢迎提出任何有价值的BUG和建议 :)\n\n
3131
QQ群:597478474</string>
3232
<string name="menu_reboot">重启</string>
33+
<string name="installing_tips">正在安装 %1$s…</string>
34+
<string name="update_success_tips">%1$s 更新成功!</string>
35+
<string name="install_success_tips">模块安装完后需要去XposedInstaller的模块设置里勾选才能生效哦~</string>
36+
<string name="install_fail_tips">%1$s 安装失败,错误码: %2$s</string>
3337
</resources>

VirtualApp/app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@
2929
<string name="menu_feedback_string">Project: https://github.com/android-hacker/VAExposed\n Feedback:https://github.com/android-hacker/exposed/issues\n\n
3030
QQ群:597478474</string>
3131
<string name="menu_reboot">Reboot</string>
32+
<string name="installing_tips">Installing %1$s…</string>
33+
<string name="update_success_tips">Update %1$s success!</string>
34+
<string name="install_success_tips">Xposed module will not take effect after check it in XposedInstaller\'s module setting!</string>
35+
<string name="install_fail_tips">Install %1$s failed: %2$s</string>
3236
</resources>

0 commit comments

Comments
 (0)