Skip to content

Commit 3959b1d

Browse files
committed
new version check, change case save mode
1 parent 389e0dc commit 3959b1d

21 files changed

Lines changed: 1208 additions & 66 deletions

File tree

src/app/proguard-rules.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ void *(**On*Event);
177177
-keep interface com.alipay.hulu.shared.node.utils.prepare.PrepareWorker { *; }
178178
-keep @com.alipay.hulu.shared.node.utils.prepare.PrepareWorker$PrepareTool class * implements com.alipay.hulu.shared.node.utils.prepare.PrepareWorker { *; }
179179

180+
#Github Replease
181+
-keep class com.alipay.hulu.bean.GithubReleaseBean { *; }
182+
-keep class com.alipay.hulu.bean.GithubReleaseBean$AuthorBean { *; }
183+
-keep class com.alipay.hulu.bean.GithubReleaseBean$AssetsBean { *; }
184+
-keep class com.alipay.hulu.bean.GithubReleaseBean$AssetsBean$UploaderBean { *; }
185+
180186
# 三方库
181187
-keep class com.cgutman.adblib.** {*;}
182188
-keep class com.mdit.library.** {*;}

src/app/src/main/java/com/alipay/hulu/activity/CaseEditActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ private void wrapRecordCase() {
164164
* 更新本地用例
165165
*/
166166
private void updateLocalCase() {
167-
wrapRecordCase();
168167
BackgroundExecutor.execute(new Runnable() {
169168
@Override
170169
public void run() {
170+
wrapRecordCase();
171171
GreenDaoManager.getInstance().getRecordCaseInfoDao().save(mRecordCase);
172172
toastShort("更新成功");
173173
InjectorService.g().pushMessage(NewRecordActivity.NEED_REFRESH_LOCAL_CASES_LIST);

src/app/src/main/java/com/alipay/hulu/activity/IndexActivity.java

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.alibaba.fastjson.JSONObject;
3737
import com.alipay.hulu.R;
3838
import com.alipay.hulu.activity.entry.EntryActivity;
39+
import com.alipay.hulu.bean.GithubReleaseBean;
3940
import com.alipay.hulu.common.application.LauncherApplication;
4041
import com.alipay.hulu.common.constant.Constant;
4142
import com.alipay.hulu.common.service.SPService;
@@ -50,6 +51,7 @@
5051
import com.alipay.hulu.ui.HeadControlPanel;
5152
import com.alipay.hulu.upgrade.PatchRequest;
5253
import com.alipay.hulu.util.SystemUtil;
54+
import com.alipay.hulu.util.UpgradeUtil;
5355
import com.alipay.hulu.util.ZipUtil;
5456

5557
import java.io.File;
@@ -72,7 +74,6 @@
7274

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

7778
private HeadControlPanel mPanel;
7879
private GridView mGridView;
@@ -86,23 +87,48 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8687
initData();
8788
loadOthers();
8889

89-
// 免责弹窗
90-
boolean showDisplay = SPService.getBoolean(DISPLAY_ALERT_INFO, true);
91-
if (showDisplay) {
92-
new AlertDialog.Builder(this).setTitle("免责声明")
93-
.setMessage(R.string.disclaimer)
94-
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
90+
// check update
91+
if (SPService.getBoolean(SPService.KEY_CHECK_UPDATE, true)) {
92+
BackgroundExecutor.execute(new Runnable() {
93+
@Override
94+
public void run() {
95+
UpgradeUtil.checkForUpdate(new UpgradeUtil.CheckUpdateListener() {
96+
@Override
97+
public void onNoUpdate() {
98+
99+
}
100+
95101
@Override
96-
public void onClick(DialogInterface dialog, int which) {
97-
dialog.dismiss();
102+
public void onNewUpdate(final GithubReleaseBean release) {
103+
runOnUiThread(new Runnable() {
104+
@Override
105+
public void run() {
106+
new AlertDialog.Builder(IndexActivity.this).setTitle("发现新版本: " + release.getTag_name())
107+
.setMessage(release.getBody())
108+
.setPositiveButton("前往更新", new DialogInterface.OnClickListener() {
109+
@Override
110+
public void onClick(DialogInterface dialog, int which) {
111+
Uri uri = Uri.parse(release.getHtml_url());
112+
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
113+
startActivity(intent);
114+
}
115+
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
116+
@Override
117+
public void onClick(DialogInterface dialog, int which) {
118+
dialog.dismiss();
119+
}
120+
}).show();
121+
}
122+
});
98123
}
99-
}).setNegativeButton("不再提示", new DialogInterface.OnClickListener() {
124+
100125
@Override
101-
public void onClick(DialogInterface dialog, int which) {
102-
SPService.putBoolean(DISPLAY_ALERT_INFO, false);
103-
dialog.dismiss();
126+
public void onUpdateFailed(Throwable t) {
127+
104128
}
105-
}).show();
129+
});
130+
}
131+
});
106132
}
107133
}
108134

@@ -299,7 +325,11 @@ public static class Entry {
299325

300326
public Entry(EntryActivity activity, Class<? extends Activity> target) {
301327
this.iconId = activity.icon();
302-
this.name = activity.name();
328+
String name = activity.name();
329+
if (activity.nameRes() > 0) {
330+
name = StringUtil.getString(activity.nameRes());
331+
}
332+
this.name = name;
303333
permissions = activity.permissions();
304334
level = activity.level();
305335
targetActivity = target;

src/app/src/main/java/com/alipay/hulu/activity/NewRecordActivity.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
/**
7272
* Created by lezhou.wyl on 2018/2/1.
7373
*/
74-
@EntryActivity(icon = R.drawable.icon_luxiang, name = "录制回放", permissions = {"adb", "float", "toast:请将Soloπ添加到后台白名单中"}, index = 1, cornerText = "图像", cornerPersist = 3, cornerBg = 0xFFFF5900)
74+
@EntryActivity(icon = R.drawable.icon_luxiang, nameRes = R.string.record__name, permissions = {"adb", "float", "toast:请将Soloπ添加到后台白名单中"}, index = 1, cornerText = "New", cornerPersist = 3, cornerBg = 0xFFFF5900)
7575
public class NewRecordActivity extends BaseActivity {
7676

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

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

197-
showProgressDialog("正在加载中");
196+
showProgressDialog(getString(R.string.record__preparing));
198197

199198
BackgroundExecutor.execute(new Runnable() {
200199
@Override
@@ -220,7 +219,7 @@ public void run() {
220219
@Override
221220
public void run() {
222221
dismissProgressDialog();
223-
Toast.makeText(NewRecordActivity.this, "环境准备失败", Toast.LENGTH_SHORT).show();
222+
Toast.makeText(NewRecordActivity.this, R.string.record__prepare_failed, Toast.LENGTH_SHORT).show();
224223
}
225224
});
226225
}
@@ -237,7 +236,7 @@ public void run() {
237236

238237
private void initHeadPanel() {
239238
mPanel = (HeadControlPanel) findViewById(R.id.head_layout);
240-
mPanel.setMiddleTitle("录制回放");
239+
mPanel.setMiddleTitle(getString(R.string.record__name));
241240
mPanel.setBackIconClickListener(new View.OnClickListener() {
242241
@Override
243242
public void onClick(View v) {
@@ -344,7 +343,7 @@ private void initAppHeadView() {
344343
@Override
345344
public void onClick(View v) {
346345
if (StringUtil.isEmpty(mCaseName.getText().toString().trim())) {
347-
Toast.makeText(NewRecordActivity.this, "用例名不能为空", Toast.LENGTH_SHORT).show();
346+
Toast.makeText(NewRecordActivity.this, R.string.record__case_name_empty, Toast.LENGTH_SHORT).show();
348347
return;
349348
}
350349

@@ -378,7 +377,7 @@ public void onClick(View v) {
378377
public void onPermissionResult(boolean result, String reason) {
379378
if (result) {
380379

381-
showProgressDialog("正在加载中");
380+
showProgressDialog(getString(R.string.record__preparing));
382381

383382
BackgroundExecutor.execute(new Runnable() {
384383
@Override
@@ -404,7 +403,7 @@ public void run() {
404403
@Override
405404
public void run() {
406405
dismissProgressDialog();
407-
Toast.makeText(NewRecordActivity.this, "环境准备失败", Toast.LENGTH_SHORT).show();
406+
Toast.makeText(NewRecordActivity.this, R.string.record__prepare_failed, Toast.LENGTH_SHORT).show();
408407
}
409408
});
410409
}

src/app/src/main/java/com/alipay/hulu/activity/SettingsActivity.java

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.alipay.hulu.shared.io.bean.RecordCaseInfo;
4949
import com.alipay.hulu.shared.io.db.GreenDaoManager;
5050
import com.alipay.hulu.shared.io.db.RecordCaseInfoDao;
51+
import com.alipay.hulu.shared.io.util.OperationStepUtil;
5152
import com.alipay.hulu.shared.node.action.OperationMethod;
5253
import com.alipay.hulu.shared.node.tree.export.bean.OperationStep;
5354
import com.alipay.hulu.ui.HeadControlPanel;
@@ -93,6 +94,9 @@ public class SettingsActivity extends BaseActivity {
9394
private View mDisplaySystemAppSettingWrapper;
9495
private TextView mDisplaySystemAppSettingInfo;
9596

97+
private View mCheckUpdateSettingWrapper;
98+
private TextView mCheckUpdateSettingInfo;
99+
96100
private View mBaseDirSettingWrapper;
97101
private TextView mBaseDirSettingInfo;
98102

@@ -330,18 +334,18 @@ public void onDialogPositive(List<String> data) {
330334
public void onClick(View v) {
331335
new AlertDialog.Builder(SettingsActivity.this, R.style.SimpleDialogTheme)
332336
.setMessage("回放时是否高亮待操作控件?")
333-
.setPositiveButton("是", new DialogInterface.OnClickListener() {
337+
.setPositiveButton(R.string.constant__yes, new DialogInterface.OnClickListener() {
334338
@Override
335339
public void onClick(DialogInterface dialog, int which) {
336340
SPService.putBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true);
337-
mHightlightSettingInfo.setText("是");
341+
mHightlightSettingInfo.setText(R.string.constant__yes);
338342
dialog.dismiss();
339343
}
340-
}).setNegativeButton("否", new DialogInterface.OnClickListener() {
344+
}).setNegativeButton(R.string.constant__no, new DialogInterface.OnClickListener() {
341345
@Override
342346
public void onClick(DialogInterface dialog, int which) {
343347
SPService.putBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, false);
344-
mHightlightSettingInfo.setText("否");
348+
mHightlightSettingInfo.setText(R.string.constant__no);
345349
dialog.dismiss();
346350
}
347351
}).show();
@@ -512,7 +516,7 @@ private void showMultipleEditDialog(final OnDialogResultListener listener, Strin
512516
new AlertDialog.Builder(SettingsActivity.this, R.style.AppDialogTheme)
513517
.setTitle(title)
514518
.setView(v)
515-
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
519+
.setPositiveButton(R.string.constant__confirm, new DialogInterface.OnClickListener() {
516520
@Override
517521
public void onClick(DialogInterface dialog, int which) {
518522
List<String> result = new ArrayList<>(editTexts.size() + 1);
@@ -527,7 +531,7 @@ public void onClick(DialogInterface dialog, int which) {
527531
}
528532
dialog.dismiss();
529533
}
530-
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
534+
}).setNegativeButton(R.string.constant__cancel, new DialogInterface.OnClickListener() {
531535
@Override
532536
public void onClick(DialogInterface dialog, int which) {
533537
dialog.dismiss();
@@ -544,7 +548,7 @@ private void initView() {
544548
mRecordScreenUploadInfo = (TextView) findViewById(R.id.recordscreen_upload_setting_info);
545549
String path = SPService.getString(SPService.KEY_RECORD_SCREEN_UPLOAD);
546550
if (StringUtil.isEmpty(path)) {
547-
mRecordScreenUploadInfo.setText("未设置");
551+
mRecordScreenUploadInfo.setText(R.string.settings__unset);
548552
} else {
549553
mRecordScreenUploadInfo.setText(path);
550554
}
@@ -553,7 +557,7 @@ private void initView() {
553557
mRecordUploadInfo = (TextView) findViewById(R.id.performance_upload_setting_info);
554558
path = SPService.getString(SPService.KEY_PERFORMANCE_UPLOAD);
555559
if (StringUtil.isEmpty(path)) {
556-
mRecordUploadInfo.setText("未设置");
560+
mRecordUploadInfo.setText(R.string.settings__unset);
557561
} else {
558562
mRecordUploadInfo.setText(path);
559563
}
@@ -578,15 +582,24 @@ private void initView() {
578582

579583
mHightlightSettingWrapper = findViewById(R.id.replay_highlight_setting_wrapper);
580584
mHightlightSettingInfo = (TextView) findViewById(R.id.replay_highlight_setting_info);
581-
mHightlightSettingInfo.setText(SPService.getBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true)? "是": "否");
585+
mHightlightSettingInfo.setText(SPService.getBoolean(SPService.KEY_HIGHLIGHT_REPLAY_NODE, true)? R.string.constant__yes: R.string.constant__no);
582586

583587
mDisplaySystemAppSettingWrapper = findViewById(R.id.display_system_app_setting_wrapper);
584588
mDisplaySystemAppSettingInfo = (TextView) findViewById(R.id.display_system_app_setting_info);
585589
boolean displaySystemApp = SPService.getBoolean(SPService.KEY_DISPLAY_SYSTEM_APP, false);
586590
if (displaySystemApp) {
587-
mDisplaySystemAppSettingInfo.setText("是");
591+
mDisplaySystemAppSettingInfo.setText(R.string.constant__yes);
592+
} else {
593+
mDisplaySystemAppSettingInfo.setText(R.string.constant__no);
594+
}
595+
596+
mCheckUpdateSettingWrapper = findViewById(R.id.check_update_setting_wrapper);
597+
mCheckUpdateSettingInfo = (TextView) findViewById(R.id.check_update_setting_info);
598+
boolean checkUpdate = SPService.getBoolean(SPService.KEY_CHECK_UPDATE, true);
599+
if (checkUpdate) {
600+
mCheckUpdateSettingInfo.setText(R.string.constant__yes);
588601
} else {
589-
mDisplaySystemAppSettingInfo.setText("否");
602+
mCheckUpdateSettingInfo.setText(R.string.constant__no);
590603
}
591604

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

596609
mAesSeedSettingWrapper = findViewById(R.id.aes_seed_setting_wrapper);
597610
mAesSeedSettingInfo = (TextView) findViewById(R.id.aes_seed_setting_info);
598-
mAesSeedSettingInfo.setText(SPService.getString(SPService.KEY_AES_KEY, "com.alipay.hulu"));
611+
mAesSeedSettingInfo.setText(SPService.getString(SPService.KEY_AES_KEY, AESUtils.DEFAULT_AES_KEY));
599612

600613
mClearFilesSettingWrapper = findViewById(R.id.clear_files_setting_wrapper);
601614
mClearFilesSettingInfo = (TextView) findViewById(R.id.clear_files_setting_info);
@@ -604,9 +617,9 @@ private void initView() {
604617
mHideLogSettingInfo = (TextView) findViewById(R.id.hide_log_setting_info);
605618
boolean hideLog = SPService.getBoolean(SPService.KEY_HIDE_LOG, true);
606619
if (hideLog) {
607-
mHideLogSettingInfo.setText("是");
620+
mHideLogSettingInfo.setText(R.string.constant__yes);
608621
} else {
609-
mHideLogSettingInfo.setText("否");
622+
mHideLogSettingInfo.setText(R.string.constant__no);
610623
}
611624

612625
mImportCaseSettingWrapper = findViewById(R.id.import_case_setting_wrapper);
@@ -647,7 +660,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
647660
* @param newSeed
648661
*/
649662
private void updateStoredRecords(final String oldSeed, final String newSeed) {
650-
showProgressDialog("开始更新用例");
663+
showProgressDialog(getString(R.string.settings__start_update_cases));
651664
BackgroundExecutor.execute(new Runnable() {
652665
@Override
653666
public void run() {
@@ -658,7 +671,7 @@ public void run() {
658671

659672
if (cases != null && cases.size() > 0) {
660673
for (int i = 0; i < cases.size(); i++) {
661-
showProgressDialog("更新用例(" + (i + 1) + "/" + cases.size() + ")");
674+
showProgressDialog(getString(R.string.settings__updating_cases, i + 1, cases.size()));
662675
RecordCaseInfo caseInfo = cases.get(i);
663676
GeneralOperationLogBean generalOperation;
664677
try {
@@ -672,6 +685,10 @@ public void run() {
672685
if (generalOperation == null) {
673686
continue;
674687
}
688+
689+
// load file content
690+
OperationStepUtil.afterLoad(generalOperation);
691+
675692
List<OperationStep> steps = generalOperation.getSteps();
676693
if (generalOperation.getSteps() != null) {
677694
for (OperationStep step : steps) {
@@ -691,6 +708,7 @@ public void run() {
691708
}
692709
}
693710
}
711+
OperationStepUtil.beforeStore(generalOperation);
694712

695713
// 更新operationLog字段
696714
caseInfo.setOperationLog(JSON.toJSONString(generalOperation));

0 commit comments

Comments
 (0)