Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"assets": [],
"useFeatures": [],
"launchConfig": {
"displaySplash": true,
"hideLogs": true,
"splashText": "Powered by AutoJs6",
"stableMode": false
"logsVisible": false,
"splashVisible": true,
"slug": "Powered by AutoJs6"
},
"main": "main.js",
"name": "专注时光",
"packageName": "org.example.android_native_focus",
"scripts": {},
"versionCode": 1,
"versionName": "1.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"assets": [],
"useFeatures": [],
"launchConfig": {
"displaySplash": true,
"hideLogs": true,
"splashText": "Powered by AutoJs6",
"stableMode": false
"logsVisible": false,
"splashVisible": true,
"slug": "Powered by AutoJs6"
},
"main": "main.js",
"name": "Vue2 + Vant (SFC)",
"packageName": "org.example.vue2_vant",
"scripts": {},
"versionCode": 1,
"versionName": "1.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"assets": [],
"useFeatures": [],
"launchConfig": {
"displaySplash": true,
"hideLogs": true,
"splashText": "Powered by AutoJs6",
"stableMode": false
"logsVisible": false,
"splashVisible": true,
"slug": "Powered by AutoJs6"
},
"main": "main.js",
"name": "可交互 HTML",
"packageName": "org.example.interactive_html",
"scripts": {},
"versionCode": 1,
"versionName": "1.0.0"
}
7 changes: 0 additions & 7 deletions app/src/main/java/org/autojs/autojs/project/LaunchConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ class LaunchConfig : FuzzyDeserializer.OriginalJsonKeyAware {
)
var slug = mContext.getString(R.string.text_powered_by_autojs)

// @SerializedName("permissions")
// @field:SerializedNameCompatible(
// With(value = "permission"),
// With(value = "permissionList"),
// )
// var permissions = emptyList<String>()

override fun recordOriginalJsonKey(canonicalKey: String, originalKey: String) {
mOriginalJsonKeys[canonicalKey] = originalKey
}
Expand Down
118 changes: 3 additions & 115 deletions app/src/main/java/org/autojs/autojs/project/ProjectConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import androidx.annotation.Nullable;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.Strictness;
import com.google.gson.annotations.SerializedName;
import org.autojs.autojs.annotation.DeserializedMethodName;
Expand Down Expand Up @@ -204,18 +202,6 @@ public class ProjectConfig implements FuzzyDeserializer.OriginalJsonKeyAware {
@DeserializedMethodName(method = "normalizeSignatureScheme", parameterTypes = {String.class})
private String mSignatureScheme = "V1 + V2";

// @Commented by SuperMonster003 on Jan 20, 2025.
// ! Unused config options: "scripts".
// ! zh-CN: 未使用的配置选项: "scripts".
// # @SerializedName("scriptConfigs")
// # @SerializedNameCompatible(with = {
// # @With(value = "scriptsConfigs"),
// # @With(value = "scriptsConfig"),
// # @With(value = "scriptConfig"),
// # @With(value = "scripts", target = {"AutoJs4", "AutoX"}),
// # })
// # private final Map<String, ScriptConfig> mScriptConfigs = new HashMap<>();

@Nullable
private transient KeyStore mKeyStore = null;

Expand Down Expand Up @@ -709,13 +695,6 @@ public ProjectConfig setAgent(@Nullable AgentManifest agent) {
return this;
}

// @Commented by SuperMonster003 on Jan 20, 2025.
// ! Unused config options: "scripts".
// ! zh-CN: 未使用的配置选项: "scripts".
// # public Map<String, ScriptConfig> getScriptConfigs() {
// # return mScriptConfigs;
// # }

public ProjectConfig setMainScriptFileName(String mainScriptFileName) {
mMainScriptFileName = mainScriptFileName;
return this;
Expand Down Expand Up @@ -771,85 +750,9 @@ public void recordOriginalJsonKey(@NonNull String canonicalKey, @NonNull String
}

public String toJson(boolean detectConflicts) {
// Serialize first using canonical keys, then rename keys to preserve the original ones.
// zh-CN: 先按 canonical key 序列化, 再重命名 key 以保留原始 key.
JsonElement tree = sGson.toJsonTree(this);
if (!tree.isJsonObject()) {
return sGson.toJson(this);
}

JsonObject obj = tree.getAsJsonObject();

// Rename canonical keys to original keys if needed.
// zh-CN: 如有需要, 将 canonical key 重命名为原始 key.
for (Map.Entry<String, String> entry : mOriginalJsonKeys.entrySet()) {
String canonicalKey = entry.getKey();
String originalKey = entry.getValue();

if (canonicalKey == null || originalKey == null) {
continue;
}
if (canonicalKey.equals(originalKey)) {
continue;
}
if (!obj.has(canonicalKey)) {
continue;
}

if (obj.has(originalKey)) {
// Detect or resolve conflicts depending on the flag.
// zh-CN: 根据开关选择检测或静默解决冲突.
if (detectConflicts) {
throw new IllegalStateException("Conflicting keys when serializing: \"" + canonicalKey + "\" and \"" + originalKey + "\"");
}
// Keep the existing original key and drop canonical key silently.
// zh-CN: 静默保留原始 key, 丢弃 canonical key.
obj.remove(canonicalKey);
continue;
}

JsonElement value = obj.remove(canonicalKey);
obj.add(originalKey, value);
}

applyNestedOriginalKeys(obj, detectConflicts);

return sGson.toJson(obj);
}

private void applyNestedOriginalKeys(@NonNull JsonObject root, boolean detectConflicts) {
applyNestedOriginalKeysForLaunchConfig(root, detectConflicts);
applyNestedOriginalKeysForBuildInfo(root, detectConflicts);
}

private void applyNestedOriginalKeysForLaunchConfig(@NonNull JsonObject root, boolean detectConflicts) {
if (mLaunchConfig == null) {
return;
}
String key = resolveTopLevelJsonKey("launchConfig");
JsonElement launchElement = root.get(key);
if (launchElement == null || !launchElement.isJsonObject()) {
return;
}
mLaunchConfig.applyOriginalJsonKeys(launchElement.getAsJsonObject(), detectConflicts);
}

private void applyNestedOriginalKeysForBuildInfo(@NonNull JsonObject root, boolean detectConflicts) {
if (mBuildInfo == null) {
return;
}
String key = resolveTopLevelJsonKey("build");
JsonElement buildElement = root.get(key);
if (buildElement == null || !buildElement.isJsonObject()) {
return;
}
mBuildInfo.applyOriginalJsonKeys(buildElement.getAsJsonObject(), detectConflicts);
}

@NonNull
private String resolveTopLevelJsonKey(@NonNull String canonicalKey) {
String original = mOriginalJsonKeys.get(canonicalKey);
return original == null || original.isBlank() ? canonicalKey : original;
// Always serialize with canonical keys: legacy keys are upgraded on save.
// zh-CN: 始终按 canonical key 序列化, 旧字段在保存时自动升级为规范字段.
return sGson.toJson(this);
}

public String getIconPath() {
Expand Down Expand Up @@ -904,21 +807,6 @@ public List<String> getFeatures() {
return mFeatures;
}

// @Commented by SuperMonster003 on Jan 20, 2025.
// ! Unused config options: "scripts".
// ! zh-CN: 未使用的配置选项: "scripts".
// # public ScriptConfig getScriptConfig(String scriptKeyName) {
// # ScriptConfig scriptConfig = Objects.requireNonNull(mScriptConfigs.getOrDefault(scriptKeyName, new ScriptConfig()));
// # List<String> combinedFeatures = new ArrayList<>(
// # new HashSet<>() {{
// # addAll(scriptConfig.getFeatures());
// # addAll(mFeatures);
// # }}
// # );
// # scriptConfig.setFeatures(combinedFeatures);
// # return scriptConfig;
// # }

public void setFeatures(@NonNull List<String> features) {
mFeatures = features;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ class ProjectConfigActivity : BaseActivity() {
mVersionCode = binding.versionCode
mMainFileName = binding.mainFileName

binding.defaultStableMode.apply {
ThemeColorHelper.setThemeColorPrimary(this, true)
}

mIcon = binding.appIcon.apply {
setOnClickListener { selectIcon() }
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/layout/activity_project_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@

</org.autojs.autojs.theme.widget.ThemeColorTextInputLayout>

<org.autojs.autojs.core.ui.widget.JsCheckBox
android:id="@+id/default_stable_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_stable_mode" />

</LinearLayout>

</LinearLayout>
Expand Down