Skip to content
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
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.codedead.deadhash/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
alt="Get it on Google Play"
height="80">](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

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.codedead.deadhash/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
alt="Get it on Google Play"
height="80">](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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".gui.MainActivity"
android:label="@string/app_name"
android:exported="true"
android:launchMode="singleInstance"
android:theme="@style/Theme.DeadHash.NoActionBar">
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
*
Expand Down
68 changes: 34 additions & 34 deletions app/src/main/java/com/codedead/deadhash/gui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,6 +107,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private CheckBox ChbCRC32;

private final String tmpFile = "tmpFile";
private ActivityResultLauncher<Intent> activityResultLauncher;

@Override
protected void onCreate(final Bundle savedInstanceState) {
Expand Down Expand Up @@ -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();
}
}
});
}

/**
Expand Down Expand Up @@ -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)));
}
});

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -577,7 +608,6 @@ private void loadSettingsContent() {
lang = "ru";
}


final int checkedRadioButtonId = group.getCheckedRadioButtonId();
int themeIndex = 0;
if (checkedRadioButtonId == R.id.RdbLightTheme) {
Expand Down Expand Up @@ -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();
}
}
}
}
}
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108"
android:tint="#FFFFFF">
<group android:scaleX="2.8188"
android:scaleY="2.8188"
android:translateX="20.1744"
android:translateY="20.1744">
<path
android:fillColor="@android:color/white"
android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</group>
</vector>
10 changes: 8 additions & 2 deletions app/src/main/res/layout/content_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@
android:importantForAutofill="no"
android:inputType="text" />
</TableRow>
</TableLayout>

<TableRow>
<TableLayout
android:id="@+id/layout_compare"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_text">

<TableRow>
<TextView
android:id="@+id/Text_FileCompare"
android:layout_width="wrap_content"
Expand All @@ -57,7 +63,7 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_text"
android:layout_below="@+id/layout_compare"
android:layout_alignParentEnd="true"
android:text="@string/button_generate">

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Es kann keine Kopie der ausgewählten Datei erstellt werden!</string>
<string name="error_open_file">Die ausgewählte Datei kann nicht geöffnet werden!</string>
<string name="error_no_file">Es wurde keine Datei ausgewählt!</string>
<string name="theme">Thema</string>
<string name="theme">Thema:</string>
<string name="light">Licht</string>
<string name="dark">Dunkel</string>
<string name="defaultTheme">Standard</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Impossible de créer une copie du fichier sélectionné!</string>
<string name="error_open_file">Impossible d\'ouvrir le fichier sélectionné!</string>
<string name="error_no_file">Aucun fichier n\'a été sélectionné!</string>
<string name="theme">Thème</string>
<string name="theme">Thème:</string>
<string name="light">Lumière</string>
<string name="dark">Foncé</string>
<string name="defaultTheme">Défaut</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Impossibile creare una copia del file selezionato!</string>
<string name="error_open_file">Impossibile aprire il file selezionato!</string>
<string name="error_no_file">Nessun file è stato selezionato!</string>
<string name="theme">Tema</string>
<string name="theme">Tema:</string>
<string name="light">Luce</string>
<string name="dark">Buio</string>
<string name="defaultTheme">Predefinito</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Kon geen kopie van het bestand maken!</string>
<string name="error_open_file">Kon het geselecteerde bestand niet openen!</string>
<string name="error_no_file">Geen bestand geselecteerd!</string>
<string name="theme">Thema</string>
<string name="theme">Thema:</string>
<string name="dark">Donker</string>
<string name="light">Licht</string>
<string name="defaultTheme">Standaard</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Não foi possível criar uma cópia do arquivo selecionado!</string>
<string name="error_open_file">Não foi possível abrir o arquivo selecionado!</string>
<string name="error_no_file">Nenhum arquivo foi selecionado!</string>
<string name="theme">Tema</string>
<string name="theme">Tema:</string>
<string name="light">Claro</string>
<string name="dark">Escuro</string>
<string name="defaultTheme">Predefinição</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<string name="error_copy_file">Не могу копировать выбранный файл!</string>
<string name="error_open_file">Не могу открыть выбранный файл!</string>
<string name="error_no_file">Не был выбран ни один файл!</string>
<string name="theme">Тема</string>
<string name="theme">Тема:</string>
<string name="dark">Тёмная</string>
<string name="light">Светлая</string>
<string name="defaultTheme">По умолчанию</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#000000</color>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<string name="error_open_file">Unable to open the selected file!</string>
<string name="error_copy_file">Unable to create a copy of the selected file!</string>
<string name="error_no_file">No file was selected!</string>
<string name="theme">Theme</string>
<string name="theme">Theme:</string>
<string name="dark">Dark</string>
<string name="light">Light</string>
<string name="defaultTheme">Default</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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