Skip to content

Commit 0634eda

Browse files
authored
Merge pull request #106 from Arctosoft/develop
v2.1.0
2 parents f4174e5 + 1b848dd commit 0634eda

File tree

14 files changed

+129
-42
lines changed

14 files changed

+129
-42
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
applicationId = "se.arctosoft.vault"
1212
minSdk = 28
1313
targetSdk = 35
14-
versionCode = 32
15-
versionName = "2.0.1"
14+
versionCode = 33
15+
versionName = "2.1.0"
1616

1717
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1818
}

app/src/main/java/se/arctosoft/vault/BottomSheetImportFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
136136
} else {
137137
binding.checkboxDeleteAfter.setVisibility(View.VISIBLE);
138138
binding.checkboxDeleteAfter.setEnabled(true);
139+
binding.checkboxDeleteAfter.setChecked(settings.isDeleteByDefault());
139140
binding.deleteNote.setVisibility(View.GONE);
140141
}
141142

app/src/main/java/se/arctosoft/vault/SettingsFragment.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package se.arctosoft.vault;
22

3-
import android.net.Uri;
43
import android.os.Bundle;
54
import android.view.Menu;
65
import android.view.MenuInflater;
@@ -19,8 +18,6 @@
1918
import androidx.preference.PreferenceFragmentCompat;
2019
import androidx.preference.SwitchPreferenceCompat;
2120

22-
import java.util.List;
23-
2421
import se.arctosoft.vault.data.Password;
2522
import se.arctosoft.vault.utils.Dialogs;
2623
import se.arctosoft.vault.utils.Settings;
@@ -37,6 +34,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
3734
Preference editFolders = findPreference(Settings.PREF_APP_EDIT_FOLDERS);
3835
SwitchPreferenceCompat useDiskCache = findPreference(Settings.PREF_ENCRYPTION_USE_DISK_CACHE);
3936
SwitchPreferenceCompat secure = findPreference(Settings.PREF_APP_SECURE);
37+
SwitchPreferenceCompat deleteByDefault = findPreference(Settings.PREF_ENCRYPTION_DELETE_BY_DEFAULT);
4038

4139
FragmentActivity activity = requireActivity();
4240
Settings settings = Settings.getInstance(activity);
@@ -60,8 +58,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
6058
});
6159

6260
secure.setOnPreferenceChangeListener((preference, newValue) -> {
63-
boolean enabled = (boolean) newValue;
64-
if (enabled) {
61+
if ((boolean) newValue) {
6562
requireActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
6663
} else {
6764
requireActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -70,8 +67,12 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
7067
});
7168

7269
useDiskCache.setOnPreferenceChangeListener((preference, newValue) -> {
73-
boolean enabled = (boolean) newValue;
74-
settings.setUseDiskCache(enabled);
70+
settings.setUseDiskCache((boolean) newValue);
71+
return true;
72+
});
73+
74+
deleteByDefault.setOnPreferenceChangeListener((preference, newValue) -> {
75+
settings.setDeleteByDefault((boolean) newValue);
7576
return true;
7677
});
7778

app/src/main/java/se/arctosoft/vault/adapters/GalleryPagerAdapter.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import androidx.annotation.NonNull;
3636
import androidx.annotation.OptIn;
37+
import androidx.constraintlayout.widget.ConstraintLayout;
3738
import androidx.core.content.FileProvider;
3839
import androidx.core.content.res.ResourcesCompat;
3940
import androidx.core.graphics.Insets;
@@ -83,6 +84,7 @@
8384
import se.arctosoft.vault.utils.Dialogs;
8485
import se.arctosoft.vault.utils.FileStuff;
8586
import se.arctosoft.vault.utils.GlideStuff;
87+
import se.arctosoft.vault.utils.Pixels;
8688
import se.arctosoft.vault.utils.Settings;
8789
import se.arctosoft.vault.utils.StringStuff;
8890
import se.arctosoft.vault.utils.Toaster;
@@ -102,6 +104,17 @@ public class GalleryPagerAdapter extends RecyclerView.Adapter<GalleryPagerViewHo
102104
private final Password password;
103105
private boolean isFullscreen;
104106

107+
private final View.OnAttachStateChangeListener onAttachStateChangeListener = new View.OnAttachStateChangeListener() {
108+
@Override
109+
public void onViewAttachedToWindow(@NonNull View view) {
110+
view.requestApplyInsets();
111+
}
112+
113+
@Override
114+
public void onViewDetachedFromWindow(@NonNull View view) {
115+
}
116+
};
117+
105118
public GalleryPagerAdapter(FragmentActivity context, @NonNull List<GalleryFile> galleryFiles, IOnFileDeleted onFileDeleted, DocumentFile currentDirectory, boolean isAllFolder, String nestedPath, GalleryViewModel galleryViewModel) {
106119
this.weakReference = new WeakReference<>(context);
107120
this.galleryFiles = galleryFiles;
@@ -133,14 +146,15 @@ public GalleryPagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
133146
return new GalleryPagerViewHolder.GalleryPagerVideoViewHolder(parentBinding, videoBinding);
134147
} else if (viewType == FileType.TYPE_TEXT) {
135148
AdapterGalleryViewpagerItemTextBinding textBinding = AdapterGalleryViewpagerItemTextBinding.inflate(layoutInflater, parentBinding.content, true);
149+
setViewPadding(textBinding.text);
136150
return new GalleryPagerViewHolder.GalleryPagerTextViewHolder(parentBinding, textBinding);
137151
} else {
138152
AdapterGalleryViewpagerItemDirectoryBinding videoBinding = AdapterGalleryViewpagerItemDirectoryBinding.inflate(layoutInflater, parentBinding.content, true);
139153
return new GalleryPagerViewHolder.GalleryPagerDirectoryViewHolder(parentBinding, videoBinding);
140154
}
141155
}
142156

143-
private static void setPadding(@NonNull AdapterGalleryViewpagerItemBinding parentBinding) {
157+
private void setPadding(@NonNull AdapterGalleryViewpagerItemBinding parentBinding) {
144158
ViewCompat.setOnApplyWindowInsetsListener(parentBinding.lLButtons, (v, insets) -> {
145159
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
146160
v.setPadding(bars.left, 0, bars.right, bars.bottom);
@@ -153,24 +167,25 @@ private static void setPadding(@NonNull AdapterGalleryViewpagerItemBinding paren
153167
});
154168
ViewCompat.setOnApplyWindowInsetsListener(parentBinding.imgFullscreen, (v, insets) -> {
155169
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
156-
v.setPadding(bars.left, bars.top, bars.right, 0);
170+
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) v.getLayoutParams();
171+
layoutParams.setMargins(bars.left, bars.top, bars.right, 0);
157172
return WindowInsetsCompat.CONSUMED;
158173
});
159-
View.OnAttachStateChangeListener onAttachStateChangeListener = new View.OnAttachStateChangeListener() {
160-
@Override
161-
public void onViewAttachedToWindow(@NonNull View view) {
162-
view.requestApplyInsets();
163-
}
164-
165-
@Override
166-
public void onViewDetachedFromWindow(@NonNull View view) {
167-
}
168-
};
169174
parentBinding.lLButtons.addOnAttachStateChangeListener(onAttachStateChangeListener);
170175
parentBinding.txtName.addOnAttachStateChangeListener(onAttachStateChangeListener);
171176
parentBinding.imgFullscreen.addOnAttachStateChangeListener(onAttachStateChangeListener);
172177
}
173178

179+
private void setViewPadding(@NonNull View view) {
180+
ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> {
181+
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
182+
int horizontalPadding = Pixels.dpToPixel(4, weakReference.get());
183+
v.setPadding(bars.left + horizontalPadding, bars.top, bars.right + horizontalPadding, bars.bottom);
184+
return WindowInsetsCompat.CONSUMED;
185+
});
186+
view.addOnAttachStateChangeListener(onAttachStateChangeListener);
187+
}
188+
174189
@Override
175190
public void onBindViewHolder(@NonNull GalleryPagerViewHolder holder, int position) {
176191
FragmentActivity context = weakReference.get();
@@ -286,6 +301,7 @@ private void loadOriginalFilename(@NonNull GalleryFile galleryFile, FragmentActi
286301
private void setupTextView(GalleryPagerViewHolder.GalleryPagerTextViewHolder holder, FragmentActivity context, GalleryFile galleryFile) {
287302
holder.binding.text.setText(galleryFile.getText());
288303
holder.binding.text.setTextColor(context.getResources().getColor(this.isFullscreen || context.getResources().getBoolean(R.bool.night) ? R.color.text_color_light : R.color.text_color_dark, context.getTheme()));
304+
holder.binding.text.setTextIsSelectable(true);
289305
}
290306

291307
private void setupVideoView(GalleryPagerViewHolder.GalleryPagerVideoViewHolder holder, FragmentActivity context, GalleryFile galleryFile) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Valv-Android
3+
* Copyright (c) 2024 Arctosoft AB.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
16+
*/
17+
18+
package se.arctosoft.vault.utils;
19+
20+
import android.content.Context;
21+
import android.util.DisplayMetrics;
22+
23+
import androidx.annotation.NonNull;
24+
25+
public class Pixels {
26+
27+
public static int dpToPixel(float dp, @NonNull Context context) {
28+
return (int) (dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT));
29+
}
30+
31+
}

app/src/main/java/se/arctosoft/vault/utils/Settings.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class Settings {
4040
private static final String PREF_SHOW_FILENAMES_IN_GRID = "p.gallery.fn";
4141
public static final String PREF_ENCRYPTION_ITERATION_COUNT = "encryption_iteration_count";
4242
public static final String PREF_ENCRYPTION_USE_DISK_CACHE = "encryption_use_disk_cache";
43+
public static final String PREF_ENCRYPTION_DELETE_BY_DEFAULT = "encryption_delete_by_default";
4344
public static final String PREF_APP_SECURE = "app_secure";
4445
public static final String PREF_APP_EDIT_FOLDERS = "app_edit_folders";
4546

@@ -81,6 +82,14 @@ public void setUseDiskCache(boolean useDiskCache) {
8182
getSharedPrefsEditor().putBoolean(PREF_ENCRYPTION_USE_DISK_CACHE, useDiskCache).apply();
8283
}
8384

85+
public boolean isDeleteByDefault() {
86+
return getSharedPrefs().getBoolean(PREF_ENCRYPTION_DELETE_BY_DEFAULT, false);
87+
}
88+
89+
public void setDeleteByDefault(boolean deleteByDefault) {
90+
getSharedPrefsEditor().putBoolean(PREF_ENCRYPTION_DELETE_BY_DEFAULT, deleteByDefault).apply();
91+
}
92+
8493
public boolean isSecureFlag() {
8594
return getSharedPrefs().getBoolean(PREF_APP_SECURE, true);
8695
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="?toolbar_icon_tint"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
8+
<path
9+
android:fillColor="?toolbar_icon_tint"
10+
android:pathData="M18,4v16L6,20L6,8.83L10.83,4L18,4m0,-2h-8L4,8v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,4c0,-1.1 -0.9,-2 -2,-2zM9,7h2v4L9,11zM12,7h2v4h-2zM15,7h2v4h-2z" />
11+
12+
</vector>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:layout_width="32dp"
2727
android:layout_height="32dp"
2828
android:src="@drawable/ic_round_fullscreen_24"
29-
android:visibility="gone"
29+
android:visibility="visible"
3030
app:layout_constraintEnd_toEndOf="parent"
3131
app:layout_constraintTop_toTopOf="parent" />
3232

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<se.arctosoft.vault.views.PressableConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent">
55

66
<ScrollView
77
android:layout_width="match_parent"
8-
android:layout_height="match_parent"
9-
android:layout_marginTop="20dp">
8+
android:layout_height="match_parent">
109

1110
<LinearLayout
1211
android:layout_width="match_parent"
1312
android:layout_height="wrap_content"
13+
android:paddingTop="20dp"
1414
android:orientation="vertical">
1515

1616
<TextView
1717
android:id="@+id/text"
1818
android:layout_width="match_parent"
19-
android:layout_height="match_parent"
19+
android:layout_height="wrap_content"
2020
android:padding="4dp"
2121
android:textIsSelectable="true" />
2222

@@ -28,4 +28,4 @@
2828

2929
</ScrollView>
3030

31-
</se.arctosoft.vault.views.PressableConstraintLayout>
31+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<string name="settings_use_disk_cache_title">Use disk cache</string>
3636
<string name="settings_use_disk_cache_summary_on">Decrypts media files you view to the app\'s private cache directory for faster loading. The cache directory is deleted when locking/restarting the app.</string>
3737
<string name="settings_use_disk_cache_summary_off">Disk cache disabled. All media files are stored in-memory only. More secure but takes longer to load media and thumbnails.</string>
38+
<string name="settings_delete_by_default_title">Delete original files by default</string>
39+
<string name="settings_delete_by_default_summary_on">\"Delete the original files after importing\" is checked by default.</string>
40+
<string name="settings_delete_by_default_summary_off">\"Delete the original files after importing\" is unchecked by default.</string>
3841
<string name="settings_app">App behaviour</string>
3942
<string name="settings_secure_title">Use FLAG_SECURE</string>
4043
<string name="settings_secure_summary">Tells Android to not allow screenshots or display the window view on a non-secure display.</string>

app/src/main/res/xml/root_preferences.xml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,34 @@
33

44
<PreferenceCategory app:title="@string/settings_app">
55

6+
<Preference
7+
android:icon="@drawable/ic_round_folder_open_24"
8+
android:key="app_edit_folders"
9+
android:summary="@string/dialog_edit_included_title"
10+
android:title="@string/menu_gallery_edit_included_folders" />
11+
612
<SwitchPreferenceCompat
713
android:key="app_secure"
814
android:summary="@string/settings_secure_summary"
915
app:defaultValue="true"
1016
app:icon="@drawable/ic_outline_lock_24"
1117
app:title="@string/settings_secure_title" />
1218

13-
<Preference
14-
android:icon="@drawable/ic_round_folder_open_24"
15-
android:key="app_edit_folders"
16-
android:summary="@string/dialog_edit_included_title"
17-
android:title="@string/menu_gallery_edit_included_folders" />
19+
<SwitchPreferenceCompat
20+
android:key="encryption_use_disk_cache"
21+
app:defaultValue="true"
22+
app:icon="@drawable/outline_sd_storage_24"
23+
app:summaryOff="@string/settings_use_disk_cache_summary_off"
24+
app:summaryOn="@string/settings_use_disk_cache_summary_on"
25+
app:title="@string/settings_use_disk_cache_title" />
26+
27+
<SwitchPreferenceCompat
28+
android:key="encryption_delete_by_default"
29+
app:defaultValue="false"
30+
app:icon="@drawable/ic_outline_delete_forever_24"
31+
app:summaryOff="@string/settings_delete_by_default_summary_off"
32+
app:summaryOn="@string/settings_delete_by_default_summary_on"
33+
app:title="@string/settings_delete_by_default_title" />
1834

1935
</PreferenceCategory>
2036

@@ -26,14 +42,6 @@
2642
android:summary="@string/settings_iteration_count_summary"
2743
android:title="@string/settings_iteration_count_title" />
2844

29-
<SwitchPreferenceCompat
30-
android:key="encryption_use_disk_cache"
31-
app:defaultValue="true"
32-
app:icon="@drawable/ic_outline_lock_24"
33-
app:summaryOff="@string/settings_use_disk_cache_summary_off"
34-
app:summaryOn="@string/settings_use_disk_cache_summary_on"
35-
app:title="@string/settings_use_disk_cache_title" />
36-
3745
</PreferenceCategory>
3846

3947
</PreferenceScreen>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Added option to check "Delete after importing" by default
2+
* Fixed missing fullscreen button
3+
* Fixed text padding
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Tillagt alternativ för att markera "Delete after importing" som standard
2+
* Fixat saknad helskärmsknapp
3+
* Fixat textutfyllnad

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ espressoCore = "3.6.1"
66
appcompat = "1.7.0"
77
material = "1.12.0"
88
constraintlayout = "2.2.0"
9-
navigationFragment = "2.8.4"
10-
navigationUi = "2.8.4"
9+
navigationFragment = "2.8.5"
10+
navigationUi = "2.8.5"
1111
preferences = "1.2.1"
1212
activity = "1.9.3"
1313
crypto = "1.0.0"

0 commit comments

Comments
 (0)