Skip to content
Open
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: 26 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Android CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/markdown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configure<ApplicationExtension> {
minSdk = 28
targetSdk = 36
versionCode = 41
versionName = "2.4.1"
versionName = "2.4.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -87,6 +87,7 @@ dependencies {
implementation(libs.glide)
implementation(libs.about.libraries)
implementation(libs.about.libraries.compose)
implementation("androidx.palette:palette:1.0.0")
}

aboutLibraries {
Expand Down
128 changes: 128 additions & 0 deletions app/src/main/java/se/arctosoft/vault/DirectoryAllFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.GridLayoutManager;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,6 +30,14 @@ public class DirectoryAllFragment extends DirectoryBaseFragment {
private static final String TAG = "DirectoryAllFragment";

private int foundFiles = 0, foundFolders = 0;
private com.google.android.material.bottomnavigation.BottomNavigationView bottomNav;
private boolean isNavPillHidden = false; // The lock that prevents scroll lag!

// --- NEW: Variables for the Breathing Grid ---
private ScaleGestureDetector scaleGestureDetector;
private float scaleFactor = 1.0f;
private static final int MIN_COLUMNS = 2;
private static final int MAX_COLUMNS = 6;

@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
Expand Down Expand Up @@ -76,6 +88,83 @@ public void handleOnBackPressed() {
findAllFiles();
}

// --- RESPONSIVE BOTTOM NAV LOGIC ---
bottomNav = binding.getRoot().findViewById(R.id.bottom_navigation);
if (bottomNav != null) {
bottomNav.setVisibility(View.VISIBLE);
bottomNav.setSelectedItemId(R.id.nav_all_files);

bottomNav.setOnItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.nav_albums) {
navController.popBackStack();
return true;
} else if (id == R.id.nav_all_files) {
return true;
}
return false;
});

// Smooth, Optimized Hide-on-Scroll Animation
binding.recyclerView.addOnScrollListener(new androidx.recyclerview.widget.RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull androidx.recyclerview.widget.RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);

// Don't animate if fullscreen media is open
if (galleryViewModel.isViewpagerVisible()) return;

// Ensure we only trigger the animation ONCE per state change to prevent lag
if (dy > 15 && !isNavPillHidden) {
isNavPillHidden = true; // Lock it
bottomNav.animate().translationY(bottomNav.getHeight() + 150).setDuration(200).start();
} else if (dy < -15 && isNavPillHidden) {
isNavPillHidden = false; // Unlock it
bottomNav.animate().translationY(0).setDuration(200).start();
}
}
});
}
// -----------------------------

// --- NEW: THE "BREATHING" GRID (PINCH TO ZOOM COLUMNS) ---
scaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(@NonNull ScaleGestureDetector detector) {
scaleFactor *= detector.getScaleFactor();

if (binding.recyclerView.getLayoutManager() instanceof GridLayoutManager) {
GridLayoutManager layoutManager = (GridLayoutManager) binding.recyclerView.getLayoutManager();
int currentSpans = layoutManager.getSpanCount();

// Pinching Out (Zooming In) -> Fewer Columns
if (scaleFactor > 1.25f && currentSpans > MIN_COLUMNS) {
layoutManager.setSpanCount(currentSpans - 1);
scaleFactor = 1.0f; // Reset threshold
binding.recyclerView.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
galleryGridAdapter.notifyItemRangeChanged(0, galleryGridAdapter.getItemCount());
return true;
}
// Pinching In (Zooming Out) -> More Columns
else if (scaleFactor < 0.75f && currentSpans < MAX_COLUMNS) {
layoutManager.setSpanCount(currentSpans + 1);
scaleFactor = 1.0f; // Reset threshold
binding.recyclerView.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
galleryGridAdapter.notifyItemRangeChanged(0, galleryGridAdapter.getItemCount());
return true;
}
}
return false;
}
});

// Intercept touches on the RecyclerView to feed the detector
binding.recyclerView.setOnTouchListener((v, event) -> {
scaleGestureDetector.onTouchEvent(event);
return false; // Return false so normal scrolling still works perfectly
});
// -----------------------------

initViewModels();
}

Expand Down Expand Up @@ -253,4 +342,43 @@ private List<GalleryFile> findAllFilesInFolder(Uri uri) {
return files;
}

@Override
void showViewpager(boolean show, int pos, boolean animate) {
if (binding.layoutFabsAdd != null) binding.layoutFabsAdd.setVisibility(show ? View.GONE : View.VISIBLE);
View bottomNav = binding.getRoot().findViewById(R.id.bottom_navigation);
if (bottomNav != null) bottomNav.setVisibility(show ? View.GONE : View.VISIBLE);

if (show) {
binding.viewPager.setCurrentItem(pos, false);
binding.viewPager.setAlpha(0f);
binding.viewPager.setScaleX(0.95f);
binding.viewPager.setScaleY(0.95f);
binding.viewPager.setVisibility(View.VISIBLE);
galleryPagerAdapter.triggerActiveVideo(pos);

binding.viewPager.animate()
.alpha(1f)
.scaleX(1f)
.scaleY(1f)
.setDuration(250)
.setInterpolator(new androidx.interpolator.view.animation.FastOutSlowInInterpolator())
.start();
} else {
binding.viewPager.animate()
.alpha(0f)
.scaleX(0.95f)
.scaleY(0.95f)
.setDuration(200)
.setInterpolator(new androidx.interpolator.view.animation.FastOutSlowInInterpolator())
.withEndAction(() -> {
binding.viewPager.setVisibility(View.GONE);
binding.viewPager.setScaleX(1f);
binding.viewPager.setScaleY(1f);
binding.viewPager.setAlpha(1f);
})
.start();
}

super.showViewpager(show, pos, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ void findFilesIn(Uri directoryUri) {

void setupGrid() {
initFastScroll();
int spanCount = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 6 : 3;
// Change the portrait span count from 3 to 4.
// You can also adjust the landscape (6) if you want it even wider when rotated!
int spanCount = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 6 : 4;

// Notice it uses StaggeredGridLayoutManager here
RecyclerView.LayoutManager layoutManager = new StaggeredGridLayoutManager(spanCount, RecyclerView.VERTICAL);
binding.recyclerView.setLayoutManager(layoutManager);
galleryGridAdapter = new GalleryGridAdapter(requireActivity(), galleryViewModel.getGalleryFiles(), settings.showFilenames(), galleryViewModel.isRootDir(), galleryViewModel);
Expand Down
Loading