├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── FileBrowserView.iml ├── README.md ├── app └── demo-app.iml ├── build.gradle ├── demo-app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── psaravan │ │ └── filebrowserview │ │ └── demo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── psaravan │ │ └── filebrowserview │ │ └── demo │ │ ├── DialogFragment │ │ └── DialogFragment.java │ │ ├── GridActivity │ │ └── GridActivity.java │ │ ├── ListActivity │ │ └── ListActivity.java │ │ ├── MainActivity │ │ └── MainActivity.java │ │ └── TabbedBrowsingActivity │ │ └── TabbedListActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ ├── activity_file_browser_view.xml │ └── activity_main.xml │ ├── menu │ └── main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── array.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── library.iml ├── libs │ └── commons-io-2.4.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── psaravan │ │ └── filebrowserview │ │ └── lib │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── psaravan │ │ └── filebrowserview │ │ └── lib │ │ ├── AsyncTasks │ │ ├── AsyncCopyTask.java │ │ ├── AsyncDeleteTask.java │ │ └── AsyncMoveTask.java │ │ ├── FileBrowserEngine │ │ ├── AdapterData.java │ │ ├── FileBrowserEngine.java │ │ └── FileExtensionFilter.java │ │ ├── GridLayout │ │ ├── GridLayoutAdapter.java │ │ └── GridLayoutView.java │ │ ├── Interfaces │ │ ├── CopyInterface.java │ │ ├── DeleteInterface.java │ │ ├── MoveInterface.java │ │ └── NavigationInterface.java │ │ ├── ListLayout │ │ ├── ListLayoutAdapter.java │ │ └── ListLayoutView.java │ │ ├── Utils │ │ └── Utils.java │ │ └── View │ │ ├── AbstractFileBrowserAdapter.java │ │ ├── BaseLayoutView.java │ │ ├── FileBrowserView.java │ │ └── TabsContainer.java │ └── res │ ├── drawable-hdpi │ ├── ic_action_new.png │ ├── ic_action_new_light.png │ ├── ic_action_overflow.png │ ├── ic_action_overflow_light.png │ ├── ic_action_overflow_universal.png │ ├── ic_launcher.png │ ├── icon_apk.png │ ├── icon_archive.png │ ├── icon_avi.png │ ├── icon_default.png │ ├── icon_folderblue.png │ ├── icon_html.png │ ├── icon_js.png │ ├── icon_mp3.png │ ├── icon_png.png │ ├── icon_spreadsheet.png │ └── icon_text.png │ ├── drawable-mdpi │ ├── ic_action_new.png │ ├── ic_action_new_light.png │ ├── ic_action_overflow.png │ ├── ic_action_overflow_light.png │ ├── ic_action_overflow_universal.png │ ├── ic_launcher.png │ ├── icon_apk.png │ ├── icon_archive.png │ ├── icon_avi.png │ ├── icon_default.png │ ├── icon_folderblue.png │ ├── icon_html.png │ ├── icon_js.png │ ├── icon_mp3.png │ ├── icon_png.png │ ├── icon_spreadsheet.png │ └── icon_text.png │ ├── drawable-xhdpi │ ├── ic_action_new.png │ ├── ic_action_new_light.png │ ├── ic_action_overflow.png │ ├── ic_action_overflow_light.png │ ├── ic_action_overflow_universal.png │ ├── ic_launcher.png │ ├── icon_apk.png │ ├── icon_archive.png │ ├── icon_avi.png │ ├── icon_default.png │ ├── icon_folderblue.png │ ├── icon_html.png │ ├── icon_js.png │ ├── icon_mp3.png │ ├── icon_png.png │ ├── icon_spreadsheet.png │ └── icon_text.png │ ├── drawable-xxhdpi │ ├── ic_action_new.png │ ├── ic_action_new_light.png │ ├── ic_action_overflow.png │ ├── ic_action_overflow_light.png │ ├── ic_action_overflow_universal.png │ ├── ic_launcher.png │ ├── icon_apk.png │ ├── icon_archive.png │ ├── icon_avi.png │ ├── icon_default.png │ ├── icon_folderblue.png │ ├── icon_html.png │ ├── icon_js.png │ ├── icon_mp3.png │ ├── icon_png.png │ ├── icon_spreadsheet.png │ └── icon_text.png │ ├── drawable │ ├── empty_color_patch.xml │ ├── empty_color_patch_circular.xml │ ├── empty_color_patch_circular_light.xml │ └── empty_color_patch_light.xml │ ├── layout │ ├── grid_view_item.xml │ ├── list_view_item.xml │ ├── simple_grid_file_browser.xml │ ├── simple_list_file_browser.xml │ └── tabbed_browser_container.xml │ ├── menu │ └── filesystem_ops_menu.xml │ └── values │ ├── dimens.xml │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | FileBrowserView -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FileBrowserView.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FileBrowserView 2 | ================ 3 | 4 | FileBrowserView is a powerful Android view library for file/folder browsing. Check out this page for complete details, including screenshots, examples, and in-depth tutorials: 5 | 6 | http://psaravan.github.io/FileBrowserView/ 7 | 8 | 9 | 10 | Developed By 11 | ============ 12 | 13 | Saravan Pantham - saravan.pantham@gmail.com 14 | 15 | License 16 | ======== 17 | 18 | Copyright 2014 - Saravan Pantham 19 | 20 | Licensed under the Apache License, Version 2.0 (the "License"); 21 | you may not use this file except in compliance with the License. 22 | You may obtain a copy of the License at 23 | 24 | http://www.apache.org/licenses/LICENSE-2.0 25 | 26 | Unless required by applicable law or agreed to in writing, software 27 | distributed under the License is distributed on an "AS IS" BASIS, 28 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | See the License for the specific language governing permissions and 30 | limitations under the License. 31 | -------------------------------------------------------------------------------- /app/demo-app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.12.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demo-app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo-app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion '20.0.0' 6 | defaultConfig { 7 | applicationId 'com.psaravan.filebrowserview.demo' 8 | minSdkVersion 14 9 | targetSdkVersion 20 10 | versionCode 1 11 | versionName '1.0' 12 | } 13 | buildTypes { 14 | release { 15 | runProguard false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | productFlavors { 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(include: ['*.jar'], dir: 'libs') 25 | compile 'com.android.support:appcompat-v7:20.0.0' 26 | compile project(':library') 27 | } 28 | -------------------------------------------------------------------------------- /demo-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:/Program Files (x86)/Android/android-studio/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 | -------------------------------------------------------------------------------- /demo-app/src/androidTest/java/com/psaravan/filebrowserview/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.psaravan.filebrowserview.demo; 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 | } -------------------------------------------------------------------------------- /demo-app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 31 | 32 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /demo-app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/demo-app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /demo-app/src/main/java/com/psaravan/filebrowserview/demo/DialogFragment/DialogFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.demo.DialogFragment; 17 | 18 | import android.content.Context; 19 | import android.os.Bundle; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | 24 | import com.psaravan.filebrowserview.demo.R; 25 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 26 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 27 | 28 | import java.io.File; 29 | 30 | /** 31 | * Example implementation for a List representation of the view. 32 | * 33 | * @author Saravan Pantham 34 | */ 35 | public class DialogFragment extends android.app.DialogFragment { 36 | 37 | //Context. 38 | private Context mContext; 39 | 40 | //FileBrowserView reference. 41 | private FileBrowserView mFileBrowserView; 42 | 43 | @Override 44 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 45 | View view = inflater.inflate(R.layout.activity_file_browser_view, container); 46 | mFileBrowserView = (FileBrowserView) view.findViewById(R.id.fileBrowserView); 47 | 48 | //Customize the view. 49 | mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_LIST_LAYOUT) //Set the type of view to use. 50 | .setDefaultDirectory(new File("/")) //Set the default directory to show. 51 | .setShowHiddenFiles(true) //Set whether or not you want to show hidden files. 52 | .showItemSizes(true) //Shows the sizes of each item in the list. 53 | .showOverflowMenus(true) //Shows the overflow menus for each item in the list. 54 | .showItemIcons(true) //Shows the icons next to each item name in the list. 55 | .setNavigationInterface(navInterface) //Sets the nav interface instance for this view. 56 | .init(); //Loads the view. You MUST call this method, or the view will not be displayed. 57 | 58 | return view; 59 | } 60 | 61 | /** 62 | * Navigation interface for the view. Used to capture events such as a new 63 | * directory being loaded, files being opened, etc. For our purposes here, 64 | * we'll be using the onNewDirLoaded() method to update the ActionBar's title 65 | * with the current directory's path. 66 | */ 67 | private NavigationInterface navInterface = new NavigationInterface() { 68 | 69 | @Override 70 | public void onNewDirLoaded(File dirFile) { 71 | //Update the action bar title. 72 | getDialog().setTitle(dirFile.getAbsolutePath()); 73 | } 74 | 75 | @Override 76 | public void onFileOpened(File file) { 77 | 78 | } 79 | 80 | @Override 81 | public void onParentDirLoaded(File dirFile) { 82 | 83 | } 84 | 85 | @Override 86 | public void onFileFolderOpenFailed(File file) { 87 | 88 | } 89 | 90 | }; 91 | 92 | } 93 | -------------------------------------------------------------------------------- /demo-app/src/main/java/com/psaravan/filebrowserview/demo/GridActivity/GridActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.demo.GridActivity; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | 22 | import com.psaravan.filebrowserview.demo.R; 23 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 24 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 25 | 26 | import java.io.File; 27 | 28 | /** 29 | * Example implementation for a grid representation of the view. 30 | * 31 | * @author Saravan Pantham 32 | */ 33 | public class GridActivity extends Activity { 34 | 35 | //Context. 36 | private Context mContext; 37 | 38 | //FileBrowserView reference. 39 | private FileBrowserView mFileBrowserView; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_file_browser_view); 45 | mContext = this.getApplicationContext(); 46 | 47 | //Grab a reference handle on the view, just like you'd do with any other view. 48 | mFileBrowserView = (FileBrowserView) findViewById(R.id.fileBrowserView); 49 | 50 | //Customize the view. 51 | mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_GRID_LAYOUT) //Set the type of view to use. 52 | .setDefaultDirectory(new File("/")) //Set the default directory to show. 53 | .setShowHiddenFiles(true) //Set whether or not you want to show hidden files. 54 | .showItemSizes(true) //Shows the sizes of each item in the list. 55 | .showOverflowMenus(true) //Shows the overflow menus for each item in the list. 56 | .showItemIcons(true) //Shows the icons next to each item name in the list. 57 | .setNavigationInterface(navInterface) //Sets the nav interface instance for this view. 58 | .init(); //Loads the view. You MUST call this method, or the view will not be displayed. 59 | 60 | } 61 | 62 | /** 63 | * Navigation interface for the view. Used to capture events such as a new 64 | * directory being loaded, files being opened, etc. For our purposes here, 65 | * we'll be using the onNewDirLoaded() method to update the ActionBar's title 66 | * with the current directory's path. 67 | */ 68 | private NavigationInterface navInterface = new NavigationInterface() { 69 | 70 | @Override 71 | public void onNewDirLoaded(File dirFile) { 72 | //Update the action bar title. 73 | getActionBar().setTitle(dirFile.getAbsolutePath()); 74 | } 75 | 76 | @Override 77 | public void onFileOpened(File file) { 78 | 79 | } 80 | 81 | @Override 82 | public void onParentDirLoaded(File dirFile) { 83 | 84 | } 85 | 86 | @Override 87 | public void onFileFolderOpenFailed(File file) { 88 | 89 | } 90 | 91 | }; 92 | 93 | @Override 94 | public void onBackPressed() { 95 | if (mFileBrowserView!=null) { 96 | File parentDir = mFileBrowserView.getParentDir(); 97 | 98 | if (parentDir!=null) { 99 | mFileBrowserView.getFileBrowserEngine().loadDir(parentDir); 100 | } else { 101 | super.onBackPressed(); 102 | } 103 | 104 | } 105 | 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /demo-app/src/main/java/com/psaravan/filebrowserview/demo/ListActivity/ListActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.demo.ListActivity; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | 22 | import com.psaravan.filebrowserview.demo.R; 23 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 24 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 25 | 26 | import java.io.File; 27 | 28 | /** 29 | * Example implementation for a List representation of the view. 30 | * 31 | * @author Saravan Pantham 32 | */ 33 | public class ListActivity extends Activity { 34 | 35 | //Context. 36 | private Context mContext; 37 | 38 | //FileBrowserView reference. 39 | private FileBrowserView mFileBrowserView; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_file_browser_view); 45 | mContext = this.getApplicationContext(); 46 | 47 | //Grab a reference handle on the view, just like you'd do with any other view. 48 | mFileBrowserView = (FileBrowserView) findViewById(R.id.fileBrowserView); 49 | 50 | //Customize the view. 51 | mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_LIST_LAYOUT) //Set the type of view to use. 52 | .setDefaultDirectory(new File("/")) //Set the default directory to show. 53 | .setShowHiddenFiles(true) //Set whether or not you want to show hidden files. 54 | .showItemSizes(true) //Shows the sizes of each item in the list. 55 | .showOverflowMenus(true) //Shows the overflow menus for each item in the list. 56 | .showItemIcons(true) //Shows the icons next to each item name in the list. 57 | .setNavigationInterface(navInterface) //Sets the nav interface instance for this view. 58 | .init(); //Loads the view. You MUST call this method, or the view will not be displayed. 59 | 60 | } 61 | 62 | /** 63 | * Navigation interface for the view. Used to capture events such as a new 64 | * directory being loaded, files being opened, etc. For our purposes here, 65 | * we'll be using the onNewDirLoaded() method to update the ActionBar's title 66 | * with the current directory's path. 67 | */ 68 | private NavigationInterface navInterface = new NavigationInterface() { 69 | 70 | @Override 71 | public void onNewDirLoaded(File dirFile) { 72 | //Update the action bar title. 73 | getActionBar().setTitle(dirFile.getAbsolutePath()); 74 | } 75 | 76 | @Override 77 | public void onFileOpened(File file) { 78 | 79 | } 80 | 81 | @Override 82 | public void onParentDirLoaded(File dirFile) { 83 | 84 | } 85 | 86 | @Override 87 | public void onFileFolderOpenFailed(File file) { 88 | 89 | } 90 | 91 | }; 92 | 93 | @Override 94 | public void onBackPressed() { 95 | if (mFileBrowserView!=null) { 96 | File parentDir = mFileBrowserView.getParentDir(); 97 | 98 | if (parentDir!=null) { 99 | mFileBrowserView.getFileBrowserEngine().loadDir(parentDir); 100 | } else { 101 | super.onBackPressed(); 102 | } 103 | 104 | } 105 | 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /demo-app/src/main/java/com/psaravan/filebrowserview/demo/MainActivity/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.demo.MainActivity; 17 | 18 | import android.app.FragmentManager; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.os.Bundle; 22 | import android.support.v7.app.ActionBarActivity; 23 | import android.view.View; 24 | import android.widget.AdapterView; 25 | import android.widget.ArrayAdapter; 26 | import android.widget.ListView; 27 | 28 | import com.psaravan.filebrowserview.demo.DialogFragment.DialogFragment; 29 | import com.psaravan.filebrowserview.demo.GridActivity.GridActivity; 30 | import com.psaravan.filebrowserview.demo.ListActivity.ListActivity; 31 | import com.psaravan.filebrowserview.demo.R; 32 | import com.psaravan.filebrowserview.demo.TabbedBrowsingActivity.TabbedListActivity; 33 | 34 | /** 35 | * Launcher class that displays all the options and FileBrowserView samples. 36 | * 37 | * @author Saravan Pantham 38 | */ 39 | public class MainActivity extends ActionBarActivity { 40 | 41 | //Context. 42 | private Context mContext; 43 | 44 | //ListView reference. 45 | private ListView mListView; 46 | 47 | @Override 48 | protected void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | setContentView(R.layout.activity_main); 51 | mContext = this.getApplicationContext(); 52 | 53 | mListView = (ListView) findViewById(R.id.mainActivityListView); 54 | String[] adapterData = mContext.getResources().getStringArray(R.array.mainActivityList); 55 | ArrayAdapter adapter = new ArrayAdapter(mContext, 56 | android.R.layout.simple_expandable_list_item_1, 57 | adapterData); 58 | 59 | mListView.setAdapter(adapter); 60 | mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 61 | 62 | @Override 63 | public void onItemClick(AdapterView parent, View view, int position, long id) { 64 | Intent intent = null; 65 | switch (position) { 66 | case 0: 67 | intent = new Intent(mContext, ListActivity.class); 68 | startActivity(intent); 69 | break; 70 | case 1: 71 | intent = new Intent(mContext, GridActivity.class); 72 | startActivity(intent); 73 | break; 74 | case 2: 75 | FragmentManager fragmentManager = getFragmentManager(); 76 | DialogFragment fragment = new DialogFragment(); 77 | fragment.show(fragmentManager, "dialogFragment"); 78 | break; 79 | case 3: 80 | intent = new Intent(mContext, TabbedListActivity.class); 81 | startActivity(intent); 82 | break; 83 | } 84 | 85 | } 86 | 87 | }); 88 | 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /demo-app/src/main/java/com/psaravan/filebrowserview/demo/TabbedBrowsingActivity/TabbedListActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.demo.TabbedBrowsingActivity; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | import android.os.Environment; 22 | 23 | import com.psaravan.filebrowserview.demo.R; 24 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 25 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 26 | 27 | import java.io.File; 28 | 29 | /** 30 | * Example implementation for a tabbed, List representation of the view. 31 | * 32 | * @author Saravan Pantham 33 | */ 34 | public class TabbedListActivity extends Activity { 35 | 36 | //Context. 37 | private Context mContext; 38 | 39 | //FileBrowserView reference. 40 | private FileBrowserView mFileBrowserView; 41 | 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_file_browser_view); 46 | mContext = this.getApplicationContext(); 47 | 48 | //Grab a reference handle on the view, just like you'd do with any other view. 49 | mFileBrowserView = (FileBrowserView) findViewById(R.id.fileBrowserView); 50 | 51 | //Customize the view. 52 | mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_LIST_LAYOUT) //Set the type of view to use. 53 | .setDefaultDirectory(Environment.getExternalStorageDirectory()) //Set the default directory to show. 54 | .setShowHiddenFiles(true) //Set whether or not you want to show hidden files. 55 | .showItemSizes(true) //Shows the sizes of each item in the list. 56 | .showOverflowMenus(true) //Shows the overflow menus for each item in the list. 57 | .showItemIcons(true) //Shows the icons next to each item name in the list. 58 | .setNavigationInterface(navInterface) //Sets the nav interface instance for this view. 59 | .enableTabbedBrowsing(true) //Enable tabbed browsing. 60 | .init(); //Loads the view. You MUST call this method, or the view will not be displayed. 61 | 62 | } 63 | 64 | /** 65 | * Navigation interface for the view. Used to capture events such as a new 66 | * directory being loaded, files being opened, etc. For our purposes here, 67 | * we'll be using the onNewDirLoaded() method to update the ActionBar's title 68 | * with the current directory's path. 69 | */ 70 | private NavigationInterface navInterface = new NavigationInterface() { 71 | 72 | @Override 73 | public void onNewDirLoaded(File dirFile) { 74 | //Update the action bar title. 75 | getActionBar().setTitle(dirFile.getAbsolutePath()); 76 | } 77 | 78 | @Override 79 | public void onFileOpened(File file) { 80 | 81 | } 82 | 83 | @Override 84 | public void onParentDirLoaded(File dirFile) { 85 | 86 | } 87 | 88 | @Override 89 | public void onFileFolderOpenFailed(File file) { 90 | 91 | } 92 | 93 | }; 94 | 95 | } 96 | -------------------------------------------------------------------------------- /demo-app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/demo-app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo-app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/demo-app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo-app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/demo-app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo-app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/demo-app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo-app/src/main/res/layout/activity_file_browser_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /demo-app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo-app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /demo-app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /demo-app/src/main/res/values/array.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Simple List 5 | Simple Grid 6 | Dialog Fragment 7 | Tabbed Browsing 8 | Custom Header View 9 | 10 | 11 | -------------------------------------------------------------------------------- /demo-app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /demo-app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FileBrowserView Demo 5 | Hello world! 6 | Settings 7 | Simple List 8 | Simple Grid 9 | Dialog Fragment 10 | Tabs 11 | Custom Header View 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo-app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip 7 | -------------------------------------------------------------------------------- /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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion '20.0.0' 6 | defaultConfig { 7 | applicationId 'com.psaravan.filebrowserview.lib' 8 | minSdkVersion 14 9 | targetSdkVersion 20 10 | versionCode 1 11 | versionName '1.0' 12 | } 13 | buildTypes { 14 | release { 15 | runProguard false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | productFlavors { 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(include: ['*.jar'], dir: 'libs') 25 | compile 'com.android.support:appcompat-v7:20.0.0' 26 | compile files('libs/commons-io-2.4.jar') 27 | } 28 | -------------------------------------------------------------------------------- /library/library.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /library/libs/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/libs/commons-io-2.4.jar -------------------------------------------------------------------------------- /library/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:/Program Files (x86)/Android/android-studio/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 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/psaravan/filebrowserview/lib/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.psaravan.filebrowserview.lib; 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 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/AsyncTasks/AsyncCopyTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.AsyncTasks; 17 | 18 | import android.app.ProgressDialog; 19 | import android.content.Context; 20 | import android.content.DialogInterface; 21 | import android.content.DialogInterface.OnClickListener; 22 | import android.os.AsyncTask; 23 | import android.widget.Toast; 24 | 25 | import com.psaravan.filebrowserview.lib.Interfaces.CopyInterface; 26 | import com.psaravan.filebrowserview.lib.R; 27 | 28 | import org.apache.commons.io.FileUtils; 29 | 30 | import java.io.File; 31 | 32 | /** 33 | * AsyncTask that copies the specified file/folder recursively to a new location. 34 | * 35 | * @author Saravan Pantham 36 | */ 37 | public class AsyncCopyTask extends AsyncTask { 38 | 39 | private Context mContext; 40 | private ProgressDialog pd; 41 | private File mSourceFile; 42 | private File mDestDirFile; 43 | private boolean mShowProgress = true; 44 | private CopyInterface mCopyInterface; 45 | 46 | 47 | public AsyncCopyTask(Context context, File source, File destDir, boolean showProgress) { 48 | mContext = context; 49 | mSourceFile = source; 50 | mShowProgress = showProgress; 51 | mDestDirFile = destDir; 52 | 53 | } 54 | 55 | @Override 56 | protected void onPreExecute() { 57 | 58 | if (mSourceFile==null) 59 | return; 60 | 61 | //Skip the rest of this method if the user doesn't want a progress dialog. 62 | if (!mShowProgress) 63 | return; 64 | 65 | pd = new ProgressDialog(mContext); 66 | pd.setCancelable(false); 67 | pd.setIndeterminate(false); 68 | pd.setTitle(R.string.copy); 69 | pd.setMessage(mContext.getResources().getString(R.string.copying) + " " + mSourceFile.getName()); 70 | pd.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getResources() 71 | .getString(R.string.run_in_background), 72 | new OnClickListener() { 73 | 74 | @Override 75 | public void onClick(DialogInterface arg0, int arg1) { 76 | pd.dismiss(); 77 | 78 | } 79 | 80 | }); 81 | 82 | pd.show(); 83 | 84 | if (mCopyInterface!=null) 85 | mCopyInterface.preCopyStartSync(); 86 | 87 | } 88 | 89 | @Override 90 | protected Boolean doInBackground(String... params) { 91 | 92 | if (mCopyInterface!=null) 93 | mCopyInterface.preCopyStartAsync(); 94 | 95 | if (mSourceFile==null || mDestDirFile==null) { 96 | if (mCopyInterface!=null) 97 | mCopyInterface.onCopyCompleteAsync(false); 98 | 99 | return false; 100 | } 101 | 102 | if (mSourceFile.isDirectory()) { 103 | try { 104 | FileUtils.copyDirectory(mSourceFile, mDestDirFile); 105 | } catch (Exception e) { 106 | if (mCopyInterface!=null) 107 | mCopyInterface.onCopyCompleteAsync(false); 108 | 109 | return false; 110 | } 111 | 112 | } else { 113 | try { 114 | FileUtils.copyFile(mSourceFile, mDestDirFile); 115 | } catch (Exception e) { 116 | if (mCopyInterface!=null) 117 | mCopyInterface.onCopyCompleteAsync(false); 118 | 119 | return false; 120 | } 121 | 122 | } 123 | 124 | if (mCopyInterface!=null) 125 | mCopyInterface.onCopyCompleteAsync(true); 126 | 127 | return true; 128 | } 129 | 130 | @Override 131 | protected void onPostExecute(Boolean result) { 132 | super.onPostExecute(result); 133 | 134 | if (mCopyInterface!=null) 135 | mCopyInterface.onCopyCompleteSync(result); 136 | 137 | if (pd!=null) 138 | pd.dismiss(); 139 | 140 | if (result==true) { 141 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.copied); 142 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 143 | 144 | } else { 145 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.could_not_be_copied); 146 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 147 | 148 | } 149 | 150 | } 151 | 152 | /** 153 | * @param copyInterface The copy interface instance to attach to 154 | * this AsyncTask. 155 | */ 156 | public void setCopyInterface(CopyInterface copyInterface) { 157 | mCopyInterface = copyInterface; 158 | } 159 | 160 | } -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/AsyncTasks/AsyncDeleteTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.AsyncTasks; 17 | 18 | import android.app.ProgressDialog; 19 | import android.content.Context; 20 | import android.content.DialogInterface; 21 | import android.content.DialogInterface.OnClickListener; 22 | import android.os.AsyncTask; 23 | import android.widget.Toast; 24 | 25 | import com.psaravan.filebrowserview.lib.Interfaces.DeleteInterface; 26 | import com.psaravan.filebrowserview.lib.R; 27 | 28 | import org.apache.commons.io.FileUtils; 29 | 30 | import java.io.File; 31 | 32 | /** 33 | * AsyncTask that deletes the specified file/folder recursively. 34 | * 35 | * @author Saravan Pantham 36 | */ 37 | public class AsyncDeleteTask extends AsyncTask { 38 | 39 | private Context mContext; 40 | private ProgressDialog pd; 41 | private File mSourceFile; 42 | private boolean mShowProgress = true; 43 | private DeleteInterface mDeleteInterface; 44 | 45 | public AsyncDeleteTask(Context context, File source, boolean showProgress) { 46 | mContext = context; 47 | mSourceFile = source; 48 | mShowProgress = showProgress; 49 | 50 | } 51 | 52 | protected void onPreExecute() { 53 | 54 | if (mSourceFile==null) 55 | return; 56 | 57 | //Skip the rest of this method if the user doesn't want a progress dialog. 58 | if (!mShowProgress) 59 | return; 60 | 61 | pd = new ProgressDialog(mContext); 62 | pd.setCancelable(false); 63 | pd.setIndeterminate(false); 64 | pd.setTitle(R.string.delete); 65 | pd.setMessage(mContext.getResources().getString(R.string.deleting) + " " + mSourceFile.getName()); 66 | pd.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getResources() 67 | .getString(R.string.run_in_background), 68 | new OnClickListener() { 69 | 70 | @Override 71 | public void onClick(DialogInterface arg0, int arg1) { 72 | pd.dismiss(); 73 | 74 | } 75 | 76 | }); 77 | 78 | pd.show(); 79 | 80 | if (mDeleteInterface!=null) 81 | mDeleteInterface.preDeleteStartSync(); 82 | 83 | } 84 | 85 | @Override 86 | protected Boolean doInBackground(String... params) { 87 | 88 | if (mDeleteInterface!=null) 89 | mDeleteInterface.preDeleteStartAsync(); 90 | 91 | if (mSourceFile==null) { 92 | if (mDeleteInterface!=null) 93 | mDeleteInterface.onDeleteCompleteAsync(false); 94 | 95 | return false; 96 | } 97 | 98 | if (mSourceFile.isDirectory()) { 99 | try { 100 | FileUtils.deleteDirectory(mSourceFile); 101 | } catch (Exception e) { 102 | if (mDeleteInterface!=null) 103 | mDeleteInterface.onDeleteCompleteAsync(false); 104 | 105 | return false; 106 | } 107 | 108 | } else { 109 | try { 110 | boolean status = mSourceFile.delete(); 111 | if (status==true) { 112 | if (mDeleteInterface!=null) 113 | mDeleteInterface.onDeleteCompleteAsync(true); 114 | 115 | return true; 116 | } else { 117 | if (mDeleteInterface!=null) 118 | mDeleteInterface.onDeleteCompleteAsync(false); 119 | 120 | return false; 121 | } 122 | 123 | } catch (Exception e) { 124 | if (mDeleteInterface!=null) 125 | mDeleteInterface.onDeleteCompleteAsync(false); 126 | 127 | return false; 128 | } 129 | 130 | } 131 | 132 | if (mDeleteInterface!=null) 133 | mDeleteInterface.onDeleteCompleteAsync(true); 134 | 135 | return true; 136 | } 137 | 138 | @Override 139 | protected void onPostExecute(Boolean result) { 140 | super.onPostExecute(result); 141 | 142 | if (mDeleteInterface!=null) 143 | mDeleteInterface.onDeleteCompleteSync(result); 144 | 145 | if (pd!=null) 146 | pd.dismiss(); 147 | 148 | if (result==true) { 149 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.deleted); 150 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 151 | 152 | } else { 153 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.could_not_be_deleted); 154 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 155 | 156 | } 157 | 158 | } 159 | 160 | /** 161 | * @param deleteInterface The delete interface instance to attach to this 162 | * AsyncTask. 163 | */ 164 | public void setDeleteInterface(DeleteInterface deleteInterface) { 165 | mDeleteInterface = deleteInterface; 166 | } 167 | 168 | } -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/AsyncTasks/AsyncMoveTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.AsyncTasks; 17 | 18 | import android.app.ProgressDialog; 19 | import android.content.Context; 20 | import android.content.DialogInterface; 21 | import android.content.DialogInterface.OnClickListener; 22 | import android.os.AsyncTask; 23 | import android.widget.Toast; 24 | 25 | import com.psaravan.filebrowserview.lib.Interfaces.MoveInterface; 26 | import com.psaravan.filebrowserview.lib.R; 27 | 28 | import org.apache.commons.io.FileUtils; 29 | 30 | import java.io.File; 31 | 32 | /** 33 | * AsyncTask that moves the specified file/folder recursively to a new location. 34 | * 35 | * @author Saravan Pantham 36 | */ 37 | public class AsyncMoveTask extends AsyncTask { 38 | 39 | private Context mContext; 40 | private ProgressDialog pd; 41 | private File mSourceFile; 42 | private File mDestDirFile; 43 | private boolean mShowProgress = true; 44 | private MoveInterface mMoveInterface; 45 | 46 | public AsyncMoveTask(Context context, File source, File destDir, boolean showProgress) { 47 | mContext = context; 48 | mSourceFile = source; 49 | mShowProgress = showProgress; 50 | mDestDirFile = destDir; 51 | 52 | } 53 | 54 | @Override 55 | protected void onPreExecute() { 56 | 57 | if (mSourceFile==null) 58 | return; 59 | 60 | //Skip the rest of this method if the user doesn't want a progress dialog. 61 | if (!mShowProgress) 62 | return; 63 | 64 | pd = new ProgressDialog(mContext); 65 | pd.setCancelable(false); 66 | pd.setIndeterminate(false); 67 | pd.setTitle(R.string.move); 68 | pd.setMessage(mContext.getResources().getString(R.string.moving) + " " + mSourceFile.getName()); 69 | pd.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getResources() 70 | .getString(R.string.run_in_background), 71 | new OnClickListener() { 72 | 73 | @Override 74 | public void onClick(DialogInterface arg0, int arg1) { 75 | pd.dismiss(); 76 | 77 | } 78 | 79 | }); 80 | 81 | pd.show(); 82 | 83 | if (mMoveInterface!=null) 84 | mMoveInterface.preMoveStartSync(); 85 | 86 | } 87 | 88 | @Override 89 | protected Boolean doInBackground(String... params) { 90 | 91 | if (mMoveInterface!=null) 92 | mMoveInterface.preMoveStartAsync(); 93 | 94 | if (mSourceFile==null || mDestDirFile==null) { 95 | if (mMoveInterface!=null) 96 | mMoveInterface.onMoveCompleteAsync(false); 97 | 98 | return false; 99 | } 100 | 101 | if (mSourceFile.isDirectory()) { 102 | try { 103 | FileUtils.moveDirectory(mSourceFile, mDestDirFile); 104 | } catch (Exception e) { 105 | if (mMoveInterface!=null) 106 | mMoveInterface.onMoveCompleteAsync(false); 107 | 108 | return false; 109 | } 110 | 111 | } else { 112 | try { 113 | FileUtils.moveFile(mSourceFile, mDestDirFile); 114 | } catch (Exception e) { 115 | if (mMoveInterface!=null) 116 | mMoveInterface.onMoveCompleteAsync(false); 117 | 118 | return false; 119 | } 120 | 121 | } 122 | 123 | if (mMoveInterface!=null) 124 | mMoveInterface.onMoveCompleteAsync(true); 125 | 126 | return true; 127 | } 128 | 129 | @Override 130 | protected void onPostExecute(Boolean result) { 131 | super.onPostExecute(result); 132 | 133 | if (mMoveInterface!=null) 134 | mMoveInterface.onMoveCompleteSync(result); 135 | 136 | if (pd!=null) 137 | pd.dismiss(); 138 | 139 | if (result==true) { 140 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.moved); 141 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 142 | 143 | } else { 144 | String message = mSourceFile.getName() + " " + mContext.getResources().getString(R.string.could_not_be_moved); 145 | Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 146 | 147 | } 148 | 149 | } 150 | 151 | /** 152 | * @param moveInterface The move interface instance to attach to this 153 | * AsyncTask. 154 | */ 155 | public void setMoveInterface(MoveInterface moveInterface) { 156 | mMoveInterface = moveInterface; 157 | } 158 | 159 | } -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/FileBrowserEngine/AdapterData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.FileBrowserEngine; 17 | 18 | import java.util.ArrayList; 19 | 20 | /** 21 | * Container class for the file browser's adapter to use. 22 | * 23 | * @author Saravan Pantham 24 | */ 25 | public class AdapterData { 26 | 27 | private ArrayList mNamesList; 28 | private ArrayList mTypesList; 29 | private ArrayList mPathsList; 30 | private ArrayList mSizesList; 31 | 32 | public AdapterData(ArrayList namesList, ArrayList typesList, 33 | ArrayList pathsList, ArrayList sizesList) { 34 | mNamesList = namesList; 35 | mTypesList = typesList; 36 | mPathsList = pathsList; 37 | mSizesList = sizesList; 38 | 39 | } 40 | 41 | public ArrayList getNamesList() { 42 | return mNamesList; 43 | } 44 | 45 | public void setNamesList(ArrayList namesList) { 46 | mNamesList = namesList; 47 | } 48 | 49 | public ArrayList getTypesList() { 50 | return mTypesList; 51 | } 52 | 53 | public void setTypesList(ArrayList typesList) { 54 | mTypesList = typesList; 55 | } 56 | 57 | public ArrayList getPathsList() { 58 | return mPathsList; 59 | } 60 | 61 | public void setPathsList(ArrayList pathsList) { 62 | mPathsList = pathsList; 63 | } 64 | 65 | public ArrayList getSizesList() { 66 | return mSizesList; 67 | } 68 | 69 | public void setSizesList(ArrayList sizesList) { 70 | mSizesList = sizesList; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/FileBrowserEngine/FileBrowserEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.FileBrowserEngine; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.os.Build; 21 | import android.os.Environment; 22 | 23 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 24 | 25 | import org.apache.commons.io.comparator.NameFileComparator; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | import java.text.DecimalFormat; 30 | import java.util.ArrayList; 31 | import java.util.Arrays; 32 | 33 | /** 34 | * Convenience class that exposes the Android file system and provides a 35 | * way to browse it via {@link com.psaravan.filebrowserview.lib.View.FileBrowserView}. 36 | * 37 | * @author Saravan Pantham 38 | */ 39 | public class FileBrowserEngine { 40 | 41 | //Context. 42 | private Context mContext; 43 | 44 | //Parent FileBrowserView instance. 45 | private FileBrowserView mFileBrowserView; 46 | 47 | //Current dir instance. 48 | private File mCurrentDir; 49 | 50 | //File type constants. 51 | public static final int FILE_AUDIO = 0; 52 | public static final int FILE_VIDEO = 1; 53 | public static final int FILE_PICTURE = 2; 54 | public static final int FILE_GENERIC = 3; 55 | public static final int FOLDER = 4; 56 | 57 | //File size/unit dividers 58 | private final long KILOBYTES = 1024; 59 | private final long MEGABYTES = KILOBYTES * KILOBYTES; 60 | private final long GIGABYTES = MEGABYTES * KILOBYTES; 61 | private final long TERABYTES = GIGABYTES * KILOBYTES; 62 | 63 | public FileBrowserEngine(Context context, FileBrowserView fileBrowserView) { 64 | mContext = context; 65 | mFileBrowserView = fileBrowserView; 66 | } 67 | 68 | /** 69 | * Loads the specified folder. 70 | * 71 | * @param directory The file object to points to the directory to load. 72 | * @return An {@link AdapterData} object that holds the data of the specified directory. 73 | */ 74 | public AdapterData loadDir(File directory) { 75 | 76 | mCurrentDir = directory; 77 | 78 | //Init the directory's data arrays. 79 | ArrayList namesList = new ArrayList(); 80 | ArrayList pathsList = new ArrayList(); 81 | ArrayList typesList = new ArrayList(); 82 | ArrayList sizesList = new ArrayList(); 83 | 84 | //Grab a list of all files/subdirs within the specified directory. 85 | File[] files = directory.listFiles(); 86 | 87 | if (files!=null) { 88 | //Sort the files/subdirs by name. 89 | Arrays.sort(files, NameFileComparator.NAME_INSENSITIVE_COMPARATOR); 90 | 91 | for(int i=0; i < files.length; i++) { 92 | 93 | File file = files[i]; 94 | if ((!file.isHidden() || mFileBrowserView.shouldShowHiddenFiles()) && file.canRead()) { 95 | 96 | if (file.isDirectory() && mFileBrowserView.shouldShowFolders()) { 97 | 98 | /* 99 | * Starting with Android 4.2, /storage/emulated/legacy/... 100 | * is a symlink that points to the actual directory where 101 | * the user's files are stored. We need to detect the 102 | * actual directory's file path here. 103 | */ 104 | String filePath; 105 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) 106 | filePath = getRealFilePath(file.getAbsolutePath()); 107 | else 108 | filePath = file.getAbsolutePath(); 109 | 110 | pathsList.add(filePath); 111 | namesList.add(file.getName()); 112 | File[] listOfFiles = file.listFiles(); 113 | 114 | if (listOfFiles!=null) { 115 | typesList.add(FOLDER); 116 | if (listOfFiles.length==1) { 117 | sizesList.add("" + listOfFiles.length + " item"); 118 | } else { 119 | sizesList.add("" + listOfFiles.length + " items"); 120 | } 121 | 122 | } else { 123 | typesList.add(FOLDER); 124 | sizesList.add("Unknown items"); 125 | } 126 | 127 | } else { 128 | 129 | try { 130 | String path = file.getCanonicalPath(); 131 | 132 | //Check if the file ends with an excluded extension. 133 | String[] splits = path.split("."); 134 | if (mFileBrowserView.getFileExtensionFilter() 135 | .getFilterMap() 136 | .containsKey("." + splits[splits.length-1])) 137 | continue; 138 | 139 | pathsList.add(path); 140 | } catch (IOException e) { 141 | continue; 142 | } 143 | 144 | namesList.add(file.getName()); 145 | String fileName = ""; 146 | try { 147 | fileName = file.getCanonicalPath(); 148 | } catch (IOException e) { 149 | // TODO Auto-generated catch block 150 | e.printStackTrace(); 151 | } 152 | 153 | //Add the file element to typesList based on the file type. 154 | if (getFileExtension(fileName).equalsIgnoreCase("mp3") || 155 | getFileExtension(fileName).equalsIgnoreCase("3gp") || 156 | getFileExtension(fileName).equalsIgnoreCase("mp4") || 157 | getFileExtension(fileName).equalsIgnoreCase("m4a") || 158 | getFileExtension(fileName).equalsIgnoreCase("aac") || 159 | getFileExtension(fileName).equalsIgnoreCase("ts") || 160 | getFileExtension(fileName).equalsIgnoreCase("flac") || 161 | getFileExtension(fileName).equalsIgnoreCase("mid") || 162 | getFileExtension(fileName).equalsIgnoreCase("xmf") || 163 | getFileExtension(fileName).equalsIgnoreCase("mxmf") || 164 | getFileExtension(fileName).equalsIgnoreCase("midi") || 165 | getFileExtension(fileName).equalsIgnoreCase("rtttl") || 166 | getFileExtension(fileName).equalsIgnoreCase("rtx") || 167 | getFileExtension(fileName).equalsIgnoreCase("ota") || 168 | getFileExtension(fileName).equalsIgnoreCase("imy") || 169 | getFileExtension(fileName).equalsIgnoreCase("ogg") || 170 | getFileExtension(fileName).equalsIgnoreCase("mkv") || 171 | getFileExtension(fileName).equalsIgnoreCase("wav")) { 172 | 173 | //The file is an audio file. 174 | typesList.add(FILE_AUDIO); 175 | sizesList.add("" + getFormattedFileSize(file.length())); 176 | 177 | } else if (getFileExtension(fileName).equalsIgnoreCase("jpg") || 178 | getFileExtension(fileName).equalsIgnoreCase("gif") || 179 | getFileExtension(fileName).equalsIgnoreCase("png") || 180 | getFileExtension(fileName).equalsIgnoreCase("bmp") || 181 | getFileExtension(fileName).equalsIgnoreCase("webp")) { 182 | 183 | //The file is a picture file. 184 | typesList.add(FILE_PICTURE); 185 | sizesList.add("" + getFormattedFileSize(file.length())); 186 | 187 | } else if (getFileExtension(fileName).equalsIgnoreCase("3gp") || 188 | getFileExtension(fileName).equalsIgnoreCase("mp4") || 189 | getFileExtension(fileName).equalsIgnoreCase("3gp") || 190 | getFileExtension(fileName).equalsIgnoreCase("ts") || 191 | getFileExtension(fileName).equalsIgnoreCase("webm") || 192 | getFileExtension(fileName).equalsIgnoreCase("mkv")) { 193 | 194 | //The file is a video file. 195 | typesList.add(FILE_VIDEO); 196 | sizesList.add("" + getFormattedFileSize(file.length())); 197 | 198 | } else { 199 | 200 | //We don't have an icon for this file type so give it the generic file flag. 201 | typesList.add(FILE_GENERIC); 202 | sizesList.add("" + getFormattedFileSize(file.length())); 203 | 204 | } 205 | 206 | } 207 | 208 | } 209 | 210 | } 211 | 212 | } 213 | 214 | return new AdapterData(namesList, typesList, pathsList, sizesList); 215 | } 216 | 217 | /** 218 | * Resolves the /storage/emulated/legacy paths to 219 | * their true folder path representations. Required 220 | * for Nexii and other devices with no SD card. 221 | * 222 | * @return The true, resolved file path to the input path. 223 | */ 224 | @SuppressLint("SdCardPath") 225 | private String getRealFilePath(String filePath) { 226 | 227 | if (filePath.equals("/storage/emulated/0") || 228 | filePath.equals("/storage/emulated/0/") || 229 | filePath.equals("/storage/emulated/legacy") || 230 | filePath.equals("/storage/emulated/legacy/") || 231 | filePath.equals("/storage/sdcard0") || 232 | filePath.equals("/storage/sdcard0/") || 233 | filePath.equals("/sdcard") || 234 | filePath.equals("/sdcard/") || 235 | filePath.equals("/mnt/sdcard") || 236 | filePath.equals("/mnt/sdcard/")) { 237 | 238 | return Environment.getExternalStorageDirectory().toString(); 239 | } 240 | 241 | return filePath; 242 | } 243 | 244 | /** 245 | * Resolves the file extension for the specified file. 246 | * 247 | * @param fileName The name of the file (including its extension). 248 | * @return The extension of the file (excluding the dot "."). 249 | */ 250 | private String getFileExtension(String fileName) { 251 | String fileNameArray[] = fileName.split("\\."); 252 | String extension = fileNameArray[fileNameArray.length-1]; 253 | 254 | return extension; 255 | } 256 | 257 | /** 258 | * Formats the input value in terms of file size. 259 | * 260 | * @param value The value to convert to a file size. 261 | * @return The formatted size of the input file. 262 | */ 263 | private String getFormattedFileSize(final long value) { 264 | 265 | final long[] dividers = new long[] { TERABYTES, GIGABYTES, MEGABYTES, KILOBYTES, 1 }; 266 | final String[] units = new String[] { "TB", "GB", "MB", "KB", "bytes" }; 267 | 268 | if(value < 1) { 269 | return ""; 270 | } 271 | 272 | String result = null; 273 | for(int i = 0; i < dividers.length; i++) { 274 | final long divider = dividers[i]; 275 | if(value >= divider) { 276 | result = formatFileSizeString(value, divider, units[i]); 277 | break; 278 | } 279 | 280 | } 281 | 282 | return result; 283 | } 284 | 285 | /** 286 | * Formats the input value as a file size string. 287 | * 288 | * @param value The value to format. 289 | * @param divider The value to divide the input value by. 290 | * @param unit The output units. 291 | * @return The formatted file size string. 292 | */ 293 | private String formatFileSizeString(final long value, final long divider, final String unit) { 294 | final double result = divider > 1 ? (double) value / (double) divider : (double) value; 295 | 296 | return new DecimalFormat("#,##0.#").format(result) + " " + unit; 297 | } 298 | 299 | public File getCurrentDir() { 300 | return mCurrentDir; 301 | } 302 | 303 | } 304 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/FileBrowserEngine/FileExtensionFilter.java: -------------------------------------------------------------------------------- 1 | package com.psaravan.filebrowserview.lib.FileBrowserEngine; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * Class to handle filtering files by their extension. Each extension 7 | * is stored in a HashMap (for fast searching) which is accessible via, 8 | * the getFilterMap() method. 9 | * 10 | * @author Saravan Pantham 11 | */ 12 | public class FileExtensionFilter { 13 | 14 | private HashMap mFilterMap; 15 | 16 | public FileExtensionFilter() { 17 | mFilterMap = new HashMap(); 18 | } 19 | 20 | /** 21 | * Adds the specified extension to the HashMap. The extension MUST be 22 | * in the following format: ".xxx", where xxx is the actual file extension. 23 | * If the format doesn't match up, the extension will not be added to the 24 | * HashMap. 25 | * 26 | * @param extension The extension String to add to the HashMap. 27 | * @return True, if the extension was successfully added to the HashMap. False otherwise. 28 | */ 29 | public boolean addExtension(String extension) { 30 | if (extension.startsWith(".")) 31 | throw new IllegalArgumentException("Invalid file extension format. You must " + 32 | "start the extension with a period (.), " + 33 | "followed by the actual extension itself. " + 34 | "Exception thrown for the following extension: " + 35 | extension); 36 | 37 | return getFilterMap().put(extension, false); 38 | } 39 | 40 | /** 41 | * @return The HashMap that stores all the file extensions for this filter object. 42 | */ 43 | public HashMap getFilterMap() { 44 | return mFilterMap; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/GridLayout/GridLayoutAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.GridLayout; 17 | 18 | import android.content.Context; 19 | import android.view.LayoutInflater; 20 | import android.view.MenuItem; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.ImageButton; 24 | import android.widget.ImageView; 25 | import android.widget.PopupMenu; 26 | import android.widget.RelativeLayout; 27 | import android.widget.TextView; 28 | 29 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; 30 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.FileBrowserEngine; 31 | import com.psaravan.filebrowserview.lib.R; 32 | import com.psaravan.filebrowserview.lib.View.AbstractFileBrowserAdapter; 33 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 34 | 35 | /** 36 | * Adapter for the GridView layout. 37 | * 38 | * @author Saravan Pantham 39 | */ 40 | public class GridLayoutAdapter extends AbstractFileBrowserAdapter { 41 | 42 | public GridLayoutAdapter(Context context, FileBrowserView fileBrowserView, 43 | AdapterData adapterData) { 44 | super(context, fileBrowserView, adapterData.getNamesList()); 45 | mContext = context; 46 | mAdapterData = adapterData; 47 | mFileBrowserView = fileBrowserView; 48 | 49 | } 50 | 51 | @Override 52 | public View getView(int position, View convertView, ViewGroup parent) { 53 | 54 | FoldersViewHolder holder = null; 55 | if (convertView == null) { 56 | convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_view_item, parent, false); 57 | 58 | holder = new FoldersViewHolder(); 59 | holder.fileFolderIcon = (ImageView) convertView.findViewById(R.id.gridViewImage); 60 | holder.fileFolderSizeText = (TextView) convertView.findViewById(R.id.gridViewSubText); 61 | holder.fileFolderNameText = (TextView) convertView.findViewById(R.id.gridViewTitleText); 62 | holder.overflowButton = (ImageButton) convertView.findViewById(R.id.gridViewOverflowButton); 63 | 64 | //Show/hide any UI elements based on the user's preferences. 65 | if (!mFileBrowserView.shouldShowItemSizes()) { 66 | //Hide the item size TextViews. 67 | ((View) holder.fileFolderSizeText.getParent()).setVisibility(View.GONE); 68 | RelativeLayout.LayoutParams titleParams = (RelativeLayout.LayoutParams) 69 | holder.fileFolderNameText.getLayoutParams(); 70 | titleParams.addRule(RelativeLayout.CENTER_VERTICAL); 71 | holder.fileFolderNameText.setLayoutParams(titleParams); 72 | } 73 | 74 | if (!mFileBrowserView.shouldShowOverflowMenus()) { 75 | //Hide the overflow menus. 76 | holder.overflowButton.setVisibility(View.GONE); 77 | } else { 78 | holder.overflowButton.setImageResource(R.drawable.ic_action_overflow_universal); 79 | holder.overflowButton.setFocusable(false); 80 | holder.overflowButton.setFocusableInTouchMode(false); 81 | holder.overflowButton.setOnClickListener(overflowClickListener); 82 | 83 | } 84 | 85 | //Hide the icon if we have to. 86 | if (!mFileBrowserView.shouldShowItemIcons()) 87 | holder.fileFolderIcon.setVisibility(View.GONE); 88 | else 89 | holder.fileFolderIcon.setVisibility(View.VISIBLE); 90 | 91 | convertView.setTag(holder); 92 | } else { 93 | holder = (FoldersViewHolder) convertView.getTag(); 94 | } 95 | 96 | holder.fileFolderNameText.setText(getNamesList().get(position)); 97 | holder.fileFolderSizeText.setText(getSizesList().get(position)); 98 | 99 | /* 100 | * Set the icon based on whether the item is a folder or a file. 101 | * Also make sure to set the type of the item as a tag for this 102 | * row. 103 | */ 104 | if (mFileBrowserView.shouldShowItemIcons()) { 105 | if (getTypesList().get(position)==FileBrowserEngine.FOLDER) { 106 | holder.fileFolderIcon.setImageResource(R.drawable.icon_folderblue); 107 | convertView.setTag(R.string.type, FileBrowserEngine.FOLDER); 108 | 109 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_AUDIO) { 110 | holder.fileFolderIcon.setImageResource(R.drawable.icon_mp3); 111 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_AUDIO); 112 | 113 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_PICTURE) { 114 | holder.fileFolderIcon.setImageResource(R.drawable.icon_png); 115 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_PICTURE); 116 | 117 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_VIDEO) { 118 | holder.fileFolderIcon.setImageResource(R.drawable.icon_avi); 119 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_VIDEO); 120 | 121 | } else { 122 | holder.fileFolderIcon.setImageResource(R.drawable.icon_default); 123 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_GENERIC); 124 | 125 | } 126 | 127 | } 128 | 129 | /* 130 | * We're gonna need a way to keep track of the file/folder path of each row. 131 | * We'll set the path as the row view's tag. 132 | */ 133 | convertView.setTag(R.string.path, getPathsList().get(position)); 134 | 135 | return convertView; 136 | } 137 | 138 | @Override 139 | public void onOverflowClick(View overflowView) { 140 | //Show a popup menu that displays the filesystem operations. 141 | PopupMenu popupMenu = new PopupMenu(mContext, overflowView); 142 | popupMenu.inflate(R.menu.filesystem_ops_menu); 143 | popupMenu.setOnMenuItemClickListener(menuItemClickListener); 144 | popupMenu.show(); 145 | 146 | } 147 | 148 | /** 149 | * Use this interface to implement your filesystem operations logic. 150 | */ 151 | private PopupMenu.OnMenuItemClickListener menuItemClickListener = 152 | new PopupMenu.OnMenuItemClickListener() { 153 | 154 | @Override 155 | public boolean onMenuItemClick(MenuItem item) { 156 | 157 | int id = item.getItemId(); 158 | if (id==R.id.copy) { 159 | //TODO Implement your copy functionality here. 160 | } else if (id==R.id.paste) { 161 | //TODO Implement your paste functionality here. 162 | } else if (id==R.id.move) { 163 | //TODO Implement your move functionality here. 164 | } else if (id==R.id.rename) { 165 | //TODO Implement your rename functionality here. 166 | } else if (id==R.id.delete) { 167 | //TODO Implement your delete functionality here. 168 | } 169 | 170 | return false; 171 | } 172 | 173 | }; 174 | 175 | private View.OnClickListener overflowClickListener = new View.OnClickListener() { 176 | 177 | @Override 178 | public void onClick(View view) { 179 | onOverflowClick(view); 180 | } 181 | 182 | }; 183 | 184 | /** 185 | * Holder class for the ListView layout. 186 | */ 187 | static class FoldersViewHolder { 188 | public TextView fileFolderNameText; 189 | public TextView fileFolderSizeText; 190 | public ImageView fileFolderIcon; 191 | public ImageButton overflowButton; 192 | 193 | } 194 | 195 | } 196 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/GridLayout/GridLayoutView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.GridLayout; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.AdapterView; 23 | import android.widget.GridView; 24 | import android.widget.Toast; 25 | 26 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; 27 | import com.psaravan.filebrowserview.lib.R; 28 | import com.psaravan.filebrowserview.lib.View.BaseLayoutView; 29 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 30 | 31 | import java.io.File; 32 | 33 | /** 34 | * Grid layout view implementation for the file browser. 35 | * 36 | * @author Saravan Pantham 37 | */ 38 | public class GridLayoutView extends BaseLayoutView { 39 | 40 | //Context. 41 | private Context mContext; 42 | 43 | //Parent FileBrowserView and its children. 44 | private FileBrowserView mFileBrowserView; 45 | 46 | public GridLayoutView(Context context, AttributeSet attributeSet, FileBrowserView fileBrowserView) { 47 | super(context, attributeSet); 48 | mContext = context; 49 | mFileBrowserView = fileBrowserView; 50 | 51 | } 52 | 53 | /** 54 | * Inflates the layout and sets the grid's adapter. 55 | * 56 | * @param viewGroup The ViewGroup to inflate the layout into. 57 | * @return A reference to this view's instance. 58 | */ 59 | public GridLayoutView init(ViewGroup viewGroup) { 60 | //Inflate the view from the XML resource. 61 | View.inflate(mContext, R.layout.simple_grid_file_browser, viewGroup); 62 | mAbsListView = (GridView) viewGroup.findViewById(R.id.file_browser_grid_view); 63 | 64 | //Display the default dir. 65 | showDir(mFileBrowserView.getDefaultDirectory()); 66 | return this; 67 | } 68 | 69 | /** 70 | * Loads the directory structure of the specified dir and sets the GridView's adapter. 71 | * 72 | * @param directory The File object that points to the directory to load. 73 | */ 74 | @Override 75 | protected void showDir(File directory) { 76 | 77 | //Call the interface callback method. 78 | if (mNavigationInterface!=null) 79 | mNavigationInterface.onNewDirLoaded(directory); 80 | 81 | //Grab the directory's data to feed to the grid adapter. 82 | AdapterData adapterData = mFileBrowserView.getFileBrowserEngine().loadDir(directory); 83 | 84 | //Check if the user wants to use a custom adapter. 85 | if (mFileBrowserView.getFileBrowserAdapter()!=null) { 86 | //The user called setFileBrowserAdapter() and is using a custom adapter. 87 | mFileBrowserView.getFileBrowserAdapter().setAdapterData(adapterData); 88 | 89 | } else { 90 | //Nope, no custom adapter, so fall back to the default adapter. 91 | GridLayoutAdapter adapter = new GridLayoutAdapter(mContext, mFileBrowserView, adapterData); 92 | mFileBrowserView.setCustomAdapter(adapter); 93 | 94 | } 95 | 96 | //Apply the adapter to the GridView. 97 | mAbsListView.setAdapter(mFileBrowserView.getFileBrowserAdapter()); 98 | 99 | //Apply the click listener to the GridView. 100 | mAbsListView.setOnItemClickListener(onItemClickListener); 101 | 102 | } 103 | 104 | /** 105 | * Click listener for the GridView. 106 | */ 107 | private GridView.OnItemClickListener onItemClickListener = new GridView.OnItemClickListener() { 108 | 109 | @Override 110 | public void onItemClick(AdapterView parent, View view, int position, long id) { 111 | 112 | File file = null; 113 | try { 114 | String newPath = mFileBrowserView.getFileBrowserAdapter().getPathsList().get(position); 115 | file = new File(newPath); 116 | showDir(file); 117 | 118 | } catch (Exception e) { 119 | e.printStackTrace(); 120 | 121 | if (mNavigationInterface!=null) 122 | mNavigationInterface.onFileFolderOpenFailed(file); 123 | 124 | //Display an error toast. 125 | if (file!=null && file.isDirectory()) { 126 | Toast.makeText(mContext, R.string.unable_to_load_dir, Toast.LENGTH_SHORT).show(); 127 | } else if (file!=null && !file.isDirectory()) { 128 | Toast.makeText(mContext, R.string.unable_to_open_file, Toast.LENGTH_SHORT).show(); 129 | } 130 | 131 | } 132 | 133 | } 134 | 135 | }; 136 | 137 | } 138 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/Interfaces/CopyInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.Interfaces; 17 | 18 | /** 19 | * Interface that provides callbacks during specific checkpoints 20 | * during the copy operation. 21 | * 22 | * @author Saravan Pantham 23 | */ 24 | public interface CopyInterface { 25 | 26 | /** 27 | * This method is called right before the copy operation begins. 28 | * Any code you implement into this method will run on the main 29 | * thread. 30 | */ 31 | public void preCopyStartSync(); 32 | 33 | /** 34 | * This method is called right before the copy operation begins. 35 | * Any code you implement into this method will run on the 36 | * copy operation's AsyncTask thread. 37 | */ 38 | public void preCopyStartAsync(); 39 | 40 | /** 41 | * This method is called right after the copy operation finishes. 42 | * Any code you implement into this method will run on the main 43 | * thread. 44 | * 45 | * @param result Whether or not the copy operation completed successfully. 46 | */ 47 | public void onCopyCompleteSync(boolean result); 48 | 49 | /** 50 | * This method is called right after the copy operation finishes. 51 | * Any code you implement into this method will run on the copy 52 | * operation's AsyncTask thread. 53 | * 54 | * @param result Whether or not the copy operation completed successfully. 55 | */ 56 | public void onCopyCompleteAsync(boolean result); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/Interfaces/DeleteInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.Interfaces; 17 | 18 | /** 19 | * Interface that provides callbacks during specific checkpoints 20 | * during the delete operation. 21 | * 22 | * @author Saravan Pantham 23 | */ 24 | public interface DeleteInterface { 25 | 26 | /** 27 | * This method is called right before the delete operation begins. 28 | * Any code you implement into this method will run on the main 29 | * thread. 30 | */ 31 | public void preDeleteStartSync(); 32 | 33 | /** 34 | * This method is called right before the delete operation begins. 35 | * Any code you implement into this method will run on the 36 | * delete operation's AsyncTask thread. 37 | */ 38 | public void preDeleteStartAsync(); 39 | 40 | /** 41 | * This method is called right after the delete operation finishes. 42 | * Any code you implement into this method will run on the main 43 | * thread. 44 | * 45 | * @param result Whether or not the delete operation completed successfully. 46 | */ 47 | public void onDeleteCompleteSync(boolean result); 48 | 49 | /** 50 | * This method is called right after the delete operation finishes. 51 | * Any code you implement into this method will run on the delete 52 | * operation's AsyncTask thread. 53 | * 54 | * @param result Whether or not the delete operation completed successfully. 55 | */ 56 | public void onDeleteCompleteAsync(boolean result); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/Interfaces/MoveInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.Interfaces; 17 | 18 | /** 19 | * Interface that provides callbacks during specific checkpoints 20 | * during the move operation. 21 | * 22 | * @author Saravan Pantham 23 | */ 24 | public interface MoveInterface { 25 | 26 | /** 27 | * This method is called right before the move operation begins. 28 | * Any code you implement into this method will run on the main 29 | * thread. 30 | */ 31 | public void preMoveStartSync(); 32 | 33 | /** 34 | * This method is called right before the move operation begins. 35 | * Any code you implement into this method will run on the 36 | * move operation's AsyncTask thread. 37 | */ 38 | public void preMoveStartAsync(); 39 | 40 | /** 41 | * This method is called right after the move operation finishes. 42 | * Any code you implement into this method will run on the main 43 | * thread. 44 | * 45 | * @param result Whether or not the move operation completed successfully. 46 | */ 47 | public void onMoveCompleteSync(boolean result); 48 | 49 | /** 50 | * This method is called right after the move operation finishes. 51 | * Any code you implement into this method will run on the move 52 | * operation's AsyncTask thread. 53 | * 54 | * @param result Whether or not the move operation completed successfully. 55 | */ 56 | public void onMoveCompleteAsync(boolean result); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/Interfaces/NavigationInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.Interfaces; 17 | 18 | import java.io.File; 19 | 20 | /** 21 | * Interface that provides callbacks for navigation events, such as 22 | * browsing into a new directory, opening a file, etc. 23 | * 24 | * @author Saravan Pantham 25 | */ 26 | public interface NavigationInterface { 27 | 28 | /** 29 | * Called when a new directory is opened by the user. 30 | * 31 | * @param dirFile The file that points to the new directory 32 | * that has just been loaded. 33 | */ 34 | public void onNewDirLoaded(File dirFile); 35 | 36 | /** 37 | * Called when a new file is opened by the user. 38 | * 39 | * @param file The file that was just opened. 40 | */ 41 | public void onFileOpened(File file); 42 | 43 | /** 44 | * Called when the user navigates back to the parent directory. 45 | * 46 | * @param dirFile The file that points to the parent directory that 47 | * was just opened. 48 | */ 49 | public void onParentDirLoaded(File dirFile); 50 | 51 | /** 52 | * Called when a file or folder fails to open. 53 | * 54 | * @param file The file/folder that failed to open. 55 | */ 56 | public void onFileFolderOpenFailed(File file); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/ListLayout/ListLayoutAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.ListLayout; 17 | 18 | import android.content.Context; 19 | import android.view.LayoutInflater; 20 | import android.view.MenuItem; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.ImageButton; 24 | import android.widget.ImageView; 25 | import android.widget.ListView; 26 | import android.widget.PopupMenu; 27 | import android.widget.RelativeLayout; 28 | import android.widget.TextView; 29 | 30 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; 31 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.FileBrowserEngine; 32 | import com.psaravan.filebrowserview.lib.R; 33 | import com.psaravan.filebrowserview.lib.Utils.Utils; 34 | import com.psaravan.filebrowserview.lib.View.AbstractFileBrowserAdapter; 35 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 36 | 37 | /** 38 | * Adapter for the ListView layout. 39 | * 40 | * @author Saravan Pantham 41 | */ 42 | public class ListLayoutAdapter extends AbstractFileBrowserAdapter { 43 | 44 | public ListLayoutAdapter(Context context, FileBrowserView fileBrowserView, 45 | AdapterData adapterData) { 46 | super(context, fileBrowserView, adapterData.getNamesList()); 47 | mContext = context; 48 | mAdapterData = adapterData; 49 | mFileBrowserView = fileBrowserView; 50 | 51 | } 52 | 53 | @Override 54 | public View getView(int position, View convertView, ViewGroup parent) { 55 | 56 | FoldersViewHolder holder = null; 57 | if (convertView == null) { 58 | 59 | convertView = LayoutInflater.from(mContext).inflate(R.layout.list_view_item, parent, false); 60 | ListView.LayoutParams params = (ListView.LayoutParams) convertView.getLayoutParams(); 61 | params.height = (int) Utils.convertDpToPixels(72.0f, mContext); 62 | convertView.setLayoutParams(params); 63 | 64 | holder = new FoldersViewHolder(); 65 | holder.fileFolderIcon = (ImageView) convertView.findViewById(R.id.listViewLeftIcon); 66 | holder.fileFolderSizeText = (TextView) convertView.findViewById(R.id.listViewSubText); 67 | holder.fileFolderNameText = (TextView) convertView.findViewById(R.id.listViewTitleText); 68 | holder.overflowButton = (ImageButton) convertView.findViewById(R.id.listViewOverflow); 69 | holder.rightSubText = (TextView) convertView.findViewById(R.id.listViewRightSubText); 70 | holder.rightSubText.setVisibility(View.INVISIBLE); 71 | 72 | //Show/hide any UI elements based on the user's preferences. 73 | if (!mFileBrowserView.shouldShowItemSizes()) { 74 | //Hide the item size TextViews. 75 | ((View) holder.fileFolderSizeText.getParent()).setVisibility(View.GONE); 76 | RelativeLayout.LayoutParams titleParams = (RelativeLayout.LayoutParams) 77 | holder.fileFolderNameText.getLayoutParams(); 78 | titleParams.addRule(RelativeLayout.CENTER_VERTICAL); 79 | holder.fileFolderNameText.setLayoutParams(titleParams); 80 | } 81 | 82 | if (!mFileBrowserView.shouldShowOverflowMenus()) { 83 | //Hide the overflow menus. 84 | holder.overflowButton.setVisibility(View.GONE); 85 | } else { 86 | holder.overflowButton.setImageResource(R.drawable.ic_action_overflow_universal); 87 | holder.overflowButton.setFocusable(false); 88 | holder.overflowButton.setFocusableInTouchMode(false); 89 | holder.overflowButton.setOnClickListener(overflowClickListener); 90 | 91 | } 92 | 93 | //Hide the icon if we have to. 94 | if (!mFileBrowserView.shouldShowItemIcons()) 95 | holder.fileFolderIcon.setVisibility(View.GONE); 96 | else 97 | holder.fileFolderIcon.setVisibility(View.VISIBLE); 98 | 99 | convertView.setTag(holder); 100 | } else { 101 | holder = (FoldersViewHolder) convertView.getTag(); 102 | } 103 | 104 | holder.fileFolderNameText.setText(getNamesList().get(position)); 105 | holder.fileFolderSizeText.setText(getSizesList().get(position)); 106 | 107 | /* 108 | * Set the icon based on whether the item is a folder or a file. 109 | * Also make sure to set the type of the item as a tag for this 110 | * row. 111 | */ 112 | if (mFileBrowserView.shouldShowItemIcons()) { 113 | if (getTypesList().get(position)==FileBrowserEngine.FOLDER) { 114 | holder.fileFolderIcon.setImageResource(R.drawable.icon_folderblue); 115 | convertView.setTag(R.string.type, FileBrowserEngine.FOLDER); 116 | 117 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_AUDIO) { 118 | holder.fileFolderIcon.setImageResource(R.drawable.icon_mp3); 119 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_AUDIO); 120 | 121 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_PICTURE) { 122 | holder.fileFolderIcon.setImageResource(R.drawable.icon_png); 123 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_PICTURE); 124 | 125 | } else if (getTypesList().get(position)==FileBrowserEngine.FILE_VIDEO) { 126 | holder.fileFolderIcon.setImageResource(R.drawable.icon_avi); 127 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_VIDEO); 128 | 129 | } else { 130 | holder.fileFolderIcon.setImageResource(R.drawable.icon_default); 131 | convertView.setTag(R.string.type, FileBrowserEngine.FILE_GENERIC); 132 | 133 | } 134 | 135 | } 136 | 137 | /* 138 | * We're gonna need a way to keep track of the file/folder path of each row. 139 | * We'll set the path as the row view's tag. 140 | */ 141 | convertView.setTag(R.string.path, getPathsList().get(position)); 142 | 143 | return convertView; 144 | } 145 | 146 | @Override 147 | public void onOverflowClick(View overflowView) { 148 | //Show a popup menu that displays the filesystem operations. 149 | PopupMenu popupMenu = new PopupMenu(mContext, overflowView); 150 | popupMenu.inflate(R.menu.filesystem_ops_menu); 151 | popupMenu.setOnMenuItemClickListener(menuItemClickListener); 152 | popupMenu.show(); 153 | } 154 | 155 | /** 156 | * Use this interface to implement your filesystem operations logic. 157 | */ 158 | private PopupMenu.OnMenuItemClickListener menuItemClickListener = 159 | new PopupMenu.OnMenuItemClickListener() { 160 | 161 | @Override 162 | public boolean onMenuItemClick(MenuItem item) { 163 | 164 | int id = item.getItemId(); 165 | if (id==R.id.copy) { 166 | //TODO Implement your copy functionality here. 167 | } else if (id==R.id.paste) { 168 | //TODO Implement your paste functionality here. 169 | } else if (id==R.id.move) { 170 | //TODO Implement your move functionality here. 171 | } else if (id==R.id.rename) { 172 | //TODO Implement your rename functionality here. 173 | } else if (id==R.id.delete) { 174 | //TODO Implement your delete functionality here. 175 | } 176 | 177 | return false; 178 | } 179 | 180 | }; 181 | 182 | private View.OnClickListener overflowClickListener = new View.OnClickListener() { 183 | 184 | @Override 185 | public void onClick(View view) { 186 | onOverflowClick(view); 187 | } 188 | 189 | }; 190 | 191 | /** 192 | * Holder class for the ListView layout. 193 | */ 194 | static class FoldersViewHolder { 195 | public TextView fileFolderNameText; 196 | public TextView fileFolderSizeText; 197 | public ImageView fileFolderIcon; 198 | public ImageButton overflowButton; 199 | public TextView rightSubText; 200 | 201 | } 202 | 203 | } 204 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/ListLayout/ListLayoutView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.ListLayout; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.AdapterView; 23 | import android.widget.ListView; 24 | import android.widget.Toast; 25 | 26 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; 27 | import com.psaravan.filebrowserview.lib.R; 28 | import com.psaravan.filebrowserview.lib.View.BaseLayoutView; 29 | import com.psaravan.filebrowserview.lib.View.FileBrowserView; 30 | 31 | import java.io.File; 32 | 33 | /** 34 | * List layout view implementation for the file browser. 35 | * 36 | * @author Saravan Pantham 37 | */ 38 | public class ListLayoutView extends BaseLayoutView { 39 | 40 | //Context. 41 | private Context mContext; 42 | 43 | //Parent FileBrowserView and its children. 44 | private FileBrowserView mFileBrowserView; 45 | 46 | public ListLayoutView(Context context, AttributeSet attributeSet, FileBrowserView fileBrowserView) { 47 | super(context, attributeSet); 48 | mContext = context; 49 | mFileBrowserView = fileBrowserView; 50 | 51 | } 52 | 53 | /** 54 | * Inflates the layout and sets the list's adapter. 55 | * 56 | * @param viewGroup The ViewGroup to inflate the layout into. 57 | * @return A reference to this view's instance. 58 | */ 59 | public ListLayoutView init(ViewGroup viewGroup) { 60 | //Inflate the view from the XML resource. 61 | View.inflate(mContext, R.layout.simple_list_file_browser, viewGroup); 62 | mAbsListView = (ListView) viewGroup.findViewById(R.id.file_browser_list_view); 63 | 64 | //Display the default dir. 65 | showDir(mFileBrowserView.getDefaultDirectory()); 66 | return this; 67 | } 68 | 69 | /** 70 | * Loads the directory structure of the specified dir and sets the ListView's adapter. 71 | * 72 | * @param directory The File object that points to the directory to load. 73 | */ 74 | @Override 75 | protected void showDir(File directory) { 76 | 77 | //Call the interface callback method. 78 | if (mNavigationInterface!=null) 79 | mNavigationInterface.onNewDirLoaded(directory); 80 | 81 | //Grab the directory's data to feed to the list adapter. 82 | AdapterData adapterData = mFileBrowserView.getFileBrowserEngine().loadDir(directory); 83 | 84 | //Check if the user wants to use a custom adapter. 85 | if (mFileBrowserView.getFileBrowserAdapter()!=null) { 86 | //The user called setFileBrowserAdapter() and is using a custom adapter. 87 | mFileBrowserView.getFileBrowserAdapter().setAdapterData(adapterData); 88 | 89 | } else { 90 | //Nope, no custom adapter, so fall back to the default adapter. 91 | ListLayoutAdapter adapter = new ListLayoutAdapter(mContext, mFileBrowserView, adapterData); 92 | mFileBrowserView.setCustomAdapter(adapter); 93 | 94 | } 95 | 96 | //Apply the adapter to the ListView. 97 | mAbsListView.setAdapter(mFileBrowserView.getFileBrowserAdapter()); 98 | 99 | //Apply the click listener to the ListView. 100 | mAbsListView.setOnItemClickListener(onItemClickListener); 101 | 102 | } 103 | 104 | /** 105 | * Click listener for the ListView. 106 | */ 107 | private ListView.OnItemClickListener onItemClickListener = new ListView.OnItemClickListener() { 108 | 109 | @Override 110 | public void onItemClick(AdapterView parent, View view, int position, long id) { 111 | 112 | File file = null; 113 | try { 114 | String newPath = mFileBrowserView.getFileBrowserAdapter().getPathsList().get(position); 115 | file = new File(newPath); 116 | showDir(file); 117 | 118 | } catch (Exception e) { 119 | e.printStackTrace(); 120 | 121 | if (mNavigationInterface!=null) 122 | mNavigationInterface.onFileFolderOpenFailed(file); 123 | 124 | //Display an error toast. 125 | if (file!=null && file.isDirectory()) { 126 | Toast.makeText(mContext, R.string.unable_to_load_dir, Toast.LENGTH_SHORT).show(); 127 | } else if (file!=null && !file.isDirectory()) { 128 | Toast.makeText(mContext, R.string.unable_to_open_file, Toast.LENGTH_SHORT).show(); 129 | } 130 | 131 | } 132 | 133 | } 134 | 135 | }; 136 | 137 | } 138 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/Utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.Utils; 17 | 18 | import android.content.Context; 19 | import android.content.res.Resources; 20 | import android.util.DisplayMetrics; 21 | 22 | /** 23 | * Helper class with a set of commonly used helper methods. 24 | * 25 | * @author Saravan Pantham 26 | */ 27 | public class Utils { 28 | 29 | /** 30 | * Converts the input dp unit to pixels, depending on device density. 31 | * 32 | * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels 33 | * @param context Context to get resources and device specific display metrics 34 | * @return A floating point value to represent px equivalent to dp depending on device density. 35 | */ 36 | public static float convertDpToPixels(float dp, Context context){ 37 | Resources resources = context.getResources(); 38 | DisplayMetrics metrics = resources.getDisplayMetrics(); 39 | float px = dp * (metrics.densityDpi / 160f); 40 | return px; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/View/AbstractFileBrowserAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.View; 17 | 18 | import android.content.Context; 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.widget.ArrayAdapter; 22 | 23 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; 24 | 25 | import java.util.ArrayList; 26 | 27 | /** 28 | * Extend this abstract class if you want to create your own adapter for the ListView/GridView. 29 | * 30 | * @author Saravan Pantham 31 | */ 32 | public abstract class AbstractFileBrowserAdapter extends ArrayAdapter { 33 | 34 | protected Context mContext; 35 | protected AdapterData mAdapterData; 36 | protected FileBrowserView mFileBrowserView; 37 | 38 | public AbstractFileBrowserAdapter(Context context, FileBrowserView fileBrowserView, 39 | ArrayList namesList) { 40 | super(context, -1, namesList); 41 | mContext = context; 42 | mFileBrowserView = fileBrowserView; 43 | 44 | } 45 | 46 | @Override 47 | public int getCount() { 48 | return getNamesList().size(); 49 | } 50 | 51 | /** 52 | * Get a View that displays the data at the specified position in the data set. You can either 53 | * create a View manually or inflate it from an XML layout file. When the View is inflated, the 54 | * parent View (GridView, ListView...) will apply default layout parameters unless you use 55 | * {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} 56 | * to specify a root view and to prevent attachment to the root. 57 | * 58 | * @param position The position of the item within the adapter's data set of the item whose view 59 | * we want. 60 | * @param convertView The old view to reuse, if possible. Note: You should check that this view 61 | * is non-null and of an appropriate type before using. If it is not possible to convert 62 | * this view to display the correct data, this method can create a new view. 63 | * Heterogeneous lists can specify their number of view types, so that this View is 64 | * always of the right type (see {@link #getViewTypeCount()} and 65 | * {@link #getItemViewType(int)}). 66 | * @param parent The parent that this view will eventually be attached to 67 | * @return A View corresponding to the data at the specified position. 68 | */ 69 | @Override 70 | public abstract View getView(int position, View convertView, ViewGroup parent); 71 | 72 | /** 73 | * Called when the overflow menu button/icon is clicked. This is where you should implement 74 | * your code for displaying the overflow menu (or any other action that should be performed 75 | * when the overflow menu button is clicked). Note that this method has no effect if you 76 | * use your own custom adapter via 77 | * {@link com.psaravan.filebrowserview.lib.View.FileBrowserView#setCustomAdapter(AbstractFileBrowserAdapter)}. 78 | * 79 | * @param overflowView The view that should be used as the overflow menu's anchor. 80 | */ 81 | public abstract void onOverflowClick(View overflowView); 82 | 83 | /** 84 | * Updates the adapter with the specified {@link AdapterData} object. Must be called 85 | * BEFORE the adapter is first applied to the list/grid view. 86 | * 87 | * @param adapterData The {@link AdapterData} object to set to this adapter instance. 88 | */ 89 | public void setAdapterData(AdapterData adapterData) { 90 | mAdapterData = adapterData; 91 | } 92 | 93 | /** 94 | * @return The list of file/subfolder names within the current directory. 95 | */ 96 | public ArrayList getNamesList() { 97 | if (mAdapterData!=null) 98 | return mAdapterData.getNamesList(); 99 | else 100 | return new ArrayList(); 101 | 102 | } 103 | 104 | /** 105 | * @return The list of file/subfolder types within the current directory. 106 | */ 107 | public ArrayList getTypesList() { 108 | if (mAdapterData!=null) 109 | return mAdapterData.getTypesList(); 110 | else 111 | return new ArrayList(); 112 | 113 | } 114 | 115 | /** 116 | * @return The list of file/subfolder paths within the current directory. 117 | */ 118 | public ArrayList getPathsList() { 119 | if (mAdapterData!=null) 120 | return mAdapterData.getPathsList(); 121 | else 122 | return new ArrayList(); 123 | 124 | } 125 | 126 | /** 127 | * @return The list of file/subfolder sizes within the current directory. 128 | */ 129 | public ArrayList getSizesList() { 130 | if (mAdapterData!=null) 131 | return mAdapterData.getSizesList(); 132 | else 133 | return new ArrayList(); 134 | 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/View/BaseLayoutView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.View; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.view.View; 21 | import android.widget.AbsListView; 22 | 23 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 24 | 25 | import java.io.File; 26 | 27 | /** 28 | * The base layout that is extended by {@link com.psaravan.filebrowserview.lib.ListLayout.ListLayoutView} 29 | * and {@link com.psaravan.filebrowserview.lib.GridLayout.GridLayoutView}. 30 | * 31 | * @author Saravan Pantham 32 | */ 33 | public abstract class BaseLayoutView extends View { 34 | 35 | /** 36 | * Context intstance. 37 | */ 38 | protected Context mContext; 39 | 40 | /** 41 | * The ListView/GridView that displays the file system. 42 | */ 43 | protected AbsListView mAbsListView; 44 | 45 | /** 46 | * The interface instance that provides callbacks for filesystem 47 | * navigation events. 48 | */ 49 | protected NavigationInterface mNavigationInterface; 50 | 51 | /** 52 | * Default constructor. 53 | */ 54 | public BaseLayoutView(Context context, AttributeSet attributeSet) { 55 | super(context, attributeSet); 56 | mContext = context; 57 | } 58 | 59 | /** 60 | * Override this method to implement your logic for loading a directory structure of the 61 | * specified dir and to set your AbsListView's adapter. 62 | * 63 | * @param directory The File object that points to the directory to load. 64 | */ 65 | protected abstract void showDir(File directory); 66 | 67 | /** 68 | * Sets the navigation interface instance for this view. 69 | * 70 | * @param navInterface The interface instance to assign to this view. 71 | */ 72 | public void setNavigationInterface(NavigationInterface navInterface) { 73 | mNavigationInterface = navInterface; 74 | } 75 | 76 | /** 77 | * @return The ListView/GridView that displays the file system. 78 | */ 79 | public AbsListView getAbsListView() { 80 | return mAbsListView; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/View/FileBrowserView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.View; 17 | 18 | import android.content.Context; 19 | import android.os.Environment; 20 | import android.util.AttributeSet; 21 | import android.widget.AbsListView; 22 | import android.widget.FrameLayout; 23 | 24 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.FileBrowserEngine; 25 | import com.psaravan.filebrowserview.lib.FileBrowserEngine.FileExtensionFilter; 26 | import com.psaravan.filebrowserview.lib.GridLayout.GridLayoutView; 27 | import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface; 28 | import com.psaravan.filebrowserview.lib.ListLayout.ListLayoutView; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | 33 | /** 34 | * Base implementation class for FileBrowserView. Each FileBrowserView object is essentially a 35 | * ViewGroup that consists of other view children (an optional header view and an AbsListView). 36 | * This class is simply a container for the main view class, which is determined by the type of 37 | * layout that the user selects ({@link com.psaravan.filebrowserview.lib.ListLayout.ListLayoutView} 38 | * vs {@link com.psaravan.filebrowserview.lib.GridLayout.GridLayoutView}). This class also stores 39 | * any settings/preferences that the user requests for the view. 40 | * 41 | * @author Saravan Pantham 42 | */ 43 | public class FileBrowserView extends FrameLayout { 44 | 45 | //Context and AttributeSet. 46 | private Context mContext; 47 | private AttributeSet mAttributeSet; 48 | 49 | //Current layout type selection/view reference. 50 | private int mFileBrowserLayoutType = FILE_BROWSER_LIST_LAYOUT; 51 | private BaseLayoutView mFileBrowserLayout; 52 | 53 | //File browser engine. 54 | private FileBrowserEngine mFileBrowserEngine; 55 | 56 | //Adapter to use for the list/grid view. 57 | private AbstractFileBrowserAdapter mAdapter; 58 | 59 | //Default directory to display. 60 | private File mDefaultDir = null; 61 | 62 | //Flag to show/hide hidden files. 63 | private boolean mShowHiddenFiles = false; 64 | 65 | //Flags to display individual item attributes in the default adapter view. 66 | private boolean mShowOverflowMenus = true; 67 | private boolean mShowItemSizes = true; 68 | private boolean mShowIcons = true; 69 | 70 | //Layout type constants. 71 | public static final int FILE_BROWSER_LIST_LAYOUT = 0; 72 | public static final int FILE_BROWSER_GRID_LAYOUT = 1; 73 | 74 | //Navigation Interface. 75 | private NavigationInterface mNavigationInterface; 76 | 77 | //Whether or not tabbed browsing is enabled. 78 | private boolean mTabbedBrowsingEnabled = false; 79 | 80 | //FileExtensionFilter instance and whether or not to show other dirs in the current dir. 81 | private FileExtensionFilter mFileExtensionFilter; 82 | private boolean mShouldShowFolders = true; 83 | 84 | public FileBrowserView(Context context) { 85 | super(context); 86 | mContext = context; 87 | 88 | } 89 | 90 | public FileBrowserView(Context context, AttributeSet attributeSet) { 91 | super(context, attributeSet); 92 | mContext = context; 93 | mAttributeSet = attributeSet; 94 | 95 | } 96 | 97 | public FileBrowserView(Context context, AttributeSet attrs, int defStyleAttr) { 98 | super(context, attrs, defStyleAttr); 99 | mContext = context; 100 | 101 | } 102 | 103 | @Override 104 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 105 | for(int i = 0 ; i < getChildCount() ; i++) { 106 | getChildAt(i).layout(l, t, r, b); 107 | } 108 | 109 | } 110 | 111 | /** 112 | * Initializes the file browser view and fires it up for first use. Must be called to 113 | * properly display the file browser. 114 | */ 115 | public void init() { 116 | 117 | //Check if the default dir was set. 118 | if (getDefaultDirectory()==null) 119 | setDefaultDirectory(Environment.getExternalStorageDirectory()); 120 | 121 | //Initialize the file browser engine for this view instance. 122 | mFileBrowserEngine = new FileBrowserEngine(mContext, this); 123 | 124 | /* 125 | * If tabbed browsing is enabled, an instance of TabContainer will 126 | * become the direct child of this view. If not, we can directly 127 | * inflate the List/Grid layout views. 128 | */ 129 | if (isTabbedBrowsingEnabled()) { 130 | mFileBrowserLayout = new TabsContainer(mContext, mAttributeSet, this).init(this); 131 | } else { 132 | //Inflate the view's layout based on the selected layout. 133 | if (getFileBrowserLayoutType()==FILE_BROWSER_LIST_LAYOUT) 134 | mFileBrowserLayout = new ListLayoutView(mContext, mAttributeSet, this).init(this); 135 | else 136 | mFileBrowserLayout = new GridLayoutView(mContext, mAttributeSet, this).init(this); 137 | } 138 | 139 | //Apply the navigation interface. 140 | mFileBrowserLayout.setNavigationInterface(mNavigationInterface); 141 | 142 | } 143 | 144 | /** 145 | * Sets the default directory to show when the FileBrowserView is initialized. 146 | * 147 | * @param directory The file that points to the default directory to display. 148 | * @return An instance of this FileBrowserView to allow method chaining. 149 | * @throws java.lang.IllegalArgumentException Thrown if the input File argument doesn't 150 | * point to a valid directory or the directory can't be read. 151 | */ 152 | public FileBrowserView setDefaultDirectory(File directory) throws IllegalArgumentException { 153 | 154 | if (directory==null || !directory.isDirectory()) 155 | throw new IllegalArgumentException("You must use a File object that points to a valid, " + 156 | "accessible directory."); 157 | 158 | if (!directory.canRead()) 159 | throw new IllegalArgumentException("Could not read the specified default directory. Make " + 160 | "sure you have permission to read the directory."); 161 | 162 | mDefaultDir = directory; 163 | return this; 164 | } 165 | 166 | /** 167 | * Sets the layout type (list or grid) of this FileBrowserView instance. 168 | * 169 | * @param layoutType Use one of the following two options: {@link #FILE_BROWSER_LIST_LAYOUT} or 170 | * {@link #FILE_BROWSER_GRID_LAYOUT}. 171 | * @return An instance of this FileBrowserView to allow method chaining. 172 | */ 173 | public FileBrowserView setFileBrowserLayoutType(int layoutType) { 174 | mFileBrowserLayoutType = layoutType; 175 | return this; 176 | } 177 | 178 | /** 179 | * Call this method to use your own adapter for the list/grid view. The adapter must be a 180 | * subclass of {@link com.psaravan.filebrowserview.lib.View.AbstractFileBrowserAdapter}. See 181 | * {@link com.psaravan.filebrowserview.lib.ListLayout.ListLayoutAdapter} for an example of a 182 | * ListView adapter and {@link com.psaravan.filebrowserview.lib.GridLayout.GridLayoutAdapter} 183 | * for an example of a GridView adapter. 184 | * 185 | * @param adapter An adapter that is extended from {@link AbstractFileBrowserAdapter}. 186 | * @return An instance of this FileBrowserView to allow method chaining. 187 | * @throws java.lang.IllegalArgumentException Thrown if the adapter passed in is not an instance 188 | * of {@link com.psaravan.filebrowserview.lib.View.AbstractFileBrowserAdapter}. 189 | */ 190 | public FileBrowserView setCustomAdapter(AbstractFileBrowserAdapter adapter) 191 | throws IllegalArgumentException { 192 | 193 | if (!(adapter instanceof AbstractFileBrowserAdapter)) 194 | throw new IllegalArgumentException("The adapter you pass into setCustomAdapter() " + 195 | "must extend AbstractFileBrowserAdapter."); 196 | 197 | mAdapter = adapter; 198 | return this; 199 | } 200 | 201 | /** 202 | * Sets whether hidden files should be shown or not. 203 | * 204 | * @param show Specifies whether hidden files should be shown or not. 205 | * @return An instance of this FileBrowserView to allow method chaining. 206 | */ 207 | public FileBrowserView setShowHiddenFiles(boolean show) { 208 | mShowHiddenFiles = show; 209 | return this; 210 | } 211 | 212 | /** 213 | * Sets whether or not the overflow menu should be shown or not (defaults to true). Note that 214 | * this method will have no effect if you use your own adapter via 215 | * {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 216 | * 217 | * @param show Whether or not the overflow menu should be shown. 218 | * @return An instance of this FileBrowserView to allow method chaining. 219 | */ 220 | public FileBrowserView showOverflowMenus(boolean show) { 221 | mShowOverflowMenus = show; 222 | return this; 223 | } 224 | 225 | /** 226 | * Sets whether or not each file/folder's size should be displayed underneath the name (defaults 227 | * to true). Note that this method will have no effect if you use your own adapter via 228 | * {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 229 | * 230 | * If the item is a folder, the number of subfiles/subfolders will be displayed in the 231 | * following format: xxx items. 232 | * 233 | * If the item is a file, the size of the file will be displayed in the most appropriate 234 | * units: xxx KB, xxx bytes, xxx MB, etc. 235 | * 236 | * @param show Whether or not the item sizes should be shown. 237 | * @return An instance of this FileBrowserView to allow method chaining. 238 | */ 239 | public FileBrowserView showItemSizes(boolean show) { 240 | mShowItemSizes = show; 241 | return this; 242 | } 243 | 244 | /** 245 | * Sets whether or not each file/folder's icon should be displayed next to the name (defaults 246 | * to true). Note that this method will have no effect if you use your own adapter via 247 | * {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 248 | * 249 | * @param show Whether or not the icon should be shown. 250 | * @return An instance of this FileBrowserView to allow method chaining. 251 | */ 252 | public FileBrowserView showItemIcons(boolean show) { 253 | mShowIcons = show; 254 | return this; 255 | } 256 | 257 | /** 258 | * @param navInterface The navigation interface to assign to this view. 259 | * @return An instance of this FileBrowserView to allow method chaining 260 | */ 261 | public FileBrowserView setNavigationInterface(NavigationInterface navInterface) { 262 | mNavigationInterface = navInterface; 263 | return this; 264 | } 265 | 266 | /** 267 | * Sets whether or not tabbed browsing should be enabled. If you pass true, 268 | * a TabHost will be placed above the FileBrowserView and will allow the user 269 | * to open new tabs to browse the filesystem (à la Google Chrome tab browsing). 270 | * 271 | * @param enable Whether or not tabbed browsing should be enabled. 272 | * @return An instance of this FileBrowserView to allow method chaining. 273 | */ 274 | public FileBrowserView enableTabbedBrowsing(boolean enable) { 275 | mTabbedBrowsingEnabled = enable; 276 | return this; 277 | } 278 | 279 | /** 280 | * Prevents the browser from displaying files that match any of the file extensions that are 281 | * passed in via the param fileExtensions. Calling this method is optional; not calling it or 282 | * passing in an empty list will cause all files to be displayed regardless of their extensions. 283 | * 284 | * @param fileExtensions An ArrayList that contains string representations of the 285 | * extensions of the files to hide in the browser. The file 286 | * extension must be formatted like this: ".xxx", where xxx is 287 | * the file extension. 288 | * 289 | * @param showFolders Sets whether folders should be displayed in the view or not. Useful for 290 | * displaying a static view of the current folder with no way to navigate 291 | * away from it. 292 | * 293 | * @return An instance of this FileBrowserView to allow method chaining. 294 | */ 295 | public FileBrowserView excludeFileTypes(ArrayList fileExtensions, boolean showFolders) { 296 | if (fileExtensions==null) 297 | return this; 298 | 299 | mFileExtensionFilter = new FileExtensionFilter(); 300 | mShouldShowFolders = showFolders; 301 | 302 | for (int i=0; i < fileExtensions.size(); i++) { 303 | mFileExtensionFilter.addExtension(fileExtensions.get(i)); 304 | } 305 | 306 | return this; 307 | } 308 | 309 | /** 310 | * @return The AttributeSet object associated with this view instance. 311 | */ 312 | public AttributeSet getAttributeSet() { 313 | return mAttributeSet; 314 | } 315 | 316 | /** 317 | * @return The current layout type for this FileBrowserView instance. 318 | */ 319 | public int getFileBrowserLayoutType() { 320 | return mFileBrowserLayoutType; 321 | } 322 | 323 | /** 324 | * @return A File object that points to the default directory that should be 325 | * displayed for this FileBrowserView instance. 326 | */ 327 | public File getDefaultDirectory() { 328 | return mDefaultDir; 329 | } 330 | 331 | /** 332 | * @return Whether or not hidden files/folders should be displayed. 333 | */ 334 | public boolean shouldShowHiddenFiles() { 335 | return mShowHiddenFiles; 336 | } 337 | 338 | /** 339 | * @return The file browser engine instance for this view. 340 | */ 341 | public FileBrowserEngine getFileBrowserEngine() { 342 | return mFileBrowserEngine; 343 | } 344 | 345 | /** 346 | * @return The File object that represents the current directory. 347 | */ 348 | public File getCurrentDir() { 349 | return mFileBrowserEngine.getCurrentDir(); 350 | } 351 | 352 | /** 353 | * @return The File object that represents the current directory's parent dir. 354 | * Returns null if the current directory doesn't have a parent dir. 355 | */ 356 | public File getParentDir() { 357 | return getCurrentDir().getParentFile(); 358 | } 359 | 360 | /** 361 | * @return The adapter that backs the list/grid view for FileBrowserView instance. 362 | */ 363 | public AbstractFileBrowserAdapter getFileBrowserAdapter() { 364 | return mAdapter; 365 | } 366 | 367 | /** 368 | * @return The list/grid view that displays the file system. Note that this method 369 | * does not return the specific subclass (ListView/GridView). You must manually 370 | * cast the returned object as a ListView or a GridView to fully access each 371 | * view's functionality. 372 | */ 373 | public AbsListView getAbsListView() { 374 | return mFileBrowserLayout.getAbsListView(); 375 | } 376 | 377 | /** 378 | * @return Whether or not each individual item's overflow menu should be displayed in the 379 | * AbsListView. The returned value has no effect if you are using a custom adapter 380 | * via {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 381 | */ 382 | public boolean shouldShowOverflowMenus() { 383 | return mShowOverflowMenus; 384 | } 385 | 386 | /** 387 | * @return Whether or not each individual item's size should be displayed in the AbsListView. 388 | * The returned value has no effect if you are using a custom adapter via 389 | * {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 390 | */ 391 | public boolean shouldShowItemSizes() { 392 | return mShowItemSizes; 393 | } 394 | 395 | /** 396 | * @return Whether or not each individual item's icon should be displayed in the AbsListView. 397 | * The returned value has no effect if you are using a custom adapter via 398 | * {@link #setCustomAdapter(AbstractFileBrowserAdapter)}. 399 | */ 400 | public boolean shouldShowItemIcons() { 401 | return mShowIcons; 402 | 403 | } 404 | 405 | /** 406 | * @return Whether tabbed browsing is enabled or not for this FileBrowserView instance. 407 | */ 408 | public boolean isTabbedBrowsingEnabled() { 409 | return mTabbedBrowsingEnabled; 410 | } 411 | 412 | /** 413 | * @return The FileExtensionFilter extension that is currently in use for this FileBrowserView. 414 | */ 415 | public FileExtensionFilter getFileExtensionFilter() { 416 | return mFileExtensionFilter; 417 | } 418 | 419 | /** 420 | * @return Whether or not folders should be shown in the browser. 421 | */ 422 | public boolean shouldShowFolders() { 423 | return mShouldShowFolders; 424 | } 425 | 426 | } 427 | -------------------------------------------------------------------------------- /library/src/main/java/com/psaravan/filebrowserview/lib/View/TabsContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Saravan Pantham 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.psaravan.filebrowserview.lib.View; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.FrameLayout; 23 | import android.widget.ImageView; 24 | import android.widget.TabHost; 25 | import android.widget.TabWidget; 26 | 27 | import com.psaravan.filebrowserview.lib.GridLayout.GridLayoutView; 28 | import com.psaravan.filebrowserview.lib.ListLayout.ListLayoutView; 29 | import com.psaravan.filebrowserview.lib.R; 30 | 31 | import java.io.File; 32 | 33 | /** 34 | * Container view for tabbed browsing. Includes the TabHost, 35 | * TabWidget, and the actual tab content. If tabbed browsing 36 | * is enabled, this view becomes the direct child of the 37 | * parent FileBrowserView instance. Each tab will then host 38 | * either a {@link com.psaravan.filebrowserview.lib.ListLayout.ListLayoutView} view 39 | * or a {@link com.psaravan.filebrowserview.lib.GridLayout.GridLayoutView} view. 40 | * 41 | * @author Saravan Pantham 42 | */ 43 | public class TabsContainer extends View { 44 | 45 | private Context mContext; 46 | private FileBrowserView mFileBrowserView; 47 | protected TabHost mTabHost; 48 | protected TabWidget mTabWidget; 49 | protected ImageView mNewTabButton; 50 | protected FrameLayout mTabContentLayout; 51 | 52 | public TabsContainer(Context context, FileBrowserView fileBrowserView) { 53 | super(context); 54 | mContext = context; 55 | mFileBrowserView = fileBrowserView; 56 | 57 | } 58 | 59 | public TabsContainer(Context context, AttributeSet attrs, FileBrowserView fileBrowserView) { 60 | super(context, attrs); 61 | mContext = context; 62 | mFileBrowserView = fileBrowserView; 63 | 64 | } 65 | 66 | /** 67 | * Initializes this view instance and opens the default tab/directory structure. Also 68 | * attaches a "New Tab" button to the TabWidget. 69 | * 70 | * @param viewGroup The ViewGroup to inflate the layout into. 71 | * @return The {@link com.psaravan.filebrowserview.lib.View.BaseLayoutView} instance that 72 | * is inflated inside the default tab. 73 | * 74 | */ 75 | public BaseLayoutView init(ViewGroup viewGroup) { 76 | 77 | //Initialize the tabbed container. 78 | View view = View.inflate(mContext, R.layout.tabbed_browser_container, viewGroup); 79 | mTabHost = (TabHost) view.findViewById(R.id.tabHost); 80 | mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs); 81 | mNewTabButton = (ImageView) view.findViewById(R.id.new_tab_button); 82 | mTabContentLayout = (FrameLayout) view.findViewById(android.R.id.tabcontent); 83 | mNewTabButton.setOnClickListener(newTabClickListener); 84 | 85 | //Initialize the TabHost. 86 | mTabHost.setup(); 87 | 88 | //Open the default tab. 89 | return openNewBrowserTab(mFileBrowserView.getDefaultDirectory()); 90 | } 91 | 92 | /** 93 | * Opens a brand new browser tab. 94 | * 95 | * @param directory The directory to open when this tab is initialized. 96 | */ 97 | protected BaseLayoutView openNewBrowserTab(File directory) { 98 | 99 | //Inflate the view's layout based on the selected layout. 100 | BaseLayoutView contentView = null; 101 | if (mFileBrowserView.getFileBrowserLayoutType()==FileBrowserView.FILE_BROWSER_LIST_LAYOUT) 102 | contentView = new ListLayoutView(mContext, mFileBrowserView.getAttributeSet(), mFileBrowserView).init(mTabContentLayout); 103 | else 104 | contentView = new GridLayoutView(mContext, mFileBrowserView.getAttributeSet(), mFileBrowserView).init(mTabContentLayout); 105 | 106 | //Add a new layout to the TabHost. 107 | contentView.setId(mTabHost.getTabWidget().getTabCount() + 1); 108 | mTabContentLayout.addView(contentView); 109 | 110 | //Add the new tab to the TabHost. 111 | String directoryName = directory.getAbsoluteFile().getName(); 112 | TabHost.TabSpec newTabSpec = mTabHost.newTabSpec(directoryName); 113 | newTabSpec.setIndicator(directoryName); 114 | newTabSpec.setContent(mTabHost.getTabWidget().getTabCount() + 1); 115 | mTabHost.addTab(newTabSpec); 116 | 117 | return contentView; 118 | } 119 | 120 | /** 121 | * Click listener for the "New Tab" button. 122 | */ 123 | private OnClickListener newTabClickListener = new OnClickListener() { 124 | 125 | @Override 126 | public void onClick(View v) { 127 | openNewBrowserTab(mFileBrowserView.getDefaultDirectory()); 128 | } 129 | 130 | }; 131 | 132 | } 133 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_action_new.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_action_new_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_action_new_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_action_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_action_overflow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_action_overflow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_action_overflow_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_action_overflow_universal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_action_overflow_universal.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_apk.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_archive.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_avi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_avi.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_default.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_folderblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_folderblue.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_html.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_js.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_mp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_mp3.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_png.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_spreadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_spreadsheet.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/icon_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-hdpi/icon_text.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_action_new.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_action_new_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_action_new_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_action_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_action_overflow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_action_overflow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_action_overflow_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_action_overflow_universal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_action_overflow_universal.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_apk.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_archive.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_avi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_avi.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_default.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_folderblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_folderblue.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_html.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_js.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_mp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_mp3.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_png.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_spreadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_spreadsheet.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/icon_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-mdpi/icon_text.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_action_new.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_action_new_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_action_new_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_action_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_action_overflow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_action_overflow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_action_overflow_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_action_overflow_universal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_action_overflow_universal.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_apk.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_archive.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_avi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_avi.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_default.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_folderblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_folderblue.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_html.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_js.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_mp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_mp3.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_png.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_spreadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_spreadsheet.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xhdpi/icon_text.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_action_new.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_action_new_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_action_new_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_action_overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_action_overflow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_action_overflow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_action_overflow_light.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_action_overflow_universal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_action_overflow_universal.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_apk.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_archive.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_avi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_avi.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_default.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_folderblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_folderblue.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_html.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_js.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_mp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_mp3.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_png.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_spreadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_spreadsheet.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/icon_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psaravan/FileBrowserView/7ca90cfd198932a423411d3eded98d87e5f2b46c/library/src/main/res/drawable-xxhdpi/icon_text.png -------------------------------------------------------------------------------- /library/src/main/res/drawable/empty_color_patch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/empty_color_patch_circular.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/empty_color_patch_circular_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/empty_color_patch_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/layout/grid_view_item.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 | 22 | 23 | 28 | 29 | 41 | 42 | 53 | 54 | 55 | 56 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /library/src/main/res/layout/list_view_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 19 | 20 | 31 | 32 | 40 | 41 | 45 | 46 | 61 | 62 | 63 | 64 | 69 | 70 | 85 | 86 | 87 | 88 | 89 | 90 | 101 | 102 | -------------------------------------------------------------------------------- /library/src/main/res/layout/simple_grid_file_browser.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 13 | 14 | 15 | 25 | 26 | -------------------------------------------------------------------------------- /library/src/main/res/layout/simple_list_file_browser.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 13 | 14 | 15 | 21 | 22 | -------------------------------------------------------------------------------- /library/src/main/res/layout/tabbed_browser_container.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 17 | 18 | 22 | 23 | 30 | 31 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /library/src/main/res/menu/filesystem_ops_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | -------------------------------------------------------------------------------- /library/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 78dp 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | type 4 | path 5 | name 6 | size 7 | position 8 | 9 | Delete 10 | Copy 11 | Move 12 | Rename 13 | Paste 14 | Run in background 15 | 16 | Deleting 17 | deleted. 18 | could not be deleted. 19 | 20 | Copying 21 | copied. 22 | could not be copied. 23 | 24 | Moving 25 | moved. 26 | could not be moved. 27 | 28 | Unable to load folder. 29 | Unable to open file. 30 | 31 | 32 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':demo-app', ':library' 2 | --------------------------------------------------------------------------------