Skip to content

Commit

Permalink
Demo: showcase custom filter
Browse files Browse the repository at this point in the history
  • Loading branch information
codekidX committed Jul 28, 2017
1 parent baaf31b commit fc87dfe
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.codekidlabs.storagechooserdemo;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -134,20 +133,32 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
switch (i) {
case 0:
builder.crunch();
builder.filter(null);
break;
case 1:
builder.crunch();
builder.filter(StorageChooser.FileType.VIDEO);
break;
case 2:
builder.crunch();
builder.filter(StorageChooser.FileType.AUDIO);
break;
case 3:
builder.crunch();
builder.filter(StorageChooser.FileType.DOCS);
break;
case 4:
builder.crunch();
builder.filter(StorageChooser.FileType.IMAGES);
break;
case 5:

ArrayList<String> formats = new ArrayList<>();
formats.add("txt");
formats.add("mkv");
builder.customFilter(formats);
break;
}
}

Expand Down Expand Up @@ -192,7 +203,9 @@ public void onCancel() {
chooser.setOnMultipleSelectListener(new StorageChooser.OnMultipleSelectListener() {
@Override
public void onDone(ArrayList<String> selectedFilePaths) {

for(String s: selectedFilePaths) {
Log.e(TAG, s);
}
}
});

Expand All @@ -204,7 +217,7 @@ public void onDone(ArrayList<String> selectedFilePaths) {

private StorageChooser.Theme getScTheme(boolean isChecked) {
StorageChooser.Theme theme = new StorageChooser.Theme(getApplicationContext());
theme.setScheme((isChecked) ? theme.getDefaultDarkScheme() : theme.getDefaultScheme());
theme.setScheme((isChecked) ? getResources().getIntArray(R.array.paranoid_theme) : theme.getDefaultScheme());
return theme;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="setTheme" />
android:text="setTheme (Dark)" />

<Spinner
android:id="@+id/filter_spinner"
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,27 @@
<color name="cancel_color">#3fa19f</color>

<color name="colorExplanationBox">#ececec</color>



<array name="paranoid_theme">
<!-- Overview -->
<item>#151515</item> <!-- Top Header bg -->
<item>#2c9633</item> <!-- header text -->
<item>#252525</item> <!-- list bg -->
<item>@android:color/white</item> <!-- storage list name text -->
<item>#e1e1e1</item> <!-- free space text -->
<item>#2c9633</item> <!-- memory bar -->

<!-- secondary dialog colors -->
<item>#151515</item> <!-- folder tint -->
<item>#252525</item> <!-- list bg -->
<item>@android:color/white</item> <!-- list text -->
<item>#151515</item> <!-- address bar tint -->
<item>@color/chevronBgColor</item> <!-- new folder hint tint -->
<item>#2c9633</item> <!-- select button color -->
<item>#da6c6c</item> <!-- new folder layour bg -->
<item>#2c9633</item> <!-- fab multi color -->
<item>#151515</item> <!-- address bar bg -->
</array>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<item>Audio</item>
<item>Documents</item>
<item>Images</item>
<item>Custom</item>
</string-array>
</resources>

0 comments on commit fc87dfe

Please sign in to comment.