Skip to content

Commit

Permalink
new version check, change case save mode
Browse files Browse the repository at this point in the history
  • Loading branch information
soloPi committed Jul 18, 2019
1 parent 389e0dc commit 3959b1d
Show file tree
Hide file tree
Showing 21 changed files with 1,208 additions and 66 deletions.
6 changes: 6 additions & 0 deletions src/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ void *(**On*Event);
-keep interface com.alipay.hulu.shared.node.utils.prepare.PrepareWorker { *; }
-keep @com.alipay.hulu.shared.node.utils.prepare.PrepareWorker$PrepareTool class * implements com.alipay.hulu.shared.node.utils.prepare.PrepareWorker { *; }

#Github Replease
-keep class com.alipay.hulu.bean.GithubReleaseBean { *; }
-keep class com.alipay.hulu.bean.GithubReleaseBean$AuthorBean { *; }
-keep class com.alipay.hulu.bean.GithubReleaseBean$AssetsBean { *; }
-keep class com.alipay.hulu.bean.GithubReleaseBean$AssetsBean$UploaderBean { *; }

# 三方库
-keep class com.cgutman.adblib.** {*;}
-keep class com.mdit.library.** {*;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ private void wrapRecordCase() {
* 更新本地用例
*/
private void updateLocalCase() {
wrapRecordCase();
BackgroundExecutor.execute(new Runnable() {
@Override
public void run() {
wrapRecordCase();
GreenDaoManager.getInstance().getRecordCaseInfoDao().save(mRecordCase);
toastShort("更新成功");
InjectorService.g().pushMessage(NewRecordActivity.NEED_REFRESH_LOCAL_CASES_LIST);
Expand Down
60 changes: 45 additions & 15 deletions src/app/src/main/java/com/alipay/hulu/activity/IndexActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.alibaba.fastjson.JSONObject;
import com.alipay.hulu.R;
import com.alipay.hulu.activity.entry.EntryActivity;
import com.alipay.hulu.bean.GithubReleaseBean;
import com.alipay.hulu.common.application.LauncherApplication;
import com.alipay.hulu.common.constant.Constant;
import com.alipay.hulu.common.service.SPService;
Expand All @@ -50,6 +51,7 @@
import com.alipay.hulu.ui.HeadControlPanel;
import com.alipay.hulu.upgrade.PatchRequest;
import com.alipay.hulu.util.SystemUtil;
import com.alipay.hulu.util.UpgradeUtil;
import com.alipay.hulu.util.ZipUtil;

import java.io.File;
Expand All @@ -72,7 +74,6 @@

public class IndexActivity extends BaseActivity {
private static final String TAG = IndexActivity.class.getSimpleName();
private static final String DISPLAY_ALERT_INFO = "displayAlertInfo";

private HeadControlPanel mPanel;
private GridView mGridView;
Expand All @@ -86,23 +87,48 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initData();
loadOthers();

// 免责弹窗
boolean showDisplay = SPService.getBoolean(DISPLAY_ALERT_INFO, true);
if (showDisplay) {
new AlertDialog.Builder(this).setTitle("免责声明")
.setMessage(R.string.disclaimer)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
// check update
if (SPService.getBoolean(SPService.KEY_CHECK_UPDATE, true)) {
BackgroundExecutor.execute(new Runnable() {
@Override
public void run() {
UpgradeUtil.checkForUpdate(new UpgradeUtil.CheckUpdateListener() {
@Override
public void onNoUpdate() {

}

@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
public void onNewUpdate(final GithubReleaseBean release) {
runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialog.Builder(IndexActivity.this).setTitle("发现新版本: " + release.getTag_name())
.setMessage(release.getBody())
.setPositiveButton("前往更新", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse(release.getHtml_url());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
}
});
}
}).setNegativeButton("不再提示", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
SPService.putBoolean(DISPLAY_ALERT_INFO, false);
dialog.dismiss();
public void onUpdateFailed(Throwable t) {

}
}).show();
});
}
});
}
}

Expand Down Expand Up @@ -299,7 +325,11 @@ public static class Entry {

public Entry(EntryActivity activity, Class<? extends Activity> target) {
this.iconId = activity.icon();
this.name = activity.name();
String name = activity.name();
if (activity.nameRes() > 0) {
name = StringUtil.getString(activity.nameRes());
}
this.name = name;
permissions = activity.permissions();
level = activity.level();
targetActivity = target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/**
* Created by lezhou.wyl on 2018/2/1.
*/
@EntryActivity(icon = R.drawable.icon_luxiang, name = "录制回放", permissions = {"adb", "float", "toast:请将Soloπ添加到后台白名单中"}, index = 1, cornerText = "图像", cornerPersist = 3, cornerBg = 0xFFFF5900)
@EntryActivity(icon = R.drawable.icon_luxiang, nameRes = R.string.record__name, permissions = {"adb", "float", "toast:请将Soloπ添加到后台白名单中"}, index = 1, cornerText = "New", cornerPersist = 3, cornerBg = 0xFFFF5900)
public class NewRecordActivity extends BaseActivity {

private static final String TAG = NewRecordActivity.class.getSimpleName();
Expand Down Expand Up @@ -121,8 +121,7 @@ public void notifyCaseListChange() {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_record_new);
InjectorService injectorService = LauncherApplication.getInstance().findServiceByName(InjectorService.class.getName());
injectorService.register(this);
InjectorService.g().register(this);

initDrawerLayout();
initAppList();
Expand Down Expand Up @@ -194,7 +193,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
public void onPermissionResult(boolean result, String reason) {
if (result) {

showProgressDialog("正在加载中");
showProgressDialog(getString(R.string.record__preparing));

BackgroundExecutor.execute(new Runnable() {
@Override
Expand All @@ -220,7 +219,7 @@ public void run() {
@Override
public void run() {
dismissProgressDialog();
Toast.makeText(NewRecordActivity.this, "环境准备失败", Toast.LENGTH_SHORT).show();
Toast.makeText(NewRecordActivity.this, R.string.record__prepare_failed, Toast.LENGTH_SHORT).show();
}
});
}
Expand All @@ -237,7 +236,7 @@ public void run() {

private void initHeadPanel() {
mPanel = (HeadControlPanel) findViewById(R.id.head_layout);
mPanel.setMiddleTitle("录制回放");
mPanel.setMiddleTitle(getString(R.string.record__name));
mPanel.setBackIconClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -344,7 +343,7 @@ private void initAppHeadView() {
@Override
public void onClick(View v) {
if (StringUtil.isEmpty(mCaseName.getText().toString().trim())) {
Toast.makeText(NewRecordActivity.this, "用例名不能为空", Toast.LENGTH_SHORT).show();
Toast.makeText(NewRecordActivity.this, R.string.record__case_name_empty, Toast.LENGTH_SHORT).show();
return;
}

Expand Down Expand Up @@ -378,7 +377,7 @@ public void onClick(View v) {
public void onPermissionResult(boolean result, String reason) {
if (result) {

showProgressDialog("正在加载中");
showProgressDialog(getString(R.string.record__preparing));

BackgroundExecutor.execute(new Runnable() {
@Override
Expand All @@ -404,7 +403,7 @@ public void run() {
@Override
public void run() {
dismissProgressDialog();
Toast.makeText(NewRecordActivity.this, "环境准备失败", Toast.LENGTH_SHORT).show();
Toast.makeText(NewRecordActivity.this, R.string.record__prepare_failed, Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.alipay.hulu.shared.io.bean.RecordCaseInfo;
import com.alipay.hulu.shared.io.db.GreenDaoManager;
import com.alipay.hulu.shared.io.db.RecordCaseInfoDao;
import com.alipay.hulu.shared.io.util.OperationStepUtil;
import com.alipay.hulu.shared.node.action.OperationMethod;
import com.alipay.hulu.shared.node.tree.export.bean.OperationStep;
import com.alipay.hulu.ui.HeadControlPanel;
Expand Down Expand Up @@ -93,6 +94,9 @@ public class SettingsActivity extends BaseActivity {
private View mDisplaySystemAppSettingWrapper;
private TextView mDisplaySystemAppSettingInfo;

private View mCheckUpdateSettingWrapper;
private TextView mCheckUpdateSettingInfo;

private View mBaseDirSettingWrapper;
private TextView mBaseDirSettingInfo;

Expand Down Expand Up @@ -330,18 +334,18 @@ public void onDialogPositive(List<String> data) {
public void onClick(View v) {
new AlertDialog.Builder(SettingsActivity.this, R.style.SimpleDialogTheme)
.setMessage("回放时是否高亮待操作控件?")
.setPositiveButton("是", new DialogInterface.OnClickListener() {
.setPositiveButton(R.string.constant__yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SPService.putBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true);
mHightlightSettingInfo.setText("是");
mHightlightSettingInfo.setText(R.string.constant__yes);
dialog.dismiss();
}
}).setNegativeButton("否", new DialogInterface.OnClickListener() {
}).setNegativeButton(R.string.constant__no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SPService.putBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, false);
mHightlightSettingInfo.setText("否");
mHightlightSettingInfo.setText(R.string.constant__no);
dialog.dismiss();
}
}).show();
Expand Down Expand Up @@ -512,7 +516,7 @@ private void showMultipleEditDialog(final OnDialogResultListener listener, Strin
new AlertDialog.Builder(SettingsActivity.this, R.style.AppDialogTheme)
.setTitle(title)
.setView(v)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
.setPositiveButton(R.string.constant__confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
List<String> result = new ArrayList<>(editTexts.size() + 1);
Expand All @@ -527,7 +531,7 @@ public void onClick(DialogInterface dialog, int which) {
}
dialog.dismiss();
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
}).setNegativeButton(R.string.constant__cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Expand All @@ -544,7 +548,7 @@ private void initView() {
mRecordScreenUploadInfo = (TextView) findViewById(R.id.recordscreen_upload_setting_info);
String path = SPService.getString(SPService.KEY_RECORD_SCREEN_UPLOAD);
if (StringUtil.isEmpty(path)) {
mRecordScreenUploadInfo.setText("未设置");
mRecordScreenUploadInfo.setText(R.string.settings__unset);
} else {
mRecordScreenUploadInfo.setText(path);
}
Expand All @@ -553,7 +557,7 @@ private void initView() {
mRecordUploadInfo = (TextView) findViewById(R.id.performance_upload_setting_info);
path = SPService.getString(SPService.KEY_PERFORMANCE_UPLOAD);
if (StringUtil.isEmpty(path)) {
mRecordUploadInfo.setText("未设置");
mRecordUploadInfo.setText(R.string.settings__unset);
} else {
mRecordUploadInfo.setText(path);
}
Expand All @@ -578,15 +582,24 @@ private void initView() {

mHightlightSettingWrapper = findViewById(R.id.replay_highlight_setting_wrapper);
mHightlightSettingInfo = (TextView) findViewById(R.id.replay_highlight_setting_info);
mHightlightSettingInfo.setText(SPService.getBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true)? "是": "否");
mHightlightSettingInfo.setText(SPService.getBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true)? R.string.constant__yes: R.string.constant__no);

mDisplaySystemAppSettingWrapper = findViewById(R.id.display_system_app_setting_wrapper);
mDisplaySystemAppSettingInfo = (TextView) findViewById(R.id.display_system_app_setting_info);
boolean displaySystemApp = SPService.getBoolean(SPService.KEY_DISPLAY_SYSTEM_APP, false);
if (displaySystemApp) {
mDisplaySystemAppSettingInfo.setText("是");
mDisplaySystemAppSettingInfo.setText(R.string.constant__yes);
} else {
mDisplaySystemAppSettingInfo.setText(R.string.constant__no);
}

mCheckUpdateSettingWrapper = findViewById(R.id.check_update_setting_wrapper);
mCheckUpdateSettingInfo = (TextView) findViewById(R.id.check_update_setting_info);
boolean checkUpdate = SPService.getBoolean(SPService.KEY_CHECK_UPDATE, true);
if (checkUpdate) {
mCheckUpdateSettingInfo.setText(R.string.constant__yes);
} else {
mDisplaySystemAppSettingInfo.setText("否");
mCheckUpdateSettingInfo.setText(R.string.constant__no);
}

mBaseDirSettingWrapper = findViewById(R.id.base_dir_setting_wrapper);
Expand All @@ -595,7 +608,7 @@ private void initView() {

mAesSeedSettingWrapper = findViewById(R.id.aes_seed_setting_wrapper);
mAesSeedSettingInfo = (TextView) findViewById(R.id.aes_seed_setting_info);
mAesSeedSettingInfo.setText(SPService.getString(SPService.KEY_AES_KEY, "com.alipay.hulu"));
mAesSeedSettingInfo.setText(SPService.getString(SPService.KEY_AES_KEY, AESUtils.DEFAULT_AES_KEY));

mClearFilesSettingWrapper = findViewById(R.id.clear_files_setting_wrapper);
mClearFilesSettingInfo = (TextView) findViewById(R.id.clear_files_setting_info);
Expand All @@ -604,9 +617,9 @@ private void initView() {
mHideLogSettingInfo = (TextView) findViewById(R.id.hide_log_setting_info);
boolean hideLog = SPService.getBoolean(SPService.KEY_HIDE_LOG, true);
if (hideLog) {
mHideLogSettingInfo.setText("是");
mHideLogSettingInfo.setText(R.string.constant__yes);
} else {
mHideLogSettingInfo.setText("否");
mHideLogSettingInfo.setText(R.string.constant__no);
}

mImportCaseSettingWrapper = findViewById(R.id.import_case_setting_wrapper);
Expand Down Expand Up @@ -647,7 +660,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
* @param newSeed
*/
private void updateStoredRecords(final String oldSeed, final String newSeed) {
showProgressDialog("开始更新用例");
showProgressDialog(getString(R.string.settings__start_update_cases));
BackgroundExecutor.execute(new Runnable() {
@Override
public void run() {
Expand All @@ -658,7 +671,7 @@ public void run() {

if (cases != null && cases.size() > 0) {
for (int i = 0; i < cases.size(); i++) {
showProgressDialog("更新用例(" + (i + 1) + "/" + cases.size() + ")");
showProgressDialog(getString(R.string.settings__updating_cases, i + 1, cases.size()));
RecordCaseInfo caseInfo = cases.get(i);
GeneralOperationLogBean generalOperation;
try {
Expand All @@ -672,6 +685,10 @@ public void run() {
if (generalOperation == null) {
continue;
}

// load file content
OperationStepUtil.afterLoad(generalOperation);

List<OperationStep> steps = generalOperation.getSteps();
if (generalOperation.getSteps() != null) {
for (OperationStep step : steps) {
Expand All @@ -691,6 +708,7 @@ public void run() {
}
}
}
OperationStepUtil.beforeStore(generalOperation);

// 更新operationLog字段
caseInfo.setOperationLog(JSON.toJSONString(generalOperation));
Expand Down
Loading

0 comments on commit 3959b1d

Please sign in to comment.