├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── koma │ │ └── filemanager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── koma │ │ │ └── filemanager │ │ │ ├── FileManagerApplication.java │ │ │ ├── archive │ │ │ ├── ArchiveActivity.java │ │ │ ├── ArchiveAdapter.java │ │ │ ├── ArchiveContract.java │ │ │ ├── ArchiveFragment.java │ │ │ └── ArchivePresenter.java │ │ │ ├── audio │ │ │ ├── AudioActivity.java │ │ │ ├── AudioAdapter.java │ │ │ ├── AudioConstract.java │ │ │ ├── AudioFragment.java │ │ │ ├── AudioPlayerActivity.java │ │ │ └── AudioPresenter.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseAdapter.java │ │ │ ├── BaseFile.java │ │ │ ├── BaseFragment.java │ │ │ ├── BaseMenuActivity.java │ │ │ ├── BasePresenter.java │ │ │ ├── BaseSelectableAdapter.java │ │ │ ├── BaseSwipeBackActivity.java │ │ │ ├── BaseView.java │ │ │ └── BaseViewHolder.java │ │ │ ├── data │ │ │ ├── FileDataSource.java │ │ │ ├── FileRepository.java │ │ │ ├── LocalDataSource.java │ │ │ └── model │ │ │ │ ├── ApkFile.java │ │ │ │ ├── AudioFile.java │ │ │ │ ├── Disk.java │ │ │ │ ├── DocumentFile.java │ │ │ │ ├── ImageFile.java │ │ │ │ ├── VideoFile.java │ │ │ │ └── ZipFile.java │ │ │ ├── filecategory │ │ │ ├── FileCategoryActivity.java │ │ │ ├── FileCategoryAdapter.java │ │ │ ├── FileCategoryContract.java │ │ │ ├── FileCategoryFragment.java │ │ │ └── FileCategoryPresenter.java │ │ │ ├── fileview │ │ │ ├── FileViewActivity.java │ │ │ ├── FileViewAdapter.java │ │ │ ├── FileViewContract.java │ │ │ ├── FileViewFragment.java │ │ │ └── FileViewPresenter.java │ │ │ ├── helper │ │ │ ├── ActionModeHelper.java │ │ │ ├── FileCountHelper.java │ │ │ ├── FileHelper.java │ │ │ ├── FileSortHelper.java │ │ │ ├── ImageLoder.java │ │ │ ├── MeidaHelper.java │ │ │ ├── RxBus.java │ │ │ ├── SelectHelper.java │ │ │ └── event │ │ │ │ ├── SelectEvent.java │ │ │ │ └── SortEvent.java │ │ │ ├── image │ │ │ ├── ImageActivity.java │ │ │ ├── ImageAdapter.java │ │ │ ├── ImageConstract.java │ │ │ ├── ImageFragment.java │ │ │ └── ImagePresenter.java │ │ │ ├── main │ │ │ ├── DiskAdapter.java │ │ │ ├── MainActivity.java │ │ │ ├── MainContract.java │ │ │ └── MainPresenter.java │ │ │ ├── search │ │ │ ├── SearchActivity.java │ │ │ ├── SearchContract.java │ │ │ ├── SearchFragment.java │ │ │ └── SearchPresenter.java │ │ │ ├── splash │ │ │ └── SplashActivity.java │ │ │ ├── util │ │ │ ├── BlurUtils.java │ │ │ ├── Constants.java │ │ │ ├── FileCategoryUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── LocaleUtils.java │ │ │ ├── LogUtils.java │ │ │ └── Utils.java │ │ │ ├── video │ │ │ ├── VideoActivity.java │ │ │ ├── VideoContract.java │ │ │ ├── VideoFragment.java │ │ │ └── VideoPresenter.java │ │ │ ├── volumeinfo │ │ │ ├── VolumeInfoActivity.java │ │ │ ├── VolumeInfoAdapter.java │ │ │ ├── VolumeInfoContract.java │ │ │ ├── VolumeInfoFragment.java │ │ │ └── VolumeInfoPresenter.java │ │ │ └── widget │ │ │ ├── CategoryButton.java │ │ │ ├── DividerItemDecoration.java │ │ │ ├── FastScroller.java │ │ │ ├── InputNameDialog.java │ │ │ └── LoadingView.java │ └── res │ │ ├── drawable │ │ ├── fast_scroller_bubble.xml │ │ ├── fast_scroller_handle.xml │ │ ├── ic_add.xml │ │ ├── ic_back.xml │ │ ├── ic_create_new_folder_black_24dp.xml │ │ ├── ic_cut.xml │ │ ├── ic_cut_grey_24dp.xml │ │ ├── ic_cut_white_24dp.xml │ │ ├── ic_delete.xml │ │ ├── ic_delete_grey_24dp.xml │ │ ├── ic_delete_white_24dp.xml │ │ ├── ic_favorite.xml │ │ ├── ic_filter_list.xml │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_slideshow.xml │ │ ├── ic_more_vert.xml │ │ ├── ic_more_vert_grey_24dp.xml │ │ ├── ic_more_vert_white_24dp.xml │ │ ├── ic_search.xml │ │ ├── ic_settings.xml │ │ ├── ic_share.xml │ │ ├── ic_share_grey_24dp.xml │ │ ├── ic_share_white_24dp.xml │ │ ├── ic_unfavorite.xml │ │ ├── progress_bar.xml │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── action_mode_view.xml │ │ ├── activity_main.xml │ │ ├── app_bar_main.xml │ │ ├── archive_item_view.xml │ │ ├── category_button_layout.xml │ │ ├── common_layout.xml │ │ ├── content_main.xml │ │ ├── divider_line.xml │ │ ├── fast_scroller.xml │ │ ├── fragment_volume_info.xml │ │ ├── input_name_dialog_layout.xml │ │ ├── item_disk.xml │ │ ├── item_view.xml │ │ ├── item_view_volume_info.xml │ │ ├── library_fast_scroller_layout.xml │ │ ├── loading_view.xml │ │ ├── nav_header_main.xml │ │ ├── recyclerview.xml │ │ └── splashactivity_layout.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ ├── common_menu.xml │ │ ├── main.xml │ │ ├── menu_sort.xml │ │ └── select_mode_menu.xml │ │ ├── mipmap-xhdpi │ │ ├── category_apk.png │ │ ├── category_audio.png │ │ ├── category_doc.png │ │ ├── category_image.png │ │ ├── category_video.png │ │ ├── category_zip.png │ │ ├── defaut_image.png │ │ ├── empty_icon.png │ │ ├── ic_dropdown.png │ │ ├── ic_launcher.png │ │ ├── ic_menu_share.png │ │ ├── item_audio.png │ │ ├── item_compress.png │ │ ├── item_document.png │ │ ├── item_folder.png │ │ ├── item_ppt.png │ │ ├── item_text.png │ │ ├── item_video.png │ │ └── item_xls.png │ │ ├── mipmap-xxhdpi │ │ ├── category_apk.png │ │ ├── category_audio.png │ │ ├── category_doc.png │ │ ├── category_file_icon_video.png │ │ ├── category_image.png │ │ ├── category_zip.png │ │ ├── ic_launcher.png │ │ ├── item_app.png │ │ ├── item_audio.png │ │ ├── item_compress.png │ │ ├── item_folder.png │ │ └── item_video.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ ├── values │ │ ├── arrays.xml │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── searchable.xml │ └── test │ └── java │ └── com │ └── koma │ └── filemanager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── koma_key.jks ├── preview ├── screenshot_file_view.png └── screenshot_main_ui.png └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .metadata/ 2 | *~ 3 | 4 | # files for the dex VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # generated files 11 | bin/ 12 | gen/ 13 | 14 | # Local configuration file (sdk path, etc) 15 | local.properties 16 | project.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | .settings 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Intellij project files 27 | *.iml 28 | *.ipr 29 | *.iws 30 | .idea/ 31 | 32 | # Gradle file 33 | .gradle/ 34 | apks/ 35 | build/ 36 | *.iml 37 | .gradle 38 | /local.properties 39 | /.idea/workspace.xml 40 | /.idea/libraries 41 | .DS_Store 42 | /build 43 | /captures 44 | .externalNativeBuild 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FileManager 2 | =================== 3 | 4 | An android open source project about "FileManager". 5 | 6 | #Rxjava + MVP apply to this project. 7 | 8 | 附几张主界面效果图,仅供参考。 9 | 10 | 11 | 12 | 13 | Introduction: 14 | --- 15 | 主界面暂时分为两部分: 16 | 17 | 1.分类文件总览(可显示各类文件的总量) 18 | 19 | 2.挂在设备信息总览 20 | 21 | 子页面: 22 | 23 | 1.查看音频文件 24 | 25 | 2.查看视频文件(To do) 26 | 27 | 3.查看图片文件(To do) 28 | 29 | 4.查看文档文件(To do) 30 | 31 | 5.查看压缩文件 32 | 33 | 6.查看apk文件(To do) 34 | 35 | 7.查看最近添加的文件(To do) 36 | 37 | 8.查看收藏文件(To do) 38 | 39 | 9.密码锁(To do) 40 | 41 | --- 42 | 43 | Licence 44 | 45 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'android-apt' 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | buildToolsVersion rootProject.ext.buildToolsVersion 6 | defaultConfig { 7 | applicationId "com.koma.filemanager" 8 | minSdkVersion rootProject.ext.minSdkVersion 9 | targetSdkVersion rootProject.ext.targetSdkVersion 10 | versionCode rootProject.ext.versionCode 11 | versionName rootProject.ext.versionName 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | renderscriptTargetApi rootProject.ext.renderscriptTargetApi 14 | renderscriptSupportModeEnabled true 15 | } 16 | //签名配置 17 | signingConfigs { 18 | release { 19 | storeFile file(STORE_FILE_PATH) 20 | storePassword STORE_PASSWORD 21 | keyAlias KEY_ALIAS 22 | keyPassword KEY_PASSWORD 23 | } 24 | } 25 | 26 | buildTypes { 27 | release { 28 | //是否签名 29 | signingConfig signingConfigs.release 30 | //是否混淆 31 | minifyEnabled false 32 | useProguard false 33 | shrinkResources false // 是否去除无效的资源文件 34 | //是否移除无用资源 35 | zipAlignEnabled true 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | } 38 | } 39 | 40 | lintOptions { 41 | disable 'InvalidPackage' 42 | checkReleaseBuilds false 43 | // Or, if you prefer, you can continue to check for errors in release builds, 44 | // but continue the build even when errors are found: 45 | abortOnError false 46 | } 47 | } 48 | 49 | dependencies { 50 | compile fileTree(dir: 'libs', include: ['*.jar']) 51 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 52 | exclude group: 'com.android.support', module: 'support-annotations' 53 | }) 54 | compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion" 55 | compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion" 56 | compile "com.android.support:design:$rootProject.ext.supportLibraryVersion" 57 | compile "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion" 58 | testCompile 'junit:junit:4.12' 59 | 60 | compile "com.jakewharton:butterknife:$rootProject.ext.butterknife" 61 | apt "com.jakewharton:butterknife-compiler:$rootProject.ext.butterknife" 62 | 63 | compile "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion" 64 | 65 | compile "io.reactivex:rxandroid:$rootProject.ext.rxandroidVersion" 66 | // Because RxAndroid releases are few and far between, it is recommended you also 67 | // explicitly depend on RxJava's latest version for bug fixes and new features. 68 | compile "io.reactivex:rxjava:$rootProject.ext.rxjavaVersion" 69 | 70 | //leakcanary 71 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5' 72 | //releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' 73 | releaseCompile 'com.squareup.leakcanary:leakcanary-android:1.5' 74 | testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' 75 | } 76 | android.applicationVariants.all { variant -> 77 | variant.outputs.each { output -> 78 | // 删除unaligned apk 79 | if (output.zipAlign != null) { 80 | output.zipAlign.doLast { 81 | output.zipAlign.inputFile.delete() 82 | } 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /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 /home/koma/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/koma/filemanager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.koma.filemanager", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 19 | 20 | 25 | 26 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 42 | 43 | 48 | 52 | 57 | 62 | 63 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/FileManagerApplication.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.os.Build; 6 | import android.os.StrictMode; 7 | 8 | import com.squareup.leakcanary.LeakCanary; 9 | 10 | /** 11 | * Created by koma on 11/17/16. 12 | */ 13 | 14 | public class FileManagerApplication extends Application { 15 | private static Context sContext; 16 | 17 | @Override 18 | public void onCreate() { 19 | super.onCreate(); 20 | sContext = getApplicationContext(); 21 | enabledStrictMode(); 22 | if (LeakCanary.isInAnalyzerProcess(this)) { 23 | // This process is dedicated to LeakCanary for heap analysis. 24 | // You should not init your app in this process. 25 | return; 26 | } 27 | LeakCanary.install(this); 28 | } 29 | 30 | public static synchronized Context getContext() { 31 | return sContext; 32 | } 33 | 34 | private void enabledStrictMode() { 35 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { 36 | 37 | //线程监控,会弹出对话框 38 | StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() 39 | .detectAll() 40 | .penaltyLog() 41 | .penaltyDialog() 42 | .build()); 43 | 44 | //VM监控 45 | StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() 46 | .detectAll() 47 | .penaltyLog() 48 | .build()); 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/archive/ArchiveActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.archive; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.FragmentTransaction; 6 | import android.support.v7.widget.Toolbar; 7 | import android.text.TextUtils; 8 | 9 | import com.koma.filemanager.R; 10 | import com.koma.filemanager.base.BaseSwipeBackActivity; 11 | import com.koma.filemanager.data.FileRepository; 12 | import com.koma.filemanager.util.LogUtils; 13 | 14 | import butterknife.BindString; 15 | import butterknife.BindView; 16 | 17 | /** 18 | * Created by koma on 12/12/16. 19 | */ 20 | 21 | public class ArchiveActivity extends BaseSwipeBackActivity { 22 | private static final String TAG = "ArchiveActivity"; 23 | private ArchiveContract.Presenter mPresenter; 24 | private String mPath; 25 | @BindView(R.id.toolbar) 26 | Toolbar mToolbar; 27 | @BindString(R.string.uncompress_to) 28 | String mUnCompressToStr; 29 | 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | LogUtils.i(TAG, "onCreate"); 34 | String action = getIntent().getAction(); 35 | // 检查action是否正确 36 | if (null == action || !TextUtils.equals(action, Intent.ACTION_VIEW)) { 37 | finish(); 38 | } 39 | init(); 40 | } 41 | 42 | private void init() { 43 | setSupportActionBar(mToolbar); 44 | ArchiveFragment archiveFragment = (ArchiveFragment) getSupportFragmentManager().findFragmentById(R.id.content); 45 | if (archiveFragment == null) { 46 | archiveFragment = new ArchiveFragment(); 47 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 48 | transaction.replace(R.id.content, archiveFragment).commit(); 49 | } 50 | mPresenter = new ArchivePresenter(archiveFragment, FileRepository.getInstance()); 51 | mPath = mPresenter.getPathFromUri(getIntent().getData()); 52 | if (TextUtils.isEmpty(mPath)) { 53 | LogUtils.i(TAG, "the path is empty"); 54 | } 55 | } 56 | 57 | @Override 58 | public void onStart() { 59 | super.onStart(); 60 | LogUtils.i(TAG, "onStart"); 61 | } 62 | 63 | @Override 64 | public void onResume() { 65 | super.onResume(); 66 | LogUtils.i(TAG, "onResume"); 67 | } 68 | 69 | 70 | @Override 71 | public void onPause() { 72 | super.onPause(); 73 | LogUtils.i(TAG, "onPause"); 74 | } 75 | 76 | @Override 77 | public void onStop() { 78 | super.onStop(); 79 | LogUtils.i(TAG, "onStop"); 80 | } 81 | 82 | @Override 83 | public void onDestroy() { 84 | super.onDestroy(); 85 | LogUtils.i(TAG, "onDestroy"); 86 | if (mPresenter != null) { 87 | mPresenter.unSubscribe(); 88 | } 89 | } 90 | 91 | @Override 92 | protected int getLayoutId() { 93 | return R.layout.common_layout; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/archive/ArchiveAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.archive; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import com.koma.filemanager.R; 11 | import com.koma.filemanager.data.model.Disk; 12 | 13 | import java.util.List; 14 | 15 | import butterknife.BindView; 16 | import butterknife.ButterKnife; 17 | 18 | /** 19 | * Created by koma on 12/12/16. 20 | */ 21 | 22 | public class ArchiveAdapter extends RecyclerView.Adapter { 23 | private static final String TAG = "ArchiveAdapter"; 24 | private Context mContext; 25 | private List mData; 26 | 27 | public ArchiveAdapter(Context context, List data) { 28 | mContext = context; 29 | mData = data; 30 | } 31 | 32 | @Override 33 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 34 | View view = LayoutInflater.from(mContext).inflate(R.layout.archive_item_view, null); 35 | return new ViewHolder(view); 36 | } 37 | 38 | @Override 39 | public void onBindViewHolder(ViewHolder holder, int position) { 40 | holder.mVolumeTitle.setText(mData.get(position).getDescription()); 41 | } 42 | 43 | @Override 44 | public int getItemCount() { 45 | return mData == null ? 0 : mData.size(); 46 | } 47 | 48 | public class ViewHolder extends RecyclerView.ViewHolder { 49 | @BindView(R.id.tv_volume_title) 50 | TextView mVolumeTitle; 51 | 52 | public ViewHolder(View view) { 53 | super(view); 54 | ButterKnife.bind(this, view); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/archive/ArchiveContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.archive; 2 | 3 | import android.net.Uri; 4 | 5 | import com.koma.filemanager.base.BasePresenter; 6 | import com.koma.filemanager.base.BaseView; 7 | import com.koma.filemanager.data.model.Disk; 8 | 9 | import java.util.ArrayList; 10 | 11 | /** 12 | * Created by koma on 12/12/16. 13 | */ 14 | 15 | public interface ArchiveContract { 16 | interface View extends BaseView { 17 | void refreshAdapter(ArrayList disks); 18 | 19 | void showCompleted(); 20 | 21 | void showError(); 22 | } 23 | 24 | interface Presenter extends BasePresenter { 25 | void loadDisks(); 26 | 27 | void startArchive(); 28 | 29 | void endArchive(); 30 | 31 | String getPathFromUri(Uri uri); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/archive/ArchiveFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.archive; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.koma.filemanager.R; 12 | import com.koma.filemanager.base.BaseFragment; 13 | import com.koma.filemanager.data.model.Disk; 14 | import com.koma.filemanager.util.LogUtils; 15 | 16 | import java.util.ArrayList; 17 | 18 | import butterknife.BindView; 19 | import butterknife.ButterKnife; 20 | 21 | /** 22 | * Created by koma on 12/12/16. 23 | */ 24 | 25 | public class ArchiveFragment extends BaseFragment implements ArchiveContract.View { 26 | private static final String TAG = "ArchiveFragment"; 27 | @NonNull 28 | private ArchiveContract.Presenter mPresenter; 29 | @BindView(R.id.recycler_view) 30 | RecyclerView mRecyclerView; 31 | private ArrayList mData; 32 | private ArchiveAdapter mAdapter; 33 | 34 | @Override 35 | public void onActivityCreated(Bundle savedInstanceState) { 36 | super.onActivityCreated(savedInstanceState); 37 | LogUtils.i(TAG, "onActivtyCreated"); 38 | } 39 | 40 | @Override 41 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 42 | LogUtils.i(TAG, "onCreateView"); 43 | View view = inflater.inflate(R.layout.recyclerview, container, false); 44 | ButterKnife.bind(this, view); 45 | init(); 46 | return view; 47 | } 48 | 49 | private void init() { 50 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext); 51 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); 52 | mRecyclerView.setLayoutManager(linearLayoutManager); 53 | mData = new ArrayList<>(); 54 | mAdapter = new ArchiveAdapter(mContext, mData); 55 | mRecyclerView.setAdapter(mAdapter); 56 | 57 | } 58 | 59 | @Override 60 | public void onViewCreated(View view, Bundle savedInstanceState) { 61 | super.onViewCreated(view, savedInstanceState); 62 | LogUtils.i(TAG, "onViewCreated"); 63 | if (mPresenter != null) { 64 | mPresenter.subscribe(); 65 | } 66 | } 67 | 68 | @Override 69 | public void onResume() { 70 | super.onResume(); 71 | LogUtils.i(TAG, "onResume"); 72 | if (mPresenter != null) { 73 | mPresenter.loadDisks(); 74 | } 75 | } 76 | 77 | @Override 78 | public void onDestroyView() { 79 | super.onDestroyView(); 80 | LogUtils.i(TAG, "onDestroyView"); 81 | if (mPresenter != null) { 82 | mPresenter.unSubscribe(); 83 | } 84 | } 85 | 86 | @Override 87 | public void refreshAdapter(ArrayList disks) { 88 | LogUtils.i(TAG, "refershAdapter"); 89 | if (mData != null) { 90 | mData.clear(); 91 | } else { 92 | mData = new ArrayList<>(); 93 | } 94 | mData.addAll(disks); 95 | mAdapter.notifyDataSetChanged(); 96 | } 97 | 98 | @Override 99 | public void showCompleted() { 100 | LogUtils.i(TAG, "showCompleted"); 101 | } 102 | 103 | @Override 104 | public void showError() { 105 | LogUtils.i(TAG, "showError"); 106 | } 107 | 108 | @Override 109 | public void setPresenter(@NonNull ArchiveContract.Presenter presenter) { 110 | LogUtils.i(TAG, "setPresenter"); 111 | mPresenter = presenter; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/archive/ArchivePresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.archive; 2 | 3 | 4 | import android.content.ContentResolver; 5 | import android.net.Uri; 6 | import android.support.annotation.NonNull; 7 | 8 | import com.koma.filemanager.data.FileRepository; 9 | import com.koma.filemanager.data.model.Disk; 10 | import com.koma.filemanager.util.LogUtils; 11 | 12 | import java.util.ArrayList; 13 | 14 | import rx.Subscriber; 15 | import rx.Subscription; 16 | import rx.android.schedulers.AndroidSchedulers; 17 | import rx.schedulers.Schedulers; 18 | import rx.subscriptions.CompositeSubscription; 19 | 20 | /** 21 | * Created by koma on 12/12/16. 22 | */ 23 | 24 | public class ArchivePresenter implements ArchiveContract.Presenter { 25 | private static final String TAG = "ArchivePresenter"; 26 | @NonNull 27 | private ArchiveContract.View mView; 28 | @NonNull 29 | private FileRepository mRespository; 30 | private CompositeSubscription mSubsriptions; 31 | private Subscription mDisksSubscription; 32 | 33 | public ArchivePresenter(@NonNull ArchiveContract.View view, FileRepository repository) { 34 | mView = view; 35 | mView.setPresenter(this); 36 | mRespository = repository; 37 | } 38 | 39 | private Subscriber> mDisksSubscriber = new Subscriber>() { 40 | @Override 41 | public void onCompleted() { 42 | LogUtils.i(TAG, "onCompleted"); 43 | } 44 | 45 | @Override 46 | public void onError(Throwable e) { 47 | LogUtils.i(TAG, "onError :" + e.toString()); 48 | } 49 | 50 | @Override 51 | public void onNext(ArrayList disks) { 52 | LogUtils.i(TAG, "onNext"); 53 | if (mView != null) { 54 | mView.refreshAdapter(disks); 55 | } 56 | } 57 | 58 | }; 59 | 60 | @Override 61 | public void loadDisks() { 62 | if (mSubsriptions != null && mDisksSubscription != null) { 63 | mSubsriptions.remove(mDisksSubscription); 64 | } 65 | mDisksSubscription = mRespository.getDisks().subscribeOn(Schedulers.io()) 66 | .observeOn(AndroidSchedulers.mainThread()) 67 | .subscribe(mDisksSubscriber); 68 | mSubsriptions.add(mDisksSubscription); 69 | } 70 | 71 | @Override 72 | public void startArchive() { 73 | LogUtils.i(TAG, "startArchive"); 74 | } 75 | 76 | @Override 77 | public void endArchive() { 78 | LogUtils.i(TAG, "endArchive"); 79 | } 80 | 81 | @Override 82 | public void subscribe() { 83 | LogUtils.i(TAG, "subscribe"); 84 | if (mSubsriptions == null) { 85 | mSubsriptions = new CompositeSubscription(); 86 | } 87 | } 88 | 89 | @Override 90 | public String getPathFromUri(Uri uri) { 91 | if (null == uri) { 92 | return null; 93 | } 94 | final String scheme = uri.getScheme(); 95 | String path = null; 96 | if (null == scheme || ContentResolver.SCHEME_FILE.equals(scheme)) { 97 | path = uri.getPath(); 98 | } 99 | return path; 100 | } 101 | 102 | @Override 103 | public void unSubscribe() { 104 | LogUtils.i(TAG, "unSubscribe"); 105 | if (mSubsriptions != null) { 106 | mSubsriptions.clear(); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/audio/AudioActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.audio; 2 | 3 | import android.database.ContentObserver; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v4.app.FragmentTransaction; 7 | import android.support.v7.widget.Toolbar; 8 | 9 | import com.koma.filemanager.R; 10 | import com.koma.filemanager.base.BaseMenuActivity; 11 | import com.koma.filemanager.data.FileRepository; 12 | import com.koma.filemanager.util.FileCategoryUtils; 13 | import com.koma.filemanager.util.LogUtils; 14 | 15 | import butterknife.BindView; 16 | 17 | /** 18 | * Created by koma on 11/19/16. 19 | */ 20 | 21 | public class AudioActivity extends BaseMenuActivity { 22 | private static final String TAG = "AudioActivity"; 23 | AudioPresenter mPresenter; 24 | 25 | @Override 26 | public void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | LogUtils.i(TAG, "onCreate"); 29 | init(); 30 | } 31 | 32 | private void init() { 33 | AudioFragment audioFragment = (AudioFragment) getSupportFragmentManager().findFragmentById(R.id.content); 34 | if (audioFragment == null) { 35 | audioFragment = new AudioFragment(); 36 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 37 | transaction.replace(R.id.content, audioFragment).commit(); 38 | } 39 | mPresenter = new AudioPresenter(audioFragment, FileRepository.getInstance()); 40 | getContentResolver().registerContentObserver(FileCategoryUtils.getAudioUri(), true, mAudioObserver); 41 | } 42 | 43 | private final ContentObserver mAudioObserver = new ContentObserver(new Handler()) { 44 | @Override 45 | public void onChange(boolean selfChange) { 46 | super.onChange(selfChange); 47 | LogUtils.i(TAG, "Audio uri change so refresh"); 48 | if (mPresenter != null) { 49 | mPresenter.getAudioFiles(); 50 | } 51 | } 52 | }; 53 | 54 | @Override 55 | public void onStart() { 56 | super.onStart(); 57 | LogUtils.i(TAG, "onStart"); 58 | } 59 | 60 | @Override 61 | public void onResume() { 62 | super.onResume(); 63 | LogUtils.i(TAG, "onResume"); 64 | } 65 | 66 | @Override 67 | public void onPause() { 68 | super.onPause(); 69 | LogUtils.i(TAG, "onPause"); 70 | } 71 | 72 | @Override 73 | public void onStop() { 74 | super.onStop(); 75 | LogUtils.i(TAG, "onStop"); 76 | } 77 | 78 | @Override 79 | public void onDestroy() { 80 | super.onDestroy(); 81 | LogUtils.i(TAG, "onDestroy"); 82 | if (mAudioObserver != null) { 83 | getContentResolver().unregisterContentObserver(mAudioObserver); 84 | } 85 | } 86 | 87 | @Override 88 | protected int getLayoutId() { 89 | return R.layout.common_layout; 90 | } 91 | 92 | @Override 93 | protected void sortByType() { 94 | 95 | } 96 | 97 | @Override 98 | protected void sortByName() { 99 | 100 | } 101 | 102 | @Override 103 | protected void sortBySize() { 104 | 105 | } 106 | 107 | @Override 108 | protected void sortByDate() { 109 | 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/audio/AudioAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.audio; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.CheckBox; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.bumptech.glide.Glide; 13 | import com.koma.filemanager.R; 14 | import com.koma.filemanager.data.model.AudioFile; 15 | import com.koma.filemanager.helper.MeidaHelper; 16 | import com.koma.filemanager.util.FileUtils; 17 | import com.koma.filemanager.util.LogUtils; 18 | 19 | import java.util.ArrayList; 20 | 21 | import butterknife.BindView; 22 | import butterknife.ButterKnife; 23 | import butterknife.OnClick; 24 | 25 | /** 26 | * Created by koma on 11/24/16. 27 | */ 28 | 29 | public class AudioAdapter extends RecyclerView.Adapter { 30 | private static final String TAG = "AudioAdapter"; 31 | private ArrayList mData; 32 | private Context mContext; 33 | 34 | public AudioAdapter(Context context, ArrayList data) { 35 | mContext = context; 36 | mData = data; 37 | } 38 | 39 | public void setData(ArrayList data) { 40 | if (mData != null) { 41 | mData.clear(); 42 | } else { 43 | mData = new ArrayList<>(); 44 | } 45 | mData.addAll(data); 46 | notifyDataSetChanged(); 47 | } 48 | 49 | @Override 50 | public AudioViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 51 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_view, null); 52 | return new AudioViewHolder(view); 53 | } 54 | 55 | 56 | @Override 57 | public int getItemCount() { 58 | return mData == null ? 0 : mData.size(); 59 | } 60 | 61 | @Override 62 | public void onBindViewHolder(AudioViewHolder holder, int position) { 63 | Glide.with(mContext).load(MeidaHelper.getAlbumArtUri(mData.get(position).getAlbumId())) 64 | .placeholder(R.mipmap.item_audio) 65 | .crossFade(1000).into(holder.mFileImage); 66 | holder.mFileName.setText(mData.get(position).getFileName()); 67 | holder.mFileSize.setText(FileUtils.formatFileSize(mData.get(position).getFileSize())); 68 | holder.mFileModifiedTime.setText(FileUtils.formatFileModifiedTime(mData.get(position).getFileModifiedTime())); 69 | } 70 | 71 | public class AudioViewHolder extends RecyclerView.ViewHolder { 72 | @BindView(R.id.select_checkbox) 73 | CheckBox mSelectBox; 74 | @BindView(R.id.iv_file_image) 75 | ImageView mFileImage; 76 | @BindView(R.id.tv_file_name) 77 | TextView mFileName; 78 | @BindView(R.id.tv_file_size) 79 | TextView mFileSize; 80 | @BindView(R.id.tv_file_modified_time) 81 | TextView mFileModifiedTime; 82 | 83 | public AudioViewHolder(View view) { 84 | super(view); 85 | ButterKnife.bind(this, view); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/audio/AudioConstract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.audio; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.AudioFile; 6 | 7 | import java.util.ArrayList; 8 | 9 | import rx.Observable; 10 | 11 | /** 12 | * Created by koma on 11/16/16. 13 | */ 14 | 15 | public interface AudioConstract { 16 | interface View extends BaseView { 17 | void refreshAdapter(ArrayList audioFiles); 18 | 19 | void showLoadingView(); 20 | 21 | void hideLoadingView(); 22 | 23 | void showEmptyView(); 24 | } 25 | 26 | interface Presenter extends BasePresenter { 27 | void getAudioFiles(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/audio/AudioPlayerActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.audio; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | 6 | import com.koma.filemanager.base.BaseSwipeBackActivity; 7 | import com.koma.filemanager.util.LogUtils; 8 | 9 | /** 10 | * Created by koma on 11/29/16. 11 | */ 12 | 13 | public class AudioPlayerActivity extends BaseSwipeBackActivity { 14 | private static String TAG = "AudioPlayerActivity"; 15 | 16 | public void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | LogUtils.i(TAG, "onCreate"); 19 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 20 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); 21 | } 22 | 23 | @Override 24 | protected int getLayoutId() { 25 | return 0; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/audio/AudioPresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.audio; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.koma.filemanager.data.FileRepository; 6 | import com.koma.filemanager.data.model.AudioFile; 7 | import com.koma.filemanager.util.LogUtils; 8 | 9 | import java.util.ArrayList; 10 | 11 | import rx.Subscriber; 12 | import rx.Subscription; 13 | import rx.android.schedulers.AndroidSchedulers; 14 | import rx.schedulers.Schedulers; 15 | import rx.subscriptions.CompositeSubscription; 16 | 17 | /** 18 | * Created by koma on 11/24/16. 19 | */ 20 | 21 | public class AudioPresenter implements AudioConstract.Presenter { 22 | private static final String TAG = "AudioPresenter"; 23 | private CompositeSubscription mSubscription; 24 | @NonNull 25 | private AudioConstract.View mView; 26 | @NonNull 27 | private FileRepository mFileRepository; 28 | private Subscription mAudioFilesSubsription; 29 | 30 | public AudioPresenter(@NonNull AudioConstract.View view, @NonNull FileRepository repository) { 31 | mFileRepository = repository; 32 | mView = view; 33 | mSubscription = new CompositeSubscription(); 34 | mView.setPresenter(this); 35 | } 36 | 37 | @Override 38 | public void subscribe() { 39 | LogUtils.i(TAG, "subscribe"); 40 | getAudioFiles(); 41 | } 42 | 43 | @Override 44 | public void unSubscribe() { 45 | LogUtils.i(TAG, "unSubscribe"); 46 | if (mSubscription != null) { 47 | mSubscription.clear(); 48 | } 49 | } 50 | 51 | @Override 52 | public void getAudioFiles() { 53 | if (mSubscription != null && mAudioFilesSubsription != null) { 54 | mSubscription.remove(mAudioFilesSubsription); 55 | } 56 | mAudioFilesSubsription = mFileRepository.getAudioFiles().subscribeOn(Schedulers.io()) 57 | .observeOn(AndroidSchedulers.mainThread()) 58 | .subscribe(new Subscriber>() { 59 | @Override 60 | public void onCompleted() { 61 | LogUtils.i(TAG, "onCompleted Thread id : " + Thread.currentThread().getId()); 62 | } 63 | 64 | @Override 65 | public void onError(Throwable e) { 66 | LogUtils.e(TAG, "error : " + e.toString()); 67 | } 68 | 69 | @Override 70 | public void onNext(ArrayList audioFiles) { 71 | LogUtils.i(TAG, "onNext Thread id : " + Thread.currentThread().getId()); 72 | if (mView != null) { 73 | if (audioFiles.size() == 0) { 74 | mView.showEmptyView(); 75 | } else { 76 | mView.hideLoadingView(); 77 | } 78 | mView.refreshAdapter(audioFiles); 79 | } 80 | } 81 | }); 82 | mSubscription.add(mAudioFilesSubsription); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.content.pm.PackageManager; 6 | import android.os.Bundle; 7 | import android.support.annotation.NonNull; 8 | import android.support.v4.app.ActivityCompat; 9 | import android.support.v4.content.ContextCompat; 10 | import android.support.v7.app.AppCompatActivity; 11 | 12 | import com.koma.filemanager.util.LogUtils; 13 | 14 | import butterknife.ButterKnife; 15 | import rx.Subscription; 16 | import rx.subscriptions.CompositeSubscription; 17 | 18 | import static com.koma.filemanager.util.Constants.PERMISSIONS_STORAGE; 19 | import static com.koma.filemanager.util.Constants.REQUEST_CODE_ASK_PERMISSIONS; 20 | 21 | /** 22 | * Created by koma on 11/16/16. 23 | */ 24 | 25 | public abstract class BaseActivity extends AppCompatActivity { 26 | private static final String TAG = "BaseActivity"; 27 | protected Context mContext; 28 | private CompositeSubscription mSubscriptions; 29 | 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | LogUtils.i(TAG, "onCreate"); 33 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) 34 | != PackageManager.PERMISSION_GRANTED || 35 | ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) 36 | != PackageManager.PERMISSION_GRANTED) { 37 | requestStoragePermissions(); 38 | } 39 | mContext = BaseActivity.this; 40 | setContentView(getLayoutId()); 41 | ButterKnife.bind(this); 42 | } 43 | 44 | @Override 45 | protected void onDestroy() { 46 | super.onDestroy(); 47 | if (mSubscriptions != null) { 48 | mSubscriptions.clear(); 49 | } 50 | } 51 | 52 | protected abstract int getLayoutId(); 53 | 54 | private void requestStoragePermissions() { 55 | if (ActivityCompat.shouldShowRequestPermissionRationale(this, 56 | Manifest.permission.READ_EXTERNAL_STORAGE) 57 | || ActivityCompat.shouldShowRequestPermissionRationale(this, 58 | Manifest.permission.WRITE_EXTERNAL_STORAGE)) { 59 | ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_CODE_ASK_PERMISSIONS); 60 | } else { 61 | // Contact permissions have not been granted yet. Request them directly. 62 | ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_CODE_ASK_PERMISSIONS); 63 | } 64 | } 65 | 66 | /** 67 | * Callback received when a permissions request has been completed. 68 | */ 69 | @Override 70 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, 71 | @NonNull int[] grantResults) { 72 | 73 | if (requestCode == REQUEST_CODE_ASK_PERMISSIONS) { 74 | // Check if the only required permission has been granted 75 | if (!verifyPermissions(grantResults)) { 76 | this.finish(); 77 | } 78 | } 79 | } 80 | 81 | private boolean verifyPermissions(int[] grantResults) { 82 | // At least one result must be checked. 83 | if (grantResults.length < 1) { 84 | return false; 85 | } 86 | 87 | // Verify that each required permission has been granted, otherwise return false. 88 | for (int result : grantResults) { 89 | if (result != PackageManager.PERMISSION_GRANTED) { 90 | return false; 91 | } 92 | } 93 | return true; 94 | } 95 | 96 | protected void addSubscription(Subscription subscription) { 97 | if (subscription == null) return; 98 | if (mSubscriptions == null) { 99 | mSubscriptions = new CompositeSubscription(); 100 | } 101 | mSubscriptions.add(subscription); 102 | } 103 | 104 | protected void clearSubsription() { 105 | if (mSubscriptions != null) { 106 | mSubscriptions.clear(); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | 6 | /** 7 | * Created by koma on 12/27/16. 8 | */ 9 | 10 | public abstract class BaseAdapter extends RecyclerView.Adapter { 11 | private static final String TAG = BaseAdapter.class.getSimpleName(); 12 | private Context mContext; 13 | public OnItemClickListener mItemClickListener; 14 | public OnItemLongClickListener mItemLongClickListener; 15 | 16 | public BaseAdapter(Context context) { 17 | mContext = context; 18 | } 19 | 20 | public void setOnItemClickListener(OnItemClickListener listener) { 21 | mItemClickListener = listener; 22 | } 23 | 24 | public void setOnItemLongClickListener(OnItemLongClickListener listener) { 25 | mItemLongClickListener = listener; 26 | } 27 | 28 | public interface OnItemClickListener { 29 | boolean onItemClick(int position); 30 | } 31 | 32 | 33 | public interface OnItemLongClickListener { 34 | void onItemLongClick(int position); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import com.koma.filemanager.helper.FileHelper; 4 | 5 | import java.io.File; 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by koma on 11/23/16. 10 | */ 11 | 12 | public class BaseFile implements Comparable { 13 | private String mFileName; 14 | private Date mFileModifiedTime; 15 | private long mFileSize; 16 | private String mParent; 17 | private boolean mIsDirectory; 18 | 19 | public BaseFile(String fileName, String parent, long fileSize, Date fileModifiedTime) { 20 | mFileName = fileName; 21 | mFileSize = fileSize; 22 | mFileModifiedTime = fileModifiedTime; 23 | mParent = parent; 24 | mIsDirectory = true; 25 | } 26 | 27 | public BaseFile(String fileName, String parent, long fileSize, Date fileModifiedTime, boolean isDirectory) { 28 | mFileName = fileName; 29 | mFileSize = fileSize; 30 | mFileModifiedTime = fileModifiedTime; 31 | mParent = parent; 32 | mIsDirectory = isDirectory; 33 | } 34 | 35 | 36 | public void setFileName(String fileName) { 37 | mFileName = fileName; 38 | } 39 | 40 | public String getFileName() { 41 | return mFileName; 42 | } 43 | 44 | public void setFileSize(long fileSize) { 45 | mFileSize = fileSize; 46 | } 47 | 48 | public long getFileSize() { 49 | return mFileSize; 50 | } 51 | 52 | public void setFileModifiedTime(Date modifiedTime) { 53 | mFileModifiedTime = modifiedTime; 54 | } 55 | 56 | public Date getFileModifiedTime() { 57 | return mFileModifiedTime; 58 | } 59 | 60 | public void setParent(String parent) { 61 | mParent = parent; 62 | } 63 | 64 | public String getParent() { 65 | return mParent; 66 | } 67 | 68 | public boolean getIsDirectory() { 69 | return mIsDirectory; 70 | } 71 | 72 | public void setIsDirectory(boolean isDirectory) { 73 | mIsDirectory = isDirectory; 74 | } 75 | 76 | public String getFullPath() { 77 | StringBuilder stringBuilder = new StringBuilder(mParent); 78 | if (FileHelper.isRootDirectory(this)) { 79 | return FileHelper.ROOT_DIRECTORY; 80 | } else if (FileHelper.isParentRootDirectory(this)) { 81 | if (this.mParent == null) { 82 | return FileHelper.ROOT_DIRECTORY + mFileName; 83 | } 84 | return stringBuilder.append(mFileName).toString(); 85 | } 86 | return stringBuilder.append(File.separator).append(mFileName).toString(); 87 | } 88 | 89 | @Override 90 | public int compareTo(BaseFile another) { 91 | String o1 = this.getFullPath(); 92 | String o2 = another.getFullPath(); 93 | return o1.compareTo(o2); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.view.View; 8 | 9 | import com.koma.filemanager.R; 10 | import com.koma.filemanager.util.LogUtils; 11 | import com.koma.filemanager.widget.LoadingView; 12 | 13 | import butterknife.BindView; 14 | import butterknife.ButterKnife; 15 | import rx.Subscription; 16 | import rx.subscriptions.CompositeSubscription; 17 | 18 | /** 19 | * Created by koma on 11/16/16. 20 | */ 21 | 22 | public class BaseFragment extends Fragment { 23 | private static final String TAG = "BaseFragment"; 24 | protected Context mContext; 25 | private CompositeSubscription mSubscriptions; 26 | @BindView(R.id.loading_view) 27 | LoadingView mLoadingView; 28 | 29 | @Override 30 | public void onAttach(Context context) { 31 | super.onAttach(context); 32 | LogUtils.i(TAG, "onAttach"); 33 | mContext = context; 34 | } 35 | 36 | @Override 37 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 38 | super.onViewCreated(view, savedInstanceState); 39 | ButterKnife.bind(this, view); 40 | } 41 | 42 | @Override 43 | public void onDestroyView() { 44 | super.onDestroyView(); 45 | if (mSubscriptions != null) { 46 | mSubscriptions.clear(); 47 | } 48 | } 49 | 50 | protected void showLoadingView() { 51 | mLoadingView.post(new Runnable() { 52 | @Override 53 | public void run() { 54 | mLoadingView.showLoding(); 55 | } 56 | }); 57 | } 58 | 59 | protected void hideLodingView() { 60 | mLoadingView.post(new Runnable() { 61 | @Override 62 | public void run() { 63 | mLoadingView.hideLoading(); 64 | } 65 | }); 66 | } 67 | 68 | protected void showLoadingEmpty() { 69 | mLoadingView.post(new Runnable() { 70 | @Override 71 | public void run() { 72 | mLoadingView.showLoadingEmpty(); 73 | } 74 | }); 75 | } 76 | 77 | protected void addSubscription(Subscription subscription) { 78 | if (subscription == null) return; 79 | if (mSubscriptions == null) { 80 | mSubscriptions = new CompositeSubscription(); 81 | } 82 | mSubscriptions.add(subscription); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | /** 4 | * Created by koma on 11/16/16. 5 | */ 6 | 7 | public interface BasePresenter { 8 | void subscribe(); 9 | 10 | void unSubscribe(); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseSwipeBackActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.koma.filemanager.util.LogUtils; 6 | 7 | /** 8 | * Created by koma on 11/16/16. 9 | */ 10 | 11 | public abstract class BaseSwipeBackActivity extends BaseActivity { 12 | private static final String TAG = "BaseSwipeBackActivity"; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | LogUtils.i(TAG, "onCreate"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | /** 4 | * Created by koma on 11/16/16. 5 | */ 6 | 7 | public interface BaseView { 8 | void setPresenter(T presenter); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/base/BaseViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.base; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | 6 | import com.koma.filemanager.util.LogUtils; 7 | 8 | import butterknife.ButterKnife; 9 | 10 | /** 11 | * Created by koma on 12/26/16. 12 | */ 13 | 14 | public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, 15 | View.OnLongClickListener { 16 | private static final String TAG = BaseViewHolder.class.getSimpleName(); 17 | protected final BaseAdapter mAdapter; 18 | 19 | 20 | public BaseViewHolder(View view, BaseAdapter adapter) { 21 | super(view); 22 | this.mAdapter = adapter; 23 | ButterKnife.bind(this, view); 24 | view.setOnClickListener(this); 25 | view.setOnLongClickListener(this); 26 | } 27 | 28 | public View getItemView() { 29 | return itemView; 30 | } 31 | 32 | public int getBaseViewHolderPosition() { 33 | return getAdapterPosition(); 34 | } 35 | 36 | 37 | @Override 38 | public void onClick(View v) { 39 | if (mAdapter != null) { 40 | mAdapter.mItemClickListener.onItemClick(getBaseViewHolderPosition()); 41 | } 42 | } 43 | 44 | @Override 45 | public boolean onLongClick(View v) { 46 | if (mAdapter != null) { 47 | LogUtils.i(TAG, "onItemLongClickListener position : " + getBaseViewHolderPosition()); 48 | mAdapter.mItemLongClickListener.onItemLongClick(getBaseViewHolderPosition()); 49 | return true; 50 | } 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/FileDataSource.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | import com.koma.filemanager.data.model.ApkFile; 5 | import com.koma.filemanager.data.model.AudioFile; 6 | import com.koma.filemanager.data.model.Disk; 7 | import com.koma.filemanager.data.model.DocumentFile; 8 | import com.koma.filemanager.data.model.ImageFile; 9 | import com.koma.filemanager.data.model.VideoFile; 10 | import com.koma.filemanager.data.model.ZipFile; 11 | 12 | import java.util.ArrayList; 13 | 14 | import rx.Observable; 15 | 16 | /** 17 | * Created by koma on 11/25/16. 18 | */ 19 | 20 | public interface FileDataSource { 21 | Observable getAuidoCounts(); 22 | 23 | Observable getVideoCounts(); 24 | 25 | Observable getImageCounts(); 26 | 27 | Observable getDocumentsCounts(); 28 | 29 | Observable getZipCounts(); 30 | 31 | Observable getApkCounts(); 32 | 33 | Observable> getDisks(); 34 | 35 | Observable> getAudioFiles(); 36 | 37 | Observable> getImageFiles(); 38 | 39 | Observable> getVideoFiles(); 40 | 41 | Observable> getDocumentFiles(); 42 | 43 | Observable> getZipFiles(); 44 | 45 | Observable> getApkFiles(); 46 | 47 | Observable> getFiles(String path); 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/FileRepository.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data; 2 | 3 | import com.koma.filemanager.FileManagerApplication; 4 | import com.koma.filemanager.base.BaseFile; 5 | import com.koma.filemanager.data.model.ApkFile; 6 | import com.koma.filemanager.data.model.AudioFile; 7 | import com.koma.filemanager.data.model.Disk; 8 | import com.koma.filemanager.data.model.DocumentFile; 9 | import com.koma.filemanager.data.model.ImageFile; 10 | import com.koma.filemanager.data.model.VideoFile; 11 | import com.koma.filemanager.data.model.ZipFile; 12 | 13 | import java.util.ArrayList; 14 | 15 | import rx.Observable; 16 | 17 | /** 18 | * Created by koma on 11/25/16. 19 | */ 20 | 21 | public class FileRepository implements FileDataSource { 22 | private static volatile FileRepository sRespository; 23 | private LocalDataSource mLocalDataSource; 24 | 25 | private FileRepository() { 26 | mLocalDataSource = new LocalDataSource(FileManagerApplication.getContext()); 27 | } 28 | 29 | public static FileRepository getInstance() { 30 | if (sRespository == null) { 31 | synchronized (FileRepository.class) { 32 | if (sRespository == null) { 33 | sRespository = new FileRepository(); 34 | } 35 | } 36 | } 37 | return sRespository; 38 | } 39 | 40 | @Override 41 | public Observable getAuidoCounts() { 42 | return mLocalDataSource.getAuidoCounts(); 43 | } 44 | 45 | @Override 46 | public Observable getVideoCounts() { 47 | return mLocalDataSource.getVideoCounts(); 48 | } 49 | 50 | @Override 51 | public Observable getImageCounts() { 52 | return mLocalDataSource.getImageCounts(); 53 | } 54 | 55 | @Override 56 | public Observable getDocumentsCounts() { 57 | return mLocalDataSource.getDocumentsCounts(); 58 | } 59 | 60 | @Override 61 | public Observable getZipCounts() { 62 | return mLocalDataSource.getZipCounts(); 63 | } 64 | 65 | @Override 66 | public Observable getApkCounts() { 67 | return mLocalDataSource.getApkCounts(); 68 | } 69 | 70 | @Override 71 | public Observable> getDisks() { 72 | return mLocalDataSource.getDisks(); 73 | } 74 | 75 | @Override 76 | public Observable> getAudioFiles() { 77 | return mLocalDataSource.getAudioFiles(); 78 | } 79 | 80 | @Override 81 | public Observable> getImageFiles() { 82 | return mLocalDataSource.getImageFiles(); 83 | } 84 | 85 | @Override 86 | public Observable> getVideoFiles() { 87 | return mLocalDataSource.getVideoFiles(); 88 | } 89 | 90 | @Override 91 | public Observable> getDocumentFiles() { 92 | return null; 93 | } 94 | 95 | @Override 96 | public Observable> getZipFiles() { 97 | return mLocalDataSource.getZipFiles(); 98 | } 99 | 100 | @Override 101 | public Observable> getApkFiles() { 102 | return null; 103 | } 104 | 105 | @Override 106 | public Observable> getFiles(String path) { 107 | return mLocalDataSource.getFiles(path); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/ApkFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | /** 6 | * Created by koma on 11/28/16. 7 | */ 8 | 9 | public class ApkFile extends BaseFile { 10 | public ApkFile(){ 11 | super("", "", 0, null); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/AudioFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by koma on 11/23/16. 9 | */ 10 | 11 | public class AudioFile extends BaseFile { 12 | private long mAlbumId; 13 | private String mDisplayName; 14 | 15 | public AudioFile() { 16 | super("", "", 0, null); 17 | mDisplayName = ""; 18 | } 19 | 20 | public AudioFile(String fileName, String parent, long fileSize, Date fileModifiedTime, String displayName) { 21 | super(fileName, parent, fileSize, fileModifiedTime); 22 | mDisplayName = displayName; 23 | } 24 | 25 | public void setDisplayName(String displayName) { 26 | mDisplayName = displayName; 27 | } 28 | 29 | public String getDisplayTime() { 30 | return mDisplayName; 31 | } 32 | 33 | public long getAlbumId() { 34 | return mAlbumId; 35 | } 36 | 37 | public void setAlbumId(long albumId) { 38 | mAlbumId = albumId; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/Disk.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | /** 4 | * Created by koma on 11/29/16. 5 | */ 6 | 7 | public class Disk { 8 | private String mMountPoint, mDescription; 9 | private long mTotalSpace, mVailableSpace; 10 | 11 | public Disk() { 12 | this("", "", 0, 0); 13 | } 14 | 15 | public Disk(String mountPoint, String description, long total, long vailableSpace) { 16 | mMountPoint = mountPoint; 17 | mDescription = description; 18 | mTotalSpace = total; 19 | mVailableSpace = vailableSpace; 20 | } 21 | 22 | public void setMountPoint(String mountPoint) { 23 | mMountPoint = mountPoint; 24 | } 25 | 26 | public String getMountPoint() { 27 | return mMountPoint; 28 | } 29 | 30 | public void setDescription(String description) { 31 | mDescription = description; 32 | } 33 | 34 | public String getDescription() { 35 | return mDescription; 36 | } 37 | 38 | public void setTotalSpace(long totalSpace) { 39 | mTotalSpace = totalSpace; 40 | } 41 | 42 | public long getTotalSpace() { 43 | return mTotalSpace; 44 | } 45 | 46 | public void setAvailableSpace(long availableSpace) { 47 | mVailableSpace = availableSpace; 48 | } 49 | 50 | public long getAvailavleSpace() { 51 | return mVailableSpace; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/DocumentFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | /** 6 | * Created by koma on 11/28/16. 7 | */ 8 | 9 | public class DocumentFile extends BaseFile { 10 | public DocumentFile() { 11 | super("", "", 0, null); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/ImageFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | /** 4 | * Created by koma on 11/23/16. 5 | */ 6 | 7 | public class ImageFile { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/VideoFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | /** 4 | * Created by koma on 11/23/16. 5 | */ 6 | 7 | public class VideoFile { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/data/model/ZipFile.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.data.model; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | /** 6 | * Created by koma on 11/28/16. 7 | */ 8 | 9 | public class ZipFile extends BaseFile { 10 | public ZipFile() { 11 | super("", "", 0, null); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/filecategory/FileCategoryActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.filecategory; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentTransaction; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.text.TextUtils; 8 | 9 | import com.koma.filemanager.R; 10 | import com.koma.filemanager.base.BaseMenuActivity; 11 | import com.koma.filemanager.data.FileRepository; 12 | import com.koma.filemanager.data.model.ZipFile; 13 | import com.koma.filemanager.util.Constants; 14 | import com.koma.filemanager.util.LogUtils; 15 | 16 | import java.util.ArrayList; 17 | 18 | import butterknife.BindView; 19 | 20 | /** 21 | * Created by koma on 12/12/16. 22 | */ 23 | 24 | public class FileCategoryActivity extends BaseMenuActivity { 25 | private static final String TAG = "FileCategoryActivity"; 26 | private String mCategory; 27 | private FileCategoryContract.Presenter mPresenter; 28 | private FileCategoryAdapter mAdapter; 29 | private ArrayList mData; 30 | 31 | @Override 32 | public void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | LogUtils.i(TAG, "onCreate"); 35 | if (getIntent().getExtras() != null) { 36 | mCategory = getIntent().getStringExtra(Constants.FILE_CATEGORY); 37 | } 38 | if (mCategory == null) { 39 | finish(); 40 | } 41 | LogUtils.i(TAG, "mCategory : " + mCategory); 42 | init(); 43 | } 44 | 45 | private void init() { 46 | FileCategoryFragment fileCategoryFragment = (FileCategoryFragment) getSupportFragmentManager().findFragmentById(R.id.content); 47 | if (fileCategoryFragment == null) { 48 | fileCategoryFragment = new FileCategoryFragment(); 49 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 50 | transaction.replace(R.id.content, fileCategoryFragment).commit(); 51 | } 52 | mPresenter = new FileCategoryPresenter(fileCategoryFragment, FileRepository.getInstance()); 53 | } 54 | 55 | @Override 56 | public void onStart() { 57 | super.onStart(); 58 | LogUtils.i(TAG, "onStart"); 59 | } 60 | 61 | @Override 62 | public void onResume() { 63 | super.onResume(); 64 | LogUtils.i(TAG, "onResume"); 65 | if (TextUtils.equals(mCategory, "zip")) { 66 | if (mPresenter != null) { 67 | mPresenter.getZipFiles(); 68 | } 69 | } 70 | } 71 | 72 | @Override 73 | public void onPause() { 74 | super.onPause(); 75 | LogUtils.i(TAG, "onPause"); 76 | } 77 | 78 | @Override 79 | public void onStop() { 80 | super.onStop(); 81 | LogUtils.i(TAG, "onStop"); 82 | } 83 | 84 | @Override 85 | public void onDestroy() { 86 | super.onDestroy(); 87 | LogUtils.i(TAG, "onDestroy"); 88 | if (mPresenter != null) { 89 | mPresenter.unSubscribe(); 90 | } 91 | } 92 | 93 | @Override 94 | protected void sortByType() { 95 | LogUtils.i(TAG, "sortbyType"); 96 | } 97 | 98 | @Override 99 | protected void sortByName() { 100 | LogUtils.i(TAG, "sortByName"); 101 | } 102 | 103 | @Override 104 | protected void sortBySize() { 105 | LogUtils.i(TAG, "sortBySize"); 106 | } 107 | 108 | @Override 109 | protected void sortByDate() { 110 | LogUtils.i(TAG, "sortByDate"); 111 | } 112 | 113 | @Override 114 | protected int getLayoutId() { 115 | return R.layout.common_layout; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/filecategory/FileCategoryContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.filecategory; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.ZipFile; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by koma on 12/12/16. 11 | */ 12 | 13 | public interface FileCategoryContract { 14 | interface View extends BaseView { 15 | void refreshAdapter(ArrayList zipFiles); 16 | 17 | void showEmpty(); 18 | 19 | void showLoadingView(); 20 | } 21 | 22 | interface Presenter extends BasePresenter { 23 | void getZipFiles(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/filecategory/FileCategoryFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.filecategory; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.koma.filemanager.R; 12 | import com.koma.filemanager.base.BaseFragment; 13 | import com.koma.filemanager.data.model.ZipFile; 14 | import com.koma.filemanager.util.LogUtils; 15 | 16 | import java.util.ArrayList; 17 | 18 | import butterknife.BindView; 19 | import butterknife.ButterKnife; 20 | 21 | /** 22 | * Created by koma on 12/12/16. 23 | */ 24 | 25 | public class FileCategoryFragment extends BaseFragment implements FileCategoryContract.View { 26 | private static final String TAG = "FileCategoryFragment"; 27 | private FileCategoryContract.Presenter mPresenter; 28 | @BindView(R.id.recycler_view) 29 | RecyclerView mRecyclerView; 30 | private FileCategoryAdapter mAdapter; 31 | private ArrayList mData; 32 | 33 | public void onAttach(Context context) { 34 | super.onAttach(context); 35 | LogUtils.i(TAG, "onAttach"); 36 | } 37 | 38 | public void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | LogUtils.i(TAG, "onCreate'"); 41 | } 42 | 43 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 44 | View view = inflater.inflate(R.layout.recyclerview, container, false); 45 | ButterKnife.bind(this, view); 46 | mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); 47 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); 48 | linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); 49 | mRecyclerView.setLayoutManager(linearLayoutManager); 50 | mData = new ArrayList<>(); 51 | mAdapter = new FileCategoryAdapter(mContext, mData); 52 | mRecyclerView.setAdapter(mAdapter); 53 | return view; 54 | } 55 | 56 | public void onViewCreated(View view, Bundle savedInstanceState) { 57 | super.onViewCreated(view, savedInstanceState); 58 | LogUtils.i(TAG, "onViewCreated"); 59 | } 60 | 61 | public void onDestroyView() { 62 | super.onDestroyView(); 63 | LogUtils.i(TAG, "onDestroyView"); 64 | if (mPresenter != null) { 65 | mPresenter.unSubscribe(); 66 | } 67 | } 68 | 69 | 70 | @Override 71 | public void refreshAdapter(ArrayList zipFiles) { 72 | LogUtils.i(TAG, "refreshAdapter"); 73 | if (mData != null) { 74 | mData.clear(); 75 | } else { 76 | mData = new ArrayList<>(); 77 | } 78 | mData.addAll(zipFiles); 79 | mAdapter.notifyDataSetChanged(); 80 | } 81 | 82 | @Override 83 | public void showEmpty() { 84 | LogUtils.i(TAG, "showEmpty"); 85 | } 86 | 87 | @Override 88 | public void showLoadingView() { 89 | LogUtils.i(TAG, "showLoadingView"); 90 | } 91 | 92 | @Override 93 | public void setPresenter(FileCategoryContract.Presenter presenter) { 94 | mPresenter = presenter; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/filecategory/FileCategoryPresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.filecategory; 2 | 3 | import com.koma.filemanager.data.FileRepository; 4 | import com.koma.filemanager.data.model.ZipFile; 5 | import com.koma.filemanager.util.LogUtils; 6 | 7 | import java.util.ArrayList; 8 | 9 | import rx.Subscriber; 10 | import rx.Subscription; 11 | import rx.android.schedulers.AndroidSchedulers; 12 | import rx.schedulers.Schedulers; 13 | import rx.subscriptions.CompositeSubscription; 14 | 15 | /** 16 | * Created by koma on 12/12/16. 17 | */ 18 | 19 | public class FileCategoryPresenter implements FileCategoryContract.Presenter { 20 | private static final String TAG = "FileCategoryPresenter"; 21 | private CompositeSubscription mSubscriptions; 22 | private FileRepository mRespository; 23 | private FileCategoryContract.View mView; 24 | private Subscription mZipFilesSubsription; 25 | 26 | public FileCategoryPresenter(FileCategoryContract.View view, FileRepository repository) { 27 | mView = view; 28 | mRespository = repository; 29 | mSubscriptions = new CompositeSubscription(); 30 | mView.setPresenter(this); 31 | } 32 | 33 | private Subscriber> mZipSubsriber = new Subscriber>() { 34 | @Override 35 | public void onCompleted() { 36 | LogUtils.i(TAG, "onCompleted"); 37 | } 38 | 39 | @Override 40 | public void onError(Throwable e) { 41 | LogUtils.i(TAG, "onError :" + e.toString()); 42 | } 43 | 44 | @Override 45 | public void onNext(ArrayList zipFiles) { 46 | LogUtils.i(TAG, "onNext"); 47 | if (mView != null) { 48 | if (zipFiles.size() == 0) { 49 | mView.showEmpty(); 50 | } else { 51 | mView.refreshAdapter(zipFiles); 52 | } 53 | } 54 | } 55 | }; 56 | 57 | @Override 58 | public void getZipFiles() { 59 | LogUtils.i(TAG, "getZipFiles"); 60 | if (mSubscriptions != null) { 61 | mSubscriptions.remove(mZipSubsriber); 62 | } 63 | if (mRespository != null) { 64 | mZipFilesSubsription = mRespository.getZipFiles() 65 | .subscribeOn(Schedulers.io()) 66 | .observeOn(AndroidSchedulers.mainThread()) 67 | .subscribe(mZipSubsriber); 68 | } 69 | mSubscriptions.add(mZipFilesSubsription); 70 | } 71 | 72 | @Override 73 | public void subscribe() { 74 | LogUtils.i(TAG, "subsribe"); 75 | getZipFiles(); 76 | } 77 | 78 | @Override 79 | public void unSubscribe() { 80 | LogUtils.i(TAG, "unSubsribe"); 81 | if (mSubscriptions != null) { 82 | mSubscriptions.clear(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/fileview/FileViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.fileview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentTransaction; 5 | 6 | import com.koma.filemanager.R; 7 | import com.koma.filemanager.base.BaseMenuActivity; 8 | import com.koma.filemanager.data.FileRepository; 9 | import com.koma.filemanager.helper.FileSortHelper; 10 | import com.koma.filemanager.helper.RxBus; 11 | import com.koma.filemanager.helper.event.SortEvent; 12 | import com.koma.filemanager.util.Constants; 13 | import com.koma.filemanager.util.LogUtils; 14 | 15 | /** 16 | * Created by koma on 11/30/16. 17 | */ 18 | 19 | public class FileViewActivity extends BaseMenuActivity { 20 | private static final String TAG = "FileViewActivity"; 21 | FileViewPresenter mPresenter; 22 | private String mPath; 23 | 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | LogUtils.i(TAG, "onCreate"); 27 | init(); 28 | } 29 | 30 | private void init() { 31 | if (getIntent().getExtras() != null) { 32 | mPath = getIntent().getStringExtra(Constants.EXTRA_FILE_DIRECTORY); 33 | LogUtils.i(TAG, "init mPath : " + mPath); 34 | } 35 | FileViewFragment fileViewFragment = (FileViewFragment) getSupportFragmentManager().findFragmentById(R.id.content); 36 | if (fileViewFragment == null) { 37 | fileViewFragment = FileViewFragment.newInstance(mPath); 38 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 39 | transaction.replace(R.id.content, fileViewFragment).commit(); 40 | } 41 | mPresenter = new FileViewPresenter(fileViewFragment, FileRepository.getInstance()); 42 | } 43 | 44 | public String getPath() { 45 | return mPath; 46 | } 47 | 48 | @Override 49 | protected int getLayoutId() { 50 | return R.layout.common_layout; 51 | } 52 | 53 | @Override 54 | public void onStart() { 55 | super.onStart(); 56 | LogUtils.i(TAG, "onStart"); 57 | } 58 | 59 | @Override 60 | public void onResume() { 61 | super.onResume(); 62 | LogUtils.i(TAG, "onResume"); 63 | } 64 | 65 | @Override 66 | protected void sortByType() { 67 | LogUtils.i(TAG, "sortByType"); 68 | RxBus.getInstance().post(new SortEvent(FileSortHelper.SortKey.type, FileSortHelper.SortMethod.asc)); 69 | } 70 | 71 | @Override 72 | protected void sortByName() { 73 | LogUtils.i(TAG, "sortByName"); 74 | RxBus.getInstance().post(new SortEvent(FileSortHelper.SortKey.name, FileSortHelper.SortMethod.asc)); 75 | } 76 | 77 | @Override 78 | protected void sortBySize() { 79 | LogUtils.i(TAG, "sortBySize"); 80 | RxBus.getInstance().post(new SortEvent(FileSortHelper.SortKey.size, FileSortHelper.SortMethod.asc)); 81 | } 82 | 83 | @Override 84 | protected void sortByDate() { 85 | LogUtils.i(TAG, "sortByDate"); 86 | RxBus.getInstance().post(new SortEvent(FileSortHelper.SortKey.date, FileSortHelper.SortMethod.asc)); 87 | } 88 | 89 | 90 | @Override 91 | public void onPause() { 92 | super.onPause(); 93 | LogUtils.i(TAG, "onPause"); 94 | } 95 | 96 | @Override 97 | public void onStop() { 98 | super.onStop(); 99 | LogUtils.i(TAG, "onStop"); 100 | } 101 | 102 | @Override 103 | public void onDestroy() { 104 | super.onDestroy(); 105 | LogUtils.i(TAG, "onDestroy"); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/fileview/FileViewContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.fileview; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | import com.koma.filemanager.base.BasePresenter; 5 | import com.koma.filemanager.base.BaseView; 6 | import com.koma.filemanager.helper.event.SortEvent; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * Created by koma on 12/1/16. 12 | */ 13 | 14 | public interface FileViewContract { 15 | interface View extends BaseView { 16 | void refreshAdapter(ArrayList files); 17 | 18 | void showLoadingView(); 19 | 20 | void hideLoadingView(); 21 | 22 | void showEmptyView(); 23 | 24 | String getPath(); 25 | 26 | void onSortSuccess(); 27 | } 28 | 29 | interface Presenter extends BasePresenter { 30 | void getFiles(String path); 31 | 32 | void sortFiles(ArrayList files, SortEvent sortEvent); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/FileCountHelper.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | 4 | import java.io.File; 5 | 6 | import rx.Observable; 7 | import rx.Subscriber; 8 | 9 | /** 10 | * Created by koma on 12/2/16. 11 | */ 12 | 13 | public class FileCountHelper { 14 | private static final String TAG = "FileCountHelper"; 15 | private static FileCountHelper mHelper; 16 | 17 | private FileCountHelper() { 18 | } 19 | 20 | public synchronized static FileCountHelper getInstance() { 21 | if (mHelper == null) { 22 | mHelper = new FileCountHelper(); 23 | } 24 | return mHelper; 25 | } 26 | 27 | public Observable getFileCount(final String fullPath) { 28 | return Observable.create(new Observable.OnSubscribe() { 29 | @Override 30 | public void call(Subscriber subscriber) { 31 | File file = new File(fullPath); 32 | int filesCount = FileHelper.getSubFilesCount(file); 33 | subscriber.onNext(Integer.valueOf(filesCount)); 34 | subscriber.onCompleted(); 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/FileSortHelper.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | import java.text.Collator; 6 | import java.util.Collections; 7 | import java.util.Comparator; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by koma on 12/14/16. 12 | */ 13 | 14 | public class FileSortHelper { 15 | public enum SortKey { 16 | type, name, size, date 17 | } 18 | 19 | public enum SortMethod { 20 | asc, desc 21 | } 22 | 23 | public static void sortBaseFile(List files, final SortKey sortKey, 24 | final SortMethod sortMethod) { 25 | Collections.sort(files, new Comparator() { 26 | @Override 27 | public int compare(BaseFile fileL, BaseFile fileR) { 28 | // 排序规则,文件夹放前面,文件放后面 29 | boolean isLhsDirectory = fileL.getIsDirectory(); 30 | boolean isRhsDirectory = fileR.getIsDirectory(); 31 | if (isLhsDirectory || isRhsDirectory) { 32 | if (isLhsDirectory && isRhsDirectory) { 33 | return doCompare(fileL, fileR, sortKey, sortMethod); 34 | } 35 | return (isLhsDirectory) ? -1 : 1; 36 | } 37 | return doCompare(fileL, fileR, sortKey, sortMethod); 38 | } 39 | }); 40 | } 41 | 42 | public static int doCompare(final BaseFile file1, final BaseFile file2, 43 | SortKey sortKey, 44 | SortMethod sortMethod) { 45 | int sortFactor = 1;// 先确定是升序,还是降序 46 | if (sortMethod == SortMethod.desc) { 47 | sortFactor = -1; 48 | } 49 | if (sortKey == SortKey.name) { 50 | return Collator.getInstance(java.util.Locale.CHINA).compare(file1.getFileName(), 51 | file2.getFileName()) * sortFactor; 52 | } 53 | if (sortKey == SortKey.date) { 54 | return file1.getFileModifiedTime().compareTo(file2.getFileModifiedTime()) * sortFactor; 55 | } 56 | if (sortKey == SortKey.size) { 57 | return Long.compare(file1.getFileSize(), file2.getFileSize()) * sortFactor; 58 | } 59 | return file1.compareTo(file2); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/ImageLoder.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | /** 4 | * Created by koma on 12/2/16. 5 | */ 6 | 7 | public class ImageLoder { 8 | public static void loadImage() { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/MeidaHelper.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | import android.content.ContentUris; 4 | import android.net.Uri; 5 | 6 | /** 7 | * Created by koma on 12/5/16. 8 | */ 9 | 10 | public class MeidaHelper { 11 | private static final String TAG = "MediaHelper"; 12 | public static Uri getAlbumArtUri(long albumId) { 13 | return ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), albumId); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/RxBus.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | import com.koma.filemanager.util.LogUtils; 4 | 5 | import rx.Observable; 6 | import rx.Subscriber; 7 | import rx.subjects.PublishSubject; 8 | 9 | /** 10 | * Created by koma on 12/14/16. 11 | */ 12 | 13 | public class RxBus { 14 | private static final String TAG = "RxBus"; 15 | 16 | private static volatile RxBus sInstance; 17 | 18 | public static RxBus getInstance() { 19 | if (sInstance == null) { 20 | synchronized (RxBus.class) { 21 | if (sInstance == null) { 22 | sInstance = new RxBus(); 23 | } 24 | } 25 | } 26 | return sInstance; 27 | } 28 | 29 | /** 30 | * PublishSubject subject = PublishSubject.create(); 31 | * // observer1 will receive all onNext and onCompleted events 32 | * subject.subscribe(observer1); 33 | * subject.onNext("one"); 34 | * subject.onNext("two"); 35 | * // observer2 will only receive "three" and onCompleted 36 | * subject.subscribe(observer2); 37 | * subject.onNext("three"); 38 | * subject.onCompleted(); 39 | */ 40 | private PublishSubject mEventBus = PublishSubject.create(); 41 | 42 | public void post(Object event) { 43 | mEventBus.onNext(event); 44 | } 45 | 46 | public Observable toObservable() { 47 | return mEventBus; 48 | } 49 | 50 | public static Subscriber defaultSubscriber() { 51 | return new Subscriber() { 52 | @Override 53 | public void onCompleted() { 54 | LogUtils.i(TAG, "Duty off!!!"); 55 | } 56 | 57 | @Override 58 | public void onError(Throwable e) { 59 | LogUtils.e(TAG, "Throwable error : " + e.toString()); 60 | } 61 | 62 | @Override 63 | public void onNext(Object o) { 64 | LogUtils.i(TAG, "New event received: " + o); 65 | } 66 | }; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/SelectHelper.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | import com.koma.filemanager.helper.event.SelectEvent; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by koma on 12/16/16. 11 | */ 12 | 13 | public class SelectHelper { 14 | private static final String TAG = "SelectHelper"; 15 | //Select Mode 16 | public static final int MODE_IDLE = 0, MODE_MULTI = 1; 17 | private static SelectHelper sInstance; 18 | private List mClickedItem; 19 | 20 | private SelectHelper() { 21 | mClickedItem = new ArrayList<>(); 22 | } 23 | 24 | public static SelectHelper getInstance() { 25 | if (sInstance == null) { 26 | sInstance = new SelectHelper(); 27 | } 28 | return sInstance; 29 | } 30 | 31 | public void toggle(BaseFile baseFile) { 32 | if (mClickedItem.contains(baseFile)) { 33 | mClickedItem.remove(baseFile); 34 | } else { 35 | mClickedItem.add(baseFile); 36 | } 37 | } 38 | 39 | public void selectAll() { 40 | if (mClickedItem != null) { 41 | mClickedItem.clear(); 42 | } 43 | RxBus.getInstance().post(new SelectEvent(MODE_MULTI)); 44 | } 45 | 46 | public int getTotalCount() { 47 | return 0; 48 | } 49 | 50 | public int getSelectedCount() { 51 | return 0; 52 | } 53 | 54 | public List getSelected() { 55 | return mClickedItem; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/event/SelectEvent.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper.event; 2 | 3 | import com.koma.filemanager.base.BaseFile; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by koma on 12/16/16. 10 | */ 11 | 12 | public class SelectEvent { 13 | private int mSelectMode; 14 | private List mSelectedFiles; 15 | 16 | public SelectEvent(int selectMode) { 17 | this.mSelectMode = selectMode; 18 | } 19 | 20 | public SelectEvent(int selectMode, ArrayList selectedFiles) { 21 | this.mSelectMode = selectMode; 22 | mSelectedFiles = selectedFiles; 23 | } 24 | 25 | public void setSelectMode(int selectMode) { 26 | this.mSelectMode = selectMode; 27 | } 28 | 29 | public int getSelectMode() { 30 | return mSelectMode; 31 | } 32 | 33 | public void setSelectedFiles(ArrayList selectedFiles) { 34 | if (mSelectedFiles != null) { 35 | mSelectedFiles.clear(); 36 | } else { 37 | mSelectedFiles = new ArrayList<>(); 38 | } 39 | this.mSelectedFiles.addAll(selectedFiles); 40 | } 41 | 42 | public List getSelectedFiles() { 43 | return mSelectedFiles; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/helper/event/SortEvent.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.helper.event; 2 | 3 | import com.koma.filemanager.helper.FileSortHelper; 4 | 5 | /** 6 | * Created by koma on 12/14/16. 7 | */ 8 | 9 | public class SortEvent { 10 | private FileSortHelper.SortKey mSortKey; 11 | private FileSortHelper.SortMethod mSortMethod; 12 | 13 | public SortEvent(FileSortHelper.SortKey sortKey, FileSortHelper.SortMethod sortMethod) { 14 | this.mSortKey = sortKey; 15 | this.mSortMethod = sortMethod; 16 | } 17 | 18 | public void setSortKey(FileSortHelper.SortKey sortKey) { 19 | this.mSortKey = sortKey; 20 | } 21 | 22 | public FileSortHelper.SortKey getSortKey() { 23 | return mSortKey; 24 | } 25 | 26 | public void setSortMethod(FileSortHelper.SortMethod sortMethod) { 27 | this.mSortMethod = sortMethod; 28 | } 29 | 30 | public FileSortHelper.SortMethod getSortMethod() { 31 | return mSortMethod; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/image/ImageActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.image; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.koma.filemanager.base.BaseSwipeBackActivity; 6 | import com.koma.filemanager.util.LogUtils; 7 | 8 | /** 9 | * Created by koma on 11/16/16. 10 | */ 11 | 12 | public class ImageActivity extends BaseSwipeBackActivity { 13 | private static final String TAG = "ImageActivity"; 14 | 15 | public void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | LogUtils.i(TAG, "onCreate"); 18 | } 19 | 20 | @Override 21 | protected int getLayoutId() { 22 | return 0; 23 | } 24 | 25 | public void onStart() { 26 | super.onStart(); 27 | LogUtils.i(TAG, "onStart"); 28 | } 29 | 30 | public void onResume() { 31 | super.onResume(); 32 | LogUtils.i(TAG, "onResume"); 33 | } 34 | 35 | public void onStop() { 36 | super.onStop(); 37 | LogUtils.i(TAG, "onStop"); 38 | } 39 | 40 | public void onDestroy() { 41 | super.onDestroy(); 42 | LogUtils.i(TAG, "onDestroy"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/image/ImageAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.image; 2 | 3 | /** 4 | * Created by koma on 2016/11/26. 5 | */ 6 | 7 | public class ImageAdapter { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/image/ImageConstract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.image; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.ImageFile; 6 | 7 | import java.util.List; 8 | 9 | import rx.Observable; 10 | 11 | /** 12 | * Created by koma on 11/16/16. 13 | */ 14 | 15 | public interface ImageConstract { 16 | interface View extends BaseView { 17 | void showEmptyView(); 18 | void refreshAdapter(); 19 | } 20 | 21 | interface Presenter extends BasePresenter { 22 | Observable> getImageFiles(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/image/ImageFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.image; 2 | 3 | import com.koma.filemanager.base.BaseFragment; 4 | import com.koma.filemanager.util.LogUtils; 5 | 6 | /** 7 | * Created by koma on 2016/11/26. 8 | */ 9 | 10 | public class ImageFragment extends BaseFragment implements ImageConstract.View { 11 | private static final String TAG = "ImageFragment"; 12 | @Override 13 | public void showEmptyView() { 14 | LogUtils.i(TAG,"showEmptyView"); 15 | } 16 | 17 | @Override 18 | public void refreshAdapter() { 19 | LogUtils.i(TAG,"refreshAdapter"); 20 | } 21 | 22 | @Override 23 | public void setPresenter(ImageConstract.Presenter presenter) { 24 | LogUtils.i(TAG,"setPresenter"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/image/ImagePresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.image; 2 | 3 | import com.koma.filemanager.data.model.ImageFile; 4 | import com.koma.filemanager.util.LogUtils; 5 | 6 | import java.util.List; 7 | 8 | import rx.Observable; 9 | 10 | /** 11 | * Created by koma on 2016/11/26. 12 | */ 13 | 14 | public class ImagePresenter implements ImageConstract.Presenter { 15 | private static final String TAG = "ImagePresenter"; 16 | @Override 17 | public Observable> getImageFiles() { 18 | LogUtils.i(TAG,"getImageFiles"); 19 | return null; 20 | } 21 | 22 | @Override 23 | public void subscribe() { 24 | LogUtils.i(TAG,"subscribe"); 25 | } 26 | 27 | @Override 28 | public void unSubscribe() { 29 | LogUtils.i(TAG,"unSubscribe"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/main/DiskAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.main; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ProgressBar; 11 | import android.widget.TextView; 12 | 13 | import com.koma.filemanager.R; 14 | import com.koma.filemanager.data.model.Disk; 15 | import com.koma.filemanager.util.Constants; 16 | import com.koma.filemanager.util.LocaleUtils; 17 | import com.koma.filemanager.util.LogUtils; 18 | 19 | import java.util.ArrayList; 20 | 21 | import butterknife.BindView; 22 | import butterknife.ButterKnife; 23 | 24 | /** 25 | * Created by koma on 11/29/16. 26 | */ 27 | 28 | public class DiskAdapter extends RecyclerView.Adapter { 29 | private static final String TAG = "VolumeInfoAdapter"; 30 | private ArrayList mData; 31 | private Context mContext; 32 | 33 | public DiskAdapter(Context context, ArrayList data) { 34 | mContext = context; 35 | mData = data; 36 | } 37 | 38 | public void setData(ArrayList data) { 39 | if (mData != null) { 40 | mData.clear(); 41 | } else { 42 | mData = new ArrayList<>(); 43 | } 44 | mData.addAll(data); 45 | notifyDataSetChanged(); 46 | } 47 | 48 | @Override 49 | public VolumeInfoHolder onCreateViewHolder(ViewGroup parent, int viewType) { 50 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_disk, null); 51 | return new VolumeInfoHolder(view); 52 | } 53 | 54 | @Override 55 | public void onBindViewHolder(VolumeInfoHolder holder, final int position) { 56 | 57 | holder.mVolumeTitle.setText(mData.get(position).getDescription()); 58 | holder.mVolumeAvailable.setText(LocaleUtils.formatVolumeInfo( 59 | mData.get(position).getTotalSpace(), mData.get(position).getAvailavleSpace())); 60 | long usedSpace = mData.get(position).getTotalSpace() - mData.get(position).getAvailavleSpace(); 61 | LogUtils.i(TAG, "onBindViewHolder usedSpace : " + usedSpace); 62 | holder.mProgressBar.setProgress((int) (100 * usedSpace / mData.get(position).getTotalSpace())); 63 | holder.mItemView.setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | Intent intent = new Intent(); 67 | ComponentName componentName = new ComponentName("com.koma.filemanager", 68 | "com.koma.filemanager.fileview.FileViewActivity"); 69 | intent.setComponent(componentName); 70 | intent.putExtra(Constants.EXTRA_FILE_DIRECTORY, mData.get(position) 71 | .getMountPoint()); 72 | mContext.startActivity(intent); 73 | } 74 | }); 75 | } 76 | 77 | @Override 78 | public int getItemCount() { 79 | return mData == null ? 0 : mData.size(); 80 | } 81 | 82 | public class VolumeInfoHolder extends RecyclerView.ViewHolder { 83 | @BindView(R.id.tv_volume_title) 84 | TextView mVolumeTitle; 85 | @BindView(R.id.tv_volume_available) 86 | TextView mVolumeAvailable; 87 | @BindView(R.id.pb_volume_available) 88 | ProgressBar mProgressBar; 89 | 90 | @BindView(R.id.layout_volume_info) 91 | View mItemView; 92 | 93 | public VolumeInfoHolder(View view) { 94 | super(view); 95 | ButterKnife.bind(this, view); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/main/MainContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.main; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.Disk; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by koma on 11/23/16. 11 | */ 12 | 13 | public interface MainContract { 14 | interface View extends BaseView { 15 | void refreshAudioCounts(String count); 16 | 17 | void refreshVideoCounts(String count); 18 | 19 | void refreshImageCounts(String count); 20 | 21 | void refreshDocumentCounts(String count); 22 | 23 | void refreshZipCounts(String count); 24 | 25 | void refreshApkCounts(String count); 26 | 27 | void refreshAdapter(ArrayList disks); 28 | } 29 | 30 | interface Presenter extends BasePresenter { 31 | void launchCategoryActivity(int resourceId); 32 | 33 | void getAudioCounts(); 34 | 35 | void getVideoCounts(); 36 | 37 | void getImageCounts(); 38 | 39 | void getDocumentCounts(); 40 | 41 | void getZipCounts(); 42 | 43 | void getApkCounts(); 44 | 45 | void getDisks(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/search/SearchActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.search; 2 | 3 | import com.koma.filemanager.base.BaseSwipeBackActivity; 4 | 5 | /** 6 | * Created by koma on 11/23/16. 7 | */ 8 | 9 | public class SearchActivity extends BaseSwipeBackActivity { 10 | @Override 11 | protected int getLayoutId() { 12 | return 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/search/SearchContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.search; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | 6 | /** 7 | * Created by koma on 11/23/16. 8 | */ 9 | 10 | public interface SearchContract { 11 | interface View extends BaseView { 12 | } 13 | 14 | interface Presenter extends BasePresenter { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/search/SearchFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.search; 2 | 3 | import com.koma.filemanager.base.BaseFragment; 4 | 5 | /** 6 | * Created by koma on 11/23/16. 7 | */ 8 | 9 | public class SearchFragment extends BaseFragment implements SearchContract.View { 10 | @Override 11 | public void setPresenter(SearchContract.Presenter presenter) { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/search/SearchPresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.search; 2 | 3 | /** 4 | * Created by koma on 11/23/16. 5 | */ 6 | 7 | public class SearchPresenter implements SearchContract.Presenter { 8 | @Override 9 | public void subscribe() { 10 | 11 | } 12 | 13 | @Override 14 | public void unSubscribe() { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/BlurUtils.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.graphics.drawable.BitmapDrawable; 7 | import android.graphics.drawable.Drawable; 8 | import android.support.v8.renderscript.Allocation; 9 | import android.support.v8.renderscript.Element; 10 | import android.support.v8.renderscript.RenderScript; 11 | import android.support.v8.renderscript.ScriptIntrinsicBlur; 12 | 13 | import java.io.ByteArrayInputStream; 14 | import java.io.ByteArrayOutputStream; 15 | 16 | /** 17 | * Created by koma on 11/19/16. 18 | */ 19 | 20 | public class BlurUtils { 21 | 22 | public static Drawable blurBitmap(Context context, Bitmap bitmap) { 23 | final RenderScript renderScript = RenderScript.create(context); 24 | final BitmapFactory.Options options = new BitmapFactory.Options(); 25 | options.inSampleSize = Constants.IN_SAMPLE_SIZE; 26 | ByteArrayOutputStream stream = new ByteArrayOutputStream(); 27 | bitmap.compress(Bitmap.CompressFormat.JPEG, Constants.COMPRESS_QUALITY, stream); 28 | byte[] imageInByte = stream.toByteArray(); 29 | ByteArrayInputStream bis = new ByteArrayInputStream(imageInByte); 30 | Bitmap blurTemplate = BitmapFactory.decodeStream(bis, null, options); 31 | final Allocation input = Allocation.createFromBitmap(renderScript, blurTemplate); 32 | final Allocation output = Allocation.createTyped(renderScript, input.getType()); 33 | final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript)); 34 | script.setRadius(Constants.BLUR_RADIUS); 35 | script.setInput(input); 36 | script.forEach(output); 37 | output.copyTo(blurTemplate); 38 | renderScript.destroy(); 39 | return new BitmapDrawable(context.getResources(), blurTemplate); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import android.Manifest; 4 | import android.provider.MediaStore; 5 | 6 | import com.koma.filemanager.helper.MeidaHelper; 7 | 8 | /** 9 | * Created by koma on 11/19/16. 10 | */ 11 | 12 | public final class Constants { 13 | //FileCategory 14 | public static final String FILE_CATEGORY = "filecategory"; 15 | public static final int IN_SAMPLE_SIZE = 4; 16 | public static final int COMPRESS_QUALITY = 100; 17 | // 25f is the max blur radius. 18 | public static final float BLUR_RADIUS = 10f; 19 | 20 | //Permissions 21 | public static String[] PERMISSIONS_STORAGE = {Manifest.permission.WRITE_EXTERNAL_STORAGE, 22 | Manifest.permission.READ_EXTERNAL_STORAGE}; 23 | public static final int REQUEST_CODE_ASK_PERMISSIONS = 1; 24 | 25 | //CategoryFiles 26 | public static final String EXTERNAL = "external"; 27 | public static final String[] MEDIA_PROJECTION = new String[]{"_id"}; 28 | public static final String[] FILE_PROJECTION_DEFAULT = new String[]{ 29 | MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.MIME_TYPE 30 | }; 31 | 32 | public static final String[] AUDIO_PROJECTION = new String[]{ 33 | MediaStore.Audio.AudioColumns.ALBUM_ID, MediaStore.Audio.AudioColumns.DATA, 34 | MediaStore.Audio.AudioColumns.DISPLAY_NAME, 35 | MediaStore.Audio.AudioColumns.SIZE, MediaStore.Audio.AudioColumns.DATE_MODIFIED 36 | }; 37 | 38 | 39 | public static final String[] SUB_FILE_PROJECTION = new String[]{ 40 | MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.MIME_TYPE, 41 | MediaStore.Files.FileColumns.SIZE, MediaStore.Files.FileColumns.DATE_MODIFIED 42 | }; 43 | //Formate Date 44 | public static final String FILE_MODIFIED_TIME_FORMAT = "yyyyMMdd"; 45 | 46 | //FileViewActivity 47 | public static final String EXTRA_FILE_DIRECTORY = "extra_file_directory"; 48 | 49 | //Operation Action 50 | public static final String OPERATION_ACTION = "operation_action"; 51 | public static final String COPY_ACTION = "copy_action"; 52 | public static final String CUT_ACTION = "cut_action"; 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import android.text.format.Formatter; 4 | 5 | import com.koma.filemanager.FileManagerApplication; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | import java.util.Locale; 10 | 11 | /** 12 | * Created by koma on 11/24/16. 13 | */ 14 | 15 | public class FileUtils { 16 | // 直接使用系统内置API进行转换 17 | public static String formatFileSize(long size) { 18 | return Formatter.formatFileSize(FileManagerApplication.getContext(), size); 19 | } 20 | 21 | public static String formatFileModifiedTime(Date filetime) { 22 | SimpleDateFormat df = new SimpleDateFormat(android.text.format.DateFormat.getBestDateTimePattern(Locale.getDefault(), 23 | Constants.FILE_MODIFIED_TIME_FORMAT)); 24 | return df.format(filetime); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/LocaleUtils.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import com.koma.filemanager.FileManagerApplication; 4 | import com.koma.filemanager.R; 5 | 6 | import java.util.Locale; 7 | 8 | /** 9 | * Created by koma on 11/30/16. 10 | */ 11 | 12 | public class LocaleUtils { 13 | private static final String TAG = "LocaleUtils"; 14 | private static final String LANG_FARSI_FA = "fa"; 15 | 16 | private static String getLocalLanguage() { 17 | Locale local = FileManagerApplication.getContext().getResources().getConfiguration().locale; 18 | return local.getLanguage(); 19 | } 20 | 21 | public static String formatVolumeInfo(long totalSpace, long availSpace) { 22 | if (getLocalLanguage().endsWith(LANG_FARSI_FA)) { 23 | return String.format(FileManagerApplication.getContext().getString(R.string.volume_info_size), 24 | FileUtils.formatFileSize(totalSpace), 25 | FileUtils.formatFileSize(availSpace)); 26 | } else { 27 | return String.format(FileManagerApplication.getContext().getString(R.string.volume_info_size), 28 | FileUtils.formatFileSize(availSpace), 29 | FileUtils.formatFileSize(totalSpace)); 30 | } 31 | } 32 | 33 | public static String formatItemCount(int count) { 34 | if (count <= 1) { 35 | return String.format(FileManagerApplication.getContext() 36 | .getString(R.string.item_count), count); 37 | } else { 38 | return String.format(FileManagerApplication.getContext() 39 | .getString(R.string.item_counts), count); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * Created by koma on 11/16/16. 7 | */ 8 | 9 | public class LogUtils { 10 | private static final boolean IS_DEBUG = true; 11 | private static final String TAG = "FileManager"; 12 | 13 | public static void i(String tag, String msg) { 14 | if (IS_DEBUG) { 15 | Log.i(TAG, buildString(tag, msg)); 16 | } 17 | } 18 | 19 | public static void e(String tag, String msg) { 20 | if (IS_DEBUG) { 21 | Log.e(TAG, buildString(tag, msg)); 22 | } 23 | } 24 | 25 | private static String buildString(String tag, String msg) { 26 | StringBuilder sb = new StringBuilder(tag); 27 | sb.append("----"); 28 | sb.append(msg); 29 | return sb.toString(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/util/Utils.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.util; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.os.Build; 8 | import android.support.annotation.ColorInt; 9 | import android.support.v7.widget.LinearLayoutManager; 10 | import android.support.v7.widget.OrientationHelper; 11 | import android.support.v7.widget.RecyclerView; 12 | import android.support.v7.widget.StaggeredGridLayoutManager; 13 | import android.view.View; 14 | import android.view.inputmethod.InputMethodManager; 15 | 16 | /** 17 | * Created by koma on 12/15/16. 18 | */ 19 | 20 | public class Utils { 21 | /** 22 | * Show Soft Keyboard with new Thread 23 | * 24 | * @param activity 25 | */ 26 | public static void hideSoftInput(final Activity activity) { 27 | if (activity.getCurrentFocus() != null) { 28 | new Runnable() { 29 | public void run() { 30 | InputMethodManager imm = 31 | (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); 32 | imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); 33 | } 34 | }.run(); 35 | } 36 | } 37 | 38 | /** 39 | * Hide Soft Keyboard from Dialogs with new Thread 40 | * 41 | * @param context 42 | * @param view 43 | */ 44 | public static void hideSoftInputFrom(final Context context, final View view) { 45 | new Runnable() { 46 | @Override 47 | public void run() { 48 | InputMethodManager imm = 49 | (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); 50 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 51 | } 52 | }.run(); 53 | } 54 | 55 | /** 56 | * Show Soft Keyboard with new Thread 57 | * 58 | * @param context 59 | * @param view 60 | */ 61 | public static void showSoftInput(final Context context, final View view) { 62 | new Runnable() { 63 | @Override 64 | public void run() { 65 | InputMethodManager imm = 66 | (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 67 | imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); 68 | } 69 | }.run(); 70 | } 71 | 72 | /** 73 | * Finds the layout orientation of the RecyclerView, no matter which LayoutManager is in use. 74 | * 75 | * @param layoutManager the LayoutManager instance in use by the RV 76 | * @return one of {@link OrientationHelper#HORIZONTAL}, {@link OrientationHelper#VERTICAL} 77 | */ 78 | public static int getOrientation(RecyclerView.LayoutManager layoutManager) { 79 | if (layoutManager instanceof LinearLayoutManager) { 80 | return ((LinearLayoutManager) layoutManager).getOrientation(); 81 | } else if (layoutManager instanceof StaggeredGridLayoutManager) { 82 | return ((StaggeredGridLayoutManager) layoutManager).getOrientation(); 83 | } 84 | return OrientationHelper.HORIZONTAL; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/video/VideoActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.video; 2 | 3 | import android.database.ContentObserver; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v4.app.FragmentTransaction; 7 | import android.support.v7.widget.Toolbar; 8 | 9 | import com.koma.filemanager.R; 10 | import com.koma.filemanager.audio.AudioFragment; 11 | import com.koma.filemanager.audio.AudioPresenter; 12 | import com.koma.filemanager.base.BaseMenuActivity; 13 | import com.koma.filemanager.data.FileRepository; 14 | import com.koma.filemanager.util.FileCategoryUtils; 15 | import com.koma.filemanager.util.LogUtils; 16 | 17 | import butterknife.BindView; 18 | 19 | /** 20 | * Created by koma on 11/28/16. 21 | */ 22 | 23 | public class VideoActivity extends BaseMenuActivity { 24 | private static final String TAG = "VideoActivity"; 25 | private VideoContract.Presenter mPresenter; 26 | 27 | public void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | LogUtils.i(TAG, "onCreate"); 30 | init(); 31 | } 32 | 33 | private void init() { 34 | VideoFragment videoFragment = (VideoFragment) getSupportFragmentManager().findFragmentById(R.id.content); 35 | if (videoFragment == null) { 36 | videoFragment = new VideoFragment(); 37 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 38 | transaction.replace(R.id.content, videoFragment).commit(); 39 | } 40 | mPresenter = new VideoPresenter(videoFragment, FileRepository.getInstance()); 41 | mPresenter.subscribe(); 42 | getContentResolver().registerContentObserver(FileCategoryUtils.getAudioUri(), true, mVideoObserver); 43 | } 44 | 45 | private final ContentObserver mVideoObserver = new ContentObserver(new Handler()) { 46 | @Override 47 | public void onChange(boolean selfChange) { 48 | super.onChange(selfChange); 49 | LogUtils.i(TAG, "Video uri change so refresh"); 50 | if (mPresenter != null) { 51 | mPresenter.getVideoFiles(); 52 | } 53 | } 54 | }; 55 | 56 | @Override 57 | public void onStart() { 58 | super.onStart(); 59 | LogUtils.i(TAG, "onStart"); 60 | } 61 | 62 | @Override 63 | public void onResume() { 64 | super.onResume(); 65 | LogUtils.i(TAG, "onResume"); 66 | } 67 | 68 | @Override 69 | public void onPause() { 70 | super.onPause(); 71 | LogUtils.i(TAG, "onPause"); 72 | } 73 | 74 | @Override 75 | public void onStop() { 76 | super.onStop(); 77 | LogUtils.i(TAG, "onStop"); 78 | } 79 | 80 | @Override 81 | public void onDestroy() { 82 | super.onDestroy(); 83 | LogUtils.i(TAG, "onDestroy"); 84 | } 85 | 86 | @Override 87 | protected int getLayoutId() { 88 | return R.layout.common_layout; 89 | } 90 | 91 | @Override 92 | protected void sortByType() { 93 | LogUtils.i(TAG, "sortByType"); 94 | } 95 | 96 | @Override 97 | protected void sortByName() { 98 | LogUtils.i(TAG, "sortByName"); 99 | } 100 | 101 | @Override 102 | protected void sortBySize() { 103 | LogUtils.i(TAG, "sortBySize"); 104 | } 105 | 106 | @Override 107 | protected void sortByDate() { 108 | LogUtils.i(TAG, "sortByDate"); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/video/VideoContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.video; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.AudioFile; 6 | 7 | import java.util.ArrayList; 8 | 9 | import rx.Observable; 10 | 11 | /** 12 | * Created by koma on 11/28/16. 13 | */ 14 | 15 | public interface VideoContract { 16 | interface View extends BaseView { 17 | void refreshAdapter(ArrayList audioFiles); 18 | 19 | void showEmpty(); 20 | } 21 | 22 | interface Presenter extends BasePresenter { 23 | Observable> getVideoFiles(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/video/VideoFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.video; 2 | 3 | import com.koma.filemanager.base.BaseFragment; 4 | import com.koma.filemanager.data.model.AudioFile; 5 | import com.koma.filemanager.util.LogUtils; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by koma on 11/28/16. 11 | */ 12 | 13 | public class VideoFragment extends BaseFragment implements VideoContract.View { 14 | private static final String TAG = "VideoFragment"; 15 | 16 | @Override 17 | public void refreshAdapter(ArrayList audioFiles) { 18 | LogUtils.i(TAG, "refreshAdapter"); 19 | } 20 | 21 | @Override 22 | public void showEmpty() { 23 | LogUtils.i(TAG, "showEmpty"); 24 | } 25 | 26 | @Override 27 | public void setPresenter(VideoContract.Presenter presenter) { 28 | LogUtils.i(TAG, "setPresenter"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/video/VideoPresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.video; 2 | 3 | import com.koma.filemanager.data.FileRepository; 4 | import com.koma.filemanager.data.model.AudioFile; 5 | import com.koma.filemanager.util.LogUtils; 6 | 7 | import java.util.ArrayList; 8 | 9 | import rx.Observable; 10 | 11 | /** 12 | * Created by koma on 11/28/16. 13 | */ 14 | 15 | public class VideoPresenter implements VideoContract.Presenter { 16 | private static final String TAG = "VideoPresenter"; 17 | private VideoContract.View mView; 18 | FileRepository mRepository; 19 | 20 | public VideoPresenter(VideoFragment view, FileRepository repository) { 21 | mView = view; 22 | mView.setPresenter(this); 23 | mRepository = repository; 24 | } 25 | 26 | @Override 27 | public Observable> getVideoFiles() { 28 | LogUtils.i(TAG, "getAudioFiles"); 29 | return null; 30 | } 31 | 32 | @Override 33 | public void subscribe() { 34 | LogUtils.i(TAG, "subscribe"); 35 | 36 | } 37 | 38 | @Override 39 | public void unSubscribe() { 40 | LogUtils.i(TAG, "unSubscribe"); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/volumeinfo/VolumeInfoActivity.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.volumeinfo; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentTransaction; 5 | 6 | import com.koma.filemanager.R; 7 | import com.koma.filemanager.base.BaseActivity; 8 | import com.koma.filemanager.data.FileRepository; 9 | import com.koma.filemanager.util.Constants; 10 | import com.koma.filemanager.util.LogUtils; 11 | 12 | 13 | /** 14 | * Created by koma on 12/13/16. 15 | */ 16 | 17 | public class VolumeInfoActivity extends BaseActivity { 18 | private static final String TAG = "VolumeInfoActivity"; 19 | private VolumeInfoContract.Presenter mPresenter; 20 | 21 | @Override 22 | public void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | init(); 25 | } 26 | 27 | private void init() { 28 | String title = getIntent().getStringExtra(Constants.OPERATION_ACTION); 29 | if (title != null) { 30 | setTitle(title); 31 | } 32 | VolumeInfoFragment fragment = (VolumeInfoFragment) getSupportFragmentManager().findFragmentById(R.id.content); 33 | if (fragment == null) { 34 | fragment = VolumeInfoFragment.newInstance(title); 35 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 36 | transaction.replace(R.id.content, fragment).commit(); 37 | } 38 | mPresenter = new VolumeInfoPresenter(fragment, FileRepository.getInstance()); 39 | } 40 | 41 | @Override 42 | public void onResume() { 43 | super.onResume(); 44 | LogUtils.i(TAG, "onResume"); 45 | } 46 | 47 | @Override 48 | public void onBackPressed() { 49 | /*ActionSelectionManager.getInstance().clear(); 50 | BusProvider.getInstance().post( 51 | new MessageEvent(MessageEvent.EVENT_CANCEL_FILE_OPERATION));*/ 52 | super.onBackPressed(); 53 | LogUtils.i(TAG, "onBackPressed"); 54 | } 55 | 56 | @Override 57 | public void onDestroy() { 58 | super.onDestroy(); 59 | } 60 | 61 | @Override 62 | protected int getLayoutId() { 63 | return R.layout.common_layout; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/volumeinfo/VolumeInfoAdapter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.volumeinfo; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import com.koma.filemanager.R; 11 | import com.koma.filemanager.data.model.Disk; 12 | import com.koma.filemanager.util.LogUtils; 13 | 14 | import java.util.ArrayList; 15 | 16 | import butterknife.BindView; 17 | import butterknife.ButterKnife; 18 | import butterknife.OnClick; 19 | 20 | /** 21 | * Created by koma on 12/15/16. 22 | */ 23 | 24 | public class VolumeInfoAdapter extends RecyclerView.Adapter { 25 | private static final String TAG = "VolumeInfoAdapter"; 26 | private ArrayList mData; 27 | private Context mContext; 28 | private OnItemClickListener mListener; 29 | 30 | public VolumeInfoAdapter(Context context, ArrayList data) { 31 | this.mData = data; 32 | this.mContext = context; 33 | } 34 | 35 | public void setOnItemClickListener(OnItemClickListener listener) { 36 | this.mListener = listener; 37 | } 38 | 39 | public interface OnItemClickListener { 40 | void onItemClick(View view, int position); 41 | } 42 | 43 | @Override 44 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 45 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_view_volume_info, null); 46 | 47 | return new ViewHolder(view); 48 | } 49 | 50 | @Override 51 | public void onBindViewHolder(ViewHolder holder, int position) { 52 | holder.mTitle.setTag(position); 53 | holder.mTitle.setText(mData.get(position).getDescription()); 54 | } 55 | 56 | @Override 57 | public int getItemCount() { 58 | return mData == null ? 0 : mData.size(); 59 | } 60 | 61 | public class ViewHolder extends RecyclerView.ViewHolder { 62 | @OnClick(R.id.volume_info_layout) 63 | void onClick(View view) { 64 | LogUtils.i(TAG, "onItemClick"); 65 | if (mListener != null) { 66 | mListener.onItemClick(view, (Integer) view.getTag()); 67 | } 68 | } 69 | 70 | @BindView(R.id.volume_info_title) 71 | TextView mTitle; 72 | 73 | public ViewHolder(View view) { 74 | super(view); 75 | ButterKnife.bind(this, view); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/volumeinfo/VolumeInfoContract.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.volumeinfo; 2 | 3 | import com.koma.filemanager.base.BasePresenter; 4 | import com.koma.filemanager.base.BaseView; 5 | import com.koma.filemanager.data.model.Disk; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by koma on 12/13/16. 12 | */ 13 | 14 | public interface VolumeInfoContract { 15 | interface View extends BaseView { 16 | void refreshAdapter(List disks); 17 | } 18 | 19 | interface Presenter extends BasePresenter { 20 | void getDisks(); 21 | 22 | void onTaskCompleted(ArrayList disks); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/volumeinfo/VolumeInfoFragment.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.volumeinfo; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.koma.filemanager.R; 12 | import com.koma.filemanager.base.BaseFragment; 13 | import com.koma.filemanager.data.model.Disk; 14 | import com.koma.filemanager.util.Constants; 15 | import com.koma.filemanager.util.LogUtils; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import butterknife.BindView; 21 | import butterknife.ButterKnife; 22 | 23 | /** 24 | * Created by koma on 12/15/16. 25 | */ 26 | 27 | public class VolumeInfoFragment extends BaseFragment implements VolumeInfoContract.View { 28 | private static final String TAG = "VolumeInfoFragment"; 29 | private VolumeInfoContract.Presenter mPresenter; 30 | private ArrayList mData; 31 | private VolumeInfoAdapter mAdapter; 32 | @BindView(R.id.recycler_view) 33 | RecyclerView mRecyclerView; 34 | 35 | public static VolumeInfoFragment newInstance(String title) { 36 | VolumeInfoFragment volumeInfoFragment = new VolumeInfoFragment(); 37 | Bundle bundle = new Bundle(); 38 | volumeInfoFragment.setArguments(bundle); 39 | return volumeInfoFragment; 40 | } 41 | 42 | @Override 43 | public void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | LogUtils.i(TAG, "onCreate"); 46 | init(); 47 | } 48 | 49 | private void init() { 50 | mData = new ArrayList<>(); 51 | mAdapter = new VolumeInfoAdapter(mContext, mData); 52 | mAdapter.setOnItemClickListener(new VolumeInfoAdapter.OnItemClickListener() { 53 | @Override 54 | public void onItemClick(View view, int position) { 55 | LogUtils.i(TAG, "onItemClick"); 56 | Intent intent = new Intent(); 57 | ComponentName componentName = new ComponentName("com.koma.filemanager", 58 | "com.koma.filemanager.fileview.FileViewActivity"); 59 | intent.setComponent(componentName); 60 | intent.putExtra(Constants.EXTRA_FILE_DIRECTORY, mData.get(position) 61 | .getMountPoint()); 62 | mContext.startActivity(intent); 63 | startActivity(intent); 64 | } 65 | }); 66 | } 67 | 68 | @Override 69 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 70 | View view = inflater.inflate(R.layout.fragment_volume_info, container, false); 71 | ButterKnife.bind(this, view); 72 | return view; 73 | } 74 | 75 | @Override 76 | public void onViewCreated(View view, Bundle savedInstanceState) { 77 | super.onViewCreated(view, savedInstanceState); 78 | LogUtils.i(TAG, "onViewCreated"); 79 | } 80 | 81 | @Override 82 | public void onResume() { 83 | super.onResume(); 84 | LogUtils.i(TAG, "onResume"); 85 | if (mPresenter != null) { 86 | mPresenter.subscribe(); 87 | } 88 | } 89 | 90 | @Override 91 | public void refreshAdapter(List disks) { 92 | if (mData != null) { 93 | mData.clear(); 94 | } else { 95 | mData = new ArrayList<>(); 96 | } 97 | mData.addAll(disks); 98 | mAdapter.notifyDataSetChanged(); 99 | } 100 | 101 | @Override 102 | public void setPresenter(VolumeInfoContract.Presenter presenter) { 103 | LogUtils.i(TAG, "setPresenter"); 104 | mPresenter = presenter; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/volumeinfo/VolumeInfoPresenter.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.volumeinfo; 2 | 3 | import com.koma.filemanager.data.FileRepository; 4 | import com.koma.filemanager.data.model.Disk; 5 | import com.koma.filemanager.util.LogUtils; 6 | 7 | import java.util.ArrayList; 8 | 9 | import rx.Subscriber; 10 | import rx.Subscription; 11 | import rx.android.schedulers.AndroidSchedulers; 12 | import rx.schedulers.Schedulers; 13 | import rx.subscriptions.CompositeSubscription; 14 | 15 | /** 16 | * Created by koma on 12/13/16. 17 | */ 18 | 19 | public class VolumeInfoPresenter implements VolumeInfoContract.Presenter { 20 | private static final String TAG = "VolumeInfoPresenter"; 21 | private VolumeInfoContract.View mView; 22 | private CompositeSubscription mSubsriptions; 23 | private Subscription mGetDisksSubscription; 24 | private FileRepository mRepository; 25 | 26 | public VolumeInfoPresenter(VolumeInfoContract.View view, FileRepository repository) { 27 | mView = view; 28 | mView.setPresenter(this); 29 | mSubsriptions = new CompositeSubscription(); 30 | mRepository = repository; 31 | } 32 | 33 | @Override 34 | public synchronized void getDisks() { 35 | LogUtils.i(TAG, "getDisks"); 36 | mGetDisksSubscription = mRepository.getDisks().subscribeOn(Schedulers.io()) 37 | .observeOn(AndroidSchedulers.mainThread()) 38 | .subscribe(new Subscriber>() { 39 | @Override 40 | public void onCompleted() { 41 | LogUtils.i(TAG, "onCompleted"); 42 | } 43 | 44 | @Override 45 | public void onError(Throwable e) { 46 | LogUtils.e(TAG, "onError error : " + e.toString()); 47 | } 48 | 49 | @Override 50 | public void onNext(ArrayList disks) { 51 | if (mView != null) { 52 | onTaskCompleted(disks); 53 | } 54 | } 55 | }); 56 | mSubsriptions.add(mGetDisksSubscription); 57 | } 58 | 59 | @Override 60 | public void onTaskCompleted(ArrayList disks) { 61 | LogUtils.i(TAG, "onCompleted"); 62 | if (mView != null) { 63 | mView.refreshAdapter(disks); 64 | } 65 | } 66 | 67 | @Override 68 | public void subscribe() { 69 | LogUtils.i(TAG, "subscribe"); 70 | getDisks(); 71 | } 72 | 73 | @Override 74 | public void unSubscribe() { 75 | LogUtils.i(TAG, "unSubsribe"); 76 | if (mSubsriptions != null) { 77 | mSubsriptions.clear(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/widget/CategoryButton.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.widget; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.drawable.Drawable; 6 | import android.util.AttributeSet; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | import android.widget.TextView; 10 | 11 | import com.koma.filemanager.R; 12 | import com.koma.filemanager.util.LogUtils; 13 | 14 | /** 15 | * Created by koma on 11/19/16. 16 | */ 17 | 18 | public class CategoryButton extends LinearLayout { 19 | private static final String TAG = "CategoryButton"; 20 | private static final String DEFAULT_COUNT_TEXT = "..."; 21 | private ImageView mImageView; 22 | private TextView mTitleTextView; 23 | private TextView mCountTextView; 24 | private String mCount; 25 | private Context mContext; 26 | 27 | public CategoryButton(Context context) { 28 | this(context, null); 29 | init(context, null); 30 | } 31 | 32 | public CategoryButton(Context context, AttributeSet attributeSet) { 33 | this(context, attributeSet, 0); 34 | } 35 | 36 | public CategoryButton(Context context, AttributeSet attributeSet, int defStyleAttr) { 37 | super(context, attributeSet, 0); 38 | init(context, attributeSet); 39 | } 40 | 41 | 42 | private void init(Context context, AttributeSet attributeSet) { 43 | setOrientation(VERTICAL); 44 | inflate(context, R.layout.category_button_layout, this); 45 | mCount = DEFAULT_COUNT_TEXT; 46 | mContext = context; 47 | mImageView = (ImageView) findViewById(R.id.iv_category_button); 48 | mTitleTextView = (TextView) findViewById(R.id.tv_category_button_title); 49 | mCountTextView = (TextView) findViewById(R.id.tv_category_button_count); 50 | if (attributeSet == null) { 51 | return; 52 | } 53 | TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CategoryButton); 54 | try { 55 | setTitleText(typedArray.getString(R.styleable.CategoryButton_category_text)); 56 | setImageView(typedArray.getDrawable(R.styleable.CategoryButton_category_image)); 57 | setCountText(mCount); 58 | } catch (Exception e) { 59 | LogUtils.e(TAG, "error :" + e.toString()); 60 | } finally { 61 | typedArray.recycle(); 62 | } 63 | } 64 | 65 | public void setImageView(Drawable drawable) { 66 | this.mImageView.setImageDrawable(drawable); 67 | } 68 | 69 | public void setTitleText(CharSequence title) { 70 | this.mTitleTextView.setText(title); 71 | } 72 | 73 | // 此处的输入为个数 74 | public void setCountText(String count) { 75 | mCount = count; 76 | this.mCountTextView.setText(mContext.getString(R.string.category_num, mCount)); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/widget/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.widget; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Rect; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.util.TypedValue; 11 | import android.view.View; 12 | 13 | public class DividerItemDecoration extends RecyclerView.ItemDecoration { 14 | 15 | /* 16 | * RecyclerView的布局方向,默认先赋值 17 | * 为纵向布局 18 | * RecyclerView 布局可横向,也可纵向 19 | * 横向和纵向对应的分割想画法不一样 20 | * */ 21 | private int mOrientation = LinearLayoutManager.VERTICAL; 22 | private int mColor = Color.parseColor("#e0e0e0"); 23 | /** 24 | * item之间分割线的size,默认为1 25 | */ 26 | private int mItemSize = 1; 27 | 28 | /** 29 | * 绘制item分割线的画笔,和设置其属性 30 | * 来绘制个性分割线 31 | */ 32 | private Paint mPaint; 33 | 34 | /** 35 | * 构造方法传入布局方向,不可不传 36 | * 37 | * @param context 38 | * @param orientation 39 | */ 40 | public DividerItemDecoration(Context context, int orientation) { 41 | this.mOrientation = orientation; 42 | if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) { 43 | throw new IllegalArgumentException("请传入正确的参数"); 44 | } 45 | mItemSize = (int) TypedValue.applyDimension(mItemSize, TypedValue.COMPLEX_UNIT_DIP, context.getResources().getDisplayMetrics()); 46 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 47 | mPaint.setColor(mColor); 48 | /*设置填充*/ 49 | mPaint.setStyle(Paint.Style.FILL); 50 | } 51 | 52 | @Override 53 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { 54 | if (mOrientation == LinearLayoutManager.VERTICAL) { 55 | drawVertical(c, parent); 56 | } else { 57 | drawHorizontal(c, parent); 58 | } 59 | } 60 | 61 | /** 62 | * 绘制纵向 item 分割线 63 | * 64 | * @param canvas 65 | * @param parent 66 | */ 67 | private void drawVertical(Canvas canvas, RecyclerView parent) { 68 | final int left = parent.getPaddingLeft(); 69 | final int right = parent.getMeasuredWidth() - parent.getPaddingRight(); 70 | final int childSize = parent.getChildCount(); 71 | for (int i = 0; i < childSize; i++) { 72 | final View child = parent.getChildAt(i); 73 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); 74 | final int top = child.getBottom() + layoutParams.bottomMargin; 75 | final int bottom = top + mItemSize; 76 | canvas.drawRect(left, top, right, bottom, mPaint); 77 | } 78 | } 79 | 80 | /** 81 | * 绘制横向 item 分割线 82 | * 83 | * @param canvas 84 | * @param parent 85 | */ 86 | private void drawHorizontal(Canvas canvas, RecyclerView parent) { 87 | final int top = parent.getPaddingTop(); 88 | final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); 89 | final int childSize = parent.getChildCount(); 90 | for (int i = 0; i < childSize; i++) { 91 | final View child = parent.getChildAt(i); 92 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); 93 | final int left = child.getRight() + layoutParams.rightMargin; 94 | final int right = left + mItemSize; 95 | canvas.drawRect(left, top, right, bottom, mPaint); 96 | } 97 | } 98 | 99 | /** 100 | * 设置item分割线的size 101 | * 102 | * @param outRect 103 | * @param view 104 | * @param parent 105 | * @param state 106 | */ 107 | @Override 108 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 109 | if (mOrientation == LinearLayoutManager.VERTICAL) { 110 | outRect.set(0, 0, 0, mItemSize); 111 | } else { 112 | outRect.set(0, 0, mItemSize, 0); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /app/src/main/java/com/koma/filemanager/widget/LoadingView.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager.widget; 2 | 3 | import android.content.Context; 4 | import android.support.v4.widget.ContentLoadingProgressBar; 5 | import android.util.AttributeSet; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.widget.FrameLayout; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.koma.filemanager.R; 13 | 14 | import butterknife.BindString; 15 | import butterknife.BindView; 16 | import butterknife.ButterKnife; 17 | 18 | /** 19 | * Created by koma on 12/21/16. 20 | */ 21 | 22 | public class LoadingView extends FrameLayout { 23 | private static final String TAG = "LoadingView"; 24 | private Context mContext; 25 | @BindString(R.string.no_file) 26 | String mNoFileString; 27 | @BindString(R.string.loading) 28 | String mLoadingString; 29 | @BindView(R.id.progress_bar) 30 | ContentLoadingProgressBar mProgressBar; 31 | @BindView(R.id.empty_icon) 32 | ImageView mEmptyImageView; 33 | @BindView(R.id.loading_text) 34 | TextView mLoadingText; 35 | 36 | public LoadingView(Context context) { 37 | super(context); 38 | init(context); 39 | } 40 | 41 | private void init(Context context) { 42 | mContext = context; 43 | LayoutInflater inflater = LayoutInflater.from(mContext); 44 | inflater.inflate(R.layout.loading_view, this); 45 | } 46 | 47 | public LoadingView(Context context, AttributeSet attributeSet) { 48 | super(context, attributeSet); 49 | init(context); 50 | } 51 | 52 | @Override 53 | public void onFinishInflate() { 54 | super.onFinishInflate(); 55 | ButterKnife.bind(this, this); 56 | } 57 | 58 | public void hideLoading() { 59 | mProgressBar.hide(); 60 | this.setVisibility(View.GONE); 61 | } 62 | 63 | public void showLoding() { 64 | this.setVisibility(View.VISIBLE); 65 | mLoadingText.setText(mLoadingString); 66 | mProgressBar.show(); 67 | } 68 | 69 | public void showLoadingEmpty() { 70 | this.setVisibility(View.VISIBLE); 71 | mEmptyImageView.setVisibility(View.VISIBLE); 72 | mLoadingText.setText(mNoFileString); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/fast_scroller_bubble.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/fast_scroller_handle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_create_new_folder_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cut.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cut_grey_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cut_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete_grey_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_filter_list.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_more_vert.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_more_vert_grey_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_more_vert_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_settings.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share_grey_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_share_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_unfavorite.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/progress_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/action_mode_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 26 | 27 | 34 | 35 | 42 | 43 | 50 | 51 | 52 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/archive_item_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/category_button_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 17 | 18 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/common_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 29 | 30 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 23 | 24 | 29 | 30 | 35 | 36 | 41 | 42 | 43 | 48 | 49 | 54 | 55 | 60 | 61 | 66 | 67 | 68 | 69 | 70 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /app/src/main/res/layout/divider_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fast_scroller.xml: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_volume_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/input_name_dialog_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_disk.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 18 | 27 | 28 | 35 | 36 | 37 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_view.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 13 | 14 | 23 | 24 | 33 | 34 | 42 | 43 | 44 | 52 | 53 | 57 | 58 | 68 | 69 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_view_volume_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/library_fast_scroller_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 17 | 18 | 35 | 36 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/loading_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 20 | 21 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 21 | 22 | 28 | 29 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recyclerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 17 | 18 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/splashactivity_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | 19 | 26 | 27 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 25 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/menu/common_menu.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_sort.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 11 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/menu/select_mode_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 14 | 19 | 24 | 29 | 32 | 35 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_apk.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_audio.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_doc.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_image.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/category_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/category_zip.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/defaut_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/defaut_image.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/empty_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/empty_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_dropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/ic_dropdown.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_menu_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/ic_menu_share.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_audio.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_compress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_compress.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_document.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_folder.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_ppt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_ppt.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_text.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/item_xls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xhdpi/item_xls.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_apk.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_audio.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_doc.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_file_icon_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_file_icon_video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_image.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/category_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/category_zip.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/item_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/item_app.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/item_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/item_audio.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/item_compress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/item_compress.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/item_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/item_folder.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/item_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/app/src/main/res/mipmap-xxhdpi/item_video.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @string/sort_by_type 5 | @string/sort_by_name 6 | @string/sort_by_size 7 | @string/sort_by_date 8 | 9 | 10 | 11 | text/plain 12 | text/html 13 | application/pdf 14 | application/msword 15 | application/vnd.ms-excel 16 | application/mspowerpoint 17 | 18 | 19 | docx 20 | pptx 21 | xlsx 22 | ppt 23 | doc 24 | xls 25 | 26 | 27 | 28 | application/x-tar 29 | application/x-compressed 30 | application/zip 31 | application/x-gtar 32 | application/x-gzip 33 | application/x-rar-compressed 34 | 35 | 36 | 7z 37 | zip 38 | rar 39 | tar 40 | gz 41 | bz2 42 | tgz 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #808080 7 | #e0e0e0 8 | #FFFFFFFF 9 | 10 | 11 | #ececec 12 | #02a9ec 13 | 14 | 15 | #767676 16 | #E49741 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 160dp 5 | 6 | 16dp 7 | 16dp 8 | 16dp 9 | 10 | 11 | 12sp 12 | 22dp 13 | 22dp 14 | 15 | 16 | 1dp 17 | 18 | 19 | 42dp 20 | 42dp 21 | 4dp 22 | 23 | 24 | 4dp 25 | 10dp 26 | 27 | 28 | 12dp 29 | 5dp 30 | 31 | 32 | 10dp 33 | 34 | 35 | 35dp 36 | 16sp 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FileManager 3 | 4 | Open navigation drawer 5 | Close navigation drawer 6 | 7 | Search 8 | CopyRight@2016 9 | 10 | 11 | %1$d item 12 | %1$d items 13 | 14 | 15 | %1$s 16 | 17 | %1$s/%2$s 18 | 19 | 20 | Audio Files 21 | 22 | 23 | Video Files 24 | 25 | 26 | Image Files 27 | 28 | 29 | Document Files 30 | 31 | 32 | Zip Files 33 | 34 | 35 | Apk Files 36 | 37 | 38 | Phone 39 | 40 | More 41 | 42 | Sort Type 43 | Type 44 | Name 45 | Size 46 | Date 47 | 48 | 49 | Share 50 | Copy 51 | Cut 52 | Delete 53 | Select 54 | Select All 55 | Deselect All 56 | Rename 57 | Detail 58 | 59 | 60 | UnCompress 61 | UnCompress To 62 | 63 | 64 | Please input the folder name 65 | Title 66 | Nothing to modify 67 | 68 | 69 | Loading... 70 | No File 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 17 | 18 | 21 | 22 | 27 | 28 | 31 | 32 | 37 | 38 | 42 | 43 | 44 | 45 | 46 | 54 | 55 | 62 | 63 | 64 | 68 | 69 | 73 | 74 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /app/src/main/res/xml/searchable.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/test/java/com/koma/filemanager/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.koma.filemanager; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /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:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | } 20 | //全局设定编码 21 | tasks.withType(JavaCompile) { 22 | options.encoding = "UTF-8" 23 | } 24 | tasks.withType(JavaCompile) { 25 | sourceCompatibility = JavaVersion.VERSION_1_8 26 | targetCompatibility = JavaVersion.VERSION_1_8 27 | } 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | ext { 34 | // Sdk and tools 35 | minSdkVersion = 21 36 | targetSdkVersion = 23 37 | compileSdkVersion = 24 38 | buildToolsVersion = '24.0.2' 39 | versionCode = 1 40 | versionName = '1.0' 41 | renderscriptTargetApi = 20 42 | 43 | // App dependencies 44 | supportLibraryVersion = '24.2.1' 45 | glideVersion = '3.7.0' 46 | rxjavaVersion = '1.1.6' 47 | rxandroidVersion = '1.2.1' 48 | butterknife = '8.4.0' 49 | leakcanaryVersion = '1.5' 50 | } 51 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/gradle.properties -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /koma_key.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/koma_key.jks -------------------------------------------------------------------------------- /preview/screenshot_file_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/preview/screenshot_file_view.png -------------------------------------------------------------------------------- /preview/screenshot_main_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/komamj/FileManager/4d33663d9a215db54806929752ef7d9896b85e9d/preview/screenshot_main_ui.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------