-
Notifications
You must be signed in to change notification settings - Fork 127
/
action_legado_myself.sh
105 lines (94 loc) · 3.93 KB
/
action_legado_myself.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
source $GITHUB_WORKSPACE/action_util.sh
#阅读3.0自用定制脚本
function build_gradle_setting()
{
debug "maven中央仓库回归"
sed "/google()/i\ mavenCentral()" $APP_WORKSPACE/build.gradle -i
debug "Speed Up Gradle"
sed -e '/android {/r '"$GITHUB_WORKSPACE/.github/legado/speedup.gradle"'' \
-e '/kapt {/a\ useBuildCache = true' \
-e '/minSdkVersion/c\ minSdkVersion 26' \
$APP_WORKSPACE/app/build.gradle -i
}
function bookshelfAdd_no_alert()
{
debug "关闭加入书架提示"
find $APP_WORKSPACE/app/src -regex '.*/ReadBookActivity.kt' -exec \
sed -e '/fun finish()/,/fun onDestroy()/{s/alert/\/*&/;s/show()/&*\//}' \
-e '/!ReadBook.inBookshelf/a\viewModel.removeFromBookshelf{ super.finish() }' \
{} -i \;
}
function exploreShow_be_better()
{
debug "发现书籍界面优化"
find $APP_WORKSPACE/app/src -regex '.*/ExploreShowActivity.kt' -exec \
sed -e "/loadMoreView.error(it)/i\isLoading = false" \
-e "/ExploreShowActivity/i\import io.legado.app.utils.longToastOnUi" \
-e '/loadMoreView.error(it)/i\longToastOnUi(it)' \
-e 's/loadMoreView.error(it)/loadMoreView.error("目标网站连接失败或超时")/' \
{} -i \;
find $APP_WORKSPACE/app/src -regex '.*/ExploreShowViewModel.kt' -exec \
sed "s/30000L/8000L/" {} -i \;
}
function explore_can_search()
{
debug "发现界面支持搜索书籍"
find $APP_WORKSPACE/app/src -regex '.*/ExploreFragment.kt' -exec \
sed -e 's/getString(R.string.screen_find)/"搜索书籍、书源"/' \
-e '/fun initSearchView()/i\override fun onResume(){super.onResume();searchView.clearFocus()}' \
-e '/ExploreFragment/i\import io.legado.app.ui.book.search.SearchActivity' \
-e '/onQueryTextSubmit/a\if(!query?.contains("group:")!!){startActivity<SearchActivity> { putExtra("key", query) }}' \
{} -i \;
}
function rhino_safe_js()
{
debug "safe JsExtensions.kt"
if version_ge "$APP_TAG" "3.21.021012"; then
sed -e '/^import io.legado.app.App$/c\import splitties.init.appCtx' \
-e 's/(App.INSTANCE)/(appCtx)/' \
$GITHUB_WORKSPACE/.github/fake/safe_JsExtensions.kt -i
fi
if version_ge "$APP_TAG" "3.21.031511"; then
sed "s/str.htmlFormat()/HtmlFormatter.formatKeepImg(str)/" \
$GITHUB_WORKSPACE/.github/fake/safe_JsExtensions.kt -i
fi
find $APP_WORKSPACE/app/src -type d -regex '.*/app/help' -exec \
cp $GITHUB_WORKSPACE/.github/fake/safe_JsExtensions.kt {}/JsExtensions.kt \;
debug "开启Rhino安全沙箱,移步https://github.com/10bits/rhino-android"
sed "/gedoor:rhino-android/c\ implementation 'com.github.10bits:rhino-android:1.6'" \
$APP_WORKSPACE/app/build.gradle -i
}
function no_google_services()
{
debug "删除google services相关"
sed -e "/com.google.firebase/d" \
-e "/com.google.gms/d" \
-e "/androidx.appcompat/a\ implementation 'androidx.documentfile:documentfile:1.0.1'" \
$APP_WORKSPACE/app/build.gradle -i
}
function my_launcher_icon(){
debug "替换图标"
find $APP_WORKSPACE/app/src -type d -regex '.*/res/drawable' -exec \
cp $GITHUB_WORKSPACE/.github/legado/ic_launcher_my.xml {}/ic_launcher1.xml \;
find $APP_WORKSPACE/app/src -regex '.*/res/.*/ic_launcher.xml' -exec \
sed "/background/d" {} -i \;
}
function quick_checkSource(){
debug "快速校验书源"
find $APP_WORKSPACE/app/src -regex '.*/service/CheckSourceService.kt' -exec \
sed -e "/getBookInfoAwait/i\/*" \
-e "/timeout(/i\*/" \
-e '/exploreBookAwait/a\if(books.isEmpty()){throw Exception("发现书籍为空")}' \
{} -i \;
}
if [[ "$APP_NAME" == "legado" ]] && [[ "$REPO_ACTOR" == "10bits" ]]; then
exploreShow_be_better;
#bookshelfAdd_no_alert;
build_gradle_setting;
explore_can_search;
no_google_services;
#rhino_safe_js;
my_launcher_icon;
#quick_checkSource;
fi