├── app
├── .gitignore
├── libs
│ ├── zip4j_1.3.2.jar
│ └── commons-io-2.5.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── file.png
│ │ │ │ ├── folder.png
│ │ │ │ ├── header_back_green.png
│ │ │ │ ├── divider.xml
│ │ │ │ └── fab_label_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_add_black_24dp.png
│ │ │ │ ├── ic_done_black_24dp.png
│ │ │ │ ├── ic_home_black_24dp.png
│ │ │ │ ├── ic_menu_black_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_file_grey600_48dp.png
│ │ │ │ ├── ic_image_black_24dp.png
│ │ │ │ ├── ic_search_black_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_download_black_24dp.png
│ │ │ │ ├── ic_folder_grey600_48dp.png
│ │ │ │ ├── ic_settings_black_24dp.png
│ │ │ │ ├── ic_headphones_black_24dp.png
│ │ │ │ └── ic_headphones_grey600_48dp.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_add_black_24dp.png
│ │ │ │ ├── ic_home_black_24dp.png
│ │ │ │ ├── ic_menu_black_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_file_grey600_48dp.png
│ │ │ │ ├── ic_image_black_24dp.png
│ │ │ │ ├── ic_search_black_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_download_black_24dp.png
│ │ │ │ ├── ic_folder_grey600_48dp.png
│ │ │ │ ├── ic_settings_black_24dp.png
│ │ │ │ ├── ic_headphones_black_24dp.png
│ │ │ │ └── ic_headphones_grey600_48dp.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_add_black_24dp.png
│ │ │ │ ├── ic_home_black_24dp.png
│ │ │ │ ├── ic_image_black_24dp.png
│ │ │ │ ├── ic_menu_black_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_download_black_24dp.png
│ │ │ │ ├── ic_file_grey600_48dp.png
│ │ │ │ ├── ic_folder_grey600_48dp.png
│ │ │ │ ├── ic_search_black_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_settings_black_24dp.png
│ │ │ │ ├── ic_headphones_black_24dp.png
│ │ │ │ └── ic_headphones_grey600_48dp.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_add_black_24dp.png
│ │ │ │ ├── ic_home_black_24dp.png
│ │ │ │ ├── ic_menu_black_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_file_grey600_48dp.png
│ │ │ │ ├── ic_image_black_24dp.png
│ │ │ │ ├── ic_search_black_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_download_black_24dp.png
│ │ │ │ ├── ic_folder_grey600_48dp.png
│ │ │ │ ├── ic_settings_black_24dp.png
│ │ │ │ ├── ic_headphones_black_24dp.png
│ │ │ │ └── ic_headphones_grey600_48dp.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── wallpaper_47.png
│ │ │ │ ├── ic_launcher_mat.png
│ │ │ │ ├── wallpaper_1088.png
│ │ │ │ ├── wallpaper_1376.png
│ │ │ │ ├── wallpaper_5114.png
│ │ │ │ ├── wallpaper_5870.png
│ │ │ │ ├── wallpaper_6713.png
│ │ │ │ ├── header_back_green.png
│ │ │ │ ├── ic_add_black_24dp.png
│ │ │ │ ├── ic_file_grey600_48dp.png
│ │ │ │ ├── ic_home_black_24dp.png
│ │ │ │ ├── ic_image_black_24dp.png
│ │ │ │ ├── ic_menu_black_24dp.png
│ │ │ │ ├── ic_menu_white_24dp.png
│ │ │ │ ├── ic_search_black_24dp.png
│ │ │ │ ├── ic_search_white_24dp.png
│ │ │ │ ├── ic_download_black_24dp.png
│ │ │ │ ├── ic_folder_grey600_48dp.png
│ │ │ │ ├── ic_settings_black_24dp.png
│ │ │ │ ├── ic_headphones_black_24dp.png
│ │ │ │ └── ic_headphones_grey600_48dp.png
│ │ │ ├── xml
│ │ │ │ ├── provider_paths.xml
│ │ │ │ └── preference_hierarchy.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── layout
│ │ │ │ ├── fragment_newfile.xml
│ │ │ │ ├── header.xml
│ │ │ │ ├── developer_prefs.xml
│ │ │ │ ├── fragment_main.xml
│ │ │ │ ├── recycler_row_no_checkbox.xml
│ │ │ │ ├── fragment_copy.xml
│ │ │ │ ├── fragment_long_click_multipleselection.xml
│ │ │ │ ├── recycler_row.xml
│ │ │ │ ├── fragment_long_click.xml
│ │ │ │ └── activity_main.xml
│ │ │ └── menu
│ │ │ │ └── drawer.xml
│ │ ├── java
│ │ │ └── app
│ │ │ │ └── android
│ │ │ │ └── com
│ │ │ │ └── materialfilemanager
│ │ │ │ ├── VerticalSpaceRecycler.java
│ │ │ │ ├── SettingsFragment.java
│ │ │ │ ├── Item.java
│ │ │ │ ├── DividerItemRecycler.java
│ │ │ │ ├── DialogSearch.java
│ │ │ │ ├── DialogNewFile.java
│ │ │ │ ├── DialogLongPress.java
│ │ │ │ ├── FileAdapter.java
│ │ │ │ ├── CopyMoveFragment.java
│ │ │ │ ├── DownloadDrawerFragment.java
│ │ │ │ ├── MusicDrawerFragment.java
│ │ │ │ ├── ImagesDrawerFragment.java
│ │ │ │ ├── MainFragment.java
│ │ │ │ └── SearchResultsFragment.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── app
│ │ │ └── android
│ │ │ └── com
│ │ │ └── materialfilemanager
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── app
│ │ └── android
│ │ └── com
│ │ └── materialfilemanager
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
├── gradlew
└── License.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/libs/zip4j_1.3.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/libs/zip4j_1.3.2.jar
--------------------------------------------------------------------------------
/app/libs/commons-io-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/libs/commons-io-2.5.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/drawable/file.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/drawable/folder.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/header_back_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/drawable/header_back_green.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_47.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_47.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_add_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_add_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_done_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_done_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_menu_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_menu_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_add_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_add_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_menu_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_menu_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_add_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_add_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_mat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_mat.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_1088.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_1088.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_1376.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_1376.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_5114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_5114.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_5870.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_5870.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/wallpaper_6713.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/wallpaper_6713.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_file_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_file_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_image_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_image_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_search_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_search_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_file_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_file_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_image_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_image_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_search_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_search_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_image_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_image_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_menu_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_menu_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_add_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_add_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_menu_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_menu_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/header_back_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/header_back_green.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_add_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_add_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_download_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_download_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_folder_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_folder_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_settings_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_settings_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_download_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_download_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_folder_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_folder_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_settings_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_settings_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_download_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_download_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_file_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_file_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_folder_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_folder_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_search_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_search_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_settings_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_settings_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_file_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_file_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_image_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_image_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_search_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_search_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_file_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_file_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_image_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_image_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_menu_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_menu_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_menu_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_menu_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_search_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_search_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_search_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_search_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_headphones_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_headphones_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_headphones_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_headphones_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_headphones_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_headphones_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_download_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_download_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_folder_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_folder_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_settings_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_settings_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_download_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_download_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_folder_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_folder_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_settings_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_settings_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_headphones_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-hdpi/ic_headphones_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_headphones_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-mdpi/ic_headphones_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_headphones_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xhdpi/ic_headphones_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_headphones_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_headphones_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_headphones_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_headphones_grey600_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_headphones_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_headphones_black_24dp.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_headphones_grey600_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CosimoSguanci/Material-File-Manager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_headphones_grey600_48dp.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Dec 24 01:18:29 GMT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | - Green
7 | - Red
8 | - Yellow
9 | - Blue
10 | - Orange
11 | - Dark
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/app/android/com/materialfilemanager/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/app/android/com/materialfilemanager/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_newfile.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\shind\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fab_label_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/VerticalSpaceRecycler.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | /**
8 | * Created by Cosimo Sguanci on 12/09/2016.
9 | */
10 | public class VerticalSpaceRecycler extends RecyclerView.ItemDecoration {
11 | private final int mVerticalSpaceHeight;
12 |
13 | public VerticalSpaceRecycler(int mVerticalSpaceHeight) {
14 | this.mVerticalSpaceHeight = mVerticalSpaceHeight;
15 | }
16 |
17 | @Override
18 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
19 | RecyclerView.State state) {
20 | outRect.bottom = mVerticalSpaceHeight;
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/header.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
10 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/developer_prefs.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
21 |
22 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | applicationId "app.android.com.materialfilemanager"
9 | minSdkVersion 21
10 | targetSdkVersion 24
11 | versionCode 4
12 | versionName "1.5"
13 | multiDexEnabled true
14 | }
15 | dexOptions {
16 | incremental true
17 | javaMaxHeapSize "4g"
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | compile files('libs/commons-io-2.5.jar')
30 | compile files('libs/zip4j_1.3.2.jar')
31 |
32 | compile 'com.android.support:appcompat-v7:24.2.1'
33 | compile 'com.android.support:recyclerview-v7:24.2.1'
34 | compile 'com.android.support:design:24.2.1'
35 | compile 'com.android.support:support-v4:24.2.1'
36 | compile 'com.github.clans:fab:1.6.4'
37 | compile 'com.github.bumptech.glide:glide:3.7.0'
38 | compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
39 | testCompile 'junit:junit:4.12'
40 | compile 'com.google.android.gms:play-services-appindexing:8.4.0'
41 | compile 'com.android.support:multidex:1.0.0'
42 | compile 'com.android.support:cardview-v7:24.0.0'
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4CAF50
4 | #388E3C
5 | #FF9800
6 | #C8E6C9
7 | #646464
8 |
9 | #D32F2F
10 | #B71C1C
11 | #607D8B
12 | #FFCDD2
13 |
14 | #FFEB3B
15 | #FFD600
16 | #00E676
17 | #FFF9C4
18 |
19 | #3F51B5
20 | #1A237E
21 | #E91E63
22 | #9FA8DA
23 |
24 | #F57C00
25 | #E65100
26 | #5D4037
27 | #FFE0B2
28 |
29 | #000
30 | #000
31 | #000
32 | #fff
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 | # Material File Manager
4 | A simple, smooth and elegant Android File Manager with Material Design UI.
5 | I started to develop this App as my first Android Project. I focalized mainly about three things:
6 | - Material Design UI patterns;
7 | - Providing a fast and responsive experience for the user.
8 | - Give the user the possibility to customize the experience with various themes.
9 |
10 | It has also the most common functions as a File Explorer, like:
11 | - Multiple files selection;
12 | - Create new files or directories;
13 | - Copy, Move, Delete, or Rename files or directories;
14 | - Zip and Unzip files and directories;
15 | - Global search of files and directories in the phone memory.
16 |
17 | I think also that customization is a fundamental part of an Android App, so i've given the user the opportunity to change the drawer shortcut paths (to Images folder, Music folder, and Download folder).
18 |
19 | Material File Manager is on the Play Store:
20 |
21 |
22 | UI Example:
23 | 
24 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.preference.ListPreference;
6 | import android.preference.Preference;
7 | import android.preference.PreferenceFragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 |
13 | public class SettingsFragment extends PreferenceFragment {
14 |
15 | private ListPreference mListPreference;
16 |
17 | @Override
18 | public void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | addPreferencesFromResource(R.xml.preference_hierarchy);
21 | }
22 |
23 | @Override
24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
25 |
26 | View view = super.onCreateView(inflater, container, savedInstanceState);
27 | view.setBackgroundColor(Color.WHITE);
28 | mListPreference = (ListPreference) getPreferenceManager().findPreference("theme");
29 | mListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
30 | @Override
31 | public boolean onPreferenceChange(Preference preference, Object newValue) {
32 | getActivity().recreate();
33 | return true;
34 | }
35 | });
36 |
37 |
38 | return view;
39 |
40 |
41 | }
42 |
43 | @Override
44 | public void onStop() {
45 | super.onStop();
46 | }
47 |
48 |
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/Item.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | /**
4 | * Created by Cosimo Sguanci on 08/09/2016.
5 | */
6 | public class Item implements Comparable- {
7 | private String name;
8 | private String data; //number of data (Dirs), size of file (Files)
9 | private String date;
10 | private String path;
11 | private String image;
12 | public boolean isSelected=false;
13 |
14 | public Item(String name, String data, String date, String path, String image) {
15 | this.name = name;
16 | this.data = data;
17 | this.date = date;
18 | this.path = path;
19 | this.image = image;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public void setName(String name){
27 | this.name=name;
28 | }
29 |
30 | public String getData() {
31 | return data;
32 | }
33 |
34 | public String getDate() {
35 | return date;
36 | }
37 |
38 | public String getPath() {
39 | return path;
40 | }
41 |
42 | public String getImage() {
43 | return image;
44 | }
45 |
46 | public int compareTo(Item x) {
47 | if (this.name != null)
48 | return this.name.toLowerCase().compareTo(x.getName().toLowerCase());
49 | else
50 | throw new IllegalArgumentException();
51 | }
52 |
53 | public void setSelected(boolean isSelected){
54 | this.isSelected=isSelected;
55 | }
56 |
57 | public boolean isSelected(){
58 | return isSelected;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
27 |
30 |
31 |
32 |
34 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preference_hierarchy.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_row_no_checkbox.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
19 |
20 |
27 |
28 |
34 |
35 |
36 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/DividerItemRecycler.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.drawable.Drawable;
7 | import android.support.v4.content.ContextCompat;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | /**
12 | * Created by Cosimo Sguanci on 12/09/2016.
13 | */
14 | public class DividerItemRecycler extends RecyclerView.ItemDecoration {
15 | private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
16 |
17 | private Drawable mDivider;
18 |
19 | /**
20 | * Default divider will be used
21 | */
22 | public DividerItemRecycler(Context context) {
23 | final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
24 | mDivider = styledAttributes.getDrawable(0);
25 | styledAttributes.recycle();
26 | }
27 |
28 | /**
29 | * Custom divider will be used
30 | */
31 | public DividerItemRecycler(Context context, int resId) {
32 | mDivider = ContextCompat.getDrawable(context, resId);
33 | }
34 |
35 |
36 | @Override
37 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
38 | int left = parent.getPaddingLeft();
39 | int right = parent.getWidth() - parent.getPaddingRight();
40 |
41 | int childCount = parent.getChildCount();
42 | for (int i = 0; i < childCount - 1; i++) {
43 | View child = parent.getChildAt(i);
44 |
45 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
46 |
47 | int top = child.getBottom() + params.bottomMargin;
48 | int bottom = top + mDivider.getIntrinsicHeight();
49 |
50 | mDivider.setBounds(left, top, right, bottom);
51 | mDivider.draw(c);
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_copy.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
21 |
22 |
25 |
26 |
32 |
33 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_long_click_multipleselection.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
29 |
30 |
41 |
42 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
19 |
20 |
27 |
28 |
34 |
35 |
41 |
49 |
50 |
51 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Material File Manager
3 | Root Directory
4 | Images
5 | Music
6 | Downloads
7 | Documents
8 | Settings
9 | Open navigation drawer
10 | Close navigation drawer
11 | New File
12 | New Directory
13 | File name...
14 | Free space:
15 | File Created
16 | Directory Created
17 | File/Directory Renamed
18 | File/Directory Deleted
19 | File/Directory Copied
20 | File/Directory Moved
21 | Empty Folder
22 | Move
23 | Copy
24 | Rename
25 | Delete
26 | Internal Storage
27 | Removable SD Card
28 | No app can open this file
29 | No results
30 | Authorization denied
31 | Zip File(s)
32 | Unzip File
33 | File(s) successfully zipped!
34 | File(s) successfully unzipped!
35 | The selected file is not a zip
36 | Choose default folders
37 | Images Default Folder
38 | Music Default Folder
39 | Downloads default folder
40 | The folder should be in the root directory, otherwise it will not be found.
41 | Informations
42 | Themes
43 | Choose a theme
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_long_click.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
29 |
30 |
40 |
41 |
53 |
64 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
21 |
22 |
30 |
31 |
39 |
40 |
48 |
49 |
58 |
59 |
62 |
63 |
70 |
71 |
77 |
78 |
81 |
82 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/DialogSearch.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.app.DialogFragment;
9 | import android.support.v7.app.AlertDialog;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.WindowManager;
14 | import android.widget.EditText;
15 |
16 | import com.github.clans.fab.FloatingActionMenu;
17 |
18 | /**
19 | * Created by Cosimo Sguanci on 16/10/2016.
20 | */
21 |
22 | public class DialogSearch extends DialogFragment {
23 |
24 |
25 | private EditText searchText;
26 | private onSearchListener listener;
27 |
28 | public DialogSearch() {
29 | }
30 |
31 | public static DialogSearch newIstance(String title) {
32 | DialogSearch frag = new DialogSearch();
33 | Bundle args = new Bundle();
34 | args.putString("title", title);
35 | frag.setArguments(args);
36 | return frag;
37 | }
38 |
39 | @Override
40 | public Dialog onCreateDialog(Bundle savedInstanceState) {
41 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
42 | fabMain.close(true);
43 | String title = getArguments().getString("title");
44 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
45 | alertDialogBuilder.setTitle(title);
46 | alertDialogBuilder.setView(R.layout.fragment_newfile);
47 | alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
48 | @Override
49 | public void onClick(DialogInterface dialog, int which) {
50 | searchText = (EditText) getDialog().findViewById(R.id.edit_text_newfile);
51 | listener.onNameSearchTyped(searchText.getText().toString());
52 |
53 |
54 | }
55 | });
56 | alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
57 | @Override
58 | public void onClick(DialogInterface dialog, int which) {
59 | dialog.dismiss();
60 | }
61 | });
62 |
63 | return alertDialogBuilder.create();
64 | }
65 |
66 |
67 | @Override
68 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedIstanceState) {
69 |
70 | return inflater.inflate(R.layout.fragment_newfile, container);
71 | }
72 |
73 |
74 | @Override
75 | public void onViewCreated(View view, @Nullable Bundle savedIstanceState) {
76 | super.onViewCreated(view, savedIstanceState);
77 | String title = getArguments().getString("title", "Enter name");
78 | getDialog().setTitle(title);
79 | getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
80 | }
81 |
82 | @Override
83 | public void onStart() {
84 | /**
85 | * Setting Dialog size
86 | */
87 | /*
88 | Window window = getDialog().getWindow();
89 | window.setLayout(50,200);
90 | window.setGravity(Gravity.CENTER);
91 | */
92 | // Call super onResume after sizing
93 | super.onStart();
94 |
95 | }
96 |
97 | @Override
98 | public void onAttach(Activity activity) {
99 | super.onAttach(activity);
100 | if (activity instanceof onSearchListener) {
101 | listener = (onSearchListener) activity;
102 | } else {
103 | throw new RuntimeException(activity.toString()
104 | + " must implement OnSearchListener");
105 | }
106 | }
107 |
108 | @Override
109 | public void onDetach() {
110 | super.onDetach();
111 | listener = null;
112 | }
113 |
114 | @Override
115 | public void onDismiss(DialogInterface dialog) {
116 | super.onDismiss(dialog);
117 | if (!((MainActivity) getActivity()).getOnSearchItem())
118 | getActivity().findViewById(R.id.fabMain).setVisibility(View.VISIBLE);
119 |
120 |
121 | }
122 |
123 | public interface onSearchListener {
124 | void onNameSearchTyped(String fileName);
125 |
126 | }
127 | }
128 |
129 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/DialogNewFile.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.app.DialogFragment;
9 | import android.support.v7.app.AlertDialog;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.WindowManager;
14 | import android.widget.EditText;
15 |
16 | import com.github.clans.fab.FloatingActionMenu;
17 |
18 | /**
19 | * Created by Cosimo Sguanci on 03/10/2016.
20 | */
21 | public class DialogNewFile extends DialogFragment {
22 |
23 |
24 | private EditText textNewFile;
25 | private onNameTypedListener listener;
26 |
27 | public DialogNewFile() {
28 | }
29 |
30 | public static DialogNewFile newIstance(String title) {
31 | DialogNewFile frag = new DialogNewFile();
32 | Bundle args = new Bundle();
33 | args.putString("title", title);
34 | frag.setArguments(args);
35 | return frag;
36 | }
37 |
38 | @Override
39 | public Dialog onCreateDialog(Bundle savedInstanceState) {
40 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
41 | fabMain.close(true);
42 | String title = getArguments().getString("title");
43 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
44 | alertDialogBuilder.setTitle(title);
45 | alertDialogBuilder.setView(R.layout.fragment_newfile);
46 | alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
47 | @Override
48 | public void onClick(DialogInterface dialog, int which) {
49 | textNewFile = (EditText) getDialog().findViewById(R.id.edit_text_newfile);
50 | listener.onNameTyped(textNewFile.getText().toString());
51 |
52 |
53 | }
54 | });
55 | alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
56 | @Override
57 | public void onClick(DialogInterface dialog, int which) {
58 | dialog.dismiss();
59 | }
60 | });
61 |
62 | return alertDialogBuilder.create();
63 | }
64 |
65 |
66 | @Override
67 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedIstanceState) {
68 |
69 | return inflater.inflate(R.layout.fragment_newfile, container);
70 | }
71 |
72 |
73 | @Override
74 | public void onViewCreated(View view, @Nullable Bundle savedIstanceState) {
75 | super.onViewCreated(view, savedIstanceState);
76 | String title = getArguments().getString("title", "Enter name");
77 | getDialog().setTitle(title);
78 | getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
79 | }
80 |
81 | /*@Override
82 | public void onResume() {
83 |
84 | Window window = getDialog().getWindow();
85 | Point size = new Point();
86 | // Store dimensions of the screen in `size`
87 | Display display = window.getWindowManager().getDefaultDisplay();
88 | display.getSize(size);
89 | window.setLayout((int) (size.x * 0.75), (int) (size.x * 0.50));
90 | window.setGravity(Gravity.CENTER);
91 | // Call super onResume after sizing
92 | super.onResume();
93 |
94 | }*/
95 |
96 | @Override
97 | public void onAttach(Activity activity) {
98 | super.onAttach(activity);
99 | if (activity instanceof onNameTypedListener) {
100 | listener = (onNameTypedListener) activity;
101 | } else {
102 | throw new RuntimeException(activity.toString()
103 | + " must implement OnFileTypedListener");
104 | }
105 | }
106 |
107 | @Override
108 | public void onDetach() {
109 | super.onDetach();
110 | listener = null;
111 | }
112 |
113 | @Override
114 | public void onDismiss(DialogInterface dialog) {
115 | super.onDismiss(dialog);
116 | getActivity().findViewById(R.id.fabMain).setVisibility(View.VISIBLE);
117 | ((MainActivity) getActivity()).setFileOrDirToNull();
118 |
119 | }
120 |
121 | public interface onNameTypedListener {
122 | void onNameTyped(String fileName);
123 |
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
46 |
47 |
51 |
52 |
53 |
72 |
73 |
80 |
81 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/DialogLongPress.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.DialogFragment;
8 | import android.support.v7.app.AlertDialog;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.WindowManager;
13 |
14 | /**
15 | * Created by Cosimo Sguanci on 10/10/2016.
16 | */
17 |
18 | public class DialogLongPress extends DialogFragment {
19 |
20 |
21 | private static boolean multipleSelection = false;
22 | private onLongPressActions listener;
23 |
24 | public DialogLongPress() {
25 | }
26 |
27 |
28 | public static DialogLongPress newIstance(String title, boolean multiple_Selection) {
29 | multipleSelection = multiple_Selection;
30 | DialogLongPress frag = new DialogLongPress();
31 | Bundle args = new Bundle();
32 | args.putString("title", title);
33 | frag.setArguments(args);
34 | return frag;
35 | }
36 |
37 | @Override
38 | public Dialog onCreateDialog(Bundle savedInstanceState) {
39 | String title = getArguments().getString("title");
40 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
41 | alertDialogBuilder.setTitle(title);
42 | if (!multipleSelection)
43 | alertDialogBuilder.setView(R.layout.fragment_long_click);
44 | else
45 | alertDialogBuilder.setView(R.layout.fragment_long_click_multipleselection);
46 | return alertDialogBuilder.create();
47 | }
48 |
49 |
50 | @Override
51 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedIstanceState) {
52 | if (!multipleSelection)
53 | return inflater.inflate(R.layout.fragment_long_click, container);
54 | else {
55 | return inflater.inflate(R.layout.fragment_long_click_multipleselection, container);
56 | }
57 |
58 | }
59 |
60 |
61 | @Override
62 | public void onViewCreated(View view, @Nullable Bundle savedIstanceState) {
63 | super.onViewCreated(view, savedIstanceState);
64 | String title = getArguments().getString("title", "Enter name");
65 | getDialog().setTitle(title);
66 | getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
67 |
68 | }
69 |
70 | @Override
71 | public void onResume() {
72 | getDialog().findViewById(R.id.deleteButton).setOnClickListener(new View.OnClickListener() {
73 | @Override
74 | public void onClick(View view) {
75 | listener.onDeleteClicked();
76 | dismiss();
77 | }
78 | });
79 | getDialog().findViewById(R.id.copyButton).setOnClickListener(new View.OnClickListener() {
80 | @Override
81 | public void onClick(View view) {
82 | listener.onCopyClicked();
83 | dismiss();
84 | }
85 | });
86 | getDialog().findViewById(R.id.moveButton).setOnClickListener(new View.OnClickListener() {
87 | @Override
88 | public void onClick(View view) {
89 | listener.onMoveClicked();
90 | dismiss();
91 | }
92 | });
93 | if (!multipleSelection) {
94 | getDialog().findViewById(R.id.renameButton).setOnClickListener(new View.OnClickListener() {
95 | @Override
96 | public void onClick(View view) {
97 | listener.onRenameClicked();
98 | dismiss();
99 | }
100 | });
101 | getDialog().findViewById(R.id.unzipButton).setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View view) {
104 | listener.onUnZipClicked();
105 | dismiss();
106 | }
107 | });
108 | }
109 | getDialog().findViewById(R.id.zipButton).setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View view) {
112 | listener.onZipClicked();
113 | dismiss();
114 | }
115 | });
116 |
117 |
118 | super.onResume();
119 |
120 |
121 | }
122 |
123 | @Override
124 | public void onAttach(Activity activity) {
125 | super.onAttach(activity);
126 | if (activity instanceof onLongPressActions) {
127 | listener = (onLongPressActions) activity;
128 | } else {
129 | throw new RuntimeException(activity.toString()
130 | + " must implement OnLongPressActions");
131 | }
132 | }
133 |
134 | @Override
135 | public void onDetach() {
136 | super.onDetach();
137 | listener = null;
138 | }
139 |
140 | public interface onLongPressActions {
141 | void onDeleteClicked();
142 |
143 | void onMoveClicked();
144 |
145 | void onCopyClicked();
146 |
147 | void onRenameClicked();
148 |
149 | void onZipClicked();
150 |
151 | void onUnZipClicked();
152 | }
153 |
154 |
155 | }
156 |
157 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/FileAdapter.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.CheckBox;
10 | import android.widget.CompoundButton;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.bumptech.glide.Glide;
15 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | * Created by Cosimo Sguanci on 08/09/2016.
22 | */
23 | public class FileAdapter extends RecyclerView.Adapter {
24 |
25 | private final List- items;
26 | private final List
- itemsChecked = new ArrayList<>();
27 | private Context c;
28 | private int id;
29 | private onFileClickedListener listener;
30 | private boolean hasExternalSD = false;
31 |
32 | public FileAdapter(Context c, int id, List
- items, boolean hasExternalSD) {
33 | this.items = items;
34 | this.id = id;
35 | this.c = c;
36 | this.listener = null;
37 | this.hasExternalSD = hasExternalSD;
38 | }
39 |
40 | public FileAdapter(Context c, int id, List
- items) {
41 | this.items = items;
42 | this.id = id;
43 | this.c = c;
44 | this.listener = null;
45 |
46 | }
47 |
48 |
49 | public void setOnFileClickedListener(onFileClickedListener listener) {
50 | this.listener = listener;
51 | }
52 |
53 | @Override
54 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
55 | View itemView;
56 | if (!hasExternalSD) {
57 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_row, parent, false);
58 | } else
59 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_row_no_checkbox, parent, false);
60 | return new MyViewHolder(itemView);
61 | }
62 |
63 | @Override
64 | public void onBindViewHolder(MyViewHolder holder, int position) {
65 | final Item item = items.get(position);
66 | holder.textViewName.setText(item.getName());
67 | holder.textViewSecond.setText(item.getData());
68 | holder.textViewDate.setText(item.getDate());
69 | if(holder.checkbox!=null){
70 | holder.checkbox.setOnCheckedChangeListener(null);
71 | holder.checkbox.setChecked(item.isSelected());
72 | holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
73 | @Override
74 | public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
75 | item.setSelected(isChecked);
76 | }
77 | });
78 | }
79 |
80 |
81 | if (item.getImage().equals("directory_icon"))
82 | holder.icon.setImageResource(R.mipmap.ic_folder_grey600_48dp);
83 | else if (item.getImage().equals("file_icon")) {
84 | holder.icon.setImageResource(R.mipmap.ic_file_grey600_48dp);
85 | } else if (item.getImage().equals("image_icon")) {
86 |
87 | //FIX Image Cropping
88 | Glide.with(c).load(item.getPath())
89 | .thumbnail(0.5f)
90 | .crossFade()
91 | .diskCacheStrategy(DiskCacheStrategy.ALL)
92 | .override(holder.icon.getMaxWidth(), holder.icon.getMaxHeight())
93 | //.centerCrop()
94 | .into(holder.icon);
95 | } else if (item.getImage().equals("music_icon")) {
96 | holder.icon.setImageResource(R.mipmap.ic_headphones_grey600_48dp);
97 | }
98 |
99 |
100 | }
101 |
102 |
103 | @Override
104 | public int getItemCount() {
105 | return items.size();
106 | }
107 |
108 | public interface onFileClickedListener {
109 | void onFileClick(String newPath);
110 |
111 | void onLongFileClick(List
- itemsChecked);
112 | }
113 |
114 | public class MyViewHolder extends RecyclerView.ViewHolder {
115 | TextView textViewName;
116 | TextView textViewSecond;
117 | TextView textViewDate;
118 | ImageView icon;
119 | CheckBox checkbox;
120 |
121 |
122 | public MyViewHolder(View v) {
123 | super(v);
124 | textViewName = (TextView) v.findViewById(R.id.text_view_name);
125 | textViewSecond = (TextView) v.findViewById(R.id.second_text_view);
126 | textViewDate = (TextView) v.findViewById(R.id.text_view_date);
127 | icon = (ImageView) v.findViewById(R.id.icon);
128 | checkbox = (CheckBox) v.findViewById(R.id.checkbox);
129 | v.setOnClickListener(new View.OnClickListener() {
130 | @Override
131 | public void onClick(View v) {
132 | listener.onFileClick(items.get(getAdapterPosition()).getPath());
133 |
134 | }
135 | });
136 |
137 | v.setOnLongClickListener(new View.OnLongClickListener() {
138 | @Override
139 | public boolean onLongClick(View view) {
140 | if (checkbox != null) {
141 | if (!checkbox.isChecked()) {
142 | itemsChecked.add(items.get(getAdapterPosition()));
143 | }
144 | }
145 |
146 | listener.onLongFileClick(itemsChecked);
147 | return false;
148 | }
149 | });
150 | if (checkbox != null)
151 | checkbox.setOnClickListener(new View.OnClickListener() {
152 | @Override
153 | public void onClick(View view) {
154 |
155 | if (checkbox.isChecked()) {
156 | itemsChecked.add(items.get(getAdapterPosition()));
157 |
158 | } else {
159 | int i = -1;
160 | for (Item h : itemsChecked) {
161 | i++;
162 | if (items.get(getAdapterPosition()).equals(itemsChecked.get(i))) {
163 |
164 | break;
165 | }
166 |
167 | }
168 |
169 | if(i!=-1)
170 | itemsChecked.remove(i);
171 | }
172 |
173 | int i=0;
174 | for(Item u: itemsChecked)
175 | {
176 | Log.w("ITEMS","CHECKED "+itemsChecked.get(i).getName());
177 | i++;
178 | }
179 |
180 | }
181 | });
182 |
183 | }
184 |
185 |
186 | }
187 |
188 |
189 | }
190 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/CopyMoveFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Environment;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.app.FragmentManager;
9 | import android.support.v4.app.FragmentTransaction;
10 | import android.support.v7.widget.DefaultItemAnimator;
11 | import android.support.v7.widget.LinearLayoutManager;
12 | import android.support.v7.widget.RecyclerView;
13 | import android.view.KeyEvent;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.TextView;
18 |
19 | import com.github.clans.fab.FloatingActionMenu;
20 |
21 | import java.io.File;
22 | import java.text.DateFormat;
23 | import java.util.ArrayList;
24 | import java.util.Collections;
25 | import java.util.Date;
26 | import java.util.List;
27 | import java.util.Stack;
28 |
29 | /**
30 | * Created by Cosimo Sguanci on 12/10/2016.
31 | */
32 |
33 | public class CopyMoveFragment extends Fragment {
34 | private static final String TAG_FRAGMENT = "TAG_FRAGMENT";
35 | private static final int VERTICAL_ITEM_SPACE = 48;
36 | private final List
- dir = new ArrayList<>(); // Only 1 ArrayList is needed, as we want show only directories
37 | private File currentDir;
38 | private FileAdapter adapter;
39 | private RecyclerView recyclerView;
40 | private final Stack pathStack = new Stack<>();
41 | private TextView textCurrentPath;
42 | private OnFolderSelectedListener listener;
43 |
44 |
45 | public static CopyMoveFragment newIstance() {
46 | return new CopyMoveFragment();
47 | }
48 |
49 |
50 | @Override
51 | public void onActivityCreated(Bundle savedInstanceState) {
52 | super.onActivityCreated(savedInstanceState);
53 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
54 | fabMain.setVisibility(View.INVISIBLE);
55 | getView().setFocusableInTouchMode(true);
56 | getView().requestFocus();
57 |
58 |
59 | getView().setOnKeyListener(new View.OnKeyListener() {
60 | @Override
61 | public boolean onKey(View v, int keyCode, KeyEvent event) {
62 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
63 | if (keyCode == KeyEvent.KEYCODE_BACK) {
64 |
65 |
66 | if (!pathStack.isEmpty()) {
67 | currentDir = new File(pathStack.pop());
68 | setupData(currentDir);
69 | adapter.notifyDataSetChanged();
70 | textCurrentPath.setText(currentDir.getAbsolutePath());
71 | } else {
72 | FragmentManager fragmentManager = getFragmentManager();
73 | FragmentTransaction ft = fragmentManager.beginTransaction().replace(R.id.fragmentContainer, MainFragment.newIstance(), TAG_FRAGMENT);
74 | ft.commit();
75 | }
76 | return true;
77 | }
78 | }
79 | return false;
80 | }
81 | });
82 |
83 |
84 | }
85 |
86 | @Override
87 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
88 | Bundle savedInstanceState) {
89 |
90 | return inflater.inflate(R.layout.fragment_copy, container, false);
91 | }
92 |
93 | @Override
94 | public void onViewCreated(View view, Bundle savedInstanceState) {
95 | View parentLayout = getActivity().findViewById(R.id.rootView);
96 | Snackbar snackbar = Snackbar
97 | .make(parentLayout, "Choose the copy/move folder", Snackbar.LENGTH_LONG);
98 |
99 | snackbar.show();
100 |
101 | getView().findViewById(R.id.doneFab).setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View view) {
104 | listener.onFolderSelected(currentDir.getAbsolutePath());
105 | }
106 | });
107 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
108 | textCurrentPath.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
109 | recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
110 | currentDir = Environment.getExternalStorageDirectory();
111 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
112 | recyclerView.setLayoutManager(mLayoutManager);
113 | recyclerView.setItemAnimator(new DefaultItemAnimator());
114 | recyclerView.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
115 | recyclerView.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
116 | setupData(currentDir);
117 |
118 | }
119 |
120 | /**
121 | * Method that creates the ArrayList for showing the directory to the user
122 | *
123 | * @param f
124 | */
125 | public void setupData(File f) {
126 | File[] dirs = f.listFiles();
127 | try {
128 | for (File ff : dirs) {
129 | Date lastModDate = new Date(ff.lastModified());
130 | DateFormat formater = DateFormat.getDateInstance();
131 | String date_modify = formater.format(lastModDate);
132 | if (ff.isDirectory()) {
133 | File[] dirFls = ff.listFiles();
134 | int buf;
135 | if (dirFls != null) {
136 | buf = dirFls.length;
137 | } else buf = 0;
138 | String num_item = String.valueOf(buf);
139 | if (buf == 1)
140 | num_item = num_item + " item";
141 | else
142 | num_item = num_item + " items";
143 | dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
144 | }
145 |
146 | }
147 | } catch (Exception e) {
148 | e.printStackTrace();
149 | }
150 | Collections.sort(dir);
151 | setupAdapter();
152 |
153 |
154 | }
155 |
156 | private void setupAdapter() {
157 |
158 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, dir);
159 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
160 | @Override
161 | public void onFileClick(String newPath) {
162 | if (currentDir != null) {
163 | pathStack.push(currentDir.getPath());
164 | }
165 | currentDir = new File(newPath);
166 | setupData(currentDir);
167 | adapter.notifyDataSetChanged();
168 | textCurrentPath.setText(currentDir.getAbsolutePath());
169 |
170 |
171 | }
172 |
173 | @Override
174 | public void onLongFileClick(List
- i) {
175 | // The App hasn't to react to a LongClick here
176 | }
177 | });
178 |
179 |
180 | recyclerView.setAdapter(adapter);
181 | }
182 |
183 | /**
184 | * Communication between Fragment and Activity
185 | *
186 | * @param activity
187 | */
188 | @Override
189 | public void onAttach(Activity activity) {
190 | super.onAttach(activity);
191 | if (activity instanceof DialogLongPress.onLongPressActions) {
192 | listener = (CopyMoveFragment.OnFolderSelectedListener) activity;
193 | } else {
194 | throw new RuntimeException(activity.toString()
195 | + " must implement OnFolderSelected");
196 | }
197 | }
198 |
199 | @Override
200 | public void onDetach() {
201 | super.onDetach();
202 | listener = null;
203 | }
204 |
205 | public interface OnFolderSelectedListener {
206 | void onFolderSelected(String path);
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/DownloadDrawerFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.graphics.Typeface;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.os.Environment;
9 | import android.preference.PreferenceManager;
10 | import android.support.design.widget.Snackbar;
11 | import android.support.v4.app.DialogFragment;
12 | import android.support.v4.app.Fragment;
13 | import android.support.v4.app.FragmentManager;
14 | import android.support.v4.content.FileProvider;
15 | import android.support.v7.widget.DefaultItemAnimator;
16 | import android.support.v7.widget.LinearLayoutManager;
17 | import android.support.v7.widget.RecyclerView;
18 | import android.view.Gravity;
19 | import android.view.KeyEvent;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.webkit.MimeTypeMap;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | import com.github.clans.fab.FloatingActionMenu;
28 |
29 | import java.io.File;
30 | import java.text.DateFormat;
31 | import java.text.DecimalFormat;
32 | import java.util.ArrayList;
33 | import java.util.Collections;
34 | import java.util.Date;
35 | import java.util.List;
36 | import java.util.Stack;
37 |
38 | /**
39 | * Created by Cosimo Sguanci on 13/09/2016.
40 | */
41 | public class DownloadDrawerFragment extends Fragment {
42 | private static final int VERTICAL_ITEM_SPACE = 48;
43 | private static LinearLayout parentLayout;
44 | private RecyclerView recyclerViewDownloads;
45 | private File currentDir;
46 | private final Stack pathStack = new Stack<>();
47 | private final List
- dir = new ArrayList<>();
48 | private final List
- fls = new ArrayList<>();
49 | private FileAdapter adapter;
50 | private String fileName = null;
51 | private TextView textCurrentPath;
52 | private TextView emptyTextView;
53 | private String tmpPathBuff;
54 | private boolean exceptionLaunched = false;
55 | private final List checkedPaths = new ArrayList<>();
56 | private int scrollPosition;
57 | private String defaultFolderName;
58 |
59 | public static DownloadDrawerFragment newIstance() {
60 | return new DownloadDrawerFragment();
61 |
62 | }
63 |
64 | @Override
65 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
66 | return inflater.inflate(R.layout.fragment_main, parent, false);
67 | }
68 |
69 |
70 | @Override
71 | public void onViewCreated(View view, Bundle savedInstanceState) {
72 | SharedPreferences defaultFolder= PreferenceManager.getDefaultSharedPreferences(getActivity());
73 | emptyTextView = new TextView(getContext());
74 | parentLayout = (LinearLayout) getActivity().findViewById(R.id.rootView);
75 | emptyTextView.setVisibility(View.VISIBLE);
76 | parentLayout.addView(emptyTextView);
77 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
78 | fabMain.setVisibility(View.VISIBLE);
79 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
80 | recyclerViewDownloads = (RecyclerView) getView().findViewById(R.id.recycler_view);
81 | if(!(defaultFolderName=defaultFolder.getString("downloads_preference","")).equals("")){
82 | currentDir=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+defaultFolderName);
83 | }
84 | else
85 | currentDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); // Setting current directory to Downloads default directory
86 | textCurrentPath.setText(currentDir.getAbsolutePath());
87 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
88 | recyclerViewDownloads.setLayoutManager(mLayoutManager);
89 | recyclerViewDownloads.setItemAnimator(new DefaultItemAnimator());
90 | recyclerViewDownloads.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
91 | recyclerViewDownloads.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
92 | setupData(currentDir);
93 | setupAdapter();
94 |
95 |
96 | }
97 |
98 | @Override
99 | public void onActivityCreated(Bundle savedInstanceState) {
100 | super.onActivityCreated(savedInstanceState);
101 | getView().setFocusableInTouchMode(true);
102 | getView().requestFocus();
103 |
104 | getView().setOnKeyListener(new View.OnKeyListener() {
105 | @Override
106 | public boolean onKey(View v, int keyCode, KeyEvent event) {
107 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
108 | if (keyCode == KeyEvent.KEYCODE_BACK) {
109 | if (emptyTextView != null) {
110 | emptyTextView.setVisibility(View.GONE);
111 | }
112 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
113 | fabMain.close(true);
114 | if (!pathStack.isEmpty()) {
115 | currentDir = new File(pathStack.pop());
116 | setupData(currentDir);
117 | adapter.notifyDataSetChanged();
118 | textCurrentPath.setText(currentDir.getAbsolutePath());
119 | } else {
120 | getActivity().finish();
121 | }
122 |
123 | return true;
124 | }
125 | }
126 | return false;
127 | }
128 | });
129 | }
130 |
131 | public void setupData(File f) {
132 |
133 | File[] dirs = f.listFiles();
134 |
135 | try {
136 | for (File ff : dirs) {
137 | Date lastModDate = new Date(ff.lastModified());
138 | DateFormat formater = DateFormat.getDateInstance();
139 | String date_modify = formater.format(lastModDate);
140 | if (ff.isDirectory()) {
141 | File[] dirFls = ff.listFiles();
142 | int buf = 0;
143 | if (dirFls != null) {
144 | buf = dirFls.length;
145 | } else buf = 0;
146 | String num_item = String.valueOf(buf);
147 | if (buf == 1)
148 | num_item = num_item + " item";
149 | else
150 | num_item = num_item + " items";
151 | dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
152 | } else {
153 | fileName = ff.getName();
154 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
155 | if (fileName.equals("jpg") || fileName.equals("png") || fileName.equals("bmp"))
156 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "image_icon"));
157 | else
158 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "file_icon"));
159 | }
160 |
161 |
162 | }
163 | } catch (Exception e) {
164 | }
165 | Collections.sort(dir);
166 | Collections.sort(fls);
167 | dir.addAll(fls);
168 | if (dir.isEmpty()) {
169 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.empty_folder, Snackbar.LENGTH_SHORT);
170 | snackbar.show();
171 | emptyTextView.setText(getString(R.string.empty_folder));
172 | emptyTextView.setTextSize(20);
173 | emptyTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
174 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
175 | params.gravity = Gravity.CENTER;
176 | emptyTextView.setLayoutParams(params);
177 | emptyTextView.setVisibility(View.VISIBLE);
178 | } else if (emptyTextView.isShown())
179 | emptyTextView.setVisibility(View.GONE);
180 | setupAdapter();
181 |
182 | }
183 |
184 | private String getFileSize(long size) {
185 |
186 | if (size <= 0) return "0" + " Byte";
187 | final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
188 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
189 | return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
190 |
191 |
192 | }
193 |
194 | private void setupAdapter() {
195 | exceptionLaunched = false;
196 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, dir);
197 |
198 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
199 | @Override
200 | public void onFileClick(String newPath) {
201 | scrollPosition = ((LinearLayoutManager) recyclerViewDownloads.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
202 | File fileToOpen;
203 | if (currentDir != null) {
204 | tmpPathBuff = currentDir.getAbsolutePath();
205 | }
206 | fileToOpen = new File(newPath);
207 | if (!fileToOpen.isDirectory()) {
208 | /**
209 | * If file isn't a directory, here is decided the intent to be used based on Mime Type from extension
210 | */
211 | try {
212 | fileName = fileToOpen.getName();
213 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
214 |
215 | Intent intent = new Intent();
216 | intent.setAction(Intent.ACTION_VIEW);
217 | Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", fileToOpen);
218 | intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName));
219 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
220 | startActivity(intent);
221 | } catch (Exception e) {
222 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.acitivty_not_found, Snackbar.LENGTH_SHORT);
223 | snackbar.show();
224 | exceptionLaunched = true;
225 | }
226 |
227 | } else {
228 | currentDir = new File(newPath);
229 | setupData(currentDir);
230 | adapter.notifyDataSetChanged();
231 | textCurrentPath.setText(currentDir.getAbsolutePath());
232 | }
233 |
234 | if (!exceptionLaunched && fileToOpen.isDirectory())
235 | pathStack.push(tmpPathBuff);
236 |
237 |
238 | }
239 |
240 | @Override
241 | public void onLongFileClick(List
- itemsChecked) {
242 | int i = 0;
243 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
244 | fabMain.close(true);
245 | for (Item it : itemsChecked) {
246 | checkedPaths.add(itemsChecked.get(i).getPath());
247 | i++;
248 | }
249 | ((MainActivity) getActivity()).setOnLongPressPaths(checkedPaths);
250 | FragmentManager fm = getFragmentManager();
251 | DialogLongPress dialog = DialogLongPress.newIstance("Actions", itemsChecked.size() > 1);
252 | dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
253 | dialog.show(fm, "fragment_LongPress");
254 |
255 | }
256 | });
257 | (recyclerViewDownloads.getLayoutManager()).scrollToPosition(scrollPosition);
258 | recyclerViewDownloads.setAdapter(adapter);
259 | }
260 |
261 |
262 | public File getCurrentDir() {
263 | return currentDir;
264 | }
265 | }
266 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/MusicDrawerFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.graphics.Typeface;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.os.Environment;
9 | import android.preference.PreferenceManager;
10 | import android.support.design.widget.Snackbar;
11 | import android.support.v4.app.DialogFragment;
12 | import android.support.v4.app.Fragment;
13 | import android.support.v4.app.FragmentManager;
14 | import android.support.v4.content.FileProvider;
15 | import android.support.v7.widget.DefaultItemAnimator;
16 | import android.support.v7.widget.LinearLayoutManager;
17 | import android.support.v7.widget.RecyclerView;
18 | import android.view.Gravity;
19 | import android.view.KeyEvent;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.webkit.MimeTypeMap;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | import com.github.clans.fab.FloatingActionMenu;
28 |
29 | import java.io.File;
30 | import java.text.DateFormat;
31 | import java.text.DecimalFormat;
32 | import java.util.ArrayList;
33 | import java.util.Collections;
34 | import java.util.Date;
35 | import java.util.List;
36 | import java.util.Stack;
37 |
38 | /**
39 | * Created by Cosimo Sguanci on 13/09/2016.
40 | */
41 | public class MusicDrawerFragment extends Fragment {
42 | private static final int VERTICAL_ITEM_SPACE = 48;
43 | private static LinearLayout parentLayout;
44 | private RecyclerView recyclerViewMusic;
45 | private File currentDir;
46 | private final Stack pathStack = new Stack<>();
47 | private final List
- dir = new ArrayList<>();
48 | private final List
- fls = new ArrayList<>();
49 | private FileAdapter adapter;
50 | private String fileName = null;
51 | private TextView textCurrentPath;
52 | private TextView emptyTextView;
53 | private String tmpPathBuff;
54 | private boolean exceptionLaunched = false;
55 | private final List checkedPaths = new ArrayList<>();
56 | private int scrollPosition;
57 | private String defaultFolderName;
58 |
59 | public static MusicDrawerFragment newIstance() {
60 | return new MusicDrawerFragment();
61 |
62 | }
63 |
64 | @Override
65 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
66 |
67 | return inflater.inflate(R.layout.fragment_main, parent, false);
68 | }
69 |
70 |
71 | @Override
72 | public void onViewCreated(View view, Bundle savedInstanceState) {
73 | SharedPreferences defaultFolder= PreferenceManager.getDefaultSharedPreferences(getActivity());
74 | emptyTextView = new TextView(getContext());
75 | parentLayout = (LinearLayout) getActivity().findViewById(R.id.rootView);
76 | emptyTextView.setVisibility(View.VISIBLE);
77 | parentLayout.addView(emptyTextView);
78 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
79 | fabMain.setVisibility(View.VISIBLE);
80 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
81 | recyclerViewMusic = (RecyclerView) getView().findViewById(R.id.recycler_view);
82 | if(!(defaultFolderName=defaultFolder.getString("music_preference","")).equals("")){
83 | currentDir=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+defaultFolderName);
84 | }
85 | else
86 | currentDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC); // Setting current directory to Music default directory
87 | textCurrentPath.setText(currentDir.getAbsolutePath());
88 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
89 | recyclerViewMusic.setLayoutManager(mLayoutManager);
90 | recyclerViewMusic.setItemAnimator(new DefaultItemAnimator());
91 | recyclerViewMusic.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
92 | recyclerViewMusic.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
93 | setupData(currentDir);
94 | setupAdapter();
95 |
96 |
97 | }
98 |
99 | @Override
100 | public void onActivityCreated(Bundle savedInstanceState) {
101 | super.onActivityCreated(savedInstanceState);
102 | getView().setFocusableInTouchMode(true);
103 | getView().requestFocus();
104 |
105 | getView().setOnKeyListener(new View.OnKeyListener() {
106 | @Override
107 | public boolean onKey(View v, int keyCode, KeyEvent event) {
108 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
109 | if (keyCode == KeyEvent.KEYCODE_BACK) {
110 | if (emptyTextView != null) {
111 | emptyTextView.setVisibility(View.GONE);
112 | }
113 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
114 | fabMain.close(true);
115 | if (!pathStack.isEmpty()) {
116 | currentDir = new File(pathStack.pop());
117 | setupData(currentDir);
118 | adapter.notifyDataSetChanged();
119 | textCurrentPath.setText(currentDir.getAbsolutePath());
120 | } else {
121 | getActivity().finish();
122 | }
123 |
124 | return true;
125 | }
126 | }
127 | return false;
128 | }
129 | });
130 | }
131 |
132 | public void setupData(File f) {
133 |
134 | File[] dirs = f.listFiles();
135 |
136 | try {
137 | for (File ff : dirs) {
138 | Date lastModDate = new Date(ff.lastModified());
139 | DateFormat formater = DateFormat.getDateInstance();
140 | String date_modify = formater.format(lastModDate);
141 | if (ff.isDirectory()) {
142 | File[] dirFls = ff.listFiles();
143 | int buf = 0;
144 | if (dirFls != null) {
145 | buf = dirFls.length;
146 | } else buf = 0;
147 | String num_item = String.valueOf(buf);
148 | if (buf == 1)
149 | num_item = num_item + " item";
150 | else
151 | num_item = num_item + " items";
152 | dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
153 | } else {
154 | fileName = ff.getName();
155 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
156 | if (fileName.equals("jpg") || fileName.equals("png") || fileName.equals("bmp"))
157 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "image_icon"));
158 | else if (fileName.equals("mp3") || fileName.equals("flac"))
159 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "music_icon"));
160 | else
161 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "file_icon"));
162 | }
163 |
164 |
165 | }
166 | } catch (Exception e) {
167 | e.printStackTrace();
168 | }
169 | Collections.sort(dir);
170 | Collections.sort(fls);
171 | dir.addAll(fls);
172 | if (dir.isEmpty()) {
173 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.empty_folder, Snackbar.LENGTH_SHORT);
174 | snackbar.show();
175 | emptyTextView.setText(getString(R.string.empty_folder));
176 | emptyTextView.setTextSize(20);
177 | emptyTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
178 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
179 | params.gravity = Gravity.CENTER;
180 | emptyTextView.setLayoutParams(params);
181 | emptyTextView.setVisibility(View.VISIBLE);
182 | }
183 | else
184 | if(emptyTextView.isShown())
185 | emptyTextView.setVisibility(View.GONE);
186 | setupAdapter();
187 |
188 |
189 | }
190 |
191 | private String getFileSize(long size){
192 |
193 | if(size <= 0) return "0"+" Byte";
194 | final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
195 | int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
196 | return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
197 |
198 |
199 | }
200 |
201 | private void setupAdapter() {
202 | exceptionLaunched = false;
203 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, dir);
204 |
205 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
206 | @Override
207 | public void onFileClick(String newPath) {
208 | scrollPosition = ((LinearLayoutManager)recyclerViewMusic.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
209 | File fileToOpen;
210 | if (currentDir != null) {
211 | tmpPathBuff = currentDir.getAbsolutePath();
212 | }
213 | fileToOpen = new File(newPath);
214 | if (!fileToOpen.isDirectory()) {
215 | /**
216 | * If file isn't a directory, here is decided the intent to be used based on Mime Type from extension
217 | */
218 | try {
219 | fileName = fileToOpen.getName();
220 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
221 |
222 | Intent intent = new Intent();
223 | intent.setAction(Intent.ACTION_VIEW);
224 | Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", fileToOpen);
225 | intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName));
226 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
227 | startActivity(intent);
228 | } catch (Exception e) {
229 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.acitivty_not_found, Snackbar.LENGTH_SHORT);
230 | snackbar.show();
231 | exceptionLaunched = true;
232 | }
233 |
234 | } else {
235 | currentDir=new File(newPath);
236 | setupData(currentDir);
237 | adapter.notifyDataSetChanged();
238 | textCurrentPath.setText(currentDir.getAbsolutePath());
239 | }
240 |
241 | if (!exceptionLaunched && fileToOpen.isDirectory())
242 | pathStack.push(tmpPathBuff);
243 |
244 |
245 | }
246 |
247 | @Override
248 | public void onLongFileClick(List
- itemsChecked) {
249 | int i=0;
250 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
251 | fabMain.close(true);
252 | for(Item it:itemsChecked){
253 | checkedPaths.add(itemsChecked.get(i).getPath());
254 | i++;
255 | }
256 | ((MainActivity) getActivity()).setOnLongPressPaths(checkedPaths);
257 | FragmentManager fm = getFragmentManager();
258 | DialogLongPress dialog = DialogLongPress.newIstance("Actions",itemsChecked.size()>1);
259 | dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
260 | dialog.show(fm, "fragment_LongPress");
261 |
262 | }
263 | });
264 | (recyclerViewMusic.getLayoutManager()).scrollToPosition(scrollPosition);
265 | recyclerViewMusic.setAdapter(adapter);
266 | }
267 |
268 | public File getCurrentDir() {
269 | return currentDir;
270 | }
271 | }
272 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/ImagesDrawerFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.graphics.Typeface;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.os.Environment;
9 | import android.preference.PreferenceManager;
10 | import android.support.design.widget.Snackbar;
11 | import android.support.v4.app.DialogFragment;
12 | import android.support.v4.app.Fragment;
13 | import android.support.v4.app.FragmentManager;
14 | import android.support.v4.content.FileProvider;
15 | import android.support.v7.widget.DefaultItemAnimator;
16 | import android.support.v7.widget.LinearLayoutManager;
17 | import android.support.v7.widget.RecyclerView;
18 | import android.view.Gravity;
19 | import android.view.KeyEvent;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.webkit.MimeTypeMap;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | import com.github.clans.fab.FloatingActionMenu;
28 |
29 | import java.io.File;
30 | import java.text.DateFormat;
31 | import java.text.DecimalFormat;
32 | import java.util.ArrayList;
33 | import java.util.Collections;
34 | import java.util.Date;
35 | import java.util.List;
36 | import java.util.Stack;
37 |
38 | /**
39 | * Created by Cosimo Sguanci on 12/09/2016.
40 | */
41 | public class ImagesDrawerFragment extends Fragment {
42 | private static final int VERTICAL_ITEM_SPACE = 48;
43 | private static LinearLayout parentLayout;
44 | private RecyclerView recyclerViewImages;
45 | private File currentDir;
46 | private final Stack pathStack = new Stack<>();
47 | private final List
- dir = new ArrayList<>();
48 | private final List
- fls = new ArrayList<>();
49 | private FileAdapter adapter;
50 | private String fileName = null;
51 | private TextView textCurrentPath;
52 | private TextView emptyTextView;
53 | private String tmpPathBuff;
54 | private boolean exceptionLaunched = false;
55 | private final List checkedPaths = new ArrayList<>();
56 | private int scrollPosition;
57 | private String defaultFolderName;
58 |
59 | public static ImagesDrawerFragment newIstance() {
60 | return new ImagesDrawerFragment();
61 | }
62 |
63 | @Override
64 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
65 |
66 | return inflater.inflate(R.layout.fragment_main, parent, false);
67 | }
68 |
69 | @Override
70 | public void onViewCreated(View view, Bundle savedInstanceState) {
71 |
72 | SharedPreferences defaultFolder = PreferenceManager.getDefaultSharedPreferences(getActivity());
73 | emptyTextView = new TextView(getContext());
74 | parentLayout = (LinearLayout) getActivity().findViewById(R.id.rootView);
75 | emptyTextView.setVisibility(View.VISIBLE);
76 | parentLayout.addView(emptyTextView);
77 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
78 | fabMain.setVisibility(View.VISIBLE);
79 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
80 | recyclerViewImages = (RecyclerView) getView().findViewById(R.id.recycler_view);
81 | if(!(defaultFolderName=defaultFolder.getString("images_preference","")).equals("")){
82 | currentDir=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+defaultFolderName);
83 | }
84 | else
85 | currentDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); // Setting current directory to Pictures default directory
86 | textCurrentPath.setText(currentDir.getAbsolutePath());
87 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
88 | recyclerViewImages.setLayoutManager(mLayoutManager);
89 | recyclerViewImages.setItemAnimator(new DefaultItemAnimator());
90 | recyclerViewImages.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
91 | recyclerViewImages.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
92 | setupData(currentDir);
93 | setupAdapter();
94 |
95 |
96 | }
97 |
98 | @Override
99 | public void onActivityCreated(Bundle savedInstanceState) {
100 | super.onActivityCreated(savedInstanceState);
101 | getView().setFocusableInTouchMode(true);
102 | getView().requestFocus();
103 | getView().setOnKeyListener(new View.OnKeyListener() {
104 | @Override
105 | public boolean onKey(View v, int keyCode, KeyEvent event) {
106 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
107 | if (keyCode == KeyEvent.KEYCODE_BACK) {
108 | if (emptyTextView != null) {
109 | emptyTextView.setVisibility(View.GONE);
110 | }
111 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
112 | fabMain.close(true);
113 | if (!pathStack.isEmpty()) {
114 | currentDir = new File(pathStack.pop());
115 | setupData(currentDir);
116 | adapter.notifyDataSetChanged();
117 | textCurrentPath.setText(currentDir.getAbsolutePath());
118 | } else {
119 | getActivity().finish();
120 | }
121 |
122 | return true;
123 | }
124 | }
125 | return false;
126 | }
127 | });
128 | }
129 |
130 | public void setupData(File f) {
131 | File[] dirs = f.listFiles();
132 |
133 | try {
134 | for (File ff : dirs) {
135 | Date lastModDate = new Date(ff.lastModified());
136 | DateFormat formater = DateFormat.getDateInstance();
137 | String date_modify = formater.format(lastModDate);
138 | if (ff.isDirectory()) {
139 | File[] dirFls = ff.listFiles();
140 | int buf = 0;
141 | if (dirFls != null) {
142 | buf = dirFls.length;
143 | } else buf = 0;
144 | String num_item = String.valueOf(buf);
145 | if (buf == 1)
146 | num_item = num_item + " item";
147 | else
148 | num_item = num_item + " items";
149 | dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
150 | } else {
151 | fileName = ff.getName();
152 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
153 | if (fileName.equals("jpg") || fileName.equals("png") || fileName.equals("bmp"))
154 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "image_icon"));
155 |
156 | else if (fileName.equals("mp3") || fileName.equals("flac"))
157 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "music_icon"));
158 |
159 | else
160 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "file_icon"));
161 | }
162 |
163 |
164 | }
165 | } catch (Exception e) {
166 | e.printStackTrace();
167 | }
168 | Collections.sort(dir);
169 | Collections.sort(fls);
170 | dir.addAll(fls);
171 | if (dir.isEmpty()) {
172 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.empty_folder, Snackbar.LENGTH_SHORT);
173 | snackbar.show();
174 | emptyTextView.setText(getString(R.string.empty_folder));
175 | emptyTextView.setTextSize(20);
176 | emptyTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
177 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
178 | params.gravity = Gravity.CENTER;
179 | emptyTextView.setLayoutParams(params);
180 | emptyTextView.setVisibility(View.VISIBLE);
181 | } else if (emptyTextView.isShown())
182 | emptyTextView.setVisibility(View.GONE);
183 | setupAdapter();
184 |
185 |
186 | }
187 |
188 | private String getFileSize(long size) {
189 |
190 | if (size <= 0) return "0" + " Byte";
191 | final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
192 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
193 | return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
194 |
195 |
196 | }
197 |
198 | private void setupAdapter() {
199 | exceptionLaunched = false;
200 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, dir);
201 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
202 | @Override
203 | public void onFileClick(String newPath) {
204 | scrollPosition = ((LinearLayoutManager) recyclerViewImages.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
205 | File fileToOpen;
206 | if (currentDir != null) {
207 | tmpPathBuff = currentDir.getAbsolutePath();
208 | }
209 | fileToOpen = new File(newPath);
210 | if (!fileToOpen.isDirectory()) {
211 | /**
212 | * If file isn't a directory, here is decided the intent to be used based on Mime Type from extension
213 | */
214 | try {
215 | fileName = fileToOpen.getName();
216 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
217 |
218 | Intent intent = new Intent();
219 | intent.setAction(Intent.ACTION_VIEW);
220 | Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", fileToOpen);
221 | intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName));
222 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
223 | startActivity(intent);
224 | } catch (Exception e) {
225 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.acitivty_not_found, Snackbar.LENGTH_SHORT);
226 | snackbar.show();
227 | exceptionLaunched = true;
228 | }
229 |
230 | } else {
231 | currentDir = new File(newPath);
232 | setupData(currentDir);
233 | adapter.notifyDataSetChanged();
234 | textCurrentPath.setText(currentDir.getAbsolutePath());
235 | }
236 |
237 | if (!exceptionLaunched && fileToOpen.isDirectory())
238 | pathStack.push(tmpPathBuff);
239 |
240 |
241 | }
242 |
243 | @Override
244 | public void onLongFileClick(List
- itemsChecked) {
245 | int i = 0;
246 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
247 | fabMain.close(true);
248 | for (Item it : itemsChecked) {
249 | checkedPaths.add(itemsChecked.get(i).getPath());
250 | i++;
251 | }
252 | ((MainActivity) getActivity()).setOnLongPressPaths(checkedPaths);
253 | FragmentManager fm = getFragmentManager();
254 | DialogLongPress dialog = DialogLongPress.newIstance("Actions", itemsChecked.size() > 1);
255 | dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
256 | dialog.show(fm, "fragment_LongPress");
257 |
258 | }
259 | });
260 | (recyclerViewImages.getLayoutManager()).scrollToPosition(scrollPosition);
261 | recyclerViewImages.setAdapter(adapter);
262 | }
263 |
264 | public File getCurrentDir() {
265 | return currentDir;
266 | }
267 |
268 |
269 | }
270 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/MainFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Typeface;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.os.Environment;
8 | import android.support.design.widget.Snackbar;
9 | import android.support.v4.app.DialogFragment;
10 | import android.support.v4.app.Fragment;
11 | import android.support.v4.app.FragmentManager;
12 | import android.support.v4.content.ContextCompat;
13 | import android.support.v4.content.FileProvider;
14 | import android.support.v7.widget.DefaultItemAnimator;
15 | import android.support.v7.widget.LinearLayoutManager;
16 | import android.support.v7.widget.RecyclerView;
17 | import android.util.Log;
18 | import android.view.Gravity;
19 | import android.view.KeyEvent;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.webkit.MimeTypeMap;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | import com.github.clans.fab.FloatingActionMenu;
28 |
29 | import java.io.File;
30 | import java.text.DateFormat;
31 | import java.text.DecimalFormat;
32 | import java.util.ArrayList;
33 | import java.util.Collections;
34 | import java.util.Date;
35 | import java.util.List;
36 | import java.util.Stack;
37 |
38 | /**
39 | * Created by Cosimo Sguanci on 08/09/2016.
40 | */
41 | public class MainFragment extends Fragment {
42 | private static final int VERTICAL_ITEM_SPACE = 48;
43 | private static LinearLayout parentLayout;
44 | private final List
- dir = new ArrayList<>();
45 | private final List
- fls = new ArrayList<>();
46 | private String fileName = null;
47 | private File currentDir;
48 | private FileAdapter adapter;
49 | private RecyclerView recyclerView;
50 | private final Stack pathStack = new Stack<>(); // Stack that contains the navigation history
51 | private TextView textCurrentPath; // String used to display the current path visited
52 | private File[] filesDirs;
53 | private TextView emptyTextView;
54 | private String tmpPathBuff; // String to keep the previous path before pushing it on the stack
55 | private boolean exceptionLaunched = false; // String to check if ActivityNotFoundException has been launched
56 | private boolean hasExternalSD = false;
57 | private final List checkedPaths = new ArrayList<>();
58 | private int scrollPosition;
59 |
60 |
61 | public static MainFragment newIstance() {
62 | return new MainFragment();
63 | }
64 |
65 |
66 | @Override
67 | public void onActivityCreated(Bundle savedInstanceState) {
68 | super.onActivityCreated(savedInstanceState);
69 | getView().setFocusableInTouchMode(true);
70 | getView().requestFocus();
71 | /**
72 | * When the back button is pressed, the previous directory is shown
73 | */
74 | getView().setOnKeyListener(new View.OnKeyListener() {
75 | @Override
76 | public boolean onKey(View v, int keyCode, KeyEvent event) {
77 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
78 | if (keyCode == KeyEvent.KEYCODE_BACK) {
79 | if (emptyTextView != null) {
80 | emptyTextView.setVisibility(View.GONE);
81 | }
82 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
83 | fabMain.close(true);
84 | if (!pathStack.isEmpty()) {
85 | currentDir = new File(pathStack.pop());
86 | setupData(currentDir);
87 | adapter.notifyDataSetChanged();
88 | textCurrentPath.setText(currentDir.getAbsolutePath());
89 | } else {
90 | /**
91 | * Should handle the case hasRemovableSD==true, and return to the initial choose bewteen the SDs
92 | */
93 | getActivity().finish();
94 | }
95 | return true;
96 | }
97 | }
98 | return false;
99 | }
100 | });
101 |
102 |
103 | }
104 |
105 | @Override
106 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
107 | Bundle savedInstanceState) {
108 |
109 | return inflater.inflate(R.layout.fragment_main, container, false);
110 | }
111 |
112 | @Override
113 | public void onViewCreated(View view, Bundle savedInstanceState) {
114 |
115 | ((MainActivity) getActivity()).setCurrentFragment("First");
116 | emptyTextView = new TextView(getContext());
117 | parentLayout = (LinearLayout) getActivity().findViewById(R.id.rootView);
118 | emptyTextView.setVisibility(View.VISIBLE);
119 | parentLayout.addView(emptyTextView);
120 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
121 | fabMain.setVisibility(View.VISIBLE);
122 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
123 | recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
124 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
125 | recyclerView.setLayoutManager(mLayoutManager);
126 | recyclerView.setItemAnimator(new DefaultItemAnimator());
127 | recyclerView.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
128 | recyclerView.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
129 | // Should Hide FAB on Scroll of RecyclerView?
130 | filesDirs = ContextCompat.getExternalFilesDirs(getContext(), null);
131 | /**
132 | * Checking if there is removable sd card available
133 | */
134 | if (filesDirs.length > 1) {
135 | hasExternalSD = true;
136 | textCurrentPath.setVisibility(View.GONE);
137 | fabMain.setVisibility(View.GONE);
138 | setupMultipleStorage(filesDirs);
139 | } else {
140 |
141 | currentDir = Environment.getExternalStorageDirectory(); // Getting root directory (internal storage)
142 | textCurrentPath.setText(currentDir.getAbsolutePath());
143 | setupData(currentDir);
144 | }
145 |
146 | }
147 |
148 | /**
149 | * Method that creates the ArrayList that has to be passed to the adapter to populate the RecyclerView
150 | *
151 | * @param f
152 | */
153 | public void setupData(File f) {
154 | textCurrentPath.setVisibility(View.VISIBLE);
155 | getActivity().findViewById(R.id.fabMain).setVisibility(View.VISIBLE);
156 | File[] dirs = f.listFiles();
157 | try {
158 | for (File ff : dirs) {
159 | Date lastModDate = new Date(ff.lastModified());
160 | DateFormat formater = DateFormat.getDateInstance();
161 | String date_modify = formater.format(lastModDate);
162 | if (ff.isDirectory()) {
163 | File[] dirFls = ff.listFiles();
164 | int buf;
165 | if (dirFls != null) {
166 | buf = dirFls.length;
167 | } else buf = 0;
168 | String num_item = String.valueOf(buf);
169 | if (buf == 1)
170 | num_item = num_item + " item";
171 | else
172 | num_item = num_item + " items";
173 | dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
174 | } else {
175 | fileName = ff.getName();
176 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
177 |
178 | /**
179 | * Checking the file extension to decide the icon to set
180 | */
181 |
182 | if (fileName.equals("jpg") || fileName.equals("png") || fileName.equals("bmp"))
183 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "image_icon"));
184 |
185 | else if (fileName.equals("mp3") || fileName.equals("flac"))
186 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "music_icon"));
187 |
188 | else
189 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "file_icon"));
190 |
191 | }
192 |
193 | }
194 | } catch (Exception e) {
195 | e.printStackTrace();
196 | }
197 | Collections.sort(dir);
198 | Collections.sort(fls);
199 | dir.addAll(fls);
200 | if (dir.isEmpty()) {
201 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.empty_folder, Snackbar.LENGTH_SHORT);
202 | snackbar.show();
203 | emptyTextView.setText(getString(R.string.empty_folder));
204 | emptyTextView.setTextSize(20);
205 | emptyTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
206 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
207 | params.gravity = Gravity.CENTER;
208 | emptyTextView.setLayoutParams(params);
209 | emptyTextView.setVisibility(View.VISIBLE);
210 | } else if (emptyTextView.isShown())
211 | emptyTextView.setVisibility(View.GONE);
212 |
213 | setupAdapter();
214 |
215 | }
216 |
217 | private String getFileSize(long size) {
218 |
219 | if (size <= 0) return "0" + " Byte";
220 | final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
221 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
222 | return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
223 |
224 |
225 | }
226 |
227 |
228 | private void setupMultipleStorage(File[] roots) {
229 | String[] rootPaths = new String[2];
230 | int i = 0;
231 | for (File f : roots) {
232 | if (f != null) {
233 | String path = f.getAbsolutePath();
234 | int indexMountRoot = path.indexOf("/Android/data/");
235 | if (indexMountRoot >= 0 && indexMountRoot <= path.length()) {
236 | //Get the root path for the external directory
237 | rootPaths[i] = path.substring(0, indexMountRoot);
238 | }
239 | i++;
240 | }
241 | }
242 | dir.add(new Item(getString(R.string.internal_storage), "", "", rootPaths[0], "directory_icon"));
243 | if (rootPaths[1] != null)
244 | dir.add(new Item(getString(R.string.removable_sd), "", "", rootPaths[1], "directory_icon"));
245 | setupAdapter();
246 | }
247 |
248 |
249 | private void setupAdapter() {
250 |
251 | exceptionLaunched = false;
252 |
253 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, dir, hasExternalSD);
254 |
255 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
256 | /**
257 | * Recycler View item clicked
258 | * @param newPath
259 | */
260 | @Override
261 | public void onFileClick(String newPath) {
262 | scrollPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
263 | /** Variable that is needed if there's a removable sd to add the path to the history folder stack only when the user has chosen the storage.*/
264 | boolean hadSDbefore = false;
265 | File fileToOpen;
266 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
267 | fabMain.close(true);
268 | if (currentDir != null && hasExternalSD == false) {
269 | /**
270 | * tmpPathBuff is used to push the path in pathStack
271 | * ONLY if ActivityNotFound isn't launched. Otherwise,
272 | * when back is pressed the first time, it would remain
273 | * in the same folder.
274 | */
275 | tmpPathBuff = currentDir.getAbsolutePath();
276 | }
277 | fileToOpen = new File(newPath);
278 |
279 | if (!fileToOpen.isDirectory()) {
280 | /**
281 | * If file isn't a directory, here is decided the intent to be used based on Mime Type from extension
282 | */
283 | try {
284 | fileName = fileToOpen.getName();
285 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
286 | Intent intent = new Intent();
287 | intent.setAction(Intent.ACTION_VIEW);
288 | Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", fileToOpen);
289 | intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName));
290 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
291 | startActivity(intent);
292 | } catch (Exception e) {
293 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.acitivty_not_found, Snackbar.LENGTH_SHORT);
294 | snackbar.show();
295 | exceptionLaunched = true;
296 | }
297 |
298 |
299 | } else {
300 | currentDir = new File(newPath);
301 | hadSDbefore = hasExternalSD;
302 | if (pathStack.isEmpty() && hasExternalSD)
303 | hasExternalSD = false;
304 | setupData(currentDir);
305 | adapter.notifyDataSetChanged();
306 | textCurrentPath.setText(currentDir.getAbsolutePath());
307 | }
308 |
309 | if (!exceptionLaunched && hadSDbefore == false && fileToOpen.isDirectory())
310 | pathStack.push(tmpPathBuff);
311 | else if (hasExternalSD)
312 | hasExternalSD = false;
313 |
314 | }
315 |
316 | /**
317 | * Recycler View item long clicked, Multiple Actions fragment gets created
318 | * @param itemsChecked
319 | */
320 | @Override
321 | public void onLongFileClick(List
- itemsChecked) {
322 | if (!hasExternalSD) {
323 | int i = 0;
324 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
325 | fabMain.close(true);
326 | for (Item it : itemsChecked) {
327 | checkedPaths.add(itemsChecked.get(i).getPath());
328 | Log.w("ItemsChecked", ": " + itemsChecked.get(i).getName());
329 | i++;
330 | }
331 | ((MainActivity) getActivity()).setOnLongPressPaths(checkedPaths);
332 | FragmentManager fm = getFragmentManager();
333 | DialogLongPress dialog = DialogLongPress.newIstance("Actions", itemsChecked.size() > 1);
334 | dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
335 | dialog.show(fm, "fragment_LongPress");
336 | }
337 | }
338 | });
339 | (recyclerView.getLayoutManager()).scrollToPosition(scrollPosition);
340 | recyclerView.setAdapter(adapter);
341 | }
342 |
343 |
344 | public File getCurrentDir() {
345 | return currentDir;
346 | }
347 |
348 |
349 | }
350 |
--------------------------------------------------------------------------------
/app/src/main/java/app/android/com/materialfilemanager/SearchResultsFragment.java:
--------------------------------------------------------------------------------
1 | package app.android.com.materialfilemanager;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Intent;
6 | import android.graphics.Typeface;
7 | import android.net.Uri;
8 | import android.os.AsyncTask;
9 | import android.os.Bundle;
10 | import android.os.Environment;
11 | import android.support.design.widget.Snackbar;
12 | import android.support.v4.app.DialogFragment;
13 | import android.support.v4.app.Fragment;
14 | import android.support.v4.app.FragmentManager;
15 | import android.support.v4.app.FragmentTransaction;
16 | import android.support.v4.content.FileProvider;
17 | import android.support.v7.widget.DefaultItemAnimator;
18 | import android.support.v7.widget.LinearLayoutManager;
19 | import android.support.v7.widget.RecyclerView;
20 | import android.view.Gravity;
21 | import android.view.KeyEvent;
22 | import android.view.LayoutInflater;
23 | import android.view.View;
24 | import android.view.ViewGroup;
25 | import android.webkit.MimeTypeMap;
26 | import android.widget.LinearLayout;
27 | import android.widget.TextView;
28 |
29 | import com.github.clans.fab.FloatingActionMenu;
30 |
31 | import java.io.File;
32 | import java.text.DateFormat;
33 | import java.text.DecimalFormat;
34 | import java.util.ArrayList;
35 | import java.util.Collections;
36 | import java.util.Date;
37 | import java.util.List;
38 | import java.util.Stack;
39 |
40 | /**
41 | * Created by shind on 16/10/2016.
42 | */
43 |
44 | public class SearchResultsFragment extends Fragment {
45 | private final static String TAG_FRAGMENT = "TAG_FRAGMENT";
46 | private static final int VERTICAL_ITEM_SPACE = 48;
47 | private static LinearLayout parentLayout;
48 | private RecyclerView recyclerView;
49 | private TextView textCurrentPath; // String used to display the current path visited
50 | private String searchName;
51 | private TextView noResultsTextView;
52 | private TextView emptyTextView;
53 | private final List
- results = new ArrayList<>();
54 | private File currentDir = null;
55 | private FileAdapter adapter;
56 | private String tmpPathBuff;
57 | private boolean exceptionLaunched = false;
58 | private final Stack pathStack = new Stack<>();
59 | private final List
- fls = new ArrayList<>();
60 | private final List checkedPaths = new ArrayList<>();
61 |
62 |
63 | public static SearchResultsFragment newIstance() {
64 | return new SearchResultsFragment();
65 | }
66 |
67 |
68 | @Override
69 | public void onActivityCreated(Bundle savedInstanceState) {
70 | super.onActivityCreated(savedInstanceState);
71 | getView().setFocusableInTouchMode(true);
72 | getView().requestFocus();
73 | /**
74 | * When the back button is pressed, SHOULD show the previous directory.
75 | */
76 | getView().setOnKeyListener(new View.OnKeyListener() {
77 | @Override
78 | public boolean onKey(View v, int keyCode, KeyEvent event) {
79 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
80 | if (keyCode == KeyEvent.KEYCODE_BACK) {
81 |
82 | ((MainActivity) getActivity()).setFalseOnSearchItem();
83 | FragmentManager fragmentManager = getFragmentManager();
84 | FragmentTransaction ft = fragmentManager.beginTransaction().replace(R.id.fragmentContainer, MainFragment.newIstance(), TAG_FRAGMENT);
85 | ft.commit();
86 |
87 | return true;
88 | }
89 | }
90 | return false;
91 | }
92 | });
93 |
94 |
95 | }
96 |
97 | @Override
98 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
99 | Bundle savedInstanceState) {
100 |
101 | return inflater.inflate(R.layout.fragment_main, container, false);
102 | }
103 |
104 | @Override
105 | public void onViewCreated(View view, Bundle savedInstanceState) {
106 | emptyTextView = new TextView(getContext());
107 | parentLayout = (LinearLayout) getActivity().findViewById(R.id.rootView);
108 | emptyTextView.setVisibility(View.VISIBLE);
109 | parentLayout.addView(emptyTextView);
110 | textCurrentPath = (TextView) getView().findViewWithTag("textViewCurrentDir");
111 | textCurrentPath.setVisibility(View.GONE);
112 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
113 | fabMain.setVisibility(View.GONE);
114 | recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
115 | RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
116 | recyclerView.setLayoutManager(mLayoutManager);
117 | recyclerView.setItemAnimator(new DefaultItemAnimator());
118 | recyclerView.addItemDecoration(new VerticalSpaceRecycler(VERTICAL_ITEM_SPACE));
119 | recyclerView.addItemDecoration(new DividerItemRecycler(getActivity(), R.drawable.divider));
120 | searchName = ((MainActivity) getActivity()).getSearchName();
121 | new SetupSearchResults(recyclerView, Environment.getExternalStorageDirectory().listFiles(), searchName).execute(); // Get an error: No adapter attached; skipping layout
122 |
123 |
124 | }
125 |
126 | public void deleteItemFromArrayResults(List paths) {
127 | for (String path : paths) {
128 | int i = 0;
129 | while (!path.equals(results.get(i).getPath())) {
130 | i++;
131 | }
132 | results.remove(i);
133 | }
134 |
135 | setupAdapter();
136 |
137 | }
138 |
139 | public void nameChanged(String previousName, String newName) {
140 | int i = 0;
141 | while (!previousName.equals(results.get(i).getName())) {
142 | i++;
143 | }
144 | results.get(i).setName(newName);
145 | setupAdapter();
146 | }
147 |
148 | private void setupAdapter() {
149 | exceptionLaunched = false;
150 | adapter = new FileAdapter(getContext(), R.layout.recycler_row, results);
151 | adapter.setOnFileClickedListener(new FileAdapter.onFileClickedListener() {
152 | /**
153 | * Recycler View item clicked
154 | * @param newPath
155 | */
156 | @Override
157 | public void onFileClick(String newPath) {
158 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
159 | fabMain.close(true);
160 | if (currentDir != null) {
161 | tmpPathBuff = currentDir.getAbsolutePath();
162 | }
163 | currentDir = new File(newPath);
164 | if (!currentDir.isDirectory()) {
165 | /**
166 | * If file isn't a directory, here is decided the intent to be used based on Mime Type from extension
167 | */
168 | try {
169 | String fileName = currentDir.getName();
170 | fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
171 | Intent intent = new Intent();
172 | intent.setAction(Intent.ACTION_VIEW);
173 | Uri uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", currentDir);
174 | intent.setDataAndType(uri, MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName));
175 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
176 | startActivity(intent);
177 | } catch (ActivityNotFoundException e) {
178 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.acitivty_not_found, Snackbar.LENGTH_SHORT);
179 | snackbar.show();
180 | exceptionLaunched = true;
181 | }
182 |
183 | } else {
184 | setupData(currentDir);
185 | adapter.notifyDataSetChanged();
186 | textCurrentPath.setText(currentDir.getAbsolutePath());
187 | }
188 | if (!exceptionLaunched)
189 | pathStack.push(tmpPathBuff);
190 |
191 |
192 | }
193 |
194 | /**
195 | * Recycler View item long clicked, Multiple Actions fragment launched
196 | * @param itemsChecked
197 | */
198 | @Override
199 | public void onLongFileClick(List
- itemsChecked) {
200 | int i = 0;
201 | FloatingActionMenu fabMain = (FloatingActionMenu) getActivity().findViewById(R.id.fabMain);
202 | fabMain.close(true);
203 | for (Item it : itemsChecked) {
204 | checkedPaths.add(itemsChecked.get(i).getPath());
205 | i++;
206 | }
207 | ((MainActivity) getActivity()).setOnLongPressPaths(checkedPaths);
208 | FragmentManager fm = getFragmentManager();
209 | DialogLongPress dialog = DialogLongPress.newIstance("Actions", itemsChecked.size() > 1);
210 | dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
211 | dialog.show(fm, "fragment_LongPress");
212 |
213 | }
214 | });
215 |
216 | recyclerView.setAdapter(adapter);
217 | }
218 |
219 | /**
220 | * Method that creates the ArrayList that has to be passed to the adapter to populate the RecyclerView
221 | * This is necessary in the AsyncTask too, to open the folders found by the search Algorithm.
222 | *
223 | * @param f
224 | */
225 | public void setupData(File f) {
226 | textCurrentPath.setVisibility(View.VISIBLE);
227 | File[] dirs = f.listFiles();
228 | try {
229 | for (File ff : dirs) {
230 | Date lastModDate = new Date(ff.lastModified());
231 | DateFormat formater = DateFormat.getDateInstance();
232 | String date_modify = formater.format(lastModDate);
233 | if (ff.isDirectory()) {
234 | File[] dirFls = ff.listFiles();
235 | int buf;
236 | if (dirFls != null) {
237 | buf = dirFls.length;
238 | } else buf = 0;
239 | String num_item = String.valueOf(buf);
240 | if (buf == 1)
241 | num_item = num_item + " item";
242 | else
243 | num_item = num_item + " items";
244 | results.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "directory_icon"));
245 | } else {
246 | String extension = ff.getName().substring(ff.getName().lastIndexOf('.') + 1);
247 |
248 | /**
249 | * Checking the file extension to decide the icon to set
250 | */
251 |
252 | if (extension.equals("jpg") || extension.equals("png") || extension.equals("bmp"))
253 | fls.add(new Item(ff.getName(), getFileSize(ff.length()) + " Byte", date_modify, ff.getAbsolutePath(), "image_icon"));
254 |
255 | else if (extension.equals("mp3") || extension.equals("flac"))
256 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "music_icon"));
257 |
258 | else
259 | fls.add(new Item(ff.getName(), getFileSize(ff.length()), date_modify, ff.getAbsolutePath(), "file_icon"));
260 |
261 | }
262 |
263 | }
264 | } catch (Exception e) {
265 | e.printStackTrace();
266 | }
267 | Collections.sort(results);
268 | Collections.sort(fls);
269 | results.addAll(fls);
270 | if (results.isEmpty()) {
271 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.empty_folder, Snackbar.LENGTH_SHORT);
272 | snackbar.show();
273 | emptyTextView.setText(getString(R.string.empty_folder));
274 | emptyTextView.setTextSize(20);
275 | emptyTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
276 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
277 | params.gravity = Gravity.CENTER;
278 | emptyTextView.setLayoutParams(params);
279 | emptyTextView.setVisibility(View.VISIBLE);
280 | } else if (emptyTextView.isShown())
281 | emptyTextView.setVisibility(View.GONE);
282 |
283 | setupAdapter();
284 |
285 | }
286 |
287 | private String getFileSize(long size) {
288 |
289 | if (size <= 0) return "0" + " Byte";
290 | final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
291 | int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
292 | return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
293 |
294 |
295 | }
296 |
297 |
298 | /**
299 | * AsyncTask used to load asynchronously the results of the User research of file.
300 | */
301 | class SetupSearchResults extends AsyncTask> {
302 |
303 | private File[] files;
304 | private String searchName;
305 | private ProgressDialog progress;
306 |
307 | public SetupSearchResults(RecyclerView recyclerView_passed, File[] files, String searchName) {
308 | recyclerView = recyclerView_passed;
309 | this.files = files;
310 | this.searchName = searchName;
311 | progress = new ProgressDialog(getActivity());
312 | }
313 |
314 | protected void onPreExecute() {
315 | super.onPreExecute();
316 | progress.setTitle("");
317 | progress.setMessage("Searching...");
318 | progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
319 | progress.show();
320 |
321 | }
322 |
323 | protected List
- doInBackground(Void... params) {
324 | return setupSearchResults(searchName, files);
325 |
326 | }
327 |
328 | protected void onPostExecute(List
- results) {
329 | if (results.isEmpty()) {
330 | Snackbar snackbar = Snackbar.make(parentLayout, R.string.no_results, Snackbar.LENGTH_LONG);
331 | snackbar.show();
332 | noResultsTextView = new TextView(getContext());
333 | noResultsTextView.setText(getString(R.string.no_results));
334 | noResultsTextView.setTextSize(20);
335 | noResultsTextView.setTypeface(Typeface.create("sans-serif-medium", Typeface.ITALIC));
336 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
337 | params.gravity = Gravity.CENTER;
338 | noResultsTextView.setLayoutParams(params);
339 | parentLayout.addView(noResultsTextView);
340 |
341 | }
342 | setupAdapter();
343 | progress.dismiss();
344 |
345 | }
346 |
347 | /**
348 | * Recursive method for the file search
349 | *
350 | * @param searchName -the name of the file that has to be found.
351 | * @param files -the list of directory's files.
352 | * @return results -ArrayList that contained the Items that correspond to the name searched.
353 | */
354 | private List
- setupSearchResults(String searchName, File[] files) {
355 | for (File f : files) {
356 | if (f.getName().contains(searchName) || f.getName().contains(searchName.toLowerCase()) || f.getName().contains(searchName.toUpperCase())) {
357 | Date lastModDate = new Date(f.lastModified());
358 | DateFormat formater = DateFormat.getDateInstance();
359 | String date_modify = formater.format(lastModDate);
360 | if (f.isDirectory()) {
361 | File[] dirFls = f.listFiles();
362 | int buf;
363 | if (dirFls != null) {
364 | buf = dirFls.length;
365 | } else buf = 0;
366 | String num_item = String.valueOf(buf);
367 | if (buf == 1)
368 | num_item = num_item + " item";
369 | else
370 | num_item = num_item + " items";
371 | results.add(new Item(f.getName(), num_item, date_modify, f.getAbsolutePath(), "directory_icon"));
372 | } else {
373 | String extension = f.getName().substring(f.getName().lastIndexOf('.') + 1);
374 |
375 | /**
376 | * Checking the file extension to decide the icon to set
377 | */
378 |
379 | if (extension.equals("jpg") || extension.equals("png") || extension.equals("bmp"))
380 | results.add(new Item(f.getName(), getFileSize(f.length()), date_modify, f.getAbsolutePath(), "image_icon"));
381 |
382 | else if (extension.equals("mp3") || extension.equals("flac"))
383 | results.add(new Item(f.getName(), getFileSize(f.length()), date_modify, f.getAbsolutePath(), "music_icon"));
384 |
385 | else
386 | results.add(new Item(f.getName(), getFileSize(f.length()), date_modify, f.getAbsolutePath(), "file_icon"));
387 |
388 | }
389 |
390 | }
391 | if (f.isDirectory()) {
392 | /**
393 | * Recursion only if ff (the file examinated) is a directory.
394 | */
395 | setupSearchResults(searchName, f.listFiles());
396 | }
397 |
398 | }
399 | return results;
400 |
401 | }
402 |
403 |
404 | }
405 | }
406 |
--------------------------------------------------------------------------------