feat(ui): project icon setting
This commit is contained in:
@@ -48,14 +48,18 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
|||||||
Callable<Bitmap> icon;
|
Callable<Bitmap> icon;
|
||||||
|
|
||||||
public static AppConfig fromProjectConfig(String projectDir, ProjectConfig projectConfig) {
|
public static AppConfig fromProjectConfig(String projectDir, ProjectConfig projectConfig) {
|
||||||
return new AppConfig()
|
String icon = projectConfig.getIcon();
|
||||||
|
AppConfig appConfig = new AppConfig()
|
||||||
.setAppName(projectConfig.getName())
|
.setAppName(projectConfig.getName())
|
||||||
.setPackageName(projectConfig.getPackageName())
|
.setPackageName(projectConfig.getPackageName())
|
||||||
.ignoreDir(new File(projectDir, projectConfig.getBuildDir()))
|
.ignoreDir(new File(projectDir, projectConfig.getBuildDir()))
|
||||||
.setVersionCode(projectConfig.getVersionCode())
|
.setVersionCode(projectConfig.getVersionCode())
|
||||||
.setVersionName(projectConfig.getVersionName())
|
.setVersionName(projectConfig.getVersionName())
|
||||||
.setIcon(projectConfig.getIcon())
|
|
||||||
.setSourcePath(projectDir);
|
.setSourcePath(projectDir);
|
||||||
|
if (icon != null) {
|
||||||
|
appConfig.setIcon(new File(projectDir, icon).getPath());
|
||||||
|
}
|
||||||
|
return appConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ import org.androidannotations.annotations.AfterViews;
|
|||||||
import org.androidannotations.annotations.Click;
|
import org.androidannotations.annotations.Click;
|
||||||
import org.androidannotations.annotations.EActivity;
|
import org.androidannotations.annotations.EActivity;
|
||||||
import org.androidannotations.annotations.ViewById;
|
import org.androidannotations.annotations.ViewById;
|
||||||
|
import org.autojs.autojs.App;
|
||||||
import org.autojs.autojs.Pref;
|
import org.autojs.autojs.Pref;
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.autojs.build.AutoJsApkBuilder;
|
import org.autojs.autojs.autojs.build.AutoJsApkBuilder;
|
||||||
import org.autojs.autojs.build.ApkBuilderPluginHelper;
|
import org.autojs.autojs.build.ApkBuilderPluginHelper;
|
||||||
|
import org.autojs.autojs.external.fileprovider.AppFileProvider;
|
||||||
import org.autojs.autojs.model.script.ScriptFile;
|
import org.autojs.autojs.model.script.ScriptFile;
|
||||||
import org.autojs.autojs.theme.dialog.ThemeColorMaterialDialogBuilder;
|
import org.autojs.autojs.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||||
import org.autojs.autojs.tool.BitmapTool;
|
import org.autojs.autojs.tool.BitmapTool;
|
||||||
@@ -301,7 +303,7 @@ public class BuildActivity extends BaseActivity implements AutoJsApkBuilder.Prog
|
|||||||
.positiveText(R.string.text_install)
|
.positiveText(R.string.text_install)
|
||||||
.negativeText(R.string.cancel)
|
.negativeText(R.string.cancel)
|
||||||
.onPositive((dialog, which) ->
|
.onPositive((dialog, which) ->
|
||||||
IntentUtil.installApk(BuildActivity.this, outApk.getPath())
|
IntentUtil.installApk(BuildActivity.this, outApk.getPath(), AppFileProvider.AUTHORITY)
|
||||||
)
|
)
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.stardust.util.IntentUtil;
|
|||||||
import org.autojs.autojs.BuildConfig;
|
import org.autojs.autojs.BuildConfig;
|
||||||
import org.autojs.autojs.Pref;
|
import org.autojs.autojs.Pref;
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
|
import org.autojs.autojs.external.fileprovider.AppFileProvider;
|
||||||
import org.autojs.autojs.network.download.DownloadManager;
|
import org.autojs.autojs.network.download.DownloadManager;
|
||||||
import org.autojs.autojs.network.entity.VersionInfo;
|
import org.autojs.autojs.network.entity.VersionInfo;
|
||||||
import org.autojs.autojs.tool.IntentTool;
|
import org.autojs.autojs.tool.IntentTool;
|
||||||
@@ -118,7 +119,7 @@ public class UpdateInfoDialogBuilder extends MaterialDialog.Builder {
|
|||||||
final String path = new File(Pref.getScriptDirPath(), "AutoJs.apk").getPath();
|
final String path = new File(Pref.getScriptDirPath(), "AutoJs.apk").getPath();
|
||||||
DownloadManager.getInstance().downloadWithProgress(getContext(), downloadUrl, path)
|
DownloadManager.getInstance().downloadWithProgress(getContext(), downloadUrl, path)
|
||||||
.subscribeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(file -> IntentUtil.installApk(getContext(), file.getPath()),
|
.subscribe(file -> IntentUtil.installApk(getContext(), file.getPath(), AppFileProvider.AUTHORITY),
|
||||||
error -> {
|
error -> {
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
Toast.makeText(getContext(), R.string.text_download_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), R.string.text_download_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -85,12 +85,13 @@ public class IntentUtil {
|
|||||||
return goToAppDetailSettings(context, context.getPackageName());
|
return goToAppDetailSettings(context, context.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 2018/7/11 Permission denial
|
public static void installApk(Context context, String path, String fileProviderAuthority) {
|
||||||
public static void installApk(Context context, String path) {
|
Uri uri = getUriOfFile(context, path, fileProviderAuthority);
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(uri, "application/vnd.android.package-archive");
|
||||||
intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,13 +100,18 @@ public class IntentUtil {
|
|||||||
viewFile(context, path, mimeType, fileProviderAuthority);
|
viewFile(context, path, mimeType, fileProviderAuthority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void viewFile(Context context, String path, String mimeType, String fileProviderAuthority) {
|
public static Uri getUriOfFile(Context context, String path, String fileProviderAuthority) {
|
||||||
Uri uri;
|
Uri uri;
|
||||||
if (fileProviderAuthority == null) {
|
if (fileProviderAuthority == null) {
|
||||||
uri = Uri.parse("file://" + path);
|
uri = Uri.parse("file://" + path);
|
||||||
} else {
|
} else {
|
||||||
uri = FileProvider.getUriForFile(context, fileProviderAuthority, new File(path));
|
uri = FileProvider.getUriForFile(context, fileProviderAuthority, new File(path));
|
||||||
}
|
}
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void viewFile(Context context, String path, String mimeType, String fileProviderAuthority) {
|
||||||
|
Uri uri = getUriOfFile(context, path, fileProviderAuthority);
|
||||||
context.startActivity(new Intent(Intent.ACTION_VIEW)
|
context.startActivity(new Intent(Intent.ACTION_VIEW)
|
||||||
.setDataAndType(uri, mimeType)
|
.setDataAndType(uri, mimeType)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@@ -115,12 +121,7 @@ public class IntentUtil {
|
|||||||
|
|
||||||
public static void editFile(Context context, String path, String fileProviderAuthority) {
|
public static void editFile(Context context, String path, String fileProviderAuthority) {
|
||||||
String mimeType = MimeTypes.fromFileOr(path, "*/*");
|
String mimeType = MimeTypes.fromFileOr(path, "*/*");
|
||||||
Uri uri;
|
Uri uri = getUriOfFile(context, path, fileProviderAuthority);
|
||||||
if (fileProviderAuthority == null) {
|
|
||||||
uri = Uri.parse("file://" + path);
|
|
||||||
} else {
|
|
||||||
uri = FileProvider.getUriForFile(context, fileProviderAuthority, new File(path));
|
|
||||||
}
|
|
||||||
context.startActivity(new Intent(Intent.ACTION_EDIT)
|
context.startActivity(new Intent(Intent.ACTION_EDIT)
|
||||||
.setDataAndType(uri, mimeType)
|
.setDataAndType(uri, mimeType)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
|||||||
Reference in New Issue
Block a user