Skip to content

Commit

Permalink
[Exposed-UI] do not show animation when app foreground.
Browse files Browse the repository at this point in the history
  • Loading branch information
维术 committed Jan 7, 2018
1 parent 2279e97 commit d6b7d09
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,8 @@

import java.io.IOException;

import io.virtualapp.R;

/**
* @author Lody
*/
Expand All @@ -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 {
Expand All @@ -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();
}
}

Expand Down
21 changes: 19 additions & 2 deletions VirtualApp/app/src/main/java/io/virtualapp/home/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions VirtualApp/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
\n遇到问题请详细描述你的机型,系统版本,ROM,操作流程,问题情况,如果是开发者,最好能提供Logcat日志;谢谢配合(简单的"用不了,有问题, 黑屏了"等等解决不了任何问题) 欢迎提出任何有价值的BUG和建议 :)\n\n
QQ群:597478474</string>
<string name="menu_reboot">重启</string>
<string name="installing_tips">正在安装 %1$s…</string>
<string name="update_success_tips">%1$s 更新成功!</string>
<string name="install_success_tips">模块安装完后需要去XposedInstaller的模块设置里勾选才能生效哦~</string>
<string name="install_fail_tips">%1$s 安装失败,错误码: %2$s</string>
</resources>
4 changes: 4 additions & 0 deletions VirtualApp/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
<string name="menu_feedback_string">Project: https://github.com/android-hacker/VAExposed\n Feedback:https://github.com/android-hacker/exposed/issues\n\n
QQ群:597478474</string>
<string name="menu_reboot">Reboot</string>
<string name="installing_tips">Installing %1$s…</string>
<string name="update_success_tips">Update %1$s success!</string>
<string name="install_success_tips">Xposed module will not take effect after check it in XposedInstaller\'s module setting!</string>
<string name="install_fail_tips">Install %1$s failed: %2$s</string>
</resources>

0 comments on commit d6b7d09

Please sign in to comment.