Skip to content

Commit a1478b0

Browse files
committed
add: 记录下载到第几集的记录
fix: About中自动跳转的bug
1 parent 6b1556a commit a1478b0

File tree

7 files changed

+45
-27
lines changed

7 files changed

+45
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
/build
1010
/captures
1111
/python/a.flv
12+
/app/release
1213
.externalNativeBuild

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "com.brainor.bilihelper"
77
minSdkVersion 24
88
targetSdkVersion 26
9-
versionCode 6
10-
versionName '1.5'
9+
versionCode 7
10+
versionName '1.6'
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
resConfigs "zh"
1313
}
@@ -40,7 +40,7 @@ dependencies {
4040
implementation fileTree(include: ['*.jar'], dir: 'libs')
4141
implementation 'androidx.appcompat:appcompat:1.0.2'
4242
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
43-
implementation 'com.google.android.material:material:1.0.0-alpha1'
43+
implementation 'com.google.android.material:material:1.1.0-alpha01'
4444
testImplementation 'junit:junit:4.12'
4545
androidTestImplementation 'androidx.test:runner:1.1.0'
4646
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

app/src/main/java/com/brainor/bilihelper/AboutSettingsActivity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package com.brainor.bilihelper;
22

33
import android.os.Bundle;
4-
import androidx.appcompat.app.AppCompatActivity;
5-
import androidx.appcompat.widget.Toolbar;
64
import android.text.Html;
75
import android.text.Spanned;
86
import android.text.method.LinkMovementMethod;
97
import android.widget.TextView;
108

119
import java.util.Objects;
1210

11+
import androidx.appcompat.app.AppCompatActivity;
12+
import androidx.appcompat.widget.Toolbar;
13+
1314
public class AboutSettingsActivity extends AppCompatActivity {
1415

1516
@Override
@@ -25,21 +26,21 @@ protected void onCreate(Bundle savedInstanceState) {
2526
Spanned styledText = Html.fromHtml("<p style=\"text-align: center;\">版本号 " + BuildConfig.VERSION_NAME + "</p>\n" +
2627
"<h1><a id=\"_0\"></a>开发</h1>\n" +
2728
"<p><a href=\"https://github.com/brainor\">@Brainor</a> 使用Java开发<br>\n" +
28-
"<a href=\"mailto:[email protected]\">[email protected]</a><br><br>\n" +
29+
"<a href=\"mailto:[email protected]\">[email protected]</a>.<br><br>\n" +
2930
"本程序主要参考<a href=\"https://github.com/xiaoyaocz/BiliAnimeDownload\">@xiaoyaocz</a>的Xamarin程序, 该Android版APP可在<a href=\"https://www.coolapk.com/apk/com.xiaoyaocz.bilidownload\">酷安</a>下载.<br>\n" +
30-
"<a href=\"mailto:[email protected]\">[email protected]</a></p>\n" +
31+
"<a href=\"mailto:[email protected]\">[email protected]</a>.</p>\n" +
3132
"<h1><a id=\"_5\"></a>赞助</h1>\n" +
3233
"<p>虽然只有我一个人用, 但请赞助原作者xiaoyaocz<br>\n" +
33-
"支付宝<a href=\"https://qr.alipay.com/FKX06526G3SYZ8MZZE2Q77\">[email protected]</a><br>\n" +
34-
"我的支付宝<a href=\"https://qr.alipay.com/tsx01990uusq195jv3zsi49\">[email protected]</a></p>\n" +
34+
"支付宝<a href=\"https://qr.alipay.com/FKX06526G3SYZ8MZZE2Q77\">[email protected]</a>.<br>\n" +
35+
"我的支付宝<a href=\"https://qr.alipay.com/tsx01990uusq195jv3zsi49\">[email protected]</a>.</p>\n" +
3536
"<h1><a id=\"_9\"></a>使用声明</h1>\n" +
3637
"<ol>\n" +
3738
"<li>此程序仅供学习交流编程技术使用</li>\n" +
3839
"<li>如侵犯你的合法权益, 请联系本人以第一时间删除</li>\n" +
3940
"</ol>\n" +
4041
"<h1><a id=\"_12\"></a>引用&amp;开源</h1>\n" +
4142
"<p>本程序使用了Biliplus的API, 具体可参考Biliplus的<a href=\"https://www.biliplus.com/api/README\">开放接口</a>.<br>\n" +
42-
"网络通讯 <a href=\"http://square.github.io/okhttp/\">square/okhttp</a></p>"+
43+
"网络通讯 <a href=\"http://square.github.io/okhttp/\">square/okhttp</a>.</p>"+
4344
"<h1><a id=\"_15\"></a>已知问题</h1>\n" +
4445
"<ol>\n" +
4546
"<li>可能BiliPlus也没有相关资源的下载链接</li>\n" +

app/src/main/java/com/brainor/bilihelper/HistorySettingsActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
8585
private MyAdapter mAdapter;
8686
private Drawable icon;
8787
private final ColorDrawable background;
88+
8889
SwipeToDeleteCallback(MyAdapter adapter) {
8990
super(0, ItemTouchHelper.LEFT);
9091
mAdapter = adapter;

app/src/main/java/com/brainor/bilihelper/MainActivity.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import android.widget.Toast;
2323

2424
import com.google.android.material.floatingactionbutton.FloatingActionButton;
25-
import com.google.android.material.snackbar.BaseTransientBottomBar;
2625
import com.google.android.material.snackbar.Snackbar;
2726

2827
import java.io.File;
@@ -57,13 +56,13 @@ protected void onCreate(Bundle savedInstanceState) {
5756
Toolbar toolbar = findViewById(R.id.toolbar);
5857
Button searchButton = findViewById(R.id.searchButton);
5958
inputTextView = findViewById(R.id.inputText);
60-
inputTextView.setText("ss25696");//调试用
59+
// inputTextView.setText("ss25696");//调试用
6160
infoListView = findViewById(R.id.infoListView);
6261
infoListView.setAdapter(new ArrayAdapter<>(MainActivity.this, R.layout.support_simple_spinner_dropdown_item, seriesInfo.epInfo));
6362
titleTextView = findViewById(R.id.titleTextView);
6463
LoadCookies();
6564
LoadHistory();
66-
Settings.videoQuality = VideoQuality.list[Arrays.asList(VideoQuality.getEntries()).indexOf(Objects.requireNonNull(getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("quality", "超清")))];
65+
Settings.videoQuality = VideoQuality.list[Arrays.asList(VideoQuality.getEntries()).indexOf(Objects.requireNonNull(getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("quality", VideoQuality._2.description)))];
6766
Settings.clientDownload = getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("clientDown", true);
6867
searchButton.setOnClickListener(v -> {
6968
String URL = inputTextView.getText().toString();
@@ -101,14 +100,25 @@ protected void onPostExecute(String successMsg) {
101100
}
102101
Toast.makeText(MainActivity.this, "成功: 正在下载文件", Toast.LENGTH_LONG).show();
103102
}
103+
int position = HistoryList.get(0).position;//历史记录中的位置
104+
if (position != seriesInfo.position) {
105+
if (position != -1) {
106+
EpInfo epInfo = seriesInfo.epInfo.get(position);
107+
epInfo.index_title = epInfo.index_title.substring(0, epInfo.index_title.length() - 1);
108+
}
109+
seriesInfo.epInfo.get(seriesInfo.position).index_title += "☆";
110+
((ArrayAdapter) infoListView.getAdapter()).notifyDataSetChanged();
111+
HistoryList.get(0).position = seriesInfo.position;
112+
StoreHistory(getApplicationContext());
113+
}
104114
}
105115
}.execute();
106116

107117
});
108118
setSupportActionBar(toolbar);
109119

110120
FloatingActionButton fab = findViewById(R.id.fab);
111-
fab.setOnClickListener(view -> Snackbar.make(view, "Replace with your own action", BaseTransientBottomBar.LENGTH_LONG)
121+
fab.setOnClickListener(view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
112122
.setAction("Action", null).show());
113123
CheckPermissions();
114124
}
@@ -178,7 +188,6 @@ protected void onCancelled(String errorMsg) {
178188

179189
@Override
180190
protected void onPostExecute(String HTMLBody) {
181-
((ArrayAdapter) infoListView.getAdapter()).notifyDataSetChanged();
182191
titleTextView.setText(seriesInfo.title);
183192
//添加historylist
184193
String url;
@@ -193,9 +202,15 @@ protected void onPostExecute(String HTMLBody) {
193202
url = "ss";
194203
break;
195204
}
196-
HistoryInfo info = new HistoryInfo(seriesInfo.title, url + seriesInfo.season_id);
197-
HistoryList.remove(info);
205+
HistoryInfo info = new HistoryInfo(seriesInfo.title, url + seriesInfo.season_id, -1);
206+
int position = HistoryList.indexOf(info);
207+
if (position > -1) {
208+
info.position = HistoryList.get(position).position;
209+
if (info.position > -1) seriesInfo.epInfo.get(info.position).index_title += "☆";
210+
HistoryList.remove(position);
211+
}
198212
HistoryList.add(0, info);
213+
((ArrayAdapter) infoListView.getAdapter()).notifyDataSetChanged();
199214
StoreHistory(getApplicationContext());
200215
}
201216

@@ -247,7 +262,6 @@ public void onPageFinished(WebView view, String url) {
247262
.setTitle("获取BiliPlus cookies")
248263
.setView(webView)
249264
.setNegativeButton("Close", (dialog, id) -> dialog.dismiss())
250-
251265
.show();
252266
}
253267

@@ -263,14 +277,12 @@ void LoadCookies() {
263277
}
264278

265279
void LoadHistory() {
266-
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
267-
List<String> HistoryStrList = new ArrayList<>(Objects.requireNonNull(sharedPref.getStringSet("HistoryList", new HashSet<>())));
280+
List<String> HistoryStrList = new ArrayList<>(Objects.requireNonNull(getSharedPreferences("MainActivity", Context.MODE_PRIVATE).getStringSet("HistoryList", new HashSet<>())));
268281
Collections.sort(HistoryStrList);
269282
for (String history : HistoryStrList) {
270283
String[] historys = history.split(";");
271-
HistoryList.add(new HistoryInfo(historys[1], historys[2]));
284+
HistoryList.add(new HistoryInfo(historys[1], historys[2], Integer.parseInt(historys[3])));
272285
}
273-
274286
}
275287

276288
void ClearHistory() {
@@ -282,7 +294,7 @@ static void StoreHistory(Context context) {
282294
HashSet<String> HistoryStrSet = new HashSet<>();
283295
for (int i = 0; i < HistoryList.size(); i++) {
284296
HistoryInfo info = HistoryList.get(i);
285-
HistoryStrSet.add(i + ";" + info.title + ";" + info.url);
297+
HistoryStrSet.add(i + ";" + info.title + ";" + info.url + ";" + info.position);
286298
}
287299
SharedPreferences sharedPref = context.getSharedPreferences("MainActivity", Context.MODE_PRIVATE);
288300
sharedPref.edit().putStringSet("HistoryList", HistoryStrSet).apply();

app/src/main/java/com/brainor/bilihelper/SeriesInfo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ class DownloadSegmentInfo {
8585
class HistoryInfo {
8686
String title;
8787
String url;
88+
int position;
8889

89-
HistoryInfo(String title, String url) {
90+
HistoryInfo(String title, String url, int position) {
9091
this.title = title;
9192
this.url = url;
93+
this.position = position;
9294
}
9395

9496
@Override

app/src/main/java/com/brainor/bilihelper/Settings.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
public class Settings extends AppCompatActivity {
2323
static VideoQuality videoQuality;
24-
static ClientType clientType=ClientType.release;
24+
static ClientType clientType = ClientType.release;
2525
static boolean clientDownload;
2626
static String rootPath = "/storage/emulated/0/Android/data/";
27+
2728
@Override
2829
protected void onCreate(Bundle savedInstanceState) {
2930
super.onCreate(savedInstanceState);
@@ -63,14 +64,14 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
6364
quality.setEntries(VideoQuality.getEntries());
6465
quality.setEntryValues(VideoQuality.getEntries());
6566
quality.setTitle("视频清晰度");
66-
quality.setSummary(PreferenceManager.getDefaultSharedPreferences(quality.getContext()).getString(quality.getKey(), "超清"));
67+
quality.setSummary(PreferenceManager.getDefaultSharedPreferences(quality.getContext()).getString(quality.getKey(), VideoQuality._2.description));
6768
quality.setValue((String) quality.getSummary());
6869
quality.setOnPreferenceChangeListener((preference, newValue) -> {
6970
preference.setSummary(newValue.toString());
7071
videoQuality = VideoQuality.list[Arrays.asList(VideoQuality.getEntries()).indexOf(newValue.toString())];
7172
return true;
7273
});
73-
SwitchPreference clientDownloadSwitch=new SwitchPreference(context);
74+
SwitchPreference clientDownloadSwitch = new SwitchPreference(context);
7475
clientDownloadSwitch.setSummaryOn("B站");
7576
clientDownloadSwitch.setSummaryOff("系统");
7677
clientDownloadSwitch.setKey("clientDown");

0 commit comments

Comments
 (0)