From 08a930c88f88d7f46c479cec952e7fe01009f3ea Mon Sep 17 00:00:00 2001
From: Kaiserdragon2 <8929967+Kaiserdragon2@users.noreply.github.com>
Date: Sun, 1 Dec 2024 20:19:02 +0100
Subject: [PATCH 1/3] Create Changelog.java
---
.../donnnno/arcticons/helper/Changelog.java | 126 ++++++++++++++++++
1 file changed, 126 insertions(+)
create mode 100644 preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
diff --git a/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java b/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
new file mode 100644
index 0000000000..daa1d78f2e
--- /dev/null
+++ b/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
@@ -0,0 +1,126 @@
+package com.donnnno.arcticons.helper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+public class Changelog {
+ public static void main(String[] args) {
+ //String
+ String rootDir = System.getProperty("user.dir");
+ // Get the path of the root directory
+ Path rootPath = Paths.get(rootDir);
+ // Get the name of the root directory
+ String rootDirName = rootPath.getFileName().toString();
+ if (rootDirName.equals("preparehelper")) {
+ rootDir = "..";
+ }
+ String sourceDir = rootDir + "/icons/white";
+ String resDir;
+ String destDir;
+ String xmlDir = rootDir+"/app/src/main/res/xml";
+ String valuesDir = rootDir+"/app/src/main/res/values";
+ String newXML = rootDir+"/generated/newdrawables.xml";
+ String categoryGamesXml;
+ String assetsDir;
+ String appFilter = rootDir + "/newicons/appfilter.xml";
+ String drawableXml = xmlDir +"/drawable.xml";
+ String changelogXml = valuesDir +"/changelog.xml";
+
+ int countTotal = countAll(drawableXml);
+ int countNew = countAll(newXML);
+ int countFilterTotal = countAll(appFilter);
+ int countFilterOld = 19762; //tag11.4.6(21744)
+ int countReused = countFilterTotal-countFilterOld-countNew;
+
+ StringBuilder output = new StringBuilder("\n" +
+ "\n" +
+ "\n" +
+ " \n" +
+ " ");
+ output.append(currentDate());
+ output.append("\n\n");
+ output.append(" \n");
+ output.append(" \n");
+ output.append(" - 🎉 ");
+ output.append(countNew);
+ output.append(" new and updated icons!
\n");
+ output.append(" - 💡 Added support for ");
+ output.append(countReused);
+ output.append(" apps using existing icons.
\n");
+ output.append(" - 🔥 ");
+ output.append(countTotal);
+ output.append(" icons in total!
\n");
+ output.append(" \n");
+ output.append("");
+
+ // Write the output to the file
+ try {
+ writeToFile(output.toString(), changelogXml);
+ System.out.println("Changelog saved to: " + changelogXml);
+ } catch (IOException e) {
+ System.err.println("Error writing to file: " + e.getMessage());
+ }
+
+ }
+
+ // Method to write a string to a file
+ public static void writeToFile(String content, String filePath) throws IOException {
+ Path path = Paths.get(filePath);
+ Files.write(path, content.getBytes());
+ }
+ // Method to get the current date in "MMM dd, yyyy" format
+ public static String currentDate() {
+ LocalDate date = LocalDate.now();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd, yyyy");
+ return date.format(formatter);
+ }
+
+ public static int countAll(String drawableXml){
+ try {
+ // Path to the XML file
+ Path xmlPath = Paths.get(drawableXml);
+
+ // Create a DocumentBuilderFactory
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ // Create a DocumentBuilder
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ // Parse the XML file
+ Document document = builder.parse(xmlPath.toFile());
+
+ // Normalize the document (optional, but recommended)
+ document.getDocumentElement().normalize();
+
+ // Get all - nodes
+ NodeList itemList = document.getElementsByTagName("item");
+
+ // Count the
- nodes
+ int itemCount = itemList.getLength();
+
+ // Output the count
+ System.out.println("Number of
- entries: " + itemCount);
+ return itemCount;
+ } catch (Exception e) {
+ System.out.println("Error occurred: " + e.getMessage());
+ }
+ return 0;
+ }
+}
From d6d0ca0f186975cde85fb4e78361ac62f3c67dec Mon Sep 17 00:00:00 2001
From: Kaiserdragon2 <8929967+Kaiserdragon2@users.noreply.github.com>
Date: Mon, 2 Dec 2024 16:06:08 +0100
Subject: [PATCH 2/3] also generate changelog md
---
.../donnnno/arcticons/helper/Changelog.java | 68 ++++++++++++++++---
.../arcticons/helper/PrepareRelease.java | 10 +++
2 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java b/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
index daa1d78f2e..9c2216a5fd 100644
--- a/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
+++ b/preparehelper/src/main/java/com/donnnno/arcticons/helper/Changelog.java
@@ -27,24 +27,76 @@ public static void main(String[] args) {
if (rootDirName.equals("preparehelper")) {
rootDir = "..";
}
- String sourceDir = rootDir + "/icons/white";
- String resDir;
- String destDir;
String xmlDir = rootDir+"/app/src/main/res/xml";
String valuesDir = rootDir+"/app/src/main/res/values";
- String newXML = rootDir+"/generated/newdrawables.xml";
- String categoryGamesXml;
- String assetsDir;
String appFilter = rootDir + "/newicons/appfilter.xml";
String drawableXml = xmlDir +"/drawable.xml";
String changelogXml = valuesDir +"/changelog.xml";
+ String generatedDir = rootDir +"/generated";
+ generateChangelogs(generatedDir, drawableXml, appFilter, changelogXml,false);
+ }
+
+
+
+
+
+ public static void generateChangelogs(String generatedDir, String drawableXml, String appFilter, String changelogXml,boolean newRelease) {
+ String newXML = generatedDir + "/newdrawables.xml";
int countTotal = countAll(drawableXml);
int countNew = countAll(newXML);
int countFilterTotal = countAll(appFilter);
- int countFilterOld = 19762; //tag11.4.6(21744)
- int countReused = countFilterTotal-countFilterOld-countNew;
+ int countFilterOld = readCountFilterOld(generatedDir);//19762; //tag11.4.6(21744)
+ int countReused = countFilterTotal - countFilterOld - countNew;
+
+ createChangelogXML(countTotal, countNew, countReused, changelogXml);
+ createChangelogMd(countTotal, countNew, countReused, generatedDir);
+
+ if (newRelease) {
+ //save countFilterTotal to file
+ try {
+ writeToFile(String.valueOf(countFilterTotal), generatedDir + "/countFilterTotal.txt");
+ System.out.println("countFilterTotal saved to: " + generatedDir + "/countFilterTotal.txt");
+ } catch (IOException e) {
+ System.err.println("Error writing to file: " + e.getMessage());
+ }
+ }
+ }
+
+
+
+ public static int readCountFilterOld(String generatedDir) {
+ //read count from File
+ try {
+ Path path = Paths.get(generatedDir + "/countFilterTotal.txt");
+ String content = new String(Files.readAllBytes(path)).strip();
+ return Integer.parseInt(content);
+ } catch (IOException e) {
+ System.err.println("Error reading file: " + e.getMessage());
+ }
+
+ return 0 ;
+ }
+ public static void createChangelogMd(int countTotal, int countNew, int countReused, String changelogMd) {
+ StringBuilder output = new StringBuilder("* \uD83C\uDF89 **");
+ output.append(countNew);
+ output.append("** new and updated icons!\n");
+ output.append("* \uD83D\uDCA1 Added support for **");
+ output.append(countReused);
+ output.append("** apps using existing icons.\n");
+ output.append("* \uD83D\uDD25 **");
+ output.append(countTotal);
+ output.append("** icons in total!");
+
+ try {
+ writeToFile(output.toString(), changelogMd + "/changelog.md");
+ System.out.println("Changelog saved to: " + changelogMd + "/changelog.md");
+ } catch (IOException e) {
+ System.err.println("Error writing to file: " + e.getMessage());
+ }
+ }
+ public static void createChangelogXML(int countTotal, int countNew, int countReused, String changelogXml){
StringBuilder output = new StringBuilder("\n" +
"\n" +
"\n" +
diff --git a/preparehelper/src/main/java/com/donnnno/arcticons/helper/PrepareRelease.java b/preparehelper/src/main/java/com/donnnno/arcticons/helper/PrepareRelease.java
index 7ebc23775d..a9a39d81ff 100644
--- a/preparehelper/src/main/java/com/donnnno/arcticons/helper/PrepareRelease.java
+++ b/preparehelper/src/main/java/com/donnnno/arcticons/helper/PrepareRelease.java
@@ -1,5 +1,7 @@
package com.donnnno.arcticons.helper;
+import static com.donnnno.arcticons.helper.Changelog.generateChangelogs;
+
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.file.Path;
@@ -26,6 +28,12 @@ public static void main(String[] args) throws Exception {
xmlDir = rootDir + "/app/src/main/res/xml";
assetsDir = rootDir + "/app/src/main/assets";
String contributorsXml = rootDir + "/generated/contributors.xml";
+ String generatedDir = rootDir + "/generated";
+ String valuesDir = rootDir + "/app/src/main/res/values";
+ String appFilter = rootDir + "/newicons/appfilter.xml";
+ String drawableXml = xmlDir + "/drawable.xml";
+ String changelogXml = valuesDir +"/changelog.xml";
+
String task = args[0];
System.out.println("Processing with task: " + task);
switch (task) {
@@ -41,6 +49,7 @@ public static void main(String[] args) throws Exception {
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
+ generateChangelogs(generatedDir, drawableXml, appFilter, changelogXml,false);
break;
case "newrelease":
executePythonScript(rootDir + "/scripts/preparerelease.py","--new");
@@ -50,6 +59,7 @@ public static void main(String[] args) throws Exception {
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
+ generateChangelogs(generatedDir, drawableXml, appFilter, changelogXml,true);
break;
default:
}
From 2d36eb88b090ecb8facacab25f7717ee5a4178b8 Mon Sep 17 00:00:00 2001
From: Kaiserdragon2 <8929967+Kaiserdragon2@users.noreply.github.com>
Date: Mon, 2 Dec 2024 16:14:15 +0100
Subject: [PATCH 3/3] Create countFilterTotal.txt
---
generated/countFilterTotal.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 generated/countFilterTotal.txt
diff --git a/generated/countFilterTotal.txt b/generated/countFilterTotal.txt
new file mode 100644
index 0000000000..95de018631
--- /dev/null
+++ b/generated/countFilterTotal.txt
@@ -0,0 +1 @@
+21744
\ No newline at end of file