diff --git a/README.md b/README.md index 149184d..862f026 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,34 @@ # DeadHash -DeadHash is a freeware utility to calculate file and text hashes. The following hash calculations are supported: +![GitHub release (latest by date)](https://img.shields.io/github/v/release/CodeDead/DeadHash-android) +![GitHub](https://img.shields.io/badge/language-Java-green) +![GitHub](https://img.shields.io/github/license/CodeDead/DeadHash-android) + +[](https://f-droid.org/packages/com.codedead.deadhash/) +[](https://play.google.com/store/apps/details?id=com.codedead.deadhash) + +DeadHash is a freeware utility to calculate file and text hashes. + +## Features + +The following hash calculations are supported: * MD5 * SHA-1 * SHA-224 * SHA-256 -* SHA-3 * SHA-384 * SHA-512 * CRC32 -[Get it on F-Droid](https://f-droid.org/packages/com.codedead.deadhash/) -[Get it on Google Play](https://play.google.com/store/apps/details?id=com.codedead.deadhash) - ## 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) * [Facebook](https://facebook.com/deadlinecodedead) -* [Reddit](https://reddit.com/r/CodeDead/) Copyright © 2022 CodeDead diff --git a/app/build.gradle b/app/build.gradle index 3c6187c..d9d16cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,9 +7,9 @@ android { applicationId "com.codedead.deadhash" minSdkVersion 24 targetSdkVersion 31 - versionName '1.7.6' + versionName '1.7.7' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - versionCode 7 + versionCode 8 } buildTypes { release { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 06d0cce..33eb738 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,6 @@ tools:ignore="GoogleAppIndexingWarning"> diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..92d0c4a Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/codedead/deadhash/domain/utils/LocaleHelper.java b/app/src/main/java/com/codedead/deadhash/domain/utils/LocaleHelper.java index 1361fa4..b09fc51 100644 --- a/app/src/main/java/com/codedead/deadhash/domain/utils/LocaleHelper.java +++ b/app/src/main/java/com/codedead/deadhash/domain/utils/LocaleHelper.java @@ -1,11 +1,9 @@ package com.codedead.deadhash.domain.utils; -import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; -import android.os.Build; import androidx.preference.PreferenceManager; @@ -45,11 +43,6 @@ public static Context onAttach(final Context context, final String defaultLangua */ public static Context setLocale(final Context context, final String language) { persist(context, language); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return updateResources(context, language); - } - return updateResourcesLegacy(context, language); } @@ -79,24 +72,6 @@ private static void persist(final Context context, final String language) { editor.apply(); } - /** - * Update the resources of a specific Context - * - * @param context The Context that should be updated to contain the proper resources - * @param language The language code that should be set - * @return The Context that contains the correct resources and locale - */ - @TargetApi(Build.VERSION_CODES.N) - private static Context updateResources(final Context context, final String language) { - final Locale locale = new Locale(language); - Locale.setDefault(locale); - - final Configuration configuration = context.getResources().getConfiguration(); - configuration.setLocale(locale); - - return context.createConfigurationContext(configuration); - } - /** * Update the resources of a specific Context * 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 1d9d10d..062e581 100644 --- a/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java +++ b/app/src/main/java/com/codedead/deadhash/gui/MainActivity.java @@ -10,8 +10,9 @@ import android.os.CountDownTimer; import android.os.Handler; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatDelegate; import androidx.core.app.ActivityCompat; import androidx.core.app.ShareCompat; @@ -106,6 +107,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On private CheckBox ChbCRC32; private final String tmpFile = "tmpFile"; + private ActivityResultLauncher activityResultLauncher; @Override protected void onCreate(final Bundle savedInstanceState) { @@ -163,6 +165,35 @@ protected void onCreate(final Bundle savedInstanceState) { loadSettingsContent(); loadAlertContent(); + + this.activityResultLauncher = registerForActivityResult( + new ActivityResultContracts.StartActivityForResult(), + result -> { + if (result.getData() != null) { + final Uri selectedFileUri = result.getData().getData(); + if (selectedFileUri != null) { + try (final InputStream selectedFileStream = getContentResolver().openInputStream(selectedFileUri)) { + final File outputFile = new File(getApplicationContext().getCacheDir(), tmpFile); + + try (final FileOutputStream outputStream = new FileOutputStream(outputFile, false)) { + if (selectedFileStream != null) { + StreamUtility.copyStream(selectedFileStream, outputStream); + edtFilePath.setText(selectedFileUri.getPath()); + } else { + Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show(); + } + } catch (final IOException ex) { + Toast.makeText(getApplicationContext() + , R.string.error_copy_file, Toast.LENGTH_SHORT).show(); + } + } catch (final IOException ex) { + Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show(); + } + } + }); } /** @@ -297,7 +328,7 @@ private void loadFileHashContent(final Bundle savedInstance) { .setAction(Intent.ACTION_GET_CONTENT) .addCategory(Intent.CATEGORY_OPENABLE); - startActivityForResult(Intent.createChooser(intent, getString(R.string.dialog_select_file)), 123); + activityResultLauncher.launch(Intent.createChooser(intent, getString(R.string.dialog_select_file))); } }); @@ -455,7 +486,7 @@ private void loadHelpContent() { btnWebsite.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "http://codedead.com/")); - btnSupport.setOnClickListener(v -> ShareCompat.IntentBuilder.from(MainActivity.this) + btnSupport.setOnClickListener(v -> new ShareCompat.IntentBuilder(MainActivity.this) .setType("message/rfc822") .addEmailTo("admin@codedead.com") .setSubject("DeadHash - Android") @@ -577,7 +608,6 @@ private void loadSettingsContent() { lang = "ru"; } - final int checkedRadioButtonId = group.getCheckedRadioButtonId(); int themeIndex = 0; if (checkedRadioButtonId == R.id.RdbLightTheme) { @@ -683,34 +713,4 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) { drawer.closeDrawer(GravityCompat.START); return true; } - - @Override - protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == 123 && resultCode == RESULT_OK) { - if (data != null) { - final Uri selectedFileUri = data.getData(); - if (selectedFileUri != null) { - try (final InputStream selectedFileStream = getContentResolver().openInputStream(selectedFileUri)) { - final File outputFile = new File(getApplicationContext().getCacheDir(), tmpFile); - - try (final FileOutputStream outputStream = new FileOutputStream(outputFile, false)) { - if (selectedFileStream != null) { - StreamUtility.copyStream(selectedFileStream, outputStream); - edtFilePath.setText(selectedFileUri.getPath()); - } else { - Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show(); - } - } catch (final IOException ex) { - Toast.makeText(this, R.string.error_copy_file, Toast.LENGTH_SHORT).show(); - } - } catch (final IOException ex) { - Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show(); - } - } else { - Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show(); - } - } - } - } } diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..74e5b3a --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/content_text.xml b/app/src/main/res/layout/content_text.xml index 703a470..ff2c54d 100644 --- a/app/src/main/res/layout/content_text.xml +++ b/app/src/main/res/layout/content_text.xml @@ -30,9 +30,15 @@ android:importantForAutofill="no" android:inputType="text" /> + - + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 5d30b3b..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index b288363..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 043e4ae..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 6bbac87..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 073721c..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 4350072..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 6f0b3dd..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 6c44272..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 537ae8f..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index f7cdb7b..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4f44ddb..d93b893 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -46,7 +46,7 @@ Es kann keine Kopie der ausgewählten Datei erstellt werden! Die ausgewählte Datei kann nicht geöffnet werden! Es wurde keine Datei ausgewählt! - Thema + Thema: Licht Dunkel Standard diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b8f3a24..fbc00cd 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -46,7 +46,7 @@ Impossible de créer une copie du fichier sélectionné! Impossible d\'ouvrir le fichier sélectionné! Aucun fichier n\'a été sélectionné! - Thème + Thème: Lumière Foncé Défaut diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 5896451..03aaf58 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -46,7 +46,7 @@ Impossibile creare una copia del file selezionato! Impossibile aprire il file selezionato! Nessun file è stato selezionato! - Tema + Tema: Luce Buio Predefinito diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index aa9142d..14ab843 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -46,7 +46,7 @@ Kon geen kopie van het bestand maken! Kon het geselecteerde bestand niet openen! Geen bestand geselecteerd! - Thema + Thema: Donker Licht Standaard diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9ae06d3..d43dacf 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -46,7 +46,7 @@ Não foi possível criar uma cópia do arquivo selecionado! Não foi possível abrir o arquivo selecionado! Nenhum arquivo foi selecionado! - Tema + Tema: Claro Escuro Predefinição diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 4a917a7..508a482 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -46,7 +46,7 @@ Не могу копировать выбранный файл! Не могу открыть выбранный файл! Не был выбран ни один файл! - Тема + Тема: Тёмная Светлая По умолчанию diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..beab31f --- /dev/null +++ b/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #000000 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 04a3886..0677246 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,7 +58,7 @@ Unable to open the selected file! Unable to create a copy of the selected file! No file was selected! - Theme + Theme: Dark Light Default diff --git a/build.gradle b/build.gradle index da11dfb..cdf8d5c 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:7.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4410496..105209b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jul 06 16:47:53 CEST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME