From d6b7d0939022698bc94ce264e181ec83b04ced52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=B4=E6=9C=AF?= Date: Mon, 8 Jan 2018 01:23:18 +0800 Subject: [PATCH] [Exposed-UI] do not show animation when app foreground. --- .../delegate/MyAppRequestListener.java | 15 +++++++++---- .../java/io/virtualapp/home/HomeActivity.java | 21 +++++++++++++++++-- .../src/main/res/values-zh-rCN/strings.xml | 4 ++++ .../app/src/main/res/values/strings.xml | 4 ++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/VirtualApp/app/src/main/java/io/virtualapp/delegate/MyAppRequestListener.java b/VirtualApp/app/src/main/java/io/virtualapp/delegate/MyAppRequestListener.java index 707d3fa42..9f9c380fe 100644 --- a/VirtualApp/app/src/main/java/io/virtualapp/delegate/MyAppRequestListener.java +++ b/VirtualApp/app/src/main/java/io/virtualapp/delegate/MyAppRequestListener.java @@ -1,6 +1,7 @@ package io.virtualapp.delegate; import android.content.Context; +import android.content.res.Resources; import android.widget.Toast; import com.lody.virtual.client.core.InstallStrategy; @@ -9,6 +10,8 @@ import java.io.IOException; +import io.virtualapp.R; + /** * @author Lody */ @@ -23,7 +26,8 @@ public MyAppRequestListener(Context context) { @Override public void onRequestInstall(String path) { - Toast.makeText(context, "Installing: " + path, Toast.LENGTH_SHORT).show(); + Resources resources = VirtualCore.get().getContext().getResources(); + Toast.makeText(context, resources.getString(R.string.installing_tips, path), Toast.LENGTH_SHORT).show(); InstallResult res = VirtualCore.get().installPackage(path, InstallStrategy.UPDATE_IF_EXIST); if (res.isSuccess) { try { @@ -32,12 +36,15 @@ public void onRequestInstall(String path) { e.printStackTrace(); } if (res.isUpdate) { - Toast.makeText(context, "Update: " + res.packageName + " success!", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, resources.getString(R.string.update_success_tips, res.packageName), + Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(context, "Install: " + res.packageName + " success!", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, resources.getString(R.string.install_success_tips), + Toast.LENGTH_SHORT).show(); } } else { - Toast.makeText(context, "Install failed: " + res.error, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, resources.getString(R.string.install_fail_tips, res.packageName, res.error), + Toast.LENGTH_SHORT).show(); } } diff --git a/VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java b/VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java index 8f4542607..ad61036ec 100644 --- a/VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java +++ b/VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java @@ -81,12 +81,16 @@ public class HomeActivity extends VActivity implements HomeContract.HomeView { private VirtualCore.PackageObserver mPackageObserver = new VirtualCore.PackageObserver() { @Override public void onPackageInstalled(String packageName) throws RemoteException { - runOnUiThread(() -> mPresenter.dataChanged()); + if (!isForground) { + runOnUiThread(() -> mPresenter.dataChanged()); + } } @Override public void onPackageUninstalled(String packageName) throws RemoteException { - runOnUiThread(() -> mPresenter.dataChanged()); + if (!isForground) { + runOnUiThread(() -> mPresenter.dataChanged()); + } } @Override @@ -97,6 +101,7 @@ public void onPackageInstalledAsUser(int userId, String packageName) throws Remo public void onPackageUninstalledAsUser(int userId, String packageName) throws RemoteException { } }; + private boolean isForground = false; //endregion public static void goHome(Context context) { @@ -119,6 +124,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { VirtualCore.get().registerObserver(mPackageObserver); } + @Override + protected void onResume() { + super.onResume(); + isForground = true; + } + + @Override + protected void onStop() { + super.onStop(); + isForground = false; + } + @Override protected void onDestroy() { super.onDestroy(); diff --git a/VirtualApp/app/src/main/res/values-zh-rCN/strings.xml b/VirtualApp/app/src/main/res/values-zh-rCN/strings.xml index f10cf63e6..489417e19 100644 --- a/VirtualApp/app/src/main/res/values-zh-rCN/strings.xml +++ b/VirtualApp/app/src/main/res/values-zh-rCN/strings.xml @@ -30,4 +30,8 @@ \n遇到问题请详细描述你的机型,系统版本,ROM,操作流程,问题情况,如果是开发者,最好能提供Logcat日志;谢谢配合(简单的"用不了,有问题, 黑屏了"等等解决不了任何问题) 欢迎提出任何有价值的BUG和建议 :)\n\n QQ群:597478474 重启 + 正在安装 %1$s… + %1$s 更新成功! + 模块安装完后需要去XposedInstaller的模块设置里勾选才能生效哦~ + %1$s 安装失败,错误码: %2$s diff --git a/VirtualApp/app/src/main/res/values/strings.xml b/VirtualApp/app/src/main/res/values/strings.xml index 92c978e94..4c5ee90d1 100644 --- a/VirtualApp/app/src/main/res/values/strings.xml +++ b/VirtualApp/app/src/main/res/values/strings.xml @@ -29,4 +29,8 @@ Project: https://github.com/android-hacker/VAExposed\n Feedback:https://github.com/android-hacker/exposed/issues\n\n QQ群:597478474 Reboot + Installing %1$s… + Update %1$s success! + Xposed module will not take effect after check it in XposedInstaller\'s module setting! + Install %1$s failed: %2$s