Skip to content

Commit

Permalink
Merge pull request #37 from Arctosoft/develop
Browse files Browse the repository at this point in the history
Read note with UTF-8, updated version
  • Loading branch information
hej2010 authored Jan 15, 2024
2 parents 426e1bb + 5cfb810 commit 83d7629
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "se.arctosoft.vault"
minSdk 28
targetSdk 34
versionCode 17
versionName "1.5.0"
versionCode 18
versionName "1.5.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private void loadNote(GalleryPagerViewHolder holder, FragmentActivity context, G
} else {
holder.parentBinding.noteLayout.setVisibility(View.VISIBLE);
holder.parentBinding.note.setText(context.getString(R.string.gallery_loading_note));
new Thread(() -> Encryption.decryptToCache(context, galleryFile.getNoteUri(), settings.getTempPassword(), new Encryption.IOnUriResult() {
Encryption.decryptToCache(context, galleryFile.getNoteUri(), settings.getTempPassword(), new Encryption.IOnUriResult() {
@Override
public void onUriResult(Uri outputUri) { // decrypted, now read it
try {
Expand All @@ -456,7 +456,7 @@ public void onInvalidPassword(InvalidPasswordException e) {
galleryFile.setNote(context.getString(R.string.gallery_note_decrypt_failed, e.getMessage()));
context.runOnUiThread(() -> notifyItemChanged(holder.getBindingAdapterPosition(), new GalleryGridAdapter.Payload(GalleryGridAdapter.Payload.TYPE_LOADED_NOTE)));
}
})).start();
});
}
} else {
holder.parentBinding.noteLayout.setVisibility(View.GONE);
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/se/arctosoft/vault/utils/FileStuff.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -169,11 +170,13 @@ public static String getNameWithoutPrefix(@NonNull String s) {

public static String readTextFromUri(@NonNull Uri uri, Context context) throws IOException {
InputStream in = context.getContentResolver().openInputStream(uri);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));

StringBuilder sb = new StringBuilder();
String s;
while ((s = br.readLine()) != null) {
sb.append(s);
int read;
char[] buffer = new char[8192];
while ((read = br.read(buffer)) != -1) {
sb.append(buffer, 0, read);
}

return sb.toString();
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Add notes (text) to files
* Files are exported into the directory where the encrypted file is instead of the topmost directory (bug fix)
* Files are exported with the original name instead of the encrypted name
3 changes: 3 additions & 0 deletions fastlane/metadata/android/sv-SE/changelogs/18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Lägg till anteckningar/text till filer
* Filer exporteras nu till samma mapp där den krypterade filen ligger istället för den översta mappen (buggfix)
* Filer exporteras nu med originalnamnet istället för det krypterade filnamnet

0 comments on commit 83d7629

Please sign in to comment.