Skip to content

Commit 8f98bc2

Browse files
committed
optimize
1 parent 65575f8 commit 8f98bc2

File tree

10 files changed

+43
-23
lines changed

10 files changed

+43
-23
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId "com.github.jsbxyyx.xbook"
2727
minSdk 27
2828
targetSdk 33
29-
versionCode 42
30-
versionName "4.2"
29+
versionCode 43
30+
versionName "4.3"
3131
archivesBaseName = "xplay"
3232

3333
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

app/src/main/java/com/github/jsbxyyx/xbook/GeckoWebViewActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
4646
mHttpd.start();
4747
} catch (IOException e) {
4848
LogUtil.e(getClass().getSimpleName(), "onCreate: %s", LogUtil.getStackTraceString(e));
49+
UiUtils.showToast("服务启动失败");
4950
}
5051

5152
String orientation = getIntent().getStringExtra("orientation");
@@ -119,6 +120,7 @@ public void onSessionStateChange(@NonNull GeckoSession session, @NonNull GeckoSe
119120
webProgress.show();
120121
} catch (Exception e) {
121122
LogUtil.e(getClass().getSimpleName(), "onCreate: %s", LogUtil.getStackTraceString(e));
123+
UiUtils.showToast("网页打开失败");
122124
}
123125
}
124126

app/src/main/java/com/github/jsbxyyx/xbook/ListFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private void showListView(boolean clear) {
109109
}
110110
if (page == 1 && list.isEmpty()) {
111111
UiUtils.showToast("未搜索到书籍");
112+
btn_more.setVisibility(View.GONE);
112113
return;
113114
}
114115
lvListAdapter.getDataList().addAll(list);

app/src/main/java/com/github/jsbxyyx/xbook/ProfileFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public void call(byte[] bytes, Throwable err) {
444444
}
445445
} catch (Exception e) {
446446
LogUtil.e(TAG, "cloud download err. %s", LogUtil.getStackTraceString(e));
447-
UiUtils.showToast("下载失败.《" + name + "》,查看管理文件权限是否开启。");
447+
UiUtils.showToast("下载失败.《" + name + "》,前往APP-设置打开管理文件权限");
448448
} finally {
449449
latch.countDown();
450450
}

app/src/main/java/com/github/jsbxyyx/xbook/SettingsActivity.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void onProgress(long bytesRead, long total) {
156156
if (percent == 100) {
157157
notificationManager.cancel(0);
158158
} else {
159-
builder.setContentInfo(String.valueOf(percent) + "%").setProgress(100, percent, false);
159+
builder.setContentInfo(percent + "%").setProgress(100, percent, false);
160160
notificationManager.notify(0, builder.build());
161161
}
162162
});
@@ -170,9 +170,7 @@ public void onProgress(long bytesRead, long total) {
170170
public void call(JsonNode jsonNode, Throwable err) {
171171
if (err != null) {
172172
LogUtil.d(getClass().getSimpleName(), "%s", LogUtil.getStackTraceString(err));
173-
runOnUiThread(() -> {
174-
UiUtils.showToast("获取版本更新失败:" + err.getMessage());
175-
});
173+
UiUtils.showToast("获取版本更新失败:" + err.getMessage());
176174
return;
177175
}
178176
JsonNode data = jsonNode.get("data");
@@ -198,6 +196,7 @@ public void call(JsonNode jsonNode, Throwable err) {
198196
}
199197
} catch (Exception e) {
200198
LogUtil.e(getClass().getSimpleName(), "cloud versions exception. %s", LogUtil.getStackTraceString(e));
199+
UiUtils.showToast("获取版本更新失败:" + err.getMessage());
201200
}
202201
}
203202
});

app/src/main/java/com/github/jsbxyyx/xbook/ViewActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
8282
mHttpd.start();
8383
} catch (IOException e) {
8484
LogUtil.e(getClass().getSimpleName(), "onCreate: %s", LogUtil.getStackTraceString(e));
85+
UiUtils.showToast("阅读器打开失败");
8586
}
8687

8788
try {
@@ -136,6 +137,7 @@ protected void onCreate(Bundle savedInstanceState) {
136137
webView.loadUrl(url);
137138
} catch (IOException e) {
138139
LogUtil.e(getClass().getSimpleName(), "onCreate: %s", LogUtil.getStackTraceString(e));
140+
UiUtils.showToast("未开启文件管理权限,前往APP设置-打开文件管理权限");
139141
}
140142
}
141143

app/src/main/java/com/github/jsbxyyx/xbook/httpserver/FileHttpServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.jsbxyyx.xbook.common.Common;
44
import com.github.jsbxyyx.xbook.common.LogUtil;
5+
import com.github.jsbxyyx.xbook.common.UiUtils;
56

67
import java.io.File;
78
import java.io.FileInputStream;
@@ -79,7 +80,7 @@ public Response serve(IHTTPSession session) {
7980
if (name.endsWith(".js")
8081
|| name.endsWith(".css")
8182
|| name.endsWith(".htm")
82-
|| name.endsWith(".html") || name.endsWith(".htm")
83+
|| name.endsWith(".html")
8384
|| name.endsWith(".bcmap")) {
8485
LogUtil.d(TAG, "ignore : %s", name);
8586
in = new FileInputStream(rootFile);
@@ -94,6 +95,7 @@ public Response serve(IHTTPSession session) {
9495
c.close();
9596
} catch (IOException e) {
9697
LogUtil.e(TAG, "%s", LogUtil.getStackTraceString(e));
98+
UiUtils.showToast("未开启文件管理权限,请前往APP-设置打开文件管理权限");
9799
}
98100

99101
long magic = head.getLong();

app/src/main/res/layout/activity_settings.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_width="match_parent"
2323
android:layout_height="35dp"
2424
android:gravity="center_vertical"
25-
android:text="搜索书籍格式"
25+
android:text="@string/str_search_book_format"
2626
android:textStyle="bold"
2727
/>
2828

@@ -75,7 +75,7 @@
7575
android:layout_width="match_parent"
7676
android:layout_height="35dp"
7777
android:gravity="center_vertical"
78-
android:text="搜索书籍语言"
78+
android:text="@string/str_search_book_language"
7979
android:textStyle="bold"
8080
/>
8181

@@ -123,15 +123,15 @@
123123
android:layout_width="match_parent"
124124
android:layout_height="35dp"
125125
android:gravity="center_vertical"
126-
android:text="是否同步"
126+
android:text="@string/str_is_sync"
127127
android:textStyle="bold"
128128
/>
129129

130130
<CheckBox
131131
android:id="@+id/cb_sync"
132132
android:layout_width="wrap_content"
133133
android:layout_height="wrap_content"
134-
android:text="同步"
134+
android:text="@string/str_sync"
135135
/>
136136

137137
</LinearLayout>
@@ -145,15 +145,15 @@
145145
android:layout_width="match_parent"
146146
android:layout_height="35dp"
147147
android:gravity="center_vertical"
148-
android:text="下载列表设置"
148+
android:text="@string/str_download_list_settings"
149149
android:textStyle="bold"
150150
/>
151151

152152
<CheckBox
153153
android:id="@+id/cb_show_image"
154154
android:layout_width="wrap_content"
155155
android:layout_height="wrap_content"
156-
android:text="显示图片"
156+
android:text="@string/str_show_image"
157157
/>
158158

159159
</LinearLayout>
@@ -167,15 +167,15 @@
167167
android:layout_width="match_parent"
168168
android:layout_height="35dp"
169169
android:gravity="center_vertical"
170-
android:text="阅读设置"
170+
android:text="@string/str_reader_settings"
171171
android:textStyle="bold"
172172
/>
173173

174174
<CheckBox
175175
android:id="@+id/cb_online_read"
176176
android:layout_width="wrap_content"
177177
android:layout_height="wrap_content"
178-
android:text="在线阅读"
178+
android:text="@string/str_online_reader"
179179
/>
180180

181181
</LinearLayout>
@@ -184,13 +184,13 @@
184184
android:id="@+id/btn_clear_settings"
185185
android:layout_width="wrap_content"
186186
android:layout_height="wrap_content"
187-
android:text="清除设置" />
187+
android:text="@string/str_clear_settings" />
188188

189189
<Button
190190
android:id="@+id/btn_open_write"
191191
android:layout_width="wrap_content"
192192
android:layout_height="wrap_content"
193-
android:text="打开读写权限" />
193+
android:text="@string/str_files_permissions" />
194194

195195
<LinearLayout
196196
android:layout_marginTop="40dp"
@@ -210,14 +210,14 @@
210210
android:layout_width="wrap_content"
211211
android:layout_height="30dp"
212212
android:gravity="center"
213-
android:text="当前版本:" />
213+
android:text="@string/str_current_version" />
214214

215215
<TextView
216216
android:id="@+id/tv_version"
217217
android:layout_width="wrap_content"
218218
android:layout_height="30dp"
219219
android:gravity="center"
220-
android:text="0.1" />
220+
android:text="@string/str_0_1" />
221221

222222
</LinearLayout>
223223

@@ -228,7 +228,7 @@
228228
android:gravity="center_vertical"
229229
app:iconGravity="textStart"
230230
android:visibility="gone"
231-
android:text="0.1"
231+
android:text="@string/str_0_1"
232232
app:icon="@drawable/baseline_file_download_24" />
233233

234234
</LinearLayout>

app/src/main/res/layout/fragment_list.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
android:layout_width="0dp"
2828
android:layout_height="wrap_content"
2929
android:layout_weight="0.3"
30-
android:text="搜索" />
30+
android:text="@string/str_search" />
3131

3232
</LinearLayout>
3333

@@ -50,7 +50,7 @@
5050
android:layout_height="0dp"
5151
android:layout_weight="0.1"
5252
android:visibility="gone"
53-
android:text="获取更多" />
53+
android:text="@string/str_search_more" />
5454

5555
</LinearLayout>
5656

app/src/main/res/values/strings.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,18 @@
1515
<string name="str_input_code">请输入验证码</string>
1616
<string name="str_send">发送</string>
1717
<string name="str_forget_password">忘记密码</string>
18+
<string name="str_clear_settings">清除设置</string>
19+
<string name="str_files_permissions">打开文件管理权限</string>
20+
<string name="str_current_version">当前版本:</string>
21+
<string name="str_0_1">0.1</string>
22+
<string name="str_online_reader">在线阅读</string>
23+
<string name="str_reader_settings">阅读设置</string>
24+
<string name="str_show_image">显示图片</string>
25+
<string name="str_download_list_settings">下载列表设置</string>
26+
<string name="str_sync">同步</string>
27+
<string name="str_is_sync">是否同步</string>
28+
<string name="str_search_book_language">搜索书籍语言</string>
29+
<string name="str_search_book_format">搜索书籍格式</string>
30+
<string name="str_search">搜索</string>
31+
<string name="str_search_more">获取更多</string>
1832
</resources>

0 commit comments

Comments
 (0)