Skip to content

Commit cf329b2

Browse files
Merge pull request #21 from smartdevelopers-ir/v2.0.8
bug fixed
2 parents e256399 + a49f950 commit cf329b2

File tree

4 files changed

+69
-13
lines changed

4 files changed

+69
-13
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@
6262
import androidx.core.content.ContextCompat;
6363
import androidx.core.content.FileProvider;
6464
import androidx.core.content.res.ResourcesCompat;
65+
import androidx.core.graphics.ColorUtils;
6566
import androidx.core.graphics.Insets;
6667
import androidx.core.graphics.drawable.DrawableKt;
6768
import androidx.core.view.ViewCompat;
6869
import androidx.core.view.WindowCompat;
6970
import androidx.core.view.WindowInsetsCompat;
71+
import androidx.core.view.WindowInsetsControllerCompat;
7072
import androidx.exifinterface.media.ExifInterface;
7173
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
7274
import androidx.lifecycle.LiveData;
@@ -837,10 +839,7 @@ private AHBottomNavigationItem createNavItem(int colorAttr, int titleRes, int ic
837839
value.data);
838840
}
839841
private void initViews(Bundle savedInstanceState) {
840-
// ContextThemeWrapper wrapper = new ContextThemeWrapper(this,R.style.sfb_BaseAppTheme);
841-
// Drawable okDrawable = VectorDrawableCompat.create(wrapper.getResources(),R.drawable.sfb_ic_circle_tick_filled,wrapper.getTheme());
842-
// //okDrawable.setTintList(null);
843-
// btnSelectionOk.setImageDrawable(okDrawable);
842+
844843
int[] attrs={R.attr.SFBColorGallery,R.attr.SFBColorPDF,R.attr.SFBColorAudio,R.attr.SFBColorFile};
845844

846845
if (mShowGalleryTab) {
@@ -863,6 +862,10 @@ private void initViews(Bundle savedInstanceState) {
863862
mBottomNavigationView.setColoredModeColors(colorActive,colorInactive);
864863
getTheme().resolveAttribute(R.attr.SFBBottomNavColorDisabled,value,true);
865864
int colorDisabled = value.data;
865+
getTheme().resolveAttribute(com.google.android.material.R.attr.colorOnSurface,value,true);
866+
int surfaceColor =value.data;
867+
int dimColor = ColorUtils.setAlphaComponent(surfaceColor,59);
868+
findViewById(R.id.fileBrowser_activity_main_albumPlaceHolderRoot).setBackgroundColor(dimColor);
866869
mBottomNavigationView.setItemDisableColor(colorDisabled);
867870
mBottomNavigationView.setOnTabSelectedListener(mOnMenuItemSelectionListener);
868871
mBottomNavigationView.setColored(true);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package ir.smartdevelopers.smartfilebrowser.customClasses;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.Gravity;
6+
7+
import androidx.annotation.NonNull;
8+
import androidx.annotation.Nullable;
9+
import androidx.appcompat.widget.AppCompatTextView;
10+
11+
public class SquareTextView extends AppCompatTextView {
12+
private int size;
13+
public SquareTextView(@NonNull Context context) {
14+
this(context,null);
15+
}
16+
17+
public SquareTextView(@NonNull Context context, @Nullable AttributeSet attrs) {
18+
this(context, attrs,0);
19+
}
20+
21+
public SquareTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
22+
super(context, attrs, defStyleAttr);
23+
setGravity(Gravity.CENTER);
24+
}
25+
26+
27+
28+
@Override
29+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
30+
31+
final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
32+
final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
33+
34+
if (widthSize == 0 && heightSize == 0) {
35+
// If there are no constraints on size, let FrameLayout measure
36+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
37+
38+
// Now use the smallest of the measured dimensions for both dimensions
39+
final int minSize = Math.min(getMeasuredWidth(), getMeasuredHeight());
40+
setMeasuredDimension(minSize, minSize);
41+
return;
42+
}
43+
44+
final int size;
45+
if (widthSize == 0 || heightSize == 0) {
46+
// If one of the dimensions has no restriction on size, set both dimensions to be the
47+
// on that does
48+
size = Math.max(widthSize, heightSize);
49+
} else {
50+
// Both dimensions have restrictions on size, set both dimensions to be the
51+
// smallest of the two
52+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
53+
size = Math.max(getMeasuredWidth(), getMeasuredHeight());
54+
}
55+
56+
super.onMeasure(MeasureSpec.makeMeasureSpec(size,MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(size,MeasureSpec.EXACTLY));
57+
}
58+
}

SmartFileBrowser/src/main/res/color/color_gallery_dim.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

SmartFileBrowser/src/main/res/layout/activity_file_browser_main.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
app:layout_constraintEnd_toEndOf="parent"
161161
android:layout_margin="8dp"
162162
android:visibility="invisible"
163+
tools:visibility="visible"
163164
android:clipChildren="false"
164165
>
165166
<ImageView
@@ -184,11 +185,11 @@
184185
android:layout_marginBottom="6dp"
185186
android:layout_marginEnd="2dp"
186187
/>
187-
<TextView
188+
<ir.smartdevelopers.smartfilebrowser.customClasses.SquareTextView
188189
android:id="@+id/fileBrowser_activity_main_txtSelectionCount"
189190
android:layout_width="wrap_content"
190191
android:layout_height="wrap_content"
191-
tools:text="1"
192+
tools:text="22"
192193
android:textSize="12sp"
193194
android:maxLines="1"
194195
app:layout_constraintBottom_toBottomOf="@id/fileBrowser_activity_main_txtSelectionCountPositionHelper"
@@ -210,9 +211,8 @@
210211
android:visibility="gone"
211212
tools:visibility="visible"
212213
android:translationZ="16dp"
213-
android:backgroundTint="@color/color_gallery_dim"
214-
215214
>
215+
216216
<com.google.android.material.card.MaterialCardView
217217
android:id="@+id/fileBrowser_activity_main_albumPlaceHolder"
218218
android:layout_width="@dimen/sfb_max_album_menu_width"

0 commit comments

Comments
 (0)