diff --git a/app/src/main/java/com/icst/android/appstudio/dialogs/ProjectBuilderDialog.java b/app/src/main/java/com/icst/android/appstudio/dialogs/ProjectBuilderDialog.java index 9aa34a02..5aae8fce 100644 --- a/app/src/main/java/com/icst/android/appstudio/dialogs/ProjectBuilderDialog.java +++ b/app/src/main/java/com/icst/android/appstudio/dialogs/ProjectBuilderDialog.java @@ -148,11 +148,14 @@ public void onBuildCancelled() { } @Override - public void onBuildFailed(ProjectCodeBuildException e) { + public void onBuildFailed(ProjectCodeBuildException e, long buildTime) { log.append(e.getMessage()); log.append("\n"); activity.runOnUiThread( () -> { + log.append("\n"); + log.append("Build failed in ".concat(TimeUtils.convertTime(buildTime))); + log.append("\n"); binding.indicator.setVisibility(View.GONE); binding.currentLog.setVisibility(View.GONE); binding.editor.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/icst/android/appstudio/helper/ProjectCodeBuilder.java b/app/src/main/java/com/icst/android/appstudio/helper/ProjectCodeBuilder.java index 57b51ecc..2f2e403d 100644 --- a/app/src/main/java/com/icst/android/appstudio/helper/ProjectCodeBuilder.java +++ b/app/src/main/java/com/icst/android/appstudio/helper/ProjectCodeBuilder.java @@ -45,6 +45,7 @@ import com.icst.android.appstudio.builder.JavaSourceBuilder; import com.icst.android.appstudio.builder.LayoutSourceBuilder; import com.icst.android.appstudio.exception.ProjectCodeBuildException; +import com.icst.android.appstudio.listener.BuildFailListener; import com.icst.android.appstudio.listener.ProjectCodeBuildListener; import com.icst.android.appstudio.models.ModuleModel; import com.icst.android.appstudio.utils.EnvironmentUtils; @@ -115,6 +116,8 @@ public static void generateModuleCode( ProjectCodeBuildListener listener, ProjectCodeBuilderCancelToken cancelToken) { + BuildFailListener buildFailListener = new BuildFailListener(); + long executionStartTime = System.currentTimeMillis(); if (listener != null) listener.onBuildStart(); @@ -272,7 +275,10 @@ public void onArtifactNotFound(Artifact artifact) { .concat(artifact.getGroupId()) .concat(":") .concat(artifact.getVersion())); - listener.onBuildFailed(artifactNotFound); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + artifactNotFound, + System.currentTimeMillis() - executionStartTime); } } @@ -287,7 +293,9 @@ public void onDependenciesNotFound(Artifact artifact) { .concat(artifact.getGroupId()) .concat(":") .concat(artifact.getVersion()))); - listener.onBuildFailed(dependecyNotFound); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + dependecyNotFound, System.currentTimeMillis() - executionStartTime); } @Override @@ -315,7 +323,10 @@ public void onDownloadError(Artifact artifact, Throwable error) { .concat(artifact.getGroupId()) .concat(":") .concat(artifact.getVersion())); - listener.onBuildFailed(artifactNotFound); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + artifactNotFound, + System.currentTimeMillis() - executionStartTime); } } @@ -368,14 +379,18 @@ public void onInvalidPOM(Artifact artifact) { .concat(artifact.getGroupId()) .concat(":") .concat(artifact.getVersion())); - listener.onBuildFailed(invalidPOM); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + invalidPOM, System.currentTimeMillis() - executionStartTime); } @Override public void onInvalidScope(Artifact artifact, String scope) { ProjectCodeBuildException invalidScope = new ProjectCodeBuildException(); invalidScope.setMessage("Invalid Scope : ".concat(scope)); - listener.onBuildFailed(invalidScope); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + invalidScope, System.currentTimeMillis() - executionStartTime); } @Override @@ -419,7 +434,10 @@ public void onVersionNotFound(Artifact artifact) { .concat(artifact.getGroupId()) .concat(":") .concat(artifact.getVersion())); - listener.onBuildFailed(artifactNotFound); + buildFailListener.notifyBuildFailed(); + listener.onBuildFailed( + artifactNotFound, + System.currentTimeMillis() - executionStartTime); } } }; @@ -472,6 +490,10 @@ public void onVersionNotFound(Artifact artifact) { } } + if (buildFailListener.isFailed()) { + return; + } + AppBuilder apkBuilder = new AppBuilder(); apkBuilder.build( new BuildListener() { @@ -488,10 +510,18 @@ public void onBuildProgress(String arg) { }, module); + if (buildFailListener.isFailed()) { + return; + } + long endExectionTime = System.currentTimeMillis(); long executionTime = endExectionTime - executionStartTime; if (listener != null) { - listener.onBuildComplete(executionTime); + if (buildFailListener.isFailed()) { + listener.onBuildComplete(executionTime); + } else { + listener.onBuildComplete(executionTime); + } } } diff --git a/app/src/main/java/com/icst/android/appstudio/listener/BuildFailListener.java b/app/src/main/java/com/icst/android/appstudio/listener/BuildFailListener.java new file mode 100644 index 00000000..996a1c8e --- /dev/null +++ b/app/src/main/java/com/icst/android/appstudio/listener/BuildFailListener.java @@ -0,0 +1,44 @@ +/* + * This file is part of Android AppStudio [https://github.com/Innovative-CST/AndroidAppStudio]. + * + * License Agreement + * This software is licensed under the terms and conditions outlined below. By accessing, copying, modifying, or using this software in any way, you agree to abide by these terms. + * + * 1. ** Copy and Modification Restrictions ** + * - You are not permitted to copy or modify the source code of this software without the permission of the owner, which may be granted publicly on GitHub Discussions or on Discord. + * - If permission is granted by the owner, you may copy the software under the terms specified in this license agreement. + * - You are not allowed to permit others to copy the source code that you were allowed to copy by the owner. + * - Modified or copied code must not be further copied. + * 2. ** Contributor Attribution ** + * - You must attribute the contributors by creating a visible list within the application, showing who originally wrote the source code. + * - If you copy or modify this software under owner permission, you must provide links to the profiles of all contributors who contributed to this software. + * 3. ** Modification Documentation ** + * - All modifications made to the software must be documented and listed. + * - the owner may incorporate the modifications made by you to enhance this software. + * 4. ** Consistent Licensing ** + * - All copied or modified files must contain the same license text at the top of the files. + * 5. ** Permission Reversal ** + * - If you are granted permission by the owner to copy this software, it can be revoked by the owner at any time. You will be notified at least one week in advance of any such reversal. + * - In case of Permission Reversal, if you fail to acknowledge the notification sent by us, it will not be our responsibility. + * 6. ** License Updates ** + * - The license may be updated at any time. Users are required to accept and comply with any changes to the license. + * - In such circumstances, you will be given 7 days to ensure that your software complies with the updated license. + * - We will not notify you about license changes; you need to monitor the GitHub repository yourself (You can enable notifications or watch the repository to stay informed about such changes). + * By using this software, you acknowledge and agree to the terms and conditions outlined in this license agreement. If you do not agree with these terms, you are not permitted to use, copy, modify, or distribute this software. + * + * Copyright © 2024 Dev Kumar + */ + +package com.icst.android.appstudio.listener; + +public final class BuildFailListener { + boolean isFailed = false; + + public void notifyBuildFailed() { + isFailed = true; + } + + public boolean isFailed() { + return this.isFailed; + } +} diff --git a/app/src/main/java/com/icst/android/appstudio/listener/ProjectCodeBuildListener.java b/app/src/main/java/com/icst/android/appstudio/listener/ProjectCodeBuildListener.java index f6a5fdfc..82cc3527 100644 --- a/app/src/main/java/com/icst/android/appstudio/listener/ProjectCodeBuildListener.java +++ b/app/src/main/java/com/icst/android/appstudio/listener/ProjectCodeBuildListener.java @@ -46,5 +46,5 @@ public interface ProjectCodeBuildListener { void onBuildCancelled(); - void onBuildFailed(ProjectCodeBuildException e); + void onBuildFailed(ProjectCodeBuildException e, long buildTime); } diff --git a/extension/src/main/java/com/icst/android/appstudio/extensions/operatorextension/OperatorBlocks.java b/extension/src/main/java/com/icst/android/appstudio/extensions/operatorextension/OperatorBlocks.java index a899f516..95a63bc9 100644 --- a/extension/src/main/java/com/icst/android/appstudio/extensions/operatorextension/OperatorBlocks.java +++ b/extension/src/main/java/com/icst/android/appstudio/extensions/operatorextension/OperatorBlocks.java @@ -166,9 +166,9 @@ private static BlockModel getNumberEqualBlock() { tag.setSupportedFileExtensions(new String[] { "java" }); DependencyTag testDeps = new DependencyTag(); - testDeps.setDependencyGroup("group"); - testDeps.setDependencyName("name"); - testDeps.setVersion("version"); + testDeps.setDependencyGroup("com.blankj"); + testDeps.setDependencyName("utilcodex"); + testDeps.setVersion("1.31.1"); tag.setAdditionalTags(new AdditionalCodeHelperTag[] { testDeps }); block.setTags(tag);