Skip to content

Commit 7b6df5b

Browse files
committed
bugs fixed
1 parent 7af21f3 commit 7b6df5b

File tree

18 files changed

+210
-109
lines changed

18 files changed

+210
-109
lines changed

SmartFileBrowser/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ android {
2323
}
2424
}
2525
compileOptions {
26-
sourceCompatibility JavaVersion.VERSION_1_8
27-
targetCompatibility JavaVersion.VERSION_1_8
26+
sourceCompatibility JavaVersion.VERSION_11
27+
targetCompatibility JavaVersion.VERSION_11
2828
}
2929
namespace 'ir.smartdevelopers.smartfilebrowser'
3030
publishing {
@@ -34,7 +34,7 @@ android {
3434
}
3535
}
3636
group = 'ir.smartdevelopers'
37-
version = '2.0.2'
37+
version = '2.0.3'
3838

3939
dependencies {
4040

@@ -92,8 +92,8 @@ afterEvaluate {
9292
repositories {
9393
maven {
9494
// change URLs to point to your repos, e.g. http://my.org/repo
95-
def releasesRepoUrl = "$buildDir/repos/releases"
96-
def snapshotsRepoUrl = "$buildDir/repos/snapshots"
95+
def releasesRepoUrl = "${layout.buildDirectory.asFile.get()}/repos/releases"
96+
def snapshotsRepoUrl = "${layout.buildDirectory.asFile.get()}/repos/snapshots"
9797
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
9898
}
9999
}

SmartFileBrowser/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
android:name=".acitivties.FileBrowserMainActivity"
4141
android:configChanges="keyboard|orientation"
4242
android:launchMode="singleInstance"
43-
android:theme="@style/sfb_AppTheme" /> <!-- <activity -->
43+
android:theme="@style/sfb_MainAppTheme.sfb_AppTheme" /> <!-- <activity -->
4444
<!-- android:name="iamutkarshtiwari.github.io.ananas.editimage.EditImageActivity" -->
4545
<!-- android:exported="true" -->
4646
<!-- android:label="@string/sfb_image_editor_label" -->

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/FileBrowserMainActivity.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import androidx.appcompat.app.AppCompatActivity;
77
import androidx.appcompat.widget.AppCompatTextView;
88
import androidx.constraintlayout.widget.Group;
9-
import androidx.coordinatorlayout.widget.CoordinatorLayout;
109
import androidx.core.app.ActivityCompat;
1110
import androidx.core.app.ActivityOptionsCompat;
1211
import androidx.core.app.SharedElementCallback;
1312
import androidx.core.content.ContextCompat;
1413
import androidx.core.content.FileProvider;
1514
import androidx.core.graphics.Insets;
16-
import androidx.core.graphics.drawable.BitmapDrawableKt;
1715
import androidx.core.graphics.drawable.DrawableKt;
1816
import androidx.core.view.ViewCompat;
1917
import androidx.core.view.WindowCompat;
@@ -28,7 +26,6 @@
2826
import android.Manifest;
2927
import android.animation.Animator;
3028
import android.animation.AnimatorListenerAdapter;
31-
import android.animation.StateListAnimator;
3229
import android.animation.ValueAnimator;
3330
import android.annotation.SuppressLint;
3431
import android.app.Activity;
@@ -39,9 +36,9 @@
3936
import android.content.pm.ResolveInfo;
4037
import android.content.res.TypedArray;
4138
import android.graphics.Bitmap;
42-
import android.graphics.BitmapFactory;
39+
import android.graphics.Color;
4340
import android.graphics.Rect;
44-
import android.graphics.drawable.BitmapDrawable;
41+
import android.graphics.drawable.ColorDrawable;
4542
import android.net.Uri;
4643
import android.os.Build;
4744
import android.os.Bundle;
@@ -62,16 +59,13 @@
6259
import android.view.ViewTreeObserver;
6360
import android.view.Window;
6461
import android.view.WindowManager;
65-
import android.view.animation.Animation;
6662
import android.view.animation.OvershootInterpolator;
6763
import android.widget.Button;
6864
import android.widget.FrameLayout;
6965
import android.widget.ImageButton;
7066
import android.widget.ImageView;
7167
import android.widget.TextView;
7268
import android.widget.Toast;
73-
import android.window.OnBackInvokedCallback;
74-
import android.window.OnBackInvokedDispatcher;
7569

7670

7771
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
@@ -105,7 +99,7 @@
10599
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemChooseListener;
106100
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemClickListener;
107101
import ir.smartdevelopers.smartfilebrowser.customClasses.OnItemSelectListener;
108-
import ir.smartdevelopers.smartfilebrowser.customClasses.RoundViewGroup;
102+
import ir.smartdevelopers.smartfilebrowser.customClasses.RoundLinearLayout;
109103
import ir.smartdevelopers.smartfilebrowser.customClasses.SFBFileFilter;
110104
import ir.smartdevelopers.smartfilebrowser.customClasses.SearchView;
111105
import ir.smartdevelopers.smartfilebrowser.models.AlbumModel;
@@ -127,7 +121,7 @@ public class FileBrowserMainActivity extends AppCompatActivity {
127121
private static final int REQ_CODE_AUDIO_PERMISSION = 307;
128122
private static final int REQ_CODE_FILE_PERMISSION = 308;
129123
private AppBarLayout mAppBarLayout;
130-
private RoundViewGroup mBottomSheetRoot;
124+
private RoundLinearLayout mBottomSheetRoot;
131125
private MyBehavior<View> mBottomSheetBehavior;
132126
private AHBottomNavigation mBottomNavigationView;
133127
private View mMainRootView;
@@ -250,12 +244,18 @@ public boolean accept(File pathname) {
250244

251245
@Override
252246
protected void onCreate(Bundle savedInstanceState) {
253-
WindowCompat.enableEdgeToEdge(getWindow());
254-
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
255-
256-
getWindow().setAllowEnterTransitionOverlap(false);
247+
setTheme(R.style.sfb_MainAppTheme_sfb_AppTheme);
248+
Window window = getWindow();
249+
WindowCompat.enableEdgeToEdge(window);
250+
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
251+
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
252+
// window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
253+
window.setDimAmount(0.6f);
254+
255+
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
256+
window.setAllowEnterTransitionOverlap(false);
257257
Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.iten_transition_in);
258-
getWindow().setSharedElementExitTransition(transition);
258+
window.setSharedElementExitTransition(transition);
259259
setExitSharedElementCallback(new SharedElementCallback() {
260260
@Override
261261
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
@@ -282,6 +282,9 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
282282
.get(FilesViewModel.class);
283283
mResultListener = ResultListener.getInstance();
284284
findViews();
285+
// if ((window.getAttributes().flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION){
286+
// String s="true";
287+
// }
285288
manageEdgeToEdge();
286289
getDataFromIntent();
287290
if (savedInstanceState == null) {

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/acitivties/PhotoEditorActivity.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
import androidx.appcompat.app.AppCompatActivity;
55
import androidx.core.app.ActivityCompat;
66
import androidx.core.content.FileProvider;
7+
import androidx.core.graphics.Insets;
8+
import androidx.core.view.ViewCompat;
79
import androidx.core.view.WindowCompat;
10+
import androidx.core.view.WindowInsetsCompat;
11+
import androidx.core.view.WindowInsetsControllerCompat;
812

913
import android.Manifest;
1014
import android.app.SharedElementCallback;
1115
import android.content.pm.PackageManager;
1216
import android.graphics.Bitmap;
1317
import android.graphics.Color;
18+
import android.graphics.drawable.ColorDrawable;
1419
import android.net.Uri;
1520
import android.os.Build;
1621
import android.os.Bundle;
@@ -21,6 +26,7 @@
2126
import android.util.Log;
2227
import android.view.View;
2328
import android.view.Window;
29+
import android.view.WindowManager;
2430
import android.widget.ImageButton;
2531
import android.widget.ImageView;
2632
import android.widget.Toast;
@@ -61,12 +67,18 @@ public class PhotoEditorActivity extends AppCompatActivity {
6167
protected void onCreate(Bundle savedInstanceState) {
6268

6369
String transitionName = getIntent().getStringExtra(KEY_TRANSITION_NAME);
64-
65-
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
66-
70+
Window window = getWindow();
71+
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
72+
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
73+
window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
74+
WindowCompat.enableEdgeToEdge(window);
75+
WindowInsetsControllerCompat controllerCompat = WindowCompat.getInsetsController(window,window.getDecorView());
76+
if (controllerCompat != null){
77+
controllerCompat.setAppearanceLightStatusBars(false);
78+
}
6779
Transition transition= TransitionInflater.from(this).inflateTransition(R.transition.iten_transition_in);
68-
getWindow().setSharedElementEnterTransition(transition);
69-
getWindow().setSharedElementReturnTransition(transition);
80+
window.setSharedElementEnterTransition(transition);
81+
window.setSharedElementReturnTransition(transition);
7082

7183
super.onCreate(savedInstanceState);
7284
setContentView(R.layout.activity_photo_editor);
@@ -89,8 +101,15 @@ protected void onCreate(Bundle savedInstanceState) {
89101
btnDone.setOnClickListener(v -> {
90102
saveChangesAndClose();
91103
});
104+
View main = findViewById(R.id.sfb_activity_photoEditor_root);
105+
ViewCompat.setOnApplyWindowInsetsListener(main,(v,insets)->{
106+
Insets bars = insets.getInsets(WindowInsetsCompat.Type.displayCutout());
107+
v.setPadding(bars.left,bars.top,bars.right,bars.bottom);
108+
return insets;
109+
});
92110
initListener();
93111
ActivityCompat.postponeEnterTransition(this);
112+
94113
}
95114

96115
private void initListener() {

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/MyVideoView.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
7373
finalWidth=finalWidth*scaleFactor;
7474
finalHeight=finalHeight*scaleFactor;
7575

76-
// if (mVideoWidth > 0 && mVideoHeight > 0) {
77-
// if (mVideoWidth * deviceHeight > deviceWidth * mVideoHeight) {
78-
// // Log.i("@@@", "image too tall, correcting");
79-
// deviceHeight = deviceWidth * mVideoHeight / mVideoWidth;
80-
// } else if (mVideoWidth * deviceHeight < deviceWidth * mVideoHeight) {
81-
// // Log.i("@@@", "image too wide, correcting");
82-
// deviceWidth = deviceHeight * mVideoWidth / mVideoHeight;
83-
// } else {
84-
// // Log.i("@@@", "aspect ratio is correct: " +
85-
// // width+"/"+height+"="+
86-
// // mVideoWidth+"/"+mVideoHeight);
87-
// }
88-
// }
89-
// if ((Math.abs(mVideoRotation)==90 || Math.abs(mVideoRotation)==270) ){
90-
// int tempWidth=deviceWidth;
91-
// deviceWidth=deviceHeight;
92-
// deviceHeight=tempWidth;
93-
// }
9476
// Log.i("@@@", "setting size: " + width + 'x' + height);
9577
setMeasuredDimension((int)finalWidth, (int)finalHeight);
9678
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,28 @@
99

1010
import androidx.annotation.Nullable;
1111
import androidx.annotation.RequiresApi;
12-
import androidx.constraintlayout.widget.ConstraintLayout;
1312

1413
import ir.smartdevelopers.smartfilebrowser.R;
1514

16-
public class RoundViewGroup extends LinearLayout {
15+
public class RoundLinearLayout extends LinearLayout {
1716
private SmartRoundDrawable mSmartRoundDrawable;
1817
private int mBackgroundColor=Color.WHITE;
19-
public RoundViewGroup(Context context) {
18+
public RoundLinearLayout(Context context) {
2019
super(context);
2120
init(context, null);
2221
}
2322

24-
public RoundViewGroup(Context context, @Nullable AttributeSet attrs) {
23+
public RoundLinearLayout(Context context, @Nullable AttributeSet attrs) {
2524
super(context, attrs);
2625
init(context,attrs);
2726
}
2827

29-
public RoundViewGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
28+
public RoundLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
3029
super(context, attrs, defStyleAttr);
3130
init(context, attrs);
3231
}
3332

34-
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
35-
public RoundViewGroup(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
33+
public RoundLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
3634
super(context, attrs, defStyleAttr, defStyleRes);
3735
init(context, attrs);
3836
}
@@ -42,12 +40,13 @@ private void init(Context context, AttributeSet attrs){
4240
mSmartRoundDrawable=new SmartRoundDrawable();
4341
if (attrs!=null){
4442
TypedArray typedArray=context.obtainStyledAttributes(attrs,R.styleable.RoundLinearLayout);
45-
mBackgroundColor=typedArray.getColor(R.styleable.RoundLinearLayout_backgroundColor,Color.WHITE);
43+
mBackgroundColor=Utils.resolveColor(context,typedArray,R.styleable.RoundLinearLayout_backgroundColor,Color.WHITE);
4644
float topLeftRadius=typedArray.getDimension(R.styleable.RoundLinearLayout_android_topLeftRadius,30f);
4745
float topRightRadius=typedArray.getDimension(R.styleable.RoundLinearLayout_android_topRightRadius,30f);
4846
float bottomRightRadius=typedArray.getDimension(R.styleable.RoundLinearLayout_android_bottomRightRadius,30f);
4947
float bottomLeftRadius=typedArray.getDimension(R.styleable.RoundLinearLayout_android_bottomLeftRadius,30f);
5048
mSmartRoundDrawable.setRadius(topLeftRadius,topRightRadius,bottomRightRadius,bottomLeftRadius);
49+
typedArray.recycle();
5150
}
5251
mSmartRoundDrawable.setColor(mBackgroundColor);
5352
setBackground(mSmartRoundDrawable);

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SFBCheckBoxWithTick.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,13 @@ public SFBCheckBoxWithTick(@NonNull Context context, @Nullable AttributeSet attr
3232
init(context, attrs);
3333
}
3434
void init(@NonNull Context context, @Nullable AttributeSet attrs){
35-
// if (Build.VERSION.SDK_INT>=21){
3635
Drawable d = AppCompatResources.getDrawable(context, R.drawable.sfb_check_box_drawable_with_tick);
3736
if (d != null) {
38-
d = DrawableCompat.wrap(d).mutate(); // کپی متمایز از drawable تا تغییرات Share نشه
39-
CompoundButtonCompat.setButtonTintList(this, null); // حذف tint که AppCompat ممکنه زده باشه
37+
d = DrawableCompat.wrap(d).mutate();
38+
CompoundButtonCompat.setButtonTintList(this, null);
4039
setButtonDrawable(d);
4140
}
42-
// }else {
43-
// StateListDrawable stateListDrawable=new StateListDrawable();
44-
// Drawable checkedDrawable= VectorDrawableCompat.create(getResources(),R.drawable.sfb_check_box_checked,context.getTheme());
45-
// Drawable uncheckedDrawable= VectorDrawableCompat.create(getResources(),R.drawable.sfb_chech_box_unchecked,context.getTheme());
46-
// stateListDrawable.addState(new int[]{android.R.attr.state_checked},checkedDrawable);
47-
// stateListDrawable.addState(new int[]{},uncheckedDrawable);
48-
//
49-
// setButtonDrawable(stateListDrawable);
50-
// }
41+
5142

5243
}
5344
}

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/SFBCheckboxWithNumber.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ private void init(Context context, AttributeSet attr) {
9393
mAnimationDuration = typedArray.getInteger(R.styleable.SFBCheckboxWithNumber_android_animationDuration, 300);
9494
mTextSize = typedArray.getDimension(R.styleable.SFBCheckboxWithNumber_android_textSize, getResources().getDimension(R.dimen.sfb_text_size_14));
9595

96-
mFillColor = resolveColor(typedArray, R.styleable.SFBCheckboxWithNumber_fillColor, Color.parseColor("#00b8e9"));
97-
mStrokeColor = resolveColor(typedArray, R.styleable.SFBCheckboxWithNumber_strokeColor, Color.WHITE);
96+
mFillColor = Utils.resolveColor(context,typedArray, R.styleable.SFBCheckboxWithNumber_fillColor, Color.parseColor("#00b8e9"));
97+
mStrokeColor = Utils.resolveColor(context,typedArray, R.styleable.SFBCheckboxWithNumber_strokeColor, Color.WHITE);
9898
mStrokeWidth = typedArray.getDimension(R.styleable.SFBCheckboxWithNumber_strokeWidth, 12);
99-
mTextColor = resolveColor(typedArray, R.styleable.SFBCheckboxWithNumber_android_textColor, Color.WHITE);
99+
mTextColor = Utils.resolveColor(context,typedArray, R.styleable.SFBCheckboxWithNumber_android_textColor, Color.WHITE);
100100
boolean checked = typedArray.getBoolean(R.styleable.SFBCheckboxWithNumber_android_checked, false);
101101
mBlueCheckBoxPaint.setColor(mFillColor);
102102
mWhiteCheckBoxPaint.setColor(Color.WHITE);
@@ -114,22 +114,7 @@ private void init(Context context, AttributeSet attr) {
114114

115115
}
116116

117-
private int resolveColor(TypedArray typedArray, int id, int defaultColor) {
118-
TypedValue value = new TypedValue();
119-
typedArray.getValue(id, value);
120117

121-
if (value.type == TypedValue.TYPE_ATTRIBUTE) {
122-
TypedValue colorVal = new TypedValue();
123-
getContext().getTheme().resolveAttribute(value.data, colorVal, true);
124-
if (colorVal.data != 0) {
125-
return colorVal.data;
126-
}
127-
128-
} else if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
129-
return value.data;
130-
}
131-
return defaultColor;
132-
}
133118

134119
@Override
135120
protected void onSizeChanged(int w, int h, int oldw, int oldh) {

SmartFileBrowser/src/main/java/ir/smartdevelopers/smartfilebrowser/customClasses/Utils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import android.content.Context;
44
import android.content.res.Resources;
5+
import android.content.res.TypedArray;
56
import android.graphics.Bitmap;
67
import android.graphics.Canvas;
78
import android.graphics.Rect;
89
import android.graphics.drawable.Drawable;
910
import android.os.Environment;
1011
import android.util.DisplayMetrics;
12+
import android.util.TypedValue;
1113

1214
import java.io.File;
1315
import java.util.ArrayList;
@@ -138,4 +140,20 @@ public static Rect scale(Rect rect,int maxBound){
138140
}
139141
return new Rect(0,0, (int) (width/factor), (int) (height/factor));
140142
}
143+
static int resolveColor(Context context,TypedArray typedArray, int id, int defaultColor) {
144+
TypedValue value = new TypedValue();
145+
typedArray.getValue(id, value);
146+
147+
if (value.type == TypedValue.TYPE_ATTRIBUTE) {
148+
TypedValue colorVal = new TypedValue();
149+
context.getTheme().resolveAttribute(value.data, colorVal, true);
150+
if (colorVal.data != 0) {
151+
return colorVal.data;
152+
}
153+
154+
} else if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
155+
return value.data;
156+
}
157+
return defaultColor;
158+
}
141159
}

0 commit comments

Comments
 (0)