Skip to content

Commit adbdca0

Browse files
committed
Add an option to copy all the sectors
1 parent c8ffbf1 commit adbdca0

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/DumpEditor.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
292292
} else if (itemId == R.id.menuDumpEditorExportDump) {
293293
exportDump();
294294
return true;
295+
} else if (itemId == R.id.menuDumpEditorCopyAllSectors) {
296+
copyAllSectorsToClipboard();
297+
return true;
295298
}
296299
return super.onOptionsItemSelected(item);
297300
}
@@ -905,6 +908,37 @@ private void exportDump() {
905908
startActivity(intent);
906909
}
907910

911+
/**
912+
* Copy all sectors as a string to the clipboard, maintaining newlines
913+
* between all blocks.
914+
*/
915+
private void copyAllSectorsToClipboard() {
916+
int err = checkDumpAndUpdateLines();
917+
if (err != 0) {
918+
Common.isValidDumpErrorToast(err, this);
919+
return;
920+
}
921+
922+
// Build the dump string from mLines
923+
StringBuilder dumpString = new StringBuilder();
924+
for (int i = 0; i < mLines.length; i++) {
925+
String line = mLines[i];
926+
if (line.startsWith("+")) {
927+
// It's a sector header (e.g., "+Sector: 0")
928+
// Remove the "+" prefix and add newline before sector (except first)
929+
if (i > 0) {
930+
dumpString.append(System.lineSeparator());
931+
}
932+
dumpString.append(line.substring(1)); // Remove "+" prefix
933+
} else {
934+
// It's block data
935+
dumpString.append(System.lineSeparator()).append(line);
936+
}
937+
}
938+
939+
Common.copyToClipboard(dumpString.toString(), this, true);
940+
}
941+
908942
/**
909943
* The dump will be checked and stored in the {@link Common#TMP_DIR} directory.
910944
* @return The temporary dump file.

Mifare Classic Tool/app/src/main/res/menu/dump_editor_functions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@
5353
android:title="@string/action_show_ac_tool" />
5454
<item android:id="@+id/menuDumpEditorOpenBccTool"
5555
android:title="@string/action_show_bcc_tool" />
56+
<item android:id="@+id/menuDumpEditorCopyAllSectors"
57+
android:title="@string/action_copy_all_sectors" />
5658
</menu>

Mifare Classic Tool/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@
327327
<string name="action_open_clone_uid_tool">Open the Clone UID Tool</string>
328328
<string name="action_hide_identical_sectors">Hide identical sectors</string>
329329
<string name="action_clear_logs">Clear Logs</string>
330+
<string name="action_copy_all_sectors">Copy all sectors</string>
330331
<string-array name="action_themes">
331332
<item>Dark</item>
332333
<item>Light</item>

0 commit comments

Comments
 (0)