diff --git a/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsAdapter.java b/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsAdapter.java index 8f1811a662d102454ee7e4f7452dac7f49556bfb..b861bb00d559cb8f466d2ed14c732f167550718e 100644 --- a/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsAdapter.java +++ b/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsAdapter.java @@ -17,6 +17,7 @@ import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.InstanceCreator; +import com.google.gson.JsonObject; import jadx.gui.JadxGUI; import jadx.gui.utils.PathTypeAdapter; @@ -92,6 +93,10 @@ public class JadxSettingsAdapter { return GSON.toJson(settings); } + public static JsonObject makeJsonObject(JadxSettings settings) { + return GSON.toJsonTree(settings).getAsJsonObject(); + } + public static void fill(JadxSettings settings, String jsonStr) { populate(GSON_BUILDER, jsonStr, JadxSettings.class, settings); } diff --git a/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java b/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java index c28b0555d4364f38aa3172d77c88ffe82d5e41ca..66a366d9b1e5e31a11f91441c1aae372092b1adf 100644 --- a/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java +++ b/jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java @@ -1,6 +1,8 @@ package jadx.gui.settings; import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.MouseAdapter; @@ -13,6 +15,9 @@ import javax.swing.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; + import say.swing.JFontChooser; import jadx.api.JadxArgs; @@ -113,10 +118,31 @@ public class JadxSettingsWindow extends JDialog { } }); + JButton copyBtn = new JButton(NLS.str("preferences.copy")); + copyBtn.addActionListener(event -> { + + JsonObject settingsJson = JadxSettingsAdapter.makeJsonObject(this.settings); + // remove irrelevant preferences + settingsJson.remove("windowPos"); + settingsJson.remove("mainWindowExtendedState"); + settingsJson.remove("lastSaveProjectPath"); + settingsJson.remove("lastOpenFilePath"); + settingsJson.remove("lastSaveFilePath"); + settingsJson.remove("recentProjects"); + String settingsText = new GsonBuilder().setPrettyPrinting().create().toJson(settingsJson); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringSelection selection = new StringSelection(settingsText); + clipboard.setContents(selection, selection); + JOptionPane.showMessageDialog( + JadxSettingsWindow.this, + NLS.str("preferences.copy_message")); + }); + JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(resetBtn); + buttonPane.add(copyBtn); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(saveBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); diff --git a/jadx-gui/src/main/resources/i18n/Messages_de_DE.properties b/jadx-gui/src/main/resources/i18n/Messages_de_DE.properties index 0f1996034c49c2ab9efe899b36bb585fe34d504b..6f50d3e1f3c741e1689451808df1d900607eee7b 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_de_DE.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_de_DE.properties @@ -124,6 +124,8 @@ preferences.cancel=Abbrechen preferences.reset=Zurücksetzen preferences.reset_message=Einstellungen auf Standardwerte zurücksetzen? preferences.reset_title=Einstellungen zurücksetzen +#preferences.copy=Copy to clipboard +#preferences.copy_message=All settings values has been copied to clipboard preferences.rename=Umbenennen preferences.rename_case=System unterscheidet zwischen Groß/Kleinschreibung preferences.rename_valid=Ist eine gültige Kennung diff --git a/jadx-gui/src/main/resources/i18n/Messages_en_US.properties b/jadx-gui/src/main/resources/i18n/Messages_en_US.properties index 7aa16f5e12ef6ba9de2e6ccd83d7927d5091cca4..dad659340d66bf253c75384dbf56657d0c869cd2 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_en_US.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_en_US.properties @@ -124,6 +124,8 @@ preferences.cancel=Cancel preferences.reset=Reset preferences.reset_message=Reset settings to default values? preferences.reset_title=Reset settings +preferences.copy=Copy to clipboard +preferences.copy_message=All settings values has been copied to clipboard preferences.rename=Rename preferences.rename_case=System case sensitivity preferences.rename_valid=To be valid identifier diff --git a/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties b/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties index bbad9221b2585f750643a196e8d30bafbe612e84..bfacf92f74c8ddb6e97f6437c93ba7e2723d4b64 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties @@ -124,6 +124,8 @@ preferences.cancel=Cancelar preferences.reset=Reestablecer preferences.reset_message=¿Reestablecer preferencias a valores por defecto? preferences.reset_title=Reestablecer preferencias +#preferences.copy=Copy to clipboard +#preferences.copy_message=All settings values has been copied to clipboard #preferences.rename= #preferences.rename_case= #preferences.rename_valid= diff --git a/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties b/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties index f2183db81dc297706bcf492c09470983f09337b0..f80098d612d82cc14dd037c9d2d6dca792f715f5 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties @@ -124,6 +124,8 @@ preferences.cancel=取消 preferences.reset=重置 preferences.reset_message=要恢复默认设置吗? preferences.reset_title=重置设置 +#preferences.copy=Copy to clipboard +#preferences.copy_message=All settings values has been copied to clipboard preferences.rename=重命名 preferences.rename_case=系统区分大小写 preferences.rename_valid=是有效的标识符