From 43720032939dad985d413e193e235552c581f94d Mon Sep 17 00:00:00 2001 From: Deun Lee Date: Thu, 24 Aug 2023 22:26:43 +0900 Subject: [PATCH 1/3] Add Hide Identical Sectors option --- .../Activities/DiffTool.java | 26 ++++ .../main/res/layout/activity_diff_tool.xml | 113 ++++++++++-------- .../app/src/main/res/values/strings.xml | 1 + 3 files changed, 91 insertions(+), 49 deletions(-) diff --git a/Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/DiffTool.java b/Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/DiffTool.java index 6e73dbb3..c3ebbdc8 100644 --- a/Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/DiffTool.java +++ b/Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/DiffTool.java @@ -27,6 +27,7 @@ import android.util.SparseArray; import android.view.View; import android.widget.Button; +import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -59,6 +60,7 @@ public class DiffTool extends BasicActivity { private LinearLayout mDiffContent; private Button mDumpFileButton1; private Button mDumpFileButton2; + private CheckBox mDumpHideIdentical; private SparseArray mDump1; private SparseArray mDump2; @@ -74,6 +76,7 @@ protected void onCreate(Bundle savedInstanceState) { mDiffContent = findViewById(R.id.linearLayoutDiffTool); mDumpFileButton1 = findViewById(R.id.buttonDiffToolDump1); mDumpFileButton2 = findViewById(R.id.buttonDiffToolDump2); + mDumpHideIdentical = findViewById(R.id.checkBoxDiffToolHideIdentical); // Check if one or both dumps are already chosen via Intent // (from DumpEditor). @@ -145,6 +148,21 @@ private void runDiff() { continue; } + // If the Hide Identical Sectors is checked, + // Do not display the same sector. + if (mDumpHideIdentical.isChecked() && blocks.length > 1) { + int block; + for (block = 0; block < blocks.length; block++) { + if (blocks[block].length != 0) { + break; + } + } + if (block == blocks.length) { + // Identical sector. + continue; + } + } + // Add sector header. TextView header = new TextView(this); TextViewCompat.setTextAppearance(header, @@ -241,6 +259,14 @@ public void onChooseDump2(View view) { startActivityForResult(intent, FILE_CHOOSER_DUMP_FILE_2); } + /** + * Run diff if the Hide Identical Sectors option is changed. + * @see #runDiff() + */ + public void onHideIdenticalChanged(View view) { + runDiff(); + } + /** * Get the {@link FileChooser#EXTRA_CHOSEN_FILE} from the Intend, * read the file, check it for errors using diff --git a/Mifare Classic Tool/app/src/main/res/layout/activity_diff_tool.xml b/Mifare Classic Tool/app/src/main/res/layout/activity_diff_tool.xml index ee0b36e2..3321abf7 100644 --- a/Mifare Classic Tool/app/src/main/res/layout/activity_diff_tool.xml +++ b/Mifare Classic Tool/app/src/main/res/layout/activity_diff_tool.xml @@ -19,56 +19,76 @@ --> - -