Skip to content

Commit

Permalink
Merge pull request #106 from Arctosoft/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
hej2010 authored Dec 18, 2024
2 parents f4174e5 + 1b848dd commit 0634eda
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 42 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "se.arctosoft.vault"
minSdk = 28
targetSdk = 35
versionCode = 32
versionName = "2.0.1"
versionCode = 33
versionName = "2.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
} else {
binding.checkboxDeleteAfter.setVisibility(View.VISIBLE);
binding.checkboxDeleteAfter.setEnabled(true);
binding.checkboxDeleteAfter.setChecked(settings.isDeleteByDefault());
binding.deleteNote.setVisibility(View.GONE);
}

Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/se/arctosoft/vault/SettingsFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package se.arctosoft.vault;

import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -19,8 +18,6 @@
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreferenceCompat;

import java.util.List;

import se.arctosoft.vault.data.Password;
import se.arctosoft.vault.utils.Dialogs;
import se.arctosoft.vault.utils.Settings;
Expand All @@ -37,6 +34,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Preference editFolders = findPreference(Settings.PREF_APP_EDIT_FOLDERS);
SwitchPreferenceCompat useDiskCache = findPreference(Settings.PREF_ENCRYPTION_USE_DISK_CACHE);
SwitchPreferenceCompat secure = findPreference(Settings.PREF_APP_SECURE);
SwitchPreferenceCompat deleteByDefault = findPreference(Settings.PREF_ENCRYPTION_DELETE_BY_DEFAULT);

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

secure.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (boolean) newValue;
if (enabled) {
if ((boolean) newValue) {
requireActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
} else {
requireActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
Expand All @@ -70,8 +67,12 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
});

useDiskCache.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (boolean) newValue;
settings.setUseDiskCache(enabled);
settings.setUseDiskCache((boolean) newValue);
return true;
});

deleteByDefault.setOnPreferenceChangeListener((preference, newValue) -> {
settings.setDeleteByDefault((boolean) newValue);
return true;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.OptIn;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.FileProvider;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.Insets;
Expand Down Expand Up @@ -83,6 +84,7 @@
import se.arctosoft.vault.utils.Dialogs;
import se.arctosoft.vault.utils.FileStuff;
import se.arctosoft.vault.utils.GlideStuff;
import se.arctosoft.vault.utils.Pixels;
import se.arctosoft.vault.utils.Settings;
import se.arctosoft.vault.utils.StringStuff;
import se.arctosoft.vault.utils.Toaster;
Expand All @@ -102,6 +104,17 @@ public class GalleryPagerAdapter extends RecyclerView.Adapter<GalleryPagerViewHo
private final Password password;
private boolean isFullscreen;

private final View.OnAttachStateChangeListener onAttachStateChangeListener = new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(@NonNull View view) {
view.requestApplyInsets();
}

@Override
public void onViewDetachedFromWindow(@NonNull View view) {
}
};

public GalleryPagerAdapter(FragmentActivity context, @NonNull List<GalleryFile> galleryFiles, IOnFileDeleted onFileDeleted, DocumentFile currentDirectory, boolean isAllFolder, String nestedPath, GalleryViewModel galleryViewModel) {
this.weakReference = new WeakReference<>(context);
this.galleryFiles = galleryFiles;
Expand Down Expand Up @@ -133,14 +146,15 @@ public GalleryPagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
return new GalleryPagerViewHolder.GalleryPagerVideoViewHolder(parentBinding, videoBinding);
} else if (viewType == FileType.TYPE_TEXT) {
AdapterGalleryViewpagerItemTextBinding textBinding = AdapterGalleryViewpagerItemTextBinding.inflate(layoutInflater, parentBinding.content, true);
setViewPadding(textBinding.text);
return new GalleryPagerViewHolder.GalleryPagerTextViewHolder(parentBinding, textBinding);
} else {
AdapterGalleryViewpagerItemDirectoryBinding videoBinding = AdapterGalleryViewpagerItemDirectoryBinding.inflate(layoutInflater, parentBinding.content, true);
return new GalleryPagerViewHolder.GalleryPagerDirectoryViewHolder(parentBinding, videoBinding);
}
}

private static void setPadding(@NonNull AdapterGalleryViewpagerItemBinding parentBinding) {
private void setPadding(@NonNull AdapterGalleryViewpagerItemBinding parentBinding) {
ViewCompat.setOnApplyWindowInsetsListener(parentBinding.lLButtons, (v, insets) -> {
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
v.setPadding(bars.left, 0, bars.right, bars.bottom);
Expand All @@ -153,24 +167,25 @@ private static void setPadding(@NonNull AdapterGalleryViewpagerItemBinding paren
});
ViewCompat.setOnApplyWindowInsetsListener(parentBinding.imgFullscreen, (v, insets) -> {
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
v.setPadding(bars.left, bars.top, bars.right, 0);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) v.getLayoutParams();
layoutParams.setMargins(bars.left, bars.top, bars.right, 0);
return WindowInsetsCompat.CONSUMED;
});
View.OnAttachStateChangeListener onAttachStateChangeListener = new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(@NonNull View view) {
view.requestApplyInsets();
}

@Override
public void onViewDetachedFromWindow(@NonNull View view) {
}
};
parentBinding.lLButtons.addOnAttachStateChangeListener(onAttachStateChangeListener);
parentBinding.txtName.addOnAttachStateChangeListener(onAttachStateChangeListener);
parentBinding.imgFullscreen.addOnAttachStateChangeListener(onAttachStateChangeListener);
}

private void setViewPadding(@NonNull View view) {
ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> {
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
int horizontalPadding = Pixels.dpToPixel(4, weakReference.get());
v.setPadding(bars.left + horizontalPadding, bars.top, bars.right + horizontalPadding, bars.bottom);
return WindowInsetsCompat.CONSUMED;
});
view.addOnAttachStateChangeListener(onAttachStateChangeListener);
}

@Override
public void onBindViewHolder(@NonNull GalleryPagerViewHolder holder, int position) {
FragmentActivity context = weakReference.get();
Expand Down Expand Up @@ -286,6 +301,7 @@ private void loadOriginalFilename(@NonNull GalleryFile galleryFile, FragmentActi
private void setupTextView(GalleryPagerViewHolder.GalleryPagerTextViewHolder holder, FragmentActivity context, GalleryFile galleryFile) {
holder.binding.text.setText(galleryFile.getText());
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()));
holder.binding.text.setTextIsSelectable(true);
}

private void setupVideoView(GalleryPagerViewHolder.GalleryPagerVideoViewHolder holder, FragmentActivity context, GalleryFile galleryFile) {
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/se/arctosoft/vault/utils/Pixels.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Valv-Android
* Copyright (c) 2024 Arctosoft AB.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
*/

package se.arctosoft.vault.utils;

import android.content.Context;
import android.util.DisplayMetrics;

import androidx.annotation.NonNull;

public class Pixels {

public static int dpToPixel(float dp, @NonNull Context context) {
return (int) (dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT));
}

}
9 changes: 9 additions & 0 deletions app/src/main/java/se/arctosoft/vault/utils/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class Settings {
private static final String PREF_SHOW_FILENAMES_IN_GRID = "p.gallery.fn";
public static final String PREF_ENCRYPTION_ITERATION_COUNT = "encryption_iteration_count";
public static final String PREF_ENCRYPTION_USE_DISK_CACHE = "encryption_use_disk_cache";
public static final String PREF_ENCRYPTION_DELETE_BY_DEFAULT = "encryption_delete_by_default";
public static final String PREF_APP_SECURE = "app_secure";
public static final String PREF_APP_EDIT_FOLDERS = "app_edit_folders";

Expand Down Expand Up @@ -81,6 +82,14 @@ public void setUseDiskCache(boolean useDiskCache) {
getSharedPrefsEditor().putBoolean(PREF_ENCRYPTION_USE_DISK_CACHE, useDiskCache).apply();
}

public boolean isDeleteByDefault() {
return getSharedPrefs().getBoolean(PREF_ENCRYPTION_DELETE_BY_DEFAULT, false);
}

public void setDeleteByDefault(boolean deleteByDefault) {
getSharedPrefsEditor().putBoolean(PREF_ENCRYPTION_DELETE_BY_DEFAULT, deleteByDefault).apply();
}

public boolean isSecureFlag() {
return getSharedPrefs().getBoolean(PREF_APP_SECURE, true);
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/outline_sd_storage_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?toolbar_icon_tint"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="?toolbar_icon_tint"
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" />

</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/adapter_gallery_viewpager_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_round_fullscreen_24"
android:visibility="gone"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/adapter_gallery_viewpager_item_text.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<se.arctosoft.vault.views.PressableConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp">
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:orientation="vertical">

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:textIsSelectable="true" />

Expand All @@ -28,4 +28,4 @@

</ScrollView>

</se.arctosoft.vault.views.PressableConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<string name="settings_use_disk_cache_title">Use disk cache</string>
<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>
<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>
<string name="settings_delete_by_default_title">Delete original files by default</string>
<string name="settings_delete_by_default_summary_on">\"Delete the original files after importing\" is checked by default.</string>
<string name="settings_delete_by_default_summary_off">\"Delete the original files after importing\" is unchecked by default.</string>
<string name="settings_app">App behaviour</string>
<string name="settings_secure_title">Use FLAG_SECURE</string>
<string name="settings_secure_summary">Tells Android to not allow screenshots or display the window view on a non-secure display.</string>
Expand Down
34 changes: 21 additions & 13 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@

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

<Preference
android:icon="@drawable/ic_round_folder_open_24"
android:key="app_edit_folders"
android:summary="@string/dialog_edit_included_title"
android:title="@string/menu_gallery_edit_included_folders" />

<SwitchPreferenceCompat
android:key="app_secure"
android:summary="@string/settings_secure_summary"
app:defaultValue="true"
app:icon="@drawable/ic_outline_lock_24"
app:title="@string/settings_secure_title" />

<Preference
android:icon="@drawable/ic_round_folder_open_24"
android:key="app_edit_folders"
android:summary="@string/dialog_edit_included_title"
android:title="@string/menu_gallery_edit_included_folders" />
<SwitchPreferenceCompat
android:key="encryption_use_disk_cache"
app:defaultValue="true"
app:icon="@drawable/outline_sd_storage_24"
app:summaryOff="@string/settings_use_disk_cache_summary_off"
app:summaryOn="@string/settings_use_disk_cache_summary_on"
app:title="@string/settings_use_disk_cache_title" />

<SwitchPreferenceCompat
android:key="encryption_delete_by_default"
app:defaultValue="false"
app:icon="@drawable/ic_outline_delete_forever_24"
app:summaryOff="@string/settings_delete_by_default_summary_off"
app:summaryOn="@string/settings_delete_by_default_summary_on"
app:title="@string/settings_delete_by_default_title" />

</PreferenceCategory>

Expand All @@ -26,14 +42,6 @@
android:summary="@string/settings_iteration_count_summary"
android:title="@string/settings_iteration_count_title" />

<SwitchPreferenceCompat
android:key="encryption_use_disk_cache"
app:defaultValue="true"
app:icon="@drawable/ic_outline_lock_24"
app:summaryOff="@string/settings_use_disk_cache_summary_off"
app:summaryOn="@string/settings_use_disk_cache_summary_on"
app:title="@string/settings_use_disk_cache_title" />

</PreferenceCategory>

</PreferenceScreen>
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/33.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Added option to check "Delete after importing" by default
* Fixed missing fullscreen button
* Fixed text padding
3 changes: 3 additions & 0 deletions fastlane/metadata/android/sv-SE/changelogs/33.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Tillagt alternativ för att markera "Delete after importing" som standard
* Fixat saknad helskärmsknapp
* Fixat textutfyllnad
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
constraintlayout = "2.2.0"
navigationFragment = "2.8.4"
navigationUi = "2.8.4"
navigationFragment = "2.8.5"
navigationUi = "2.8.5"
preferences = "1.2.1"
activity = "1.9.3"
crypto = "1.0.0"
Expand Down

0 comments on commit 0634eda

Please sign in to comment.