Skip to content

Commit 0e64497

Browse files
committed
Stub: impl SplashWelcome
1 parent a92b038 commit 0e64497

File tree

8 files changed

+208
-15
lines changed

8 files changed

+208
-15
lines changed

app/src/main/assets/assets/anim.bshL.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,30 @@ splash_trans_override = "";
1717
splash_panel_title_size = 30;
1818
splash_panel_subtitle_size = 14;
1919
splashPanelAlpha = 90;
20+
//code executed before setting icon (size => icon size)
2021
iconCode = "";
22+
//Text paddding
2123
padding = 12;
24+
//default icon size
2225
splashIconSize = 3 * (splash_panel_title_size + splash_panel_subtitle_size) + padding;
26+
//splash is fullscreen?
2327
splash_fullscreen = true;
28+
//default background
2429
background_loading = new ColorDrawable(me.getResources().getColor(org.duangsuse.tree.R.color.brown));
30+
//see splash activity
2531
fortune_loading = " Loading…";
32+
//text colors
2633
splash_appname_color = Color.WHITE;
2734
splash_fortune_color = Color.WHITE;
2835
//which API to use? 0 == lwl hitkoto
2936
fortune_type = 0;
37+
//Title
3038
app_name = "树";
39+
//Theme, circular anim color
3140
circular_color = org.duangsuse.tree.R.color.brown;
3241
mTheme = org.duangsuse.tree.R.style.ThemeBrown;
3342

43+
//you can use this.interpreter.source(file_path) to execute custom script
3444
//how I get background?
3545
//leave blank to keep default
3646
fn_get_bg = "";

app/src/main/assets/libs/SnakeBar.bshL

Whitespace-only changes.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
//Shows welcome anim
1+
//Shows welcome anim
2+
me.beginActivity("splashWelcome");

app/src/main/assets/libs/fetchSplash.bshL

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import android.graphics.drawable.*;
55

66
SplashPicDir = me.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
77
//sets background var when finished
8-
void fetchSplash() {
8+
boolean fetchSplash() {
99
String[] files = SplashPicDir.list();
1010
if (files.length == 0) {
1111
init();
12-
return;
12+
return true;
1313
}
1414
selected_splash = files[randInt(0, files.length - 1)];
1515
loadSplash(selected_splash);
16+
return false;
1617
}
1718

1819
void loadSplash(nvme) {
@@ -23,6 +24,7 @@ void loadSplash(nvme) {
2324
}
2425

2526
void init() {
27+
app_name = "Press material tree...";
2628
me.Import("libs/SplashWelcome");
2729
}
2830

app/src/main/assets/mods.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
about "" sysadmin
2-
settings "" sysadmin
1+
about "" sysadmin ""
2+
settings "" sysadmin ""

app/src/main/assets/splash.bshA

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,11 @@ layoutParams.height = size;
111111
layoutParams.gravity = Gravity.TOP;
112112
b.setLayoutParams(layoutParams);
113113

114-
void em() { }
115-
116-
if (fn_get_bg == "") {
117-
me.Import("libs/fetchSplash");
118-
me.go("fetchSplash()", "em");
119-
} else {
120-
me.ngin.eval(fn_get_ng);
121-
}
114+
void ignore() { }
122115

123116
if (fn_get_subtitle == "") {
124117
me.Import("libs/fetchFortune");
125-
me.go("fetchFortune(" + String.valueOf(fortune_type) + ")", "em");
118+
me.go("fetchFortune(" + String.valueOf(fortune_type) + ")", "ignore");
126119
} else {
127120
me.ngin.eval(fn_get_subtitle);
128121
}
@@ -175,6 +168,17 @@ void cancelLaunch() {
175168
}
176169
}
177170

171+
void em() {
172+
if (Pthr == true)
173+
cancelLaunch();
174+
}
175+
if (fn_get_bg == "") {
176+
me.Import("libs/fetchSplash");
177+
me.go("fetchSplash()", "em");
178+
} else {
179+
me.ngin.eval(fn_get_ng);
180+
}
181+
178182
void start() {
179183
if (splash_trans_override == "") {
180184
top.wefor.circularanim.CircularAnim.fullActivity(me, b)
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
me.Import("libs/doImports");
2+
import android.graphics.*;
3+
import android.graphics.drawable.*;
4+
5+
import org.duangsuse.tree.R;
6+
7+
//why not make this as a module XD
8+
int randColor() {
9+
res = me.getResources();
10+
color = new int[5];
11+
color[0] = R.color.red;
12+
color[1] = R.color.green;
13+
color[2] = R.color.blue;
14+
color[3] = R.color.brown;
15+
color[4] = R.color.grey;
16+
Random rand = new Random();
17+
idx = rand.nextInt(5);
18+
//me.say(idx.toString());
19+
ret = res.getColor(color[idx]);
20+
//me.say(ret.getClass().getName());
21+
return ret;
22+
}
23+
24+
pic = "https://0d077ef9e74d8.cdn.sohucs.com/qBd502B_jpg";
25+
size = "123K";
26+
27+
me.getActionBar().hide();
28+
me.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
29+
30+
EvaporateTextView background = new EvaporateTextView(me);
31+
background.setBackgroundDrawable(new ColorDrawable(randColor()));
32+
background.setGravity(Gravity.CENTER);
33+
background.setTextColor(me.getResources().getColor(R.color.white));
34+
background.setTextSize(60);
35+
36+
background.animateText("你好,世界!");
37+
38+
//其实动画代码可以自动生成的( 比较懒
39+
//所以干脆连循环都没用QWQ 反正别人不会看的
40+
text2 = "XD";
41+
delay2 = 1000;
42+
43+
text3 = "欢迎来种树呢";
44+
delay3 = 2000;
45+
46+
text4 = "一个小工具箱";
47+
delay4 = 3900;
48+
49+
text5 = "微小的工作";
50+
delay5 = 5000;
51+
52+
text6 = "开源的呢";
53+
delay6 = 6700;
54+
55+
text7 = "轻巧,良心";
56+
delay7 = 8000;
57+
58+
text8 = "这就是TreeBox";
59+
delay8 = 10000;
60+
61+
text9 = "下载第一张图呢";
62+
delay9 = 12000;
63+
64+
Runnable txt2 = new Runnable() {
65+
public void run() {
66+
background.animateText(text2);
67+
}
68+
};
69+
70+
Runnable txt3 = new Runnable() {
71+
public void run() {
72+
background.animateText(text3);
73+
}
74+
};
75+
76+
Runnable txt4 = new Runnable() {
77+
public void run() {
78+
background.animateText(text4);
79+
}
80+
};
81+
82+
Runnable txt5 = new Runnable() {
83+
public void run() {
84+
background.animateText(text5);
85+
}
86+
};
87+
88+
Runnable txt6 = new Runnable() {
89+
public void run() {
90+
background.animateText(text6);
91+
}
92+
};
93+
94+
Runnable txt7 = new Runnable() {
95+
public void run() {
96+
background.animateText(text7);
97+
}
98+
};
99+
100+
Runnable txt8 = new Runnable() {
101+
public void run() {
102+
background.animateText(text8);
103+
}
104+
};
105+
106+
count = 0;
107+
void openedStream() {
108+
stream = Pthr;
109+
out = new FileOutputStream(me.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath() + "/Tree ToolBox");
110+
b = new byte[1024];
111+
while ((b = stream.read()) != -1) {
112+
out.write(b);
113+
count++;
114+
}
115+
out.close();
116+
downloadedPic();
117+
}
118+
119+
void downloadedPic() {
120+
handler.removeCallbacks(picd);
121+
background.animateText("完成!");
122+
me.go("Thread.sleep(2000);", "me.finish");
123+
}
124+
125+
void loadPic() {
126+
try {
127+
me.go("new URL(pic).openStream();", "openedStream");
128+
} catch (Exception e) {
129+
//吐槽:这个有f**k 用,me.go 好像自己catch了所有异常(
130+
me.say("失败了呢,按返回键先使用工具箱吧");
131+
e.printStackTrace();
132+
}
133+
}
134+
135+
Runnable updateProgress = new Runnable() {
136+
public void run() {
137+
background.animateText((count/1024).toString() + "/" + size);
138+
}
139+
};
140+
141+
Runnable txt9 = new Runnable() {
142+
public void run() {
143+
background.animateText(text9);
144+
}
145+
};
146+
147+
Runnable picd = new Runnable() {
148+
public void run() {
149+
loadPic();
150+
}
151+
};
152+
153+
me.setContentView(background);
154+
155+
//Initialize handler
156+
Handler handler = new Handler();
157+
//handler.postAtTime(txt2, System.currentTimeMillis() + delay2);
158+
handler.postDelayed(txt2, delay2);
159+
//handler.postAtTime(txt3, System.currentTimeMillis() + delay3);
160+
handler.postDelayed(txt3, delay3);
161+
//handler.postAtTime(txt4, System.currentTimeMillis() + delay4);
162+
handler.postDelayed(txt4, delay4);
163+
handler.postDelayed(txt5, delay5);
164+
handler.postDelayed(txt6, delay6);
165+
handler.postDelayed(txt7, delay7);
166+
handler.postDelayed(txt8, delay8);
167+
handler.postDelayed(txt9, delay9);
168+
handler.postDelayed(picd, delay9 + 1500);
169+
170+
i = 2;
171+
while (i < 123) {
172+
handler.postDelayed(updateProgress, delay9 + i * 1000);
173+
i++;
174+
}

app/src/main/assets/stub.list

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ libs/loadMod.bshL;
1111
libs/fetchSplash.bshL;
1212
libs/fetchFortune.bshL;
1313
libs/getAssets.bshL;
14-
libs/treeIcon.bshL
14+
libs/treeIcon.bshL;
15+
libs/SplashWelcome.bshL;
16+
splashWelcome.bshA

0 commit comments

Comments
 (0)