diff --git a/README.md b/README.md index 6adcc95..99dbba8 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ # DeadHash + DeadHash is a freeware utility to calculate file and text hashes. The following hash calculations are supported: * MD5 -* SHA1 -* SHA224 -* SHA256 -* SHA3 -* SHA384 -* SHA512 +* SHA-1 +* SHA-224 +* SHA-256 +* SHA-3 +* SHA-384 +* SHA-512 * CRC32 ## About + This library is maintained by CodeDead. You can find more about us using the following links: * [Website](https://codedead.com) * [Twitter](https://twitter.com/C0DEDEAD) diff --git a/app/build.gradle b/app/build.gradle index 97b470b..01bff21 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 - buildToolsVersion '29.0.2' + compileSdkVersion 30 + buildToolsVersion '30.0.2' defaultConfig { applicationId "com.codedead.deadhash" - minSdkVersion 21 - targetSdkVersion 29 - versionName '1.7.2' + minSdkVersion 24 + targetSdkVersion 30 + versionName '1.7.3' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - versionCode 3 + versionCode 4 } buildTypes { release { @@ -19,17 +19,21 @@ android { } productFlavors { } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.0.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.12' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.2.1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.13.1' implementation 'androidx.cardview:cardview:1.0.0' - implementation "androidx.preference:preference:1.1.0" + implementation "androidx.preference:preference:1.1.1" } diff --git a/app/src/main/java/com/codedead/deadhash/domain/interfaces/hashgenerator/IHashResponse.java b/app/src/main/java/com/codedead/deadhash/domain/interfaces/hashgenerator/IHashResponse.java deleted file mode 100644 index ae7bf87..0000000 --- a/app/src/main/java/com/codedead/deadhash/domain/interfaces/hashgenerator/IHashResponse.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.codedead.deadhash.domain.interfaces.hashgenerator; - -import com.codedead.deadhash.domain.objects.hashgenerator.HashData; - -import java.util.List; - -public interface IHashResponse { - void hashDataFile(List data); - - void hashDataText(List data); -} diff --git a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/FileHashGenerator.java b/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/FileHashGenerator.java deleted file mode 100644 index f460dbe..0000000 --- a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/FileHashGenerator.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.codedead.deadhash.domain.objects.hashgenerator; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -public final class FileHashGenerator extends HashGenerator { - - /** - * Initialize a new FileHashGenerator - * - * @param file The File that should be used to calculate hashes - * @param hashAlgorithms The List of HashingAlgorithm enums that should be used to calculate hashes - * @param compare The compare String for the calculated hashes - * @throws IOException When the file could not be read - */ - public FileHashGenerator(final File file, final List hashAlgorithms, final String compare) throws IOException { - super(file, hashAlgorithms, compare); - } - - @Override - protected void onPostExecute(final List data) { - hashResponse.hashDataFile(data); - } -} diff --git a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/HashGenerator.java b/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/HashGenerator.java index bed75f9..f0de758 100644 --- a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/HashGenerator.java +++ b/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/HashGenerator.java @@ -1,8 +1,5 @@ package com.codedead.deadhash.domain.objects.hashgenerator; -import android.os.AsyncTask; - -import com.codedead.deadhash.domain.interfaces.hashgenerator.IHashResponse; import com.codedead.deadhash.domain.utils.HashUtil; import java.io.File; @@ -11,14 +8,12 @@ import java.util.ArrayList; import java.util.List; -public abstract class HashGenerator extends AsyncTask> { +public final class HashGenerator { - private byte[] data; + private final byte[] data; private final List hashAlgorithms; private final List hashData; - private String compare; - - public IHashResponse hashResponse = null; + private final String compare; /** * Initialize a new HashGenerator @@ -27,7 +22,7 @@ public abstract class HashGenerator extends AsyncTask * @param hashAlgorithms The List of HashingAlgorithm enums that should be used to calculate hashes * @param compare The compare String for the calculated hashes */ - HashGenerator(final byte[] data, final List hashAlgorithms, final String compare) { + public HashGenerator(final byte[] data, final List hashAlgorithms, final String compare) { hashData = new ArrayList<>(); this.data = data; @@ -43,7 +38,7 @@ public abstract class HashGenerator extends AsyncTask * @param compare The compare String for the calculated hashes * @throws IOException When the File could not be read */ - HashGenerator(final File data, final List hashAlgorithms, final String compare) throws IOException { + public HashGenerator(final File data, final List hashAlgorithms, final String compare) throws IOException { hashData = new ArrayList<>(); this.data = readFileToBytes(data); this.hashAlgorithms = hashAlgorithms; @@ -76,8 +71,11 @@ private byte[] readFileToBytes(final File file) throws IOException { return bytes; } - @Override - protected List doInBackground(Void... params) { + /** + * Generate the List of HashData for the given input data + * @return The List of HashData for the given input data + */ + public final List generateHashes() { for (final HashAlgorithm algorithm : hashAlgorithms) { switch (algorithm) { case md5: diff --git a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/TextHashGenerator.java b/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/TextHashGenerator.java deleted file mode 100644 index c37f3b3..0000000 --- a/app/src/main/java/com/codedead/deadhash/domain/objects/hashgenerator/TextHashGenerator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.codedead.deadhash.domain.objects.hashgenerator; - -import java.util.List; - -public final class TextHashGenerator extends HashGenerator { - - /** - * Initialize a new TextHashGenerator - * - * @param data The byte array that should be hashed - * @param hashAlgorithms The List of HashingAlgorithm enums that should be used to calculate hashes - * @param compare The compare String for the calculated hashes - */ - public TextHashGenerator(final byte[] data, final List hashAlgorithms, final String compare) { - super(data, hashAlgorithms, compare); - } - - @Override - protected void onPostExecute(final List datas) { - hashResponse.hashDataText(datas); - } -} diff --git a/app/src/main/java/com/codedead/deadhash/domain/utils/DataAdapter.java b/app/src/main/java/com/codedead/deadhash/domain/utils/DataAdapter.java index 6664626..b3c6527 100644 --- a/app/src/main/java/com/codedead/deadhash/domain/utils/DataAdapter.java +++ b/app/src/main/java/com/codedead/deadhash/domain/utils/DataAdapter.java @@ -74,15 +74,12 @@ static class DataHolder extends RecyclerView.ViewHolder implements View.OnClickL final ImageButton copyData = v.findViewById(R.id.Copy_Data); copyData.setOnClickListener(this); - compareData.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - if (originalCompare == null || originalCompare.length() == 0) return; - if (originalCompare.equals(encryptionData.getText().toString())) { - Toast.makeText(v.getContext(), R.string.toast_hash_match, Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(v.getContext(), R.string.toast_hash_mismatch, Toast.LENGTH_SHORT).show(); - } + compareData.setOnClickListener(v1 -> { + if (originalCompare == null || originalCompare.length() == 0) return; + if (originalCompare.equals(encryptionData.getText().toString())) { + Toast.makeText(v1.getContext(), R.string.toast_hash_match, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(v1.getContext(), R.string.toast_hash_mismatch, Toast.LENGTH_SHORT).show(); } }); } diff --git a/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java b/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java index 65512e7..143aecb 100644 --- a/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java +++ b/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java @@ -2,7 +2,6 @@ import android.Manifest; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -32,6 +31,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import android.os.Looper; import android.view.MenuItem; import android.view.View; import android.widget.Button; @@ -46,11 +46,8 @@ import com.codedead.deadhash.R; import com.codedead.deadhash.domain.utils.DataAdapter; import com.codedead.deadhash.domain.objects.hashgenerator.HashData; -import com.codedead.deadhash.domain.objects.hashgenerator.FileHashGenerator; import com.codedead.deadhash.domain.objects.hashgenerator.HashGenerator; -import com.codedead.deadhash.domain.interfaces.hashgenerator.IHashResponse; import com.codedead.deadhash.domain.utils.LocaleHelper; -import com.codedead.deadhash.domain.objects.hashgenerator.TextHashGenerator; import java.io.File; import java.io.FileOutputStream; @@ -59,8 +56,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.concurrent.CompletableFuture; -public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, IHashResponse { +public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private boolean doubleBackToExitPressedOnce; private ViewFlipper viewFlipper; @@ -189,28 +187,21 @@ public void onFinish() { reviewBuilder.setMessage(R.string.alert_review_text); reviewBuilder.setCancelable(true); - reviewBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); + reviewBuilder.setPositiveButton(android.R.string.ok, (dialog, id) -> { + dialog.cancel(); - addReview(true); - IntentUtils.openPlayStore(MainActivity.this.getApplicationContext()); - } + addReview(true); + IntentUtils.openPlayStore(MainActivity.this.getApplicationContext()); }); - reviewBuilder.setNegativeButton(R.string.alert_review_never, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - addReview(true); - } + reviewBuilder.setNegativeButton(R.string.alert_review_never, (dialog, id) -> { + dialog.cancel(); + addReview(true); }); - reviewBuilder.setNeutralButton(android.R.string.no, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - addReview(false); - } + reviewBuilder.setNeutralButton(android.R.string.cancel, (dialog, which) -> { + dialog.cancel(); + addReview(false); }); final AlertDialog alert1 = reviewBuilder.create(); @@ -287,57 +278,60 @@ private void loadFileHashContent(final Bundle savedInstance) { mRecyclerViewFile.setAdapter(mAdapterFile); - btnOpenFile.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0); - } else { - final Intent intent = new Intent() - .setType("*/*") - .setAction(Intent.ACTION_GET_CONTENT) - .addCategory(Intent.CATEGORY_OPENABLE); + btnOpenFile.setOnClickListener(v -> { + if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0); + } else { + final Intent intent = new Intent() + .setType("*/*") + .setAction(Intent.ACTION_GET_CONTENT) + .addCategory(Intent.CATEGORY_OPENABLE); - startActivityForResult(Intent.createChooser(intent, getString(R.string.dialog_select_file)), 123); - } + startActivityForResult(Intent.createChooser(intent, getString(R.string.dialog_select_file)), 123); } }); - btnGenerate.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - if (fileLoading) return; - if (!new File(getBaseContext().getCacheDir(), tmpFile).exists()) { - Toast.makeText(getApplicationContext(), R.string.error_no_file, Toast.LENGTH_LONG).show(); - return; - } + btnGenerate.setOnClickListener(v -> { + if (fileLoading) return; + if (!new File(getBaseContext().getCacheDir(), tmpFile).exists()) { + Toast.makeText(getApplicationContext(), R.string.error_no_file, Toast.LENGTH_LONG).show(); + return; + } - mRecyclerViewFile.setAdapter(null); + mRecyclerViewFile.setAdapter(null); - fileDataArrayList = new ArrayList<>(); - mAdapterFile = new DataAdapter(fileDataArrayList); + fileDataArrayList = new ArrayList<>(); + mAdapterFile = new DataAdapter(fileDataArrayList); - mRecyclerViewFile.setAdapter(mAdapterFile); + mRecyclerViewFile.setAdapter(mAdapterFile); - fileDataArrayList.clear(); - mAdapterFile.notifyDataSetChanged(); + fileDataArrayList.clear(); + mAdapterFile.notifyDataSetChanged(); - String compare = ""; - if (edtFileCompare.getText() != null) { - compare = edtFileCompare.getText().toString(); - } + String compare = ""; + if (edtFileCompare.getText() != null) { + compare = edtFileCompare.getText().toString(); + } - try { - final HashGenerator fileHashGenerator = new FileHashGenerator(new File(getApplicationContext().getCacheDir(), tmpFile), getHashAlgorithms(), compare); - fileLoading = true; - fileHashGenerator.hashResponse = MainActivity.this; - fileHashGenerator.execute(); + try { + final HashGenerator fileHashGenerator = new HashGenerator(new File(getApplicationContext().getCacheDir(), tmpFile), getHashAlgorithms(), compare); + fileLoading = true; - pgbFile.setVisibility(View.VISIBLE); - } catch (IOException e) { - Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); - pgbFile.setVisibility(View.GONE); - } + CompletableFuture.supplyAsync(fileHashGenerator::generateHashes) + .thenAccept(s -> runOnUiThread(() -> { + fileLoading = false; + pgbFile.setVisibility(View.GONE); + + for (final HashData d : s) { + fileDataArrayList.add(d); + mAdapterFile.notifyItemInserted(fileDataArrayList.size()); + } + })); + + pgbFile.setVisibility(View.VISIBLE); + } catch (IOException e) { + Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); + pgbFile.setVisibility(View.GONE); } }); } @@ -376,38 +370,45 @@ private void loadTextHashContent(final Bundle savedInstance) { mRecyclerViewText.setAdapter(mAdapterText); - btnGenerate.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (textLoading) return; - mRecyclerViewText.setAdapter(null); + btnGenerate.setOnClickListener(v -> { + if (textLoading) return; + mRecyclerViewText.setAdapter(null); - textDataArrayList = new ArrayList<>(); - mAdapterText = new DataAdapter(textDataArrayList); + textDataArrayList = new ArrayList<>(); + mAdapterText = new DataAdapter(textDataArrayList); - mRecyclerViewText.setAdapter(mAdapterText); + mRecyclerViewText.setAdapter(mAdapterText); - fileDataArrayList.clear(); - mAdapterText.notifyDataSetChanged(); + fileDataArrayList.clear(); + mAdapterText.notifyDataSetChanged(); - if (edtTextData.getText() == null || edtTextData.getText().toString().length() == 0) { - Toast.makeText(MainActivity.this, R.string.toast_error_notext, Toast.LENGTH_SHORT).show(); - return; - } + if (edtTextData.getText() == null || edtTextData.getText().toString().length() == 0) { + Toast.makeText(MainActivity.this, R.string.toast_error_notext, Toast.LENGTH_SHORT).show(); + return; + } - final String data = edtTextData.getText().toString(); - String compare = ""; - if (edtTextCompare.getText() != null) { - compare = edtTextCompare.getText().toString(); - } + final String data = edtTextData.getText().toString(); + String compare = ""; + if (edtTextCompare.getText() != null) { + compare = edtTextCompare.getText().toString(); + } - final HashGenerator textHashGenerator = new TextHashGenerator(data.getBytes(), getHashAlgorithms(), compare); - textLoading = true; - textHashGenerator.hashResponse = MainActivity.this; - textHashGenerator.execute(); - pgbText.setVisibility(View.VISIBLE); - } + final HashGenerator textHashGenerator = new HashGenerator(data.getBytes(), getHashAlgorithms(), compare); + textLoading = true; + + CompletableFuture.supplyAsync(textHashGenerator::generateHashes) + .thenAccept(s -> runOnUiThread(() -> { + textLoading = false; + pgbText.setVisibility(View.GONE); + + for (final HashData d : s) { + textDataArrayList.add(d); + mAdapterText.notifyItemInserted(textDataArrayList.size()); + } + })); + + pgbText.setVisibility(View.VISIBLE); }); } @@ -442,25 +443,15 @@ private void loadHelpContent() { final Button btnWebsite = findViewById(R.id.ButtonWebsite); final Button btnSupport = findViewById(R.id.ButtonSupport); - btnWebsite.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - IntentUtils.openSite(v.getContext(), "http://codedead.com/"); - } - }); + btnWebsite.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "http://codedead.com/")); - btnSupport.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - ShareCompat.IntentBuilder.from(MainActivity.this) - .setType("message/rfc822") - .addEmailTo("admin@codedead.com") - .setSubject("DeadHash - Android") - .setText("") - .setChooserTitle(R.string.text_send_mail) - .startChooser(); - } - }); + btnSupport.setOnClickListener(v -> ShareCompat.IntentBuilder.from(MainActivity.this) + .setType("message/rfc822") + .addEmailTo("admin@codedead.com") + .setSubject("DeadHash - Android") + .setText("") + .setChooserTitle(R.string.text_send_mail) + .startChooser()); } /** @@ -471,26 +462,9 @@ private void loadAboutContent() { final ImageButton btnTwitter = findViewById(R.id.BtnTwitter); final ImageButton btnWebsite = findViewById(R.id.BtnWebsiteAbout); - btnWebsite.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - IntentUtils.openSite(v.getContext(), "http://codedead.com/"); - } - }); - - btnFacebook.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - IntentUtils.openSite(v.getContext(), "https://facebook.com/deadlinecodedead"); - } - }); - - btnTwitter.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - IntentUtils.openSite(v.getContext(), "https://twitter.com/C0DEDEAD"); - } - }); + btnWebsite.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "http://codedead.com/")); + btnFacebook.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "https://facebook.com/deadlinecodedead")); + btnTwitter.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "https://twitter.com/C0DEDEAD")); } /** @@ -535,47 +509,41 @@ private void loadSettingsContent() { final Button btnSave = findViewById(R.id.BtnSaveSettings); loadSettings(); - btnReset.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - saveSettings("en", true, true, true, true, true, true, true); - final Context c = LocaleHelper.setLocale(getApplicationContext(), settingsContainer.getLanguageCode()); - Toast.makeText(MainActivity.this, c.getString(R.string.toast_settings_reset), Toast.LENGTH_SHORT).show(); - recreate(); - loadSettings(); - } + btnReset.setOnClickListener(v -> { + saveSettings("en", true, true, true, true, true, true, true); + final Context c = LocaleHelper.setLocale(getApplicationContext(), settingsContainer.getLanguageCode()); + Toast.makeText(MainActivity.this, c.getString(R.string.toast_settings_reset), Toast.LENGTH_SHORT).show(); + recreate(); + loadSettings(); }); - btnSave.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String lang; - switch (spnLanguages.getSelectedItemPosition()) { - default: - lang = "en"; - break; - case 1: - lang = "nl"; - break; - case 2: - lang = "fr"; - break; - case 3: - lang = "de"; - break; - case 4: - lang = "it"; - break; - case 5: - lang = "pt"; - } - - saveSettings(lang, ChbMD5.isChecked(), ChbSHA1.isChecked(), ChbSHA224.isChecked(), ChbSHA256.isChecked(), ChbSHA384.isChecked(), ChbSHA512.isChecked(), ChbCRC32.isChecked()); - final Context c = LocaleHelper.setLocale(getApplicationContext(), settingsContainer.getLanguageCode()); - Toast.makeText(MainActivity.this, c.getString(R.string.toast_settings_save), Toast.LENGTH_SHORT).show(); - recreate(); - loadSettings(); + btnSave.setOnClickListener(v -> { + String lang; + switch (spnLanguages.getSelectedItemPosition()) { + default: + lang = "en"; + break; + case 1: + lang = "nl"; + break; + case 2: + lang = "fr"; + break; + case 3: + lang = "de"; + break; + case 4: + lang = "it"; + break; + case 5: + lang = "pt"; } + + saveSettings(lang, ChbMD5.isChecked(), ChbSHA1.isChecked(), ChbSHA224.isChecked(), ChbSHA256.isChecked(), ChbSHA384.isChecked(), ChbSHA512.isChecked(), ChbCRC32.isChecked()); + final Context c = LocaleHelper.setLocale(getApplicationContext(), settingsContainer.getLanguageCode()); + Toast.makeText(MainActivity.this, c.getString(R.string.toast_settings_save), Toast.LENGTH_SHORT).show(); + recreate(); + loadSettings(); }); } @@ -642,12 +610,7 @@ public void onBackPressed() { this.doubleBackToExitPressedOnce = true; Toast.makeText(this, R.string.toast_back_again, Toast.LENGTH_SHORT).show(); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - doubleBackToExitPressedOnce = false; - } - }, 2000); + new Handler(Looper.getMainLooper()).postDelayed(() -> doubleBackToExitPressedOnce = false, 2000); } } @@ -655,19 +618,15 @@ public void run() { public boolean onNavigationItemSelected(@NonNull final MenuItem item) { int page = 0; - switch (item.getItemId()) { - case R.id.nav_text: - page = 1; - break; - case R.id.nav_help: - page = 2; - break; - case R.id.nav_about: - page = 3; - break; - case R.id.nav_manage: - page = 4; - break; + final int itemId = item.getItemId(); + if (itemId == R.id.nav_text) { + page = 1; + } else if (itemId == R.id.nav_help) { + page = 2; + } else if (itemId == R.id.nav_about) { + page = 3; + } else if (itemId == R.id.nav_manage) { + page = 4; } viewFlipper.setDisplayedChild(page); @@ -677,28 +636,6 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) { return true; } - @Override - public void hashDataFile(final List data) { - fileLoading = false; - pgbFile.setVisibility(View.GONE); - - for (final HashData d : data) { - fileDataArrayList.add(d); - mAdapterFile.notifyItemInserted(fileDataArrayList.size()); - } - } - - @Override - public void hashDataText(final List data) { - textLoading = false; - pgbText.setVisibility(View.GONE); - - for (final HashData d : data) { - textDataArrayList.add(d); - mAdapterText.notifyItemInserted(textDataArrayList.size()); - } - } - @Override protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) { super.onActivityResult(requestCode, resultCode, data); diff --git a/build.gradle b/build.gradle index 2d1d9aa..017511d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.1' + classpath 'com.android.tools.build:gradle:4.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ab20864..be52383 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Mar 19 15:44:11 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip diff --git a/gradlew b/gradlew index b0d6d0a..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9991c50..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -5,7 +5,7 @@ @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem -@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell