Skip to content

Commit 6c80215

Browse files
committed
Add attribute show_hidden_files to FilePickerPreference & update README
1 parent c528866 commit 6c80215

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Readme.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Step 2. Add the dependency
6868
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
6969
properties.offset = new File(DialogConfigs.DEFAULT_DIR);
7070
properties.extensions = null;
71+
properties.show_hidden_files = false;
7172
```
7273

7374
3. Next create an instance of `FilePickerDialog`, and pass `Context` and `DialogProperties` references as parameters. Optional: You can change the title of dialog. Default is current directory name. Set the positive button string. Default is Select. Set the negative button string. Defalut is Cancel.
@@ -132,7 +133,8 @@ Marshmallow and above requests for the permission on runtime. You should overrid
132133
app:root_dir="/sdcard"
133134
app:selection_mode="multi_mode"
134135
app:selection_type="dir_select"
135-
app:extensions="txt:pdf:"/>
136+
app:extensions="txt:pdf:"
137+
app:show_hidden_files="false"/>
136138
```
137139

138140
2. Implement [Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/preference/Preference.OnPreferenceChangeListener.html) to class requiring selected values and `Override` `onPreferenceChange(Preference, Object)` method. Check for preference key using [Preference](https://developer.android.com/reference/android/preference/Preference.html) reference.

library/src/main/java/com/developer/filepicker/view/FilePickerPreference.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import android.preference.Preference;
99
import android.util.AttributeSet;
1010
import android.view.View;
11+
1112
import com.developer.filepicker.R;
1213
import com.developer.filepicker.controller.DialogSelectionListener;
1314
import com.developer.filepicker.model.DialogConfigs;
1415
import com.developer.filepicker.model.DialogProperties;
16+
1517
import java.io.File;
1618

1719
/**
@@ -72,7 +74,7 @@ protected Parcelable onSaveInstanceState() {
7274

7375
@Override
7476
protected void onRestoreInstanceState(Parcelable state) {
75-
if (state == null || !(state instanceof SavedState)) {
77+
if (!(state instanceof SavedState)) {
7678
super.onRestoreInstanceState(state);
7779
return;
7880
}
@@ -188,6 +190,9 @@ else if (attr == R.styleable.FilePickerPreference_extensions) {
188190
else if (attr == R.styleable.FilePickerPreference_title_text) {
189191
titleText=tarr.getString(R.styleable.FilePickerPreference_title_text);
190192
}
193+
else if (attr == R.styleable.FilePickerPreference_show_hidden_files) {
194+
properties.show_hidden_files = tarr.getBoolean(R.styleable.FilePickerPreference_show_hidden_files, false);
195+
}
191196
}
192197
tarr.recycle();
193198
}

library/src/main/res/values/attrs.xml

+4
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@
3131
name="title_text"
3232
format="string"/>
3333

34+
<attr
35+
name="show_hidden_files"
36+
format="boolean"/>
37+
3438
</declare-styleable>
3539
</resources>

0 commit comments

Comments
 (0)