新增外置打包方式
为了彻底解决安装包体积问题,不再使用将打包模板内置到assets的方法,而是打包界面新增一个模板apk选择按钮,只要将编译好的打包模板和app一起发布就行了。另外由于时间关系,新增的资源字符串只提供了中文版,其它语言需要麻烦作者自己再处理一下
This commit is contained in:
@@ -6,6 +6,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -61,6 +62,8 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
private static final String LOG_TAG = "BuildActivity";
|
||||
private static final Pattern REGEX_PACKAGE_NAME = Pattern.compile("^([A-Za-z][A-Za-z\\d_]*\\.)+([A-Za-z][A-Za-z\\d_]*)$");
|
||||
EditText mSourcePath;
|
||||
EditText mTemplatePath;
|
||||
View mTemplatePathContainer;
|
||||
View mSourcePathContainer;
|
||||
EditText mOutputPath;
|
||||
EditText mAppName;
|
||||
@@ -85,6 +88,8 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
|
||||
mSourcePath = binding.sourcePath;
|
||||
mSourcePathContainer = binding.sourcePathContainer;
|
||||
mTemplatePathContainer = binding.templatePathContainer;
|
||||
mTemplatePath=binding.templatePath;
|
||||
mOutputPath = binding.outputPath;
|
||||
mAppName = binding.appName;
|
||||
mPackageName = binding.packageName;
|
||||
@@ -96,6 +101,9 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
binding.fab.setOnClickListener(v -> buildApk());
|
||||
binding.selectSource.setOnClickListener(v -> selectSourceFilePath());
|
||||
binding.selectOutput.setOnClickListener(v -> selectOutputDirPath());
|
||||
binding.selectTemplate.setOnClickListener(
|
||||
v -> selectTemplateFilePath()
|
||||
);
|
||||
mIcon.setOnClickListener(v -> selectIcon());
|
||||
|
||||
setToolbarAsBack(R.string.text_build_apk);
|
||||
@@ -175,6 +183,21 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
super.onNewIntent(intent);
|
||||
}
|
||||
|
||||
void selectTemplateFilePath() {
|
||||
new FileChooserDialogBuilder(this)
|
||||
.title(R.string.text_template_apk_path)
|
||||
.dir(Environment.getExternalStorageDirectory().getPath(), Environment.getExternalStorageDirectory().getPath())
|
||||
.singleChoice(this::setTemplate)
|
||||
.show();
|
||||
|
||||
}
|
||||
|
||||
private void setTemplate(File file) {
|
||||
if (file.getName().toLowerCase().startsWith("inrt") && file.getName().toLowerCase().endsWith(".apk") && file.isFile()) {
|
||||
mTemplatePath.setText(file.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
void selectSourceFilePath() {
|
||||
String initialDir = new File(mSourcePath.getText().toString()).getParent();
|
||||
new FileChooserDialogBuilder(this)
|
||||
|
||||
Reference in New Issue
Block a user