Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize much #363

Merged
merged 8 commits into from
Dec 28, 2021
Merged
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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
paths:
- '.github/workflows/ci.yaml'
- 'Mifare Classic Tool/**'
pull_request:
paths:
- '.github/workflows/ci.yaml'
- 'Mifare Classic Tool/**'

env:
PROJECT_PATH: Mifare Classic Tool

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }}
- name: Build
working-directory: ${{ env.PROJECT_PATH }}
run: ./gradlew --parallel assembleRelease
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Mifare Classic Tool/app/release
# OS specific
**/.DS_Store

.idea
.vscode
build
*.jar
11 changes: 11 additions & 0 deletions Mifare Classic Tool/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yml,yaml}]
indent_size = 2
4 changes: 4 additions & 0 deletions Mifare Classic Tool/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf

*.bat text eol=crlf
*.jar binary
1 change: 0 additions & 1 deletion Mifare Classic Tool/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {

android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is safe to remove this? What build tools version will be used when it's not declared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest.


defaultConfig {
applicationId "de.syss.MifareClassicTool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
R.id.editTextCloneUidToolWriteKey);
mStatusLogContent = findViewById(
R.id.textViewCloneUidToolStatusLogContent);
mShowOptions = (CheckBox) findViewById(
mShowOptions = findViewById(
R.id.checkBoxCloneUidToolOptions);
mRadioButtonKeyB = findViewById(
R.id.radioButtonCloneUidToolKeyB);
Expand Down Expand Up @@ -390,7 +390,7 @@ private void appendToLog(String text) {
* (in this case the "show options" check box).
*/
public void onShowOptions(View view) {
LinearLayout optionsLayout = (LinearLayout) findViewById(
LinearLayout optionsLayout = findViewById(
R.id.linearLayoutOptions);
if (mShowOptions.isChecked()) {
optionsLayout.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ private void saveFile(final String[] data, final String fileName,
View dialogLayout = getLayoutInflater().inflate(
R.layout.dialog_save_file,
findViewById(android.R.id.content), false);
TextView message = (TextView) dialogLayout.findViewById(
TextView message = dialogLayout.findViewById(
R.id.textViewDialogSaveFileMessage);
final EditText input = (EditText) dialogLayout.findViewById(
final EditText input = dialogLayout.findViewById(
R.id.editTextDialogSaveFileName);
message.setText(messageId);
input.setText(fileName);
Expand Down Expand Up @@ -975,7 +975,7 @@ private void saveKeys() {
if (mDumpName == null) {
mKeysName = "UID_" + mUID;
} else {
mKeysName = new String(mDumpName);
mKeysName = mDumpName;
}
}
mKeysName += ".keys";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ private void onNewFile() {
View dialogLayout = getLayoutInflater().inflate(
R.layout.dialog_save_file,
findViewById(android.R.id.content), false);
TextView message = (TextView) dialogLayout.findViewById(
TextView message = dialogLayout.findViewById(
R.id.textViewDialogSaveFileMessage);
final EditText input = (EditText) dialogLayout.findViewById(
final EditText input = dialogLayout.findViewById(
R.id.editTextDialogSaveFileName);
message.setText(R.string.dialog_new_file);
input.setText(prefill);
Expand All @@ -344,14 +344,9 @@ private void onNewFile() {
// Show keyboard.
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
input.postDelayed(new Runnable()
{
@Override
public void run()
{
input.requestFocus();
imm.showSoftInput(input, 0);
}
input.postDelayed(() -> {
input.requestFocus();
imm.showSoftInput(input, 0);
}, 100);

// Ask user for filename.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public interface IActivityThatReactsToSave {
/**
* This method will be called after a successful save process.
*/
public abstract void onSaveSuccessful();
void onSaveSuccessful();

/**
* This method will be called, if there was an error during the
* save process or it the user hits "cancel" in the "file already exists"
* dialog.
*/
public abstract void onSaveFailure();
void onSaveFailure();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;

import org.json.JSONException;
import org.json.JSONObject;

Expand Down Expand Up @@ -97,6 +99,7 @@ private enum FileType {
this.text = text;
}

@NonNull
@Override
public String toString() {
return text;
Expand Down Expand Up @@ -488,7 +491,7 @@ private void saveConvertedDataToContent(String[] convertedContent,
Toast.LENGTH_LONG).show();
return;
}
boolean success = false;
boolean success;
if (mFileType != FileType.BIN) {
success = Common.saveFile(contentDestination, convertedContent, this);
} else {
Expand Down Expand Up @@ -551,7 +554,7 @@ private String[] convertDump(String[] source, FileType srcType,
Common.isValidDumpErrorToast(err, this);
return null;
}
int sectorNumber = 0;
int sectorNumber;
int blockNumber = 0;
for (String line : source) {
if (line.startsWith("+")) {
Expand Down Expand Up @@ -624,7 +627,7 @@ private String[] convertDump(String[] source, FileType srcType,
return null;
}

JSONObject blocks = null;
JSONObject blocks;
try {
JSONObject parsedJson = new JSONObject(TextUtils.join("", json));
blocks = parsedJson.getJSONObject("blocks");
Expand Down Expand Up @@ -886,7 +889,7 @@ private boolean backupDumpsAndKeys(Uri contentDestUri) {
file.getAbsolutePath().substring(commonPathLen));
entry.setTime(file.lastModified());
out.putNextEntry(entry);
int count = 0;
int count;
while ((count = origin.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ private void onSave() {
View dialogLayout = getLayoutInflater().inflate(
R.layout.dialog_save_file,
findViewById(android.R.id.content), false);
TextView message = (TextView) dialogLayout.findViewById(
TextView message = dialogLayout.findViewById(
R.id.textViewDialogSaveFileMessage);
final EditText input = (EditText) dialogLayout.findViewById(
final EditText input = dialogLayout.findViewById(
R.id.editTextDialogSaveFileName);
message.setText(R.string.dialog_save_keys);
input.setText(mFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import android.widget.RadioGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;

import de.syss.MifareClassicTool.Common;
import de.syss.MifareClassicTool.R;

Expand Down Expand Up @@ -62,6 +64,7 @@ public enum Preference {
this.text = text;
}

@NonNull
@Override
public String toString() {
return text;
Expand Down Expand Up @@ -370,4 +373,4 @@ public void onSave(View view) {
public void onCancel(View view) {
finish();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,21 @@ public void onCreate(Bundle savedInstanceState) {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

switch(requestCode) {
case KEY_MAP_CREATOR:
if (requestCode == KEY_MAP_CREATOR) {
if (resultCode != Activity.RESULT_OK) {
// Error.
if (resultCode == 4) {
// Error. Path from the calling intend was null.
// (This is really strange and should not occur.)
Toast.makeText(this, R.string.info_strange_error,
Toast.LENGTH_LONG).show();
Toast.LENGTH_LONG).show();
}
finish();
return;
} else {
// Read Tag.
readTag();
}
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,10 @@ public void onActivityResult(int requestCode,

// Error handling for the return value of KeyMapCreator.
// So far, only error nr. 4 needs to be handled.
switch (ckmError) {
case 4:
// Error. Path from the calling intend was null.
if (ckmError == 4) {// Error. Path from the calling intend was null.
// (This is really strange and should not occur.)
Toast.makeText(this, R.string.info_strange_error,
Toast.LENGTH_LONG).show();
Toast.LENGTH_LONG).show();
}
}

Expand Down Expand Up @@ -872,7 +870,7 @@ private void initDumpWithPosFromDump(String[] dump) {
// with the static ones.
String newBlock = dump[i].substring(0, 12)
+ mStaticAC.getText().toString()
+ dump[i].substring(18, dump[i].length());
+ dump[i].substring(18);
dump[i] = newBlock;
}
mDumpWithPos.get(sector).put(block++,
Expand Down
Loading