Skip to content

Commit 081c18b

Browse files
authored
Merge pull request #23 from CodeDead/release/v1.7.7
Release/v1.7.7
2 parents 84100c7 + 4673267 commit 081c18b

30 files changed

+98
-83
lines changed

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# DeadHash
22

3-
DeadHash is a freeware utility to calculate file and text hashes. The following hash calculations are supported:
3+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/CodeDead/DeadHash-android)
4+
![GitHub](https://img.shields.io/badge/language-Java-green)
5+
![GitHub](https://img.shields.io/github/license/CodeDead/DeadHash-android)
6+
7+
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
8+
alt="Get it on F-Droid"
9+
height="80">](https://f-droid.org/packages/com.codedead.deadhash/)
10+
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
11+
alt="Get it on Google Play"
12+
height="80">](https://play.google.com/store/apps/details?id=com.codedead.deadhash)
13+
14+
DeadHash is a freeware utility to calculate file and text hashes.
15+
16+
## Features
17+
18+
The following hash calculations are supported:
419
* MD5
520
* SHA-1
621
* SHA-224
722
* SHA-256
8-
* SHA-3
923
* SHA-384
1024
* SHA-512
1125
* CRC32
1226

13-
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
14-
alt="Get it on F-Droid"
15-
height="80">](https://f-droid.org/packages/com.codedead.deadhash/)
16-
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
17-
alt="Get it on Google Play"
18-
height="80">](https://play.google.com/store/apps/details?id=com.codedead.deadhash)
19-
2027
## About
2128

2229
This library is maintained by CodeDead. You can find more about us using the following links:
2330
* [Website](https://codedead.com)
2431
* [Twitter](https://twitter.com/C0DEDEAD)
2532
* [Facebook](https://facebook.com/deadlinecodedead)
26-
* [Reddit](https://reddit.com/r/CodeDead/)
2733

2834
Copyright © 2022 CodeDead

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ android {
77
applicationId "com.codedead.deadhash"
88
minSdkVersion 24
99
targetSdkVersion 31
10-
versionName '1.7.6'
10+
versionName '1.7.7'
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12-
versionCode 7
12+
versionCode 8
1313
}
1414
buildTypes {
1515
release {

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
tools:ignore="GoogleAppIndexingWarning">
2020
<activity
2121
android:name=".gui.MainActivity"
22-
android:label="@string/app_name"
2322
android:exported="true"
2423
android:launchMode="singleInstance"
2524
android:theme="@style/Theme.DeadHash.NoActionBar">
11.8 KB
Loading

app/src/main/java/com/codedead/deadhash/domain/utils/LocaleHelper.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.codedead.deadhash.domain.utils;
22

3-
import android.annotation.TargetApi;
43
import android.content.Context;
54
import android.content.SharedPreferences;
65
import android.content.res.Configuration;
76
import android.content.res.Resources;
8-
import android.os.Build;
97

108
import androidx.preference.PreferenceManager;
119

@@ -45,11 +43,6 @@ public static Context onAttach(final Context context, final String defaultLangua
4543
*/
4644
public static Context setLocale(final Context context, final String language) {
4745
persist(context, language);
48-
49-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
50-
return updateResources(context, language);
51-
}
52-
5346
return updateResourcesLegacy(context, language);
5447
}
5548

@@ -79,24 +72,6 @@ private static void persist(final Context context, final String language) {
7972
editor.apply();
8073
}
8174

82-
/**
83-
* Update the resources of a specific Context
84-
*
85-
* @param context The Context that should be updated to contain the proper resources
86-
* @param language The language code that should be set
87-
* @return The Context that contains the correct resources and locale
88-
*/
89-
@TargetApi(Build.VERSION_CODES.N)
90-
private static Context updateResources(final Context context, final String language) {
91-
final Locale locale = new Locale(language);
92-
Locale.setDefault(locale);
93-
94-
final Configuration configuration = context.getResources().getConfiguration();
95-
configuration.setLocale(locale);
96-
97-
return context.createConfigurationContext(configuration);
98-
}
99-
10075
/**
10176
* Update the resources of a specific Context
10277
*

app/src/main/java/com/codedead/deadhash/gui/MainActivity.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import android.os.CountDownTimer;
1111
import android.os.Handler;
1212

13+
import androidx.activity.result.ActivityResultLauncher;
14+
import androidx.activity.result.contract.ActivityResultContracts;
1315
import androidx.annotation.NonNull;
14-
import androidx.annotation.Nullable;
1516
import androidx.appcompat.app.AppCompatDelegate;
1617
import androidx.core.app.ActivityCompat;
1718
import androidx.core.app.ShareCompat;
@@ -106,6 +107,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
106107
private CheckBox ChbCRC32;
107108

108109
private final String tmpFile = "tmpFile";
110+
private ActivityResultLauncher<Intent> activityResultLauncher;
109111

110112
@Override
111113
protected void onCreate(final Bundle savedInstanceState) {
@@ -163,6 +165,35 @@ protected void onCreate(final Bundle savedInstanceState) {
163165
loadSettingsContent();
164166

165167
loadAlertContent();
168+
169+
this.activityResultLauncher = registerForActivityResult(
170+
new ActivityResultContracts.StartActivityForResult(),
171+
result -> {
172+
if (result.getData() != null) {
173+
final Uri selectedFileUri = result.getData().getData();
174+
if (selectedFileUri != null) {
175+
try (final InputStream selectedFileStream = getContentResolver().openInputStream(selectedFileUri)) {
176+
final File outputFile = new File(getApplicationContext().getCacheDir(), tmpFile);
177+
178+
try (final FileOutputStream outputStream = new FileOutputStream(outputFile, false)) {
179+
if (selectedFileStream != null) {
180+
StreamUtility.copyStream(selectedFileStream, outputStream);
181+
edtFilePath.setText(selectedFileUri.getPath());
182+
} else {
183+
Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show();
184+
}
185+
} catch (final IOException ex) {
186+
Toast.makeText(getApplicationContext()
187+
, R.string.error_copy_file, Toast.LENGTH_SHORT).show();
188+
}
189+
} catch (final IOException ex) {
190+
Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show();
191+
}
192+
} else {
193+
Toast.makeText(getApplicationContext(), R.string.error_open_file, Toast.LENGTH_SHORT).show();
194+
}
195+
}
196+
});
166197
}
167198

168199
/**
@@ -297,7 +328,7 @@ private void loadFileHashContent(final Bundle savedInstance) {
297328
.setAction(Intent.ACTION_GET_CONTENT)
298329
.addCategory(Intent.CATEGORY_OPENABLE);
299330

300-
startActivityForResult(Intent.createChooser(intent, getString(R.string.dialog_select_file)), 123);
331+
activityResultLauncher.launch(Intent.createChooser(intent, getString(R.string.dialog_select_file)));
301332
}
302333
});
303334

@@ -455,7 +486,7 @@ private void loadHelpContent() {
455486

456487
btnWebsite.setOnClickListener(v -> IntentUtils.openSite(v.getContext(), "http://codedead.com/"));
457488

458-
btnSupport.setOnClickListener(v -> ShareCompat.IntentBuilder.from(MainActivity.this)
489+
btnSupport.setOnClickListener(v -> new ShareCompat.IntentBuilder(MainActivity.this)
459490
.setType("message/rfc822")
460491
.addEmailTo("[email protected]")
461492
.setSubject("DeadHash - Android")
@@ -577,7 +608,6 @@ private void loadSettingsContent() {
577608
lang = "ru";
578609
}
579610

580-
581611
final int checkedRadioButtonId = group.getCheckedRadioButtonId();
582612
int themeIndex = 0;
583613
if (checkedRadioButtonId == R.id.RdbLightTheme) {
@@ -683,34 +713,4 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
683713
drawer.closeDrawer(GravityCompat.START);
684714
return true;
685715
}
686-
687-
@Override
688-
protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) {
689-
super.onActivityResult(requestCode, resultCode, data);
690-
if (requestCode == 123 && resultCode == RESULT_OK) {
691-
if (data != null) {
692-
final Uri selectedFileUri = data.getData();
693-
if (selectedFileUri != null) {
694-
try (final InputStream selectedFileStream = getContentResolver().openInputStream(selectedFileUri)) {
695-
final File outputFile = new File(getApplicationContext().getCacheDir(), tmpFile);
696-
697-
try (final FileOutputStream outputStream = new FileOutputStream(outputFile, false)) {
698-
if (selectedFileStream != null) {
699-
StreamUtility.copyStream(selectedFileStream, outputStream);
700-
edtFilePath.setText(selectedFileUri.getPath());
701-
} else {
702-
Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show();
703-
}
704-
} catch (final IOException ex) {
705-
Toast.makeText(this, R.string.error_copy_file, Toast.LENGTH_SHORT).show();
706-
}
707-
} catch (final IOException ex) {
708-
Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show();
709-
}
710-
} else {
711-
Toast.makeText(this, R.string.error_open_file, Toast.LENGTH_SHORT).show();
712-
}
713-
}
714-
}
715-
}
716716
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="108dp"
3+
android:height="108dp"
4+
android:viewportWidth="108"
5+
android:viewportHeight="108"
6+
android:tint="#FFFFFF">
7+
<group android:scaleX="2.8188"
8+
android:scaleY="2.8188"
9+
android:translateX="20.1744"
10+
android:translateY="20.1744">
11+
<path
12+
android:fillColor="@android:color/white"
13+
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"/>
14+
</group>
15+
</vector>

app/src/main/res/layout/content_text.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@
3030
android:importantForAutofill="no"
3131
android:inputType="text" />
3232
</TableRow>
33+
</TableLayout>
3334

34-
<TableRow>
35+
<TableLayout
36+
android:id="@+id/layout_compare"
37+
android:layout_width="match_parent"
38+
android:layout_height="wrap_content"
39+
android:layout_below="@+id/layout_text">
3540

41+
<TableRow>
3642
<TextView
3743
android:id="@+id/Text_FileCompare"
3844
android:layout_width="wrap_content"
@@ -57,7 +63,7 @@
5763
style="@style/Widget.AppCompat.Button.Colored"
5864
android:layout_width="wrap_content"
5965
android:layout_height="wrap_content"
60-
android:layout_below="@+id/layout_text"
66+
android:layout_below="@+id/layout_compare"
6167
android:layout_alignParentEnd="true"
6268
android:text="@string/button_generate">
6369

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>

0 commit comments

Comments
 (0)