Skip to content
Merged
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
2 changes: 1 addition & 1 deletion SmartFileBrowser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
}
}
group = 'ir.smartdevelopers'
version = '2.0.5'
version = '2.0.7'

dependencies {

Expand Down
6 changes: 3 additions & 3 deletions SmartFileBrowser/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@
<activity
android:name=".acitivties.VideoViewActivity"
android:exported="false"
android:theme="@style/sfb_AppTheme.sfb_EditorTheme"
android:theme="@style/sfb_BaseAppTheme.sfb_EditorTheme"
android:screenOrientation="locked"
/>
<activity
android:name=".acitivties.PhotoEditorActivity"
android:exported="false"
android:theme="@style/sfb_AppTheme.sfb_EditorTheme"
android:theme="@style/sfb_BaseAppTheme.sfb_EditorTheme"
android:screenOrientation="locked"
/>
<activity
android:name=".acitivties.FileBrowserMainActivity"
android:configChanges="keyboard|orientation"
android:launchMode="singleInstance"
android:theme="@style/sfb_AppTheme" /> <!-- <activity -->
android:theme="@style/sfb_BaseAppTheme" /> <!-- <activity -->
<!-- android:name="iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity" -->
<!-- android:exported="true" -->
<!-- android:label="@string/sfb_image_editor_label" -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -49,14 +51,17 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.constraintlayout.widget.Group;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.app.SharedElementCallback;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.Insets;
import androidx.core.graphics.drawable.DrawableKt;
import androidx.core.view.ViewCompat;
Expand All @@ -69,6 +74,7 @@
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;

import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
Expand All @@ -82,6 +88,8 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;

import ir.smartdevelopers.smartfilebrowser.R;
Expand Down Expand Up @@ -196,6 +204,7 @@ public class FileBrowserMainActivity extends AppCompatActivity {
// when it closing
private final AtomicBoolean mIsCanceled = new AtomicBoolean(true);
//</editor-fold>
private ExecutorService mExecutorService;

private void getDataFromIntent() {
mShowVideosInGallery = getIntent().getBooleanExtra("mShowVideosInGallery", true);
Expand Down Expand Up @@ -243,18 +252,25 @@ public boolean accept(File pathname) {
};
}


@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.sfb_AppTheme);


super.onCreate(savedInstanceState);

Window window = getWindow();
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
// window.setSharedElementsUseOverlay(false);
WindowCompat.enableEdgeToEdge(window);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.setDimAmount(0.6f);

window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
window.setAllowEnterTransitionOverlap(false);
Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.iten_transition_in);
window.setSharedElementExitTransition(transition);
Expand All @@ -273,7 +289,6 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
}
});

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_browser_main);
mIsCanceled.set(true);
mSelectionFileViewModel = new ViewModelProvider(this).get(SelectionFileViewModel.class);
Expand Down Expand Up @@ -339,11 +354,12 @@ public void onChanged(List<FileBrowserModel> fileBrowserModels) {
// </editor-fold>
// <editor-fold desc=" FileBrowser adapter init">
if (mShowGalleryTab) {
mExecutorService = Executors.newFixedThreadPool(3);
int spanCount = getResources().getInteger(R.integer.sfb_gallery_grid);
int gapSpace = getResources().getDimensionPixelSize(R.dimen.sfb_gallery_gap_size);

mGalleryLayoutManager = new GalleryLayoutManager(this, spanCount);
mGalleryAdapter = new GalleryAdapter(mSelectionFileViewModel.getSelectedFiles());
mGalleryAdapter = new GalleryAdapter(mSelectionFileViewModel.getSelectedFiles(),mExecutorService);
mGalleryAdapter.setCanSelectMultiple(mCanSelectMultipleInGallery);
mGalleryAdapter.setOnItemClickListener(mGalleryModelItemClickListener);
mGalleryAdapter.setOnItemSelectListener(mOnFileItemSelectListener);
Expand Down Expand Up @@ -511,9 +527,12 @@ private void manageEdgeToEdge() {

@Override
protected void onDestroy() {
super.onDestroy();
// mCallbackViewModel.clearCallback();
if (mExecutorService != null){
mExecutorService.shutdown();
}
mResultListener.clear();
super.onDestroy();

}

@Override
Expand Down Expand Up @@ -818,7 +837,10 @@ private AHBottomNavigationItem createNavItem(int colorAttr, int titleRes, int ic
value.data);
}
private void initViews(Bundle savedInstanceState) {

// ContextThemeWrapper wrapper = new ContextThemeWrapper(this,R.style.sfb_BaseAppTheme);
// Drawable okDrawable = VectorDrawableCompat.create(wrapper.getResources(),R.drawable.sfb_ic_circle_tick_filled,wrapper.getTheme());
// //okDrawable.setTintList(null);
// btnSelectionOk.setImageDrawable(okDrawable);
int[] attrs={R.attr.SFBColorGallery,R.attr.SFBColorPDF,R.attr.SFBColorAudio,R.attr.SFBColorFile};

if (mShowGalleryTab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void showThumbnail(boolean animate) {
private void hideThumbNaile(boolean animate) {
if (mVideoPrapered && mTransitionEnds){
if (animate){
imgThumbnailHolder.animate().setDuration(animationDuration).alpha(0)
imgThumbnailHolder.animate().setDuration(animationDuration).alpha(0f)
.setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(@NonNull ValueAnimator animation) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ir.smartdevelopers.smartfilebrowser.adapters;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -32,9 +34,12 @@
import com.bumptech.glide.request.target.Target;

import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;

import ir.smartdevelopers.smartfilebrowser.R;
import ir.smartdevelopers.smartfilebrowser.customClasses.FileUtil;
Expand Down Expand Up @@ -65,9 +70,11 @@ public class GalleryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private OnItemChooseListener mOnItemChooseListener;
/**For preventing multiple btnZoom click*/
private boolean mZoomButtonClicked=false;
private ExecutorService mOrientationRetrieverService;

public GalleryAdapter(List<File> selectedFiles) {
mGalleryModels=new ArrayList<>();
public GalleryAdapter(List<File> selectedFiles, ExecutorService orientationRetrieverService) {
mOrientationRetrieverService = orientationRetrieverService;
mGalleryModels=new ArrayList<>();
mSelectedFiles=selectedFiles;
setHasStableIds(true);
}
Expand Down Expand Up @@ -377,7 +384,9 @@ void bindView(GalleryModel model){
.transition(DrawableTransitionOptions.withCrossFade())
.into(mImageView);


if (model.getOrientation() == -1 && mOrientationRetrieverService != null){
mOrientationRetrieverService.execute(new OrientationRetriever(model,itemView.getContext()));
}
if (model.getType()== FileUtil.TYPE_VIDEO){
txtVideoDuration.setVisibility(View.VISIBLE);
txtVideoDuration.setText(model.getDurationTime());
Expand Down Expand Up @@ -467,4 +476,28 @@ public List<GalleryModel> getSelectedModels(){
public void setSelectedFiles(List<File> selectedFiles) {
mSelectedFiles = selectedFiles;
}
private static class OrientationRetriever implements Runnable {
private GalleryModel mModel;
private WeakReference<Context> wContext;

private OrientationRetriever(GalleryModel model,Context context) {
mModel = model;
wContext = new WeakReference<>(context.getApplicationContext());
}

@Override
public void run() {
try(MediaMetadataRetriever retriever = new MediaMetadataRetriever()){
retriever.setDataSource(wContext.get(),mModel.getUri());
String rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
if (rotation != null){
mModel.setOrientation(Integer.parseInt(rotation));
}else {
mModel.setOrientation(0);
}
} catch (IOException e) {
mModel.setOrientation(0);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@

import java.io.IOException;

public class MyVideoView extends VideoView {
public class MyVideoView extends TextureVideoView {
private int mVideoWidth;
private int mVideoHeight;
private int mVideoRotation;
public MyVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
this(context, attrs,0);

}

public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public MyVideoView(Context context) {
super(context);
this(context,null);

}


Expand Down
Loading