Skip to content

Commit

Permalink
Merge pull request #9 from molihuan/dev
Browse files Browse the repository at this point in the history
细节优化
  • Loading branch information
molihuan authored Jan 28, 2023
2 parents fdffa09 + 8ab9f29 commit 2418d4e
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 33 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,33 @@



## 演示:如果github显示不了请转到国内Gitee:[传送门](https://gitee.com/molihuan/BilibiliCacheVideoMergeAndroid))
## 演示:(如果github显示不了请转到国内Gitee:[传送门](https://gitee.com/molihuan/BilibiliCacheVideoMergeAndroid))

![https://github.com/molihuan/BilibiliCacheVideoMerge/tree/master/art/hlbDemo.gif](https://raw.kgithub.com/molihuan/BilibiliCacheVideoMerge/master/art/hlbDemo.gif)
### gif演示:

[![hlbDemo.gif](https://z4a.net/images/2023/01/28/hlbDemo.gif)](https://z4a.net/image/2p8r3U)
![https://github.com/molihuan/BilibiliCacheVideoMerge/tree/master/art/hlbDemo.gif](https://z4a.net/images/2023/01/28/hlbDemo.gif)

### 图片演示:

![1cb352c9975076400.md.jpg](https://z4a.net/images/2023/01/28/1cb352c9975076400.md.jpg)

![hlb2.md.jpg](https://z4a.net/images/2023/01/28/hlb2.md.jpg)

![hlb3.md.jpg](https://z4a.net/images/2023/01/28/hlb3.md.jpg)

![hlb4.md.jpg](https://z4a.net/images/2023/01/28/hlb4.md.jpg)

![hlb5.md.jpg](https://z4a.net/images/2023/01/28/hlb5.md.jpg)

![hlb6.md.jpg](https://z4a.net/images/2023/01/28/hlb6.md.jpg)

![hlb7.md.jpg](https://z4a.net/images/2023/01/28/hlb7.md.jpg)



# 软件协议

#### [查看](./app/src/main/assets/statement.md)

# 特别鸣谢

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ android {
applicationId "com.molihua.hlbmerge"
minSdk 21
targetSdk 33
versionCode 51
versionName "1.6.9.1beta"
versionCode 52
versionName "1.6.9.2beta"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Binary file modified app/release/app-all.apk
Binary file not shown.
Binary file modified app/release/app-arm64-v8a.apk
Binary file not shown.
Binary file modified app/release/app-armeabi-v7a.apk
Binary file not shown.
Binary file modified app/release/app-x86.apk
Binary file not shown.
Binary file modified app/release/app-x86_64.apk
Binary file not shown.
32 changes: 16 additions & 16 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
"type": "UNIVERSAL",
"filters": [],
"attributes": [],
"versionCode": 51,
"versionName": "1.6.9.1beta",
"versionCode": 52,
"versionName": "1.6.9.2beta",
"outputFile": "app-all.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
"value": "x86_64"
}
],
"attributes": [],
"versionCode": 51,
"versionName": "1.6.9.1beta",
"outputFile": "app-arm64-v8a.apk"
"versionCode": 52,
"versionName": "1.6.9.2beta",
"outputFile": "app-x86_64.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -37,35 +37,35 @@
}
],
"attributes": [],
"versionCode": 51,
"versionName": "1.6.9.1beta",
"versionCode": 52,
"versionName": "1.6.9.2beta",
"outputFile": "app-armeabi-v7a.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "x86_64"
"value": "x86"
}
],
"attributes": [],
"versionCode": 51,
"versionName": "1.6.9.1beta",
"outputFile": "app-x86_64.apk"
"versionCode": 52,
"versionName": "1.6.9.2beta",
"outputFile": "app-x86.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "x86"
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 51,
"versionName": "1.6.9.1beta",
"outputFile": "app-x86.apk"
"versionCode": 52,
"versionName": "1.6.9.2beta",
"outputFile": "app-arm64-v8a.apk"
}
],
"elementType": "File"
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions app/src/main/assets/updataLog.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ <h2>
<h3><span>因为权限问题,输出路径不能设置为SD卡,缓存文件路径可以设置为SD卡,即SD卡只能读取不能写入</span></h3>


<h3><span>1.6.9.2beta版本(新)</span></h3>
<h4><span>更新日期:2023年1月28日</span></h4>
<p><span>----修改合并命名问题</span></p>
<p><span>----设置增加"输出目录单一"</span></p>
<p><span>----分离各个架构单独打包,默认只有armeabi-v7a,需要其他架构请前往Github下载</span></p>

<h3><span>1.6.9beta版本(新)</span></h3>
<h4><span>更新日期:2023年1月26日</span></h4>
<p><span>----重新加入腾讯bugly(真香)</span></p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.molihua.hlbmerge.activity.impl;

import android.view.View;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand All @@ -23,6 +24,7 @@
import com.molihuan.pathselector.listener.CommonItemListener;
import com.molihuan.pathselector.utils.MConstants;
import com.molihuan.pathselector.utils.Mtools;
import com.xuexiang.xui.widget.button.switchbutton.SwitchButton;
import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction;
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;
import com.xuexiang.xui.widget.spinner.materialspinner.MaterialSpinner;
Expand All @@ -35,7 +37,7 @@
* @Date: 2022/12/26/19:56
* @Description:
*/
public class SettingsActivity extends BaseActivity implements View.OnClickListener, MaterialSpinner.OnItemSelectedListener {
public class SettingsActivity extends BaseActivity implements View.OnClickListener, MaterialSpinner.OnItemSelectedListener, CompoundButton.OnCheckedChangeListener {
private TextView cachePathShowTv;
private MaterialSpinner biliVersionMs;
private RelativeLayout customCachePathRela;
Expand All @@ -55,6 +57,8 @@ public class SettingsActivity extends BaseActivity implements View.OnClickListen

private RelativeLayout outputPathShowRela;

private SwitchButton switchSingleOutputDir;


@Override
public int setContentViewID() {
Expand All @@ -80,6 +84,8 @@ public void getComponents() {
ffmpegCoreTypeMs = findViewById(R.id.ms_ffmpeg_core_type);

outputPathShowRela = findViewById(R.id.relal_output_path_show);

switchSingleOutputDir = findViewById(R.id.switch_single_output_dir);
}

@Override
Expand All @@ -94,8 +100,8 @@ public void initView() {
int updateFrequency = ConfigData.getUpdateFrequency();
String ffmpegCmdTemplate = ConfigData.getFfmpegCmdTemplate();
int ffmpegCoreType = ConfigData.getFfmpegCoreType();

Mtools.log(ffmpegCoreType);
switchSingleOutputDir.setChecked(ConfigData.isSingleOutputDir());

if (BuildConfig.FFMPEG_CORE_TYPE != ConfigData.FFMPEG_CORE_TYPE_All) {
ffmpegCoreTypeLine.setVisibility(View.GONE);
Expand Down Expand Up @@ -174,6 +180,7 @@ public void setListeners() {
ffmpegCmdTypeMs.setOnItemSelectedListener(this);
ffmpegCoreTypeMs.setOnItemSelectedListener(this);
outputPathShowRela.setOnClickListener(this);
switchSingleOutputDir.setOnCheckedChangeListener(this);
}

@Override
Expand Down Expand Up @@ -329,4 +336,12 @@ public void onItemSelected(MaterialSpinner v, int position, long id, Object item


}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int id = buttonView.getId();
if (id == R.id.switch_single_output_dir) {
ConfigData.setSingleOutputDir(isChecked);
}
}
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/molihua/hlbmerge/dao/ConfigData.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class ConfigData {
private String ffmpegCmdTemplate;
//ffmpeg核心类型
private int ffmpegCoreType;
//单一输出目录,不再每个视频都创建目录
private boolean singleOutputDir;


/**
Expand Down Expand Up @@ -130,6 +132,10 @@ public static void init() {
setFfmpegCoreType(FFMPEG_CORE_TYPE_RXFFMPEG);
}

if (!kv.containsKey("singleOutputDir")) {
setSingleOutputDir(false);
}


}

Expand Down Expand Up @@ -300,5 +306,11 @@ public static boolean setFfmpegCoreType(int ffmpegCoreType) {
return kv.encode("ffmpegCoreType", ffmpegCoreType);
}

public static boolean isSingleOutputDir() {
return kv.decodeBool("singleOutputDir");
}

public static boolean setSingleOutputDir(boolean singleOutputDir) {
return kv.encode("singleOutputDir", singleOutputDir);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ public static void startMerge(List<CacheFile> cacheFileList, MaterialDialog dial
BaseFFmpegCallback ffmpegCallback = ConfigData.ffmpegCore.getFFmpegCallback(dialog);
//获取输出根目录
String outRoot = ConfigData.getOutputFilePath();
FileUtils.createOrExistsDir(outRoot);
//获取导出配置
int exportType = ConfigData.getExportType();
boolean exportDanmaku = ConfigData.isExportDanmaku();
boolean singleOutputDir = ConfigData.isSingleOutputDir();

XTask.getTaskChain()
.addTask(XTask.getTask(new TaskCommand() {
Expand All @@ -135,8 +137,12 @@ public void run() throws Exception {
cacheFile = MergeProgressDialog.cacheFileUri2File(srcCacheFile, dialog);

//创建输出目录
subOutPath = outRoot + File.separator + cacheFile.getCollectionName();
FileUtils.createOrExistsDir(subOutPath);
if (singleOutputDir) {
subOutPath = outRoot;
} else {
subOutPath = outRoot + File.separator + cacheFile.getCollectionName();
FileUtils.createOrExistsDir(subOutPath);
}
//获取完整的输出目录
completeOutPath = subOutPath + File.separator + cacheFile.getChapterName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IButtonCallback {
private static View getCustomViewOfDialog(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_statement, null);//获取自定义布局
TextView tx_statement = view.findViewById(R.id.tx_statement);
String statementContent = ResourceUtils.readAssets2String("statement.txt");//从Assets中读取
String statementContent = ResourceUtils.readAssets2String("statement.md");//从Assets中读取
tx_statement.setText(statementContent);
return view;
}
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/com/molihua/hlbmerge/utils/FileTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ public static String[] getCollectionChapterName(String jsonPath, String[] result
*/
private static String[] getCollectionChapterNameByJsonStr(String jsonStr, String[] result) {

if (StringUtils.isTrimEmpty(jsonStr)) {
return null;
}

JSONObject jsonObject;
//将json字符串转换成json对象
try {
Expand Down Expand Up @@ -213,7 +209,7 @@ private static String[] getCollectionChapterNameByJsonStr(String jsonStr, String
int subJsonType;

//获取二级json对象
JSONObject subJsonObject = null;
JSONObject subJsonObject;
try {
subJsonObject = jsonObject.getJSONObject("page_data");
subJsonType = 0;
Expand Down Expand Up @@ -242,6 +238,19 @@ private static String[] getCollectionChapterNameByJsonStr(String jsonStr, String

}

//获取当前章节索引(1、2、3、4相等为第几集)如果是1可能只有一集章节名就用合集名代替
int pageIndex = 0;
try {
pageIndex = subJsonObject.getInt("page");
} catch (JSONException e) {
Mtools.log("无法从json中获取page字段");
}

if (pageIndex == 1) {
result[1] = result[0];
return result;
}

//通过二级json对象获取章节名称
try {
result[1] = subJsonObject
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="输出位置"
android:text="输出设置"
android:textColor="@color/orange_mlh"
android:paddingHorizontal="15dp"
android:paddingTop="15dp" />
Expand Down Expand Up @@ -193,6 +193,29 @@

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:padding="15dp"
android:gravity="center_vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输出目录单一"
android:textColor="@color/black"
android:textSize="16dp" />

<com.xuexiang.xui.widget.button.switchbutton.SwitchButton
android:id="@+id/switch_single_output_dir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="0.2dp"
Expand Down

0 comments on commit 2418d4e

Please sign in to comment.