Skip to content

Commit eab7c61

Browse files
committed
search local sheet & version 24
1 parent 0d1aee5 commit eab7c61

2 files changed

Lines changed: 119 additions & 11 deletions

File tree

source/SkyAutoplayer.js

Lines changed: 114 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ sheetmgr = {
8888
}
8989
return this.cachedLocalSheetList;
9090
},
91+
92+
filterLocalSheet: function(filterBlock, listener) {
93+
var resultList = [];
94+
this.getLocalSheetList(listener).map(function(element, index) {
95+
if(filterBlock(element)) resultList.push(element);
96+
});
97+
return resultList;
98+
},
99+
91100
getOnlineSharedSheetInfoList: function(forceRefresh) {
92101
if(this.cachedOnlineSharedSheetInfoList.length == 0 || forceRefresh) {
93102
this.__internal_fetchOnlineSharedSheets();
@@ -373,7 +382,7 @@ config = {
373382
_global_storage: null,
374383

375384
values: {
376-
currentVersion: 23,
385+
currentVersion: 24,
377386
gitVersion: "",
378387

379388
key_coordinates15: [],
@@ -1415,7 +1424,8 @@ gui = {
14151424

14161425
//internal methods
14171426
__internal_show: function s(content) { gui.run(function(){
1418-
s.index = gui.main.current = content.index;
1427+
s.index = content.index;
1428+
gui.main.current = content.index;
14191429
s.initial = false;
14201430
if(!gui.main.isShowing) { //create a new window and show content view
14211431
gui.main._global_base = new android.widget.LinearLayout(ctx);
@@ -1641,7 +1651,9 @@ gui = {
16411651
}
16421652
s["navigationBtn" + i].setOnClickListener(new android.view.View.OnClickListener({
16431653
onClick: function(view) { if(gui.main.current_navigation_selection != Number(view.getId())) {
1644-
if(typeof(gui.main.currentPageChangeListener) == "function") gui.main.currentPageChangeListener(s, content);
1654+
if(typeof(gui.main.currentPageChangeListener) == "function") {
1655+
gui.main.currentPageChangeListener(s, content);
1656+
}
16451657
gui.main.__internal_show(gui.main.views[Number(view.getId())]);
16461658
gui.main.current_navigation_selection = Number(view.getId());
16471659
}}
@@ -2776,8 +2788,18 @@ gui.dialogs.showProgressDialog(function(o) {
27762788
func: [{
27772789
icon: "refresh",
27782790
onClick: function(s, selfContent) {
2791+
if(s.ns0_isShowingSearchEditTextView) selfContent.removeSearchEditTextView(s, selfContent);
27792792
selfContent.getSheetList(s, true);
27802793
},
2794+
}, {
2795+
icon: "search",
2796+
onClick: function(s, selfContent) {
2797+
if(s.ns0_isShowingSearchEditTextView) {
2798+
selfContent.removeSearchEditTextView(s, selfContent);
2799+
} else {
2800+
selfContent.showSearchEditTextView(s, selfContent);
2801+
}
2802+
},
27812803
}],
27822804
view: function(s) {
27832805
s.ns0_rl = new android.widget.RelativeLayout(ctx);
@@ -3036,12 +3058,83 @@ gui.dialogs.showProgressDialog(function(o) {
30363058
update: function(s) {
30373059
if(s.initial) this.getSheetList(s, false);
30383060
},
3039-
getSheetList: function(s, isForce) {
3061+
3062+
onPageChanged: function(s, selfContent) {
3063+
if(s.ns0_isShowingSearchEditTextView) {
3064+
selfContent.removeSearchEditTextView(s);
3065+
}
3066+
},
3067+
3068+
showSearchEditTextView: function(s, selfContent) {
3069+
gui.main.setFuncClickable(s.index, false);
3070+
s.ns0_isShowingSearchEditTextView = true;
3071+
s.ns0_searchEditText = new android.widget.EditText(ctx);
3072+
s.ns0_searchEditText.setGravity(android.view.Gravity.LEFT | android.view.Gravity.CENTER);
3073+
s.ns0_searchEditText.setLayoutParams(new android.widget.RelativeLayout.LayoutParams(-2, -1));
3074+
s.ns0_searchEditText.setPadding(dp * 5, dp * 5, dp * 5, dp * 5);
3075+
s.ns0_searchEditText.getLayoutParams().addRule(android.widget.RelativeLayout.ALIGN_PARENT_LEFT);
3076+
s.ns0_searchEditText.setTextSize(15);
3077+
s.ns0_searchEditText.setTextColor(gui.config.colors[config.values.theme].text);
3078+
s.ns0_searchEditText.setHintTextColor(gui.config.colors[config.values.theme].sec_text);
3079+
s.ns0_searchEditText.setHint(config.languages[config.values.lang].page_sc_search_hint);
3080+
s.ns0_searchEditText.setAlpha(0);
3081+
s.ns0_searchEditText.setOnClickListener(new android.view.View.OnClickListener({
3082+
onClick: function(view) {
3083+
view.setFocusable(true);
3084+
view.setFocusableInTouchMode(true);
3085+
view.requestFocus();
3086+
ctx.getSystemService(android.content.Context.INPUT_METHOD_SERVICE).showSoftInput(view, 0);
3087+
}
3088+
}));
3089+
s.ns0_searchEditText.setOnKeyListener(new android.view.View.OnKeyListener({
3090+
onKey: function(view, keycode, event) {
3091+
if (keycode == android.view.KeyEvent.KEYCODE_ENTER && event.getAction() == android.view.KeyEvent.ACTION_DOWN) {
3092+
selfContent.getSheetList(s, false, function(item) {
3093+
var regExp = new RegExp(view.getText(), "gi");
3094+
return regExp.test(item.fileName) || regExp.test(item.name);
3095+
});
3096+
return true;
3097+
}
3098+
return false;
3099+
},
3100+
}));
3101+
gui.main._global_statusbar.addView(s.ns0_searchEditText);
3102+
s.ns0_searchEditText.setFocusable(true);
3103+
s.ns0_searchEditText.setFocusableInTouchMode(true);
3104+
s.ns0_searchEditText.requestFocus();
3105+
ctx.getSystemService(android.content.Context.INPUT_METHOD_SERVICE).showSoftInput(s.ns0_searchEditText, 0);
3106+
gui.main._global_title.setEnabled(false);
3107+
gui.main._global_title.setClickable(false);
3108+
gui.utils.value_animation("Float", 0, 1.0, 300 , new android.view.animation.DecelerateInterpolator(), function(anim) {
3109+
s.ns0_searchEditText.setAlpha(anim.getAnimatedValue());
3110+
gui.main._global_title.setAlpha(1.0 - anim.getAnimatedValue());
3111+
if(anim.getAnimatedValue() == 1.0) gui.main.setFuncClickable(s.index, true);
3112+
});
3113+
},
3114+
3115+
removeSearchEditTextView: function(s, selfContent) { try {
3116+
s.ns0_isShowingSearchEditTextView = false;
3117+
gui.main.setFuncClickable(s.index, false);
3118+
s.ns0_searchEditText.setEnabled(false);
3119+
s.ns0_searchEditText.setClickable(false);
3120+
gui.main._global_title.setEnabled(true);
3121+
gui.main._global_title.setClickable(true);
3122+
gui.utils.value_animation("Float", 0, 1.0, 300 , new android.view.animation.DecelerateInterpolator(), function(anim) {
3123+
s.ns0_searchEditText.setAlpha(1.0 - anim.getAnimatedValue());
3124+
gui.main._global_title.setAlpha(anim.getAnimatedValue());
3125+
if(anim.getAnimatedValue() == 1.0) {
3126+
gui.main._global_statusbar.removeView(s.ns0_searchEditText);
3127+
gui.main.setFuncClickable(s.index, true);
3128+
}
3129+
});
3130+
} catch (e) { error(e); }},
3131+
3132+
getSheetList: function(s, isForce, filterBlock) {
30403133
gui.run(function() {
30413134
s.ns0_progress.setIndeterminate(true);
30423135
s.ns0_listAdapterController.removeAll();
30433136
gui.main.setFuncClickable(s.index, false);
3044-
gui.utils.value_animation("Float", 0, 1.0, 200, new android.view.animation.DecelerateInterpolator(), function(anim) {
3137+
if(typeof(filterBlock) != "function") gui.utils.value_animation("Float", 0, 1.0, 200, new android.view.animation.DecelerateInterpolator(), function(anim) {
30453138
gui.main._global_title.setAlpha(anim.getAnimatedValue());
30463139
});
30473140
gui.utils.value_animation("Float", 1.0, 0, 100, new android.view.animation.DecelerateInterpolator(), function(anim) {
@@ -3061,11 +3154,17 @@ gui.dialogs.showProgressDialog(function(o) {
30613154
});//修改乐谱键位提示
30623155
s.ns0_listAdapterController.notifyChange();
30633156
threads.start(function() {
3064-
sheetmgr.getLocalSheetList(isForce, function(successCount, failedCount) {
3065-
gui.run(function(){
3066-
gui.main._global_title.setText(String.format(config.languages[config.values.lang].page_lc_loading_sheet, successCount, failedCount));
3157+
var list;
3158+
if(typeof(filterBlock) != "function") {
3159+
list = sheetmgr.getLocalSheetList(isForce, function(successCount, failedCount) {
3160+
gui.run(function(){
3161+
gui.main._global_title.setText(String.format(config.languages[config.values.lang].page_lc_loading_sheet, successCount, failedCount));
3162+
});
30673163
});
3068-
}).map(function(e, i) {
3164+
} else {
3165+
list = sheetmgr.filterLocalSheet(filterBlock);
3166+
}
3167+
list.map(function(e, i) {
30693168
gui.run(function(){
30703169
if(!e.failed || config.values.showFailedSheets) {
30713170
s.ns0_listAdapterController.add((function(item) {
@@ -3080,11 +3179,15 @@ gui.dialogs.showProgressDialog(function(o) {
30803179
s.ns0_listAdapterController.notifyChange();
30813180
gui.main._global_title.setText(gui.main.getPageInfo(s.index).title);
30823181
gui.utils.value_animation("Float", 0, 1.0, 200, new android.view.animation.DecelerateInterpolator(), function(anim) {
3083-
gui.main._global_title.setAlpha(anim.getAnimatedValue());
30843182
s.ns0_listView.setAlpha(anim.getAnimatedValue());
30853183
s.ns0_progress.setAlpha(1 - anim.getAnimatedValue());
30863184
if(anim.getAnimatedValue() == 1.0) s.ns0_progress.setIndeterminate(false);
30873185
});
3186+
if(typeof(filterBlock) != "function") {
3187+
gui.utils.value_animation("Float", 0, 1.0, 200, new android.view.animation.DecelerateInterpolator(), function(anim) {
3188+
gui.main._global_title.setAlpha(anim.getAnimatedValue());
3189+
});
3190+
}
30883191
});
30893192
});
30903193
}
@@ -3430,7 +3533,7 @@ gui.dialogs.showProgressDialog(function(o) {
34303533
gui.main.setFuncClickable(s.index, true);
34313534
}
34323535
});
3433-
} catch (e) {}},
3536+
} catch (e) { error(e); }},
34343537

34353538
update: function(s) {
34363539
if(s.initial) this.getOnlineSheetList(s, false);

update_log.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
版本: 24
2+
更新时间: 2022.03.06 11:30
3+
更新内容:
4+
* 新增:本地乐谱搜索。
5+
16
版本: 23
27
更新时间: 2021.6.29 13:10
38
更新内容:

0 commit comments

Comments
 (0)