Skip to content

Commit b4d109a

Browse files
author
mahdiasd
committed
fix some bugs
1 parent a7c76ff commit b4d109a

11 files changed

Lines changed: 89 additions & 54 deletions

File tree

FilePicker/src/main/java/com/mahdiasd/filepicker/FilePicker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ data class FilePicker(
3636
var eachFileSize: Int? = null,
3737

3838
var activeColor: Int = ContextCompat.getColor(context, R.color.colorPrimary),
39-
var deActiveColor: Int = ContextCompat.getColor(context, R.color.gray),
39+
var deActiveColor: Int = ContextCompat.getColor(context, R.color.file_picker_gray),
4040
var cardBackgroundColor: Int = ContextCompat.getColor(context, R.color.white),
4141
) :
4242
BaseObservable() {

FilePicker/src/main/java/com/mahdiasd/filepicker/FilePickerAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class FilePickerAdapter(
160160
val imageUri = Uri.fromFile(file) ?: return
161161
Glide.with(view.context)
162162
.load(imageUri)
163-
.placeholder(R.color.gray)
163+
.placeholder(R.color.file_picker_gray)
164164
.skipMemoryCache(false)
165165
.diskCacheStrategy(DiskCacheStrategy.ALL)
166166
.into(view)

FilePicker/src/main/res/drawable/dash_line.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<stroke
66
android:width="1dp"
7-
android:color="@color/gray"
7+
android:color="@color/file_picker_gray"
88
android:dashWidth="10px"
99
android:dashGap="10px" />
1010
</shape>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
2+
<stroke
3+
android:width="1dp"
4+
android:color="@color/colorPrimary" />
5+
<corners android:radius="4dp" />
6+
</shape>

FilePicker/src/main/res/drawable/shape_radius_20.xml

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

FilePicker/src/main/res/layout/file_picker_fragment.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
android:layout_width="match_parent"
6262
android:layout_height="45dp"
6363
android:layout_below="@id/image"
64-
android:background="@drawable/shape_radius_20"
64+
android:background="#00000000"
6565
android:hint="@string/mahdiasd_file_picker_search"
6666
android:onTextChanged="@{presenter::search}"
6767
android:paddingLeft="16dp"
6868
android:paddingRight="38dp"
6969
android:textColor="@color/black"
70-
android:textColorHint="@color/gray"
70+
android:textColorHint="@color/file_picker_gray"
7171
android:visibility="@{config.selectedMode != PickerMode.FILE ? View.VISIBLE : View.GONE}" />
7272

7373
<ImageView

FilePicker/src/main/res/values/colors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
<color name="colorPrimary">#2196F3</color>
77
<color name="colorAccent">#E91E63</color>
8-
<color name="gray">#A4A4A4</color>
8+
<color name="file_picker_gray">#A4A4A4</color>
99

1010
</resources>

FilePicker/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources>
22
<string name="app_name">Sample</string>
3+
34
<string name="mahdiasd_file_picker_failed_open_file">Error when open file, please choose another!</string>
45
<string name="mahdiasd_file_picker_cant_find_this_file">Can`t find this file</string>
56
<string name="mahdiasd_file_picker_video">Video</string>

app/src/main/java/com/mahdiasd/sample/MainActivity.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ class MainActivity : AppCompatActivity() {
4848
}
4949

5050
val max =
51-
if (binding.maxSelection.text.isEmpty())1 else binding.maxSelection.text.toString()
51+
if (binding.maxSelection.text.isEmpty()) 1 else binding.maxSelection.text.toString()
52+
.toInt()
53+
54+
val maxTotalSize =
55+
if (binding.maxTotalSize.text.isEmpty()) 1000 * 1000 else binding.maxTotalSize.text.toString()
56+
.toInt()
57+
58+
val maxEachSize =
59+
if (binding.maxTotalEachSize.text.isEmpty()) 1000 * 1000 else binding.maxTotalEachSize.text.toString()
5260
.toInt()
5361

5462
val activeColor =
@@ -63,7 +71,8 @@ class MainActivity : AppCompatActivity() {
6371
.setMode(*modes.toTypedArray())
6472
.setDefaultMode(PickerMode.Image)
6573
.setMaxSelection(max)
66-
.setMaxEachFileSize(1500)
74+
.setMaxEachFileSize(maxEachSize)
75+
.setMaxTotalFileSize(maxTotalSize)
6776
.setCustomText(
6877
binding.videoTitle.text.toString(),
6978
binding.audioTitle.text.toString(),

app/src/main/res/layout/activity_main.xml

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
xmlns:tools="http://schemas.android.com/tools">
45

56
<data>
@@ -46,18 +47,18 @@
4647

4748
<androidx.appcompat.widget.AppCompatCheckBox
4849
android:id="@+id/storage"
49-
android:checked="true"
5050
android:layout_width="wrap_content"
5151
android:layout_height="wrap_content"
5252
android:layout_weight="1"
53+
android:checked="true"
5354
android:text="Storage" />
5455

5556
<androidx.appcompat.widget.AppCompatCheckBox
5657
android:id="@+id/audio"
5758
android:layout_width="wrap_content"
58-
android:checked="true"
5959
android:layout_height="wrap_content"
6060
android:layout_weight="1"
61+
android:checked="true"
6162
android:text="Audio" />
6263

6364
<androidx.appcompat.widget.AppCompatCheckBox
@@ -72,16 +73,11 @@
7273
android:id="@+id/video"
7374
android:layout_width="wrap_content"
7475
android:layout_height="wrap_content"
75-
android:checked="true"
7676
android:layout_weight="1"
77+
android:checked="true"
7778
android:text="Video" />
7879
</LinearLayout>
7980

80-
<ImageView
81-
android:layout_width="match_parent"
82-
android:layout_height="1dp"
83-
android:layout_marginTop="16dp"
84-
android:background="@color/colorAccent" />
8581

8682
<TextView
8783
android:layout_width="match_parent"
@@ -98,12 +94,6 @@
9894
android:layout_height="wrap_content"
9995
android:text="Show Preview" />
10096

101-
<ImageView
102-
android:layout_width="match_parent"
103-
android:layout_height="1dp"
104-
android:layout_marginTop="16dp"
105-
android:background="@color/colorAccent" />
106-
10797

10898
<TextView
10999
android:layout_width="match_parent"
@@ -119,17 +109,58 @@
119109
android:layout_width="match_parent"
120110
android:layout_height="wrap_content"
121111
android:layout_marginTop="8dp"
112+
android:background="@drawable/shape_border"
122113
android:hint="enter max number"
123114
android:inputType="number"
115+
android:padding="8dp"
124116
android:textColor="@color/black"
125117
android:textSize="14sp"
126118
android:textStyle="bold" />
127119

128-
<ImageView
120+
<TextView
129121
android:layout_width="match_parent"
130-
android:layout_height="1dp"
131-
android:layout_marginTop="16dp"
132-
android:background="@color/colorAccent" />
122+
android:layout_height="wrap_content"
123+
android:layout_marginTop="24dp"
124+
android:text="Max Total Size (kb):"
125+
android:textColor="@color/black"
126+
android:textSize="14sp"
127+
android:textStyle="bold" />
128+
129+
<EditText
130+
android:id="@+id/maxTotalSize"
131+
android:layout_width="match_parent"
132+
android:layout_height="wrap_content"
133+
android:layout_marginTop="8dp"
134+
android:background="@drawable/shape_border"
135+
android:hint="enter max total size"
136+
android:inputType="number"
137+
android:padding="8dp"
138+
android:textColor="@color/black"
139+
android:textSize="14sp"
140+
android:textStyle="bold" />
141+
142+
<TextView
143+
android:layout_width="match_parent"
144+
android:layout_height="wrap_content"
145+
android:layout_marginTop="24dp"
146+
android:text="Max Size For Each Item (kb):"
147+
android:textColor="@color/black"
148+
android:textSize="14sp"
149+
android:textStyle="bold" />
150+
151+
<EditText
152+
android:id="@+id/maxTotalEachSize"
153+
android:layout_width="match_parent"
154+
android:layout_height="wrap_content"
155+
android:layout_marginTop="8dp"
156+
android:background="@drawable/shape_border"
157+
android:hint="enter max size for each item"
158+
android:inputType="number"
159+
android:padding="8dp"
160+
android:textColor="@color/black"
161+
android:textSize="14sp"
162+
android:textStyle="bold" />
163+
133164

134165
<TextView
135166
android:layout_width="match_parent"
@@ -145,17 +176,15 @@
145176
android:layout_width="match_parent"
146177
android:layout_height="wrap_content"
147178
android:layout_marginTop="8dp"
179+
180+
android:background="@drawable/shape_border"
148181
android:hint="enter hex color like #E91E63"
149182
android:inputType="number"
183+
android:padding="8dp"
150184
android:textColor="@color/black"
151185
android:textSize="14sp"
152186
android:textStyle="bold" />
153187

154-
<ImageView
155-
android:layout_width="match_parent"
156-
android:layout_height="1dp"
157-
android:layout_marginTop="16dp"
158-
android:background="@color/colorAccent" />
159188

160189
<TextView
161190
android:layout_width="match_parent"
@@ -171,17 +200,15 @@
171200
android:layout_width="match_parent"
172201
android:layout_height="wrap_content"
173202
android:layout_marginTop="8dp"
203+
android:background="@drawable/shape_border"
174204
android:hint="enter hex color like #E91E63"
205+
175206
android:inputType="number"
207+
android:padding="8dp"
176208
android:textColor="@color/black"
177209
android:textSize="14sp"
178210
android:textStyle="bold" />
179211

180-
<ImageView
181-
android:layout_width="match_parent"
182-
android:layout_height="1dp"
183-
android:layout_marginTop="16dp"
184-
android:background="@color/colorAccent" />
185212

186213
<TextView
187214
android:layout_width="match_parent"
@@ -197,17 +224,15 @@
197224
android:layout_width="match_parent"
198225
android:layout_height="wrap_content"
199226
android:layout_marginTop="8dp"
227+
android:background="@drawable/shape_border"
228+
200229
android:hint="enter hex color like #E91E63"
201230
android:inputType="number"
231+
android:padding="8dp"
202232
android:textColor="@color/black"
203233
android:textSize="14sp"
204234
android:textStyle="bold" />
205235

206-
<ImageView
207-
android:layout_width="match_parent"
208-
android:layout_height="1dp"
209-
android:layout_marginTop="16dp"
210-
android:background="@color/colorAccent" />
211236

212237
<TextView
213238
android:layout_width="match_parent"
@@ -264,20 +289,21 @@
264289

265290
<EditText
266291
android:id="@+id/openStorageTitle"
267-
android:text="Open Storage"
268292
android:layout_width="match_parent"
269293
android:layout_height="wrap_content"
270294
android:layout_marginTop="6dp"
271295
android:gravity="center"
272-
android:hint="Open Storage" />
296+
android:hint="Open Storage"
297+
android:text="Open Storage" />
273298

274299

275-
<Button
300+
<com.google.android.material.button.MaterialButton
276301
android:layout_width="match_parent"
277302
android:layout_height="wrap_content"
278303
android:layout_marginTop="32dp"
279304
android:onClick="btn"
280-
android:text="Open Dialog" />
305+
android:text="Open Dialog"
306+
app:backgroundTint="@color/colorPrimary" />
281307

282308
</LinearLayout>
283309
</androidx.core.widget.NestedScrollView>

0 commit comments

Comments
 (0)