├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── jni
│ ├── Android.mk
│ ├── Application.mk
│ └── search_image
│ │ ├── Android.mk
│ │ └── search_image.c
├── linroid_debug.jks
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── linroid
│ │ └── viewit
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── exec
│ │ │ ├── arm64-v8a
│ │ │ └── search_image
│ │ │ ├── armeabi-v7a
│ │ │ └── search_image
│ │ │ ├── armeabi
│ │ │ └── search_image
│ │ │ ├── mips
│ │ │ └── search_image
│ │ │ ├── mips64
│ │ │ └── search_image
│ │ │ ├── x86
│ │ │ └── search_image
│ │ │ └── x86_64
│ │ │ └── search_image
│ ├── java
│ │ └── com
│ │ │ └── linroid
│ │ │ └── rxshell
│ │ │ ├── Command.java
│ │ │ ├── CommandCallback.java
│ │ │ ├── IOUtils.java
│ │ │ ├── RxShell.java
│ │ │ ├── Shell.java
│ │ │ ├── Utils.java
│ │ │ └── exception
│ │ │ ├── RootDeniedException.java
│ │ │ ├── ShellExecuteErrorException.java
│ │ │ └── ShellTerminateException.java
│ ├── kotlin
│ │ └── com
│ │ │ └── linroid
│ │ │ └── viewit
│ │ │ ├── App.kt
│ │ │ ├── data
│ │ │ ├── model
│ │ │ │ ├── AppUsage.kt
│ │ │ │ ├── CloudFavorite.kt
│ │ │ │ ├── CloudScanPath.kt
│ │ │ │ ├── Favorite.kt
│ │ │ │ ├── Image.kt
│ │ │ │ ├── ImageTree.kt
│ │ │ │ ├── ImageType.kt
│ │ │ │ └── ScanPath.kt
│ │ │ ├── repo
│ │ │ │ ├── AppRepo.kt
│ │ │ │ ├── ImageRepo.kt
│ │ │ │ ├── ImageRepoManager.kt
│ │ │ │ ├── cloud
│ │ │ │ │ ├── CloudFavoriteRepo.kt
│ │ │ │ │ └── CloudPathRepo.kt
│ │ │ │ └── local
│ │ │ │ │ ├── AppUsageRepo.kt
│ │ │ │ │ ├── DBEvent.kt
│ │ │ │ │ ├── FavoriteRepo.kt
│ │ │ │ │ ├── ImageTreeCacheRepo.kt
│ │ │ │ │ └── PathRepo.kt
│ │ │ └── scanner
│ │ │ │ └── ImageScanner.kt
│ │ │ ├── ioc
│ │ │ ├── GalleryGraph.kt
│ │ │ ├── GlobalGraph.kt
│ │ │ ├── ViewerGraph.kt
│ │ │ ├── module
│ │ │ │ ├── AndroidModule.kt
│ │ │ │ ├── DataModule.kt
│ │ │ │ ├── GalleryModule.kt
│ │ │ │ ├── PrefModule.kt
│ │ │ │ ├── RepoModule.kt
│ │ │ │ └── ViewerModule.kt
│ │ │ └── quailifer
│ │ │ │ ├── ActivityScope.kt
│ │ │ │ ├── ImageScope.kt
│ │ │ │ └── Root.kt
│ │ │ ├── ui
│ │ │ ├── BaseActivity.kt
│ │ │ ├── BaseDialogFragment.kt
│ │ │ ├── BaseFragment.kt
│ │ │ ├── BaseListActivity.kt
│ │ │ ├── ImmersiveActivity.kt
│ │ │ ├── about
│ │ │ │ ├── AboutActivity.kt
│ │ │ │ ├── Developer.kt
│ │ │ │ └── DeveloperViewProvider.kt
│ │ │ ├── gallery
│ │ │ │ ├── CloudFavoriteViewerFragment.kt
│ │ │ │ ├── CreateFavoriteFragment.kt
│ │ │ │ ├── FavoriteViewerFragment.kt
│ │ │ │ ├── GalleryActivity.kt
│ │ │ │ ├── GalleryChildFragment.kt
│ │ │ │ ├── GalleryViewerFragment.kt
│ │ │ │ ├── ImageMultiOptionsController.kt
│ │ │ │ ├── ImageSelectProvider.kt
│ │ │ │ ├── SummaryFragment.kt
│ │ │ │ ├── TreeViewerFragment.kt
│ │ │ │ └── provider
│ │ │ │ │ ├── Category.kt
│ │ │ │ │ ├── CategoryViewProvider.kt
│ │ │ │ │ ├── CloudFavoriteViewProvider.kt
│ │ │ │ │ ├── FavoriteViewProvider.kt
│ │ │ │ │ ├── ImageCategory.kt
│ │ │ │ │ ├── ImageCategoryViewProvider.kt
│ │ │ │ │ ├── ImageTreeViewProvider.kt
│ │ │ │ │ ├── ImageViewProvider.kt
│ │ │ │ │ └── TreeViewProvider.kt
│ │ │ ├── home
│ │ │ │ ├── AppViewProvider.kt
│ │ │ │ └── HomeActivity.kt
│ │ │ ├── path
│ │ │ │ ├── PathManagerActivity.kt
│ │ │ │ └── provider
│ │ │ │ │ ├── BuildInPathViewProvider.kt
│ │ │ │ │ ├── BuiltInPath.kt
│ │ │ │ │ ├── CloudScanPathViewProvider.kt
│ │ │ │ │ └── ScanPathViewProvider.kt
│ │ │ └── viewer
│ │ │ │ ├── ImageDetailDialog.kt
│ │ │ │ ├── ImageProperty.kt
│ │ │ │ ├── ImagePropertyViewProvider.kt
│ │ │ │ ├── ImageViewerActivity.kt
│ │ │ │ ├── ImageViewerFragment.kt
│ │ │ │ └── ImageViewerPagerAdapter.kt
│ │ │ ├── utils
│ │ │ ├── AndroidNavUtil.kt
│ │ │ ├── AndroidUtils.kt
│ │ │ ├── FileUtils.kt
│ │ │ ├── FormatUtils.kt
│ │ │ ├── ImageMIME.kt
│ │ │ ├── OSUtils.kt
│ │ │ ├── PathUtils.kt
│ │ │ ├── RootUtils.kt
│ │ │ ├── RxOnce.kt
│ │ │ ├── WildcardMatcher.java
│ │ │ ├── arguments.kt
│ │ │ ├── constans.kt
│ │ │ ├── daemon.kt
│ │ │ ├── events.kt
│ │ │ ├── extensions.kt
│ │ │ ├── pref
│ │ │ │ ├── BasePreference.kt
│ │ │ │ ├── BooleanPreference.kt
│ │ │ │ └── LongPreference.kt
│ │ │ └── versions.kt
│ │ │ └── widget
│ │ │ ├── AnimatedImageView.kt
│ │ │ ├── AnimatedScrollView.kt
│ │ │ ├── AnimatedSetView.kt
│ │ │ ├── InsetsFrameLayout.kt
│ │ │ ├── PaddingBackgroundColorSpan.kt
│ │ │ ├── SquareImageView.java
│ │ │ ├── ThumbnailView.kt
│ │ │ └── divider
│ │ │ ├── CategoryItemDecoration.kt
│ │ │ └── DividerDecoration.kt
│ └── res
│ │ ├── anim
│ │ └── fragment_none.xml
│ │ ├── drawable-hdpi
│ │ ├── ic_create_new_folder.png
│ │ ├── ic_delete.png
│ │ ├── ic_filter.png
│ │ ├── ic_folder.png
│ │ ├── ic_save.png
│ │ ├── ic_sd_card.png
│ │ ├── ic_search.png
│ │ ├── ic_settings.png
│ │ ├── ic_share.png
│ │ ├── ic_sort.png
│ │ ├── ic_star.png
│ │ └── ic_star_border.png
│ │ ├── drawable-mdpi
│ │ ├── ic_create_new_folder.png
│ │ ├── ic_delete.png
│ │ ├── ic_filter.png
│ │ ├── ic_folder.png
│ │ ├── ic_save.png
│ │ ├── ic_sd_card.png
│ │ ├── ic_search.png
│ │ ├── ic_settings.png
│ │ ├── ic_share.png
│ │ ├── ic_sort.png
│ │ ├── ic_star.png
│ │ └── ic_star_border.png
│ │ ├── drawable-v21
│ │ └── bg_btn_delete_path.xml
│ │ ├── drawable-xhdpi
│ │ ├── avatar.jpeg
│ │ ├── cloud.png
│ │ ├── dinosaur_01.png
│ │ ├── dinosaur_02.png
│ │ ├── dinosaur_03.png
│ │ ├── dinosaur_04.png
│ │ ├── dinosaur_05.png
│ │ ├── dinosaur_06.png
│ │ ├── ic_create_new_folder.png
│ │ ├── ic_delete.png
│ │ ├── ic_eye.png
│ │ ├── ic_filter.png
│ │ ├── ic_folder.png
│ │ ├── ic_save.png
│ │ ├── ic_sd_card.png
│ │ ├── ic_search.png
│ │ ├── ic_settings.png
│ │ ├── ic_share.png
│ │ ├── ic_sort.png
│ │ ├── ic_star.png
│ │ ├── ic_star_border.png
│ │ └── line.png
│ │ ├── drawable-xxhdpi
│ │ ├── bg_category_divider.9.png
│ │ ├── ic_create_new_folder.png
│ │ ├── ic_delete.png
│ │ ├── ic_filter.png
│ │ ├── ic_folder.png
│ │ ├── ic_save.png
│ │ ├── ic_sd_card.png
│ │ ├── ic_search.png
│ │ ├── ic_settings.png
│ │ ├── ic_share.png
│ │ ├── ic_sort.png
│ │ ├── ic_star.png
│ │ └── ic_star_border.png
│ │ ├── drawable-xxxhdpi
│ │ ├── ic_create_new_folder.png
│ │ ├── ic_delete.png
│ │ ├── ic_filter.png
│ │ ├── ic_folder.png
│ │ ├── ic_save.png
│ │ ├── ic_sd_card.png
│ │ ├── ic_search.png
│ │ ├── ic_settings.png
│ │ ├── ic_share.png
│ │ ├── ic_sort.png
│ │ ├── ic_star.png
│ │ └── ic_star_border.png
│ │ ├── drawable
│ │ ├── anim_dinosaur.xml
│ │ ├── base_divider.xml
│ │ ├── bg_btn_delete_path.xml
│ │ ├── bg_viewer_options_mask.xml
│ │ ├── bg_viewer_toolbar_mask.xml
│ │ ├── bg_widget_multi_operations.xml
│ │ └── emoji_sleepy.png
│ │ ├── layout
│ │ ├── about_page_main_activity.xml
│ │ ├── activity_base_list.xml
│ │ ├── activity_gallery.xml
│ │ ├── activity_image_viewer.xml
│ │ ├── dialog_image_detail.xml
│ │ ├── fragment_image_tree.xml
│ │ ├── fragment_image_viewer.xml
│ │ ├── fragment_summary.xml
│ │ ├── item_app.xml
│ │ ├── item_build_in_path.xml
│ │ ├── item_category.xml
│ │ ├── item_cloud_scan_path.xml
│ │ ├── item_image.xml
│ │ ├── item_image_category.xml
│ │ ├── item_image_property.xml
│ │ ├── item_image_tree.xml
│ │ ├── item_scan_path.xml
│ │ ├── layout_dialog_create_favorite.xml
│ │ ├── layout_no_image_found.xml
│ │ ├── toolbar.xml
│ │ └── widget_image_multi_options.xml
│ │ ├── menu
│ │ ├── about.xml
│ │ ├── favorite_create.xml
│ │ ├── feedback.xml
│ │ ├── gallery.xml
│ │ ├── gallery_summary.xml
│ │ ├── gallery_tree_viewer.xml
│ │ ├── gallery_viewer.xml
│ │ ├── home.xml
│ │ ├── image_filter.xml
│ │ ├── image_multi_actions.xml
│ │ ├── image_sort.xml
│ │ ├── image_viewer.xml
│ │ └── path_manager.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── themes.xml
│ │ ├── values-zh
│ │ └── strings.xml
│ │ ├── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── ids.xml
│ │ ├── strings.xml
│ │ ├── styles.xml
│ │ └── themes.xml
│ │ └── xml
│ │ └── provider_paths.xml
│ └── test
│ └── java
│ └── com
│ └── linroid
│ └── viewit
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | signing.properties
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 看应用
2 | 这是一个可以搜索到某个应用所有图片的 APP
3 |
4 | - [Google Play](https://play.google.com/store/apps/details?id=com.linroid.viewit)
5 | - [酷安](http://www.coolapk.com/apk/com.linroid.viewit)
6 |
7 |
8 |
9 | 平时我们在使用 APP 时会看到很多图片,但总有一部分图片不能保存或者导出。它可以让你方便地找到应用缓存的所有图片,比如微信表情、好友头像、聊天等图片。
10 |
11 | 目前它只能搜索图片,以后我可能会加上视频、音频等其他文件的搜索:)
12 |
13 | 通过阅读看应用的源码,你可以收获以下:
14 |
15 | - 了解 Kotlin 的各种语法糖
16 | - 10w 数量级缓存数据的秒级写入与读取
17 | - Root 权限的操作
18 | - RxJava、Dagger2等的高级用法用法
19 | - 图片文件的搜索
20 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/jni/Android.mk:
--------------------------------------------------------------------------------
1 | include $(call all-subdir-makefiles)
--------------------------------------------------------------------------------
/app/jni/Application.mk:
--------------------------------------------------------------------------------
1 | # Optimizations
2 | APP_OPTIM := release
3 |
4 | # Build target
5 | APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mips64
6 |
7 | # If APP_MODULES is not set, all modules are compiled!
8 | APP_MODULES := search_image
--------------------------------------------------------------------------------
/app/jni/search_image/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 | include $(CLEAR_VARS)
3 |
4 | LOCAL_SRC_FILES := search_image.c
5 | LOCAL_LDLIBS := -llog
6 |
7 | LOCAL_MODULE := libsearch_image
8 |
9 | LOCAL_CFLAGS += -pie -fPIE
10 | LOCAL_LDFLAGS += -pie -fPIE
11 |
12 | include $(BUILD_EXECUTABLE)
--------------------------------------------------------------------------------
/app/jni/search_image/search_image.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | typedef enum ImageType {
11 | GIF,
12 | JPEG,
13 | PNG_A,
14 | PNG,
15 | UNKNOWN = -1
16 | } ImageType;
17 |
18 | ImageType get_image_type(const char *path);
19 |
20 | uint16_t readUInt16(FILE *pFILE);
21 |
22 | uint8_t readUInt8(FILE *pFILE);
23 |
24 | const int GIF_HEADER = 0x474946;
25 | const int PNG_HEADER = 0x89504E47;
26 | const uint16_t EXIF_MAGIC_NUMBER = 0xFFD8;
27 |
28 | void search_image(const char *name) {
29 | // printf("search_image:%s\n", name);
30 | DIR *dir;
31 | struct dirent *entry;
32 | struct stat statbuf;
33 |
34 | if (!(dir = opendir(name))) {
35 | return;
36 | }
37 | while ((entry = readdir(dir))) {
38 | char path[1024];
39 | int len = snprintf(path, sizeof(path) - 1, "%s/%s", name, entry->d_name);
40 | path[len] = 0;
41 | if (entry->d_type == DT_DIR) {
42 | if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
43 | continue;
44 | search_image(path);
45 | } else if (entry->d_type == DT_REG) {
46 | ImageType type = get_image_type(path);
47 | if (type != UNKNOWN) {
48 | lstat(path, &statbuf);
49 | printf("%lli %lli %d %s\n", statbuf.st_size, statbuf.st_mtime, type, path);
50 | }
51 | }
52 | }
53 | closedir(dir);
54 | }
55 |
56 | uint16_t readUInt16(FILE *fp) {
57 | uint16_t arr[1];
58 | fread(arr, sizeof(uint16_t), 1, fp);
59 | return htons(arr[0]);
60 | }
61 |
62 | uint8_t readUInt8(FILE *fp) {
63 | uint8_t arr[1];
64 | fread(arr, sizeof(uint8_t), 1, fp);
65 | return arr[0];
66 | }
67 |
68 | ImageType get_image_type(const char *path) {
69 | FILE *fp;
70 | ImageType type = UNKNOWN;
71 | if ((fp = fopen(path, "r")) != NULL) {
72 |
73 | int firstTwoBytes = readUInt16(fp);
74 | if (firstTwoBytes == EXIF_MAGIC_NUMBER) {
75 | type = JPEG;
76 | } else {
77 | int firstFourBytes = firstTwoBytes << 16 & 0xFFFF0000 | readUInt16(fp) & 0xFFFF;
78 | // PNG.
79 | if (firstFourBytes == PNG_HEADER) {
80 | // See: http://stackoverflow.com/questions/2057923/how-to-check-a-png-for-grayscale-alpha-color-type
81 | fseek(fp, 25 - 4, SEEK_CUR);
82 | int alpha = readUInt8(fp);
83 | // A RGB indexed PNG can also have transparency. Better safe than sorry!
84 | type = alpha >= 3 ? PNG_A : PNG;
85 | } else {
86 | // GIF from first 3 bytes.
87 | if (firstFourBytes >> 8 == GIF_HEADER) {
88 | type = GIF;
89 | }
90 | }
91 | }
92 | fclose(fp);
93 | }
94 | return type;
95 | }
96 |
97 | int main(int argc, char *argv[]) {
98 | search_image(argv[1]);
99 | // printf("finished!\n");
100 | exit(0);
101 | }
--------------------------------------------------------------------------------
/app/linroid_debug.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/linroid_debug.jks
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/linroid/viewit/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit;
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.linroid.viewit", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/assets/exec/arm64-v8a/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/arm64-v8a/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/armeabi-v7a/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/armeabi-v7a/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/armeabi/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/armeabi/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/mips/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/mips/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/mips64/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/mips64/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/x86/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/x86/search_image
--------------------------------------------------------------------------------
/app/src/main/assets/exec/x86_64/search_image:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/assets/exec/x86_64/search_image
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/Command.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell;
2 |
3 | /**
4 | * @author linroid
5 | * @since 25/01/2017
6 | */
7 | class Command {
8 | int id;
9 | String cmd;
10 | int exitCode;
11 | CommandCallback callback;
12 |
13 | public Command(int id, String cmd, CommandCallback callback) {
14 | this.id = id;
15 | this.cmd = cmd;
16 | this.callback = callback;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/CommandCallback.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell;
2 |
3 | /**
4 | * @author linroid
5 | * @since 25/01/2017
6 | */
7 | interface CommandCallback {
8 | void onOutput(String line);
9 |
10 | void onTerminate();
11 |
12 | void onFinished(Command command);
13 |
14 | void onError(Exception error);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/IOUtils.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import java.io.Closeable;
6 | import java.io.IOException;
7 |
8 | /**
9 | * @author linroid
10 | * @since 23/01/2017
11 | */
12 | class IOUtils {
13 | static void closeQuietly(@Nullable Closeable closeable) {
14 | if (closeable == null) {
15 | return;
16 | }
17 | try {
18 | closeable.close();
19 | } catch (IOException e) {
20 | e.printStackTrace();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/Utils.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * @author linroid
9 | * @since 06/03/2017
10 | */
11 | /** package **/ class Utils {
12 | private static final String TAG = "RxShellUtils";
13 |
14 | static final String[] SU_PATHS = { "/data/bin/", "/system/bin/", "/system/xbin/", "/sbin/",
15 | "/data/local/xbin/", "/data/local/bin/", "/system/sd/xbin/", "/system/bin/failsafe/",
16 | "/data/local/" };
17 |
18 | /**
19 | * Determine the path of the su executable.
20 | *
21 | * Code from https://github.com/miracle2k/android-autostarts, use under Apache License was
22 | * agreed by Michael Elsdörfer
23 | */
24 | public static String getSuPath() {
25 | for (String p : SU_PATHS) {
26 | File su = new File(p + "su");
27 | if (su.exists()) {
28 | Log.d(TAG, "su found at: " + p);
29 | return su.getAbsolutePath();
30 | } else {
31 | Log.v(TAG, "No su in: " + p);
32 | }
33 | }
34 | Log.d(TAG, "No su found in a well-known location, " + "will just use \"su\".");
35 | return "su";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/exception/RootDeniedException.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell.exception;
2 |
3 | public class RootDeniedException extends Exception {
4 | public RootDeniedException() {
5 | super("root permission denied");
6 | }
7 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/exception/ShellExecuteErrorException.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell.exception;
2 |
3 | /**
4 | * @author linroid
5 | * @since 17/01/2017
6 | */
7 | public class ShellExecuteErrorException extends Exception {
8 | public ShellExecuteErrorException(String message) {
9 | super(message);
10 | }
11 |
12 | public ShellExecuteErrorException() {
13 | }
14 |
15 | public ShellExecuteErrorException(String message, Throwable cause) {
16 | super(message, cause);
17 | }
18 |
19 | public ShellExecuteErrorException(Throwable cause) {
20 | super(cause);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linroid/rxshell/exception/ShellTerminateException.java:
--------------------------------------------------------------------------------
1 | package com.linroid.rxshell.exception;
2 |
3 | /**
4 | * @author linroid
5 | * @since 17/01/2017
6 | */
7 | public class ShellTerminateException extends Exception {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/App.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit
2 |
3 | import android.app.Application
4 | import com.avos.avoscloud.AVAnalytics
5 | import com.avos.avoscloud.AVOSCloud
6 | import com.crashlytics.android.Crashlytics
7 | import com.github.piasy.biv.BigImageViewer
8 | import com.github.piasy.biv.loader.glide.GlideImageLoader
9 | import com.linroid.viewit.ioc.DaggerGlobalGraph
10 | import com.linroid.viewit.ioc.GlobalGraph
11 | import com.linroid.viewit.ioc.module.AndroidModule
12 | import com.linroid.viewit.ioc.module.DataModule
13 | import com.linroid.viewit.ioc.module.PrefModule
14 | import com.linroid.viewit.ioc.module.RepoModule
15 | import com.linroid.viewit.utils.BINARY_DIRECTORY
16 | import com.linroid.viewit.utils.BINARY_SEARCH_IMAGE
17 | import com.linroid.viewit.utils.OSUtils
18 | import com.orm.SugarContext
19 | import io.fabric.sdk.android.Fabric
20 | import timber.log.Timber
21 | import java.io.File
22 |
23 |
24 | /**
25 | * @author linroid
26 | * @since 07/01/2017
27 | */
28 | class App : Application() {
29 | companion object {
30 | @JvmStatic lateinit var graph: GlobalGraph
31 | @JvmStatic private lateinit var instance: App;
32 | fun get(): App = instance
33 | }
34 |
35 | fun graph(): GlobalGraph = graph
36 |
37 | override fun onCreate() {
38 | super.onCreate()
39 |
40 | graph = DaggerGlobalGraph.builder()
41 | .androidModule(AndroidModule(this))
42 | .repoModule(RepoModule())
43 | .dataModule(DataModule())
44 | .prefModule(PrefModule())
45 | .build();
46 | instance = this;
47 | BigImageViewer.initialize(GlideImageLoader.with(this));
48 | AVOSCloud.initialize(this, "08OVX4PAskiJf7j7G0l5ulGc-gzGzoHsz", "TwiiWxl2XWnTsU48wRfDbidq");
49 | setupDebug()
50 | installBinary()
51 | SugarContext.init(this)
52 | Fabric.with(this, Crashlytics())
53 | }
54 |
55 | override fun onTerminate() {
56 | super.onTerminate()
57 | SugarContext.terminate()
58 | }
59 |
60 | private fun installBinary() {
61 | val supportAbis = OSUtils.getSupportedAbis();
62 | val dir = assets.list(BINARY_DIRECTORY)
63 | val preferABI = OSUtils.findPreferAbi(supportAbis, dir)
64 | if (preferABI?.isNotEmpty() as Boolean) {
65 | val stream = assets.open(BINARY_DIRECTORY + File.separator + preferABI + File.separator + BINARY_SEARCH_IMAGE);
66 | graph.rxShell().installBinary(this, stream, BINARY_SEARCH_IMAGE, 1.0F)
67 | .subscribe({ result ->
68 | Timber.i("install binary $BINARY_SEARCH_IMAGE result: $result")
69 | }, { error ->
70 | Timber.e(error)
71 | })
72 |
73 | }
74 | }
75 |
76 | private fun setupDebug() {
77 | if (!BuildConfig.DEBUG) {
78 | return
79 | }
80 | Timber.plant(object : Timber.DebugTree() {
81 |
82 | override fun log(priority: Int, t: Throwable?, message: String?, vararg args: Any?) {
83 | super.log(priority, t, "[${Thread.currentThread().name}]$message", *args)
84 | }
85 | })
86 | AVOSCloud.setDebugLogEnabled(true)
87 | AVAnalytics.setAnalyticsEnabled(false)
88 | }
89 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/AppUsage.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.orm.dsl.Table
4 | import com.orm.dsl.Unique
5 |
6 | /**
7 | * @author linroid
8 | * @since 07/02/2017
9 | */
10 | @Table
11 | class AppUsage {
12 | var id: Long? = null
13 | @Unique
14 | var packageName: String = ""
15 | var count: Int = 0
16 |
17 | override fun toString(): String {
18 | return "AppUsage(id=$id, packageName='$packageName', count=$count)"
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/CloudFavorite.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.avos.avoscloud.AVObject
4 | import com.orm.dsl.Ignore
5 |
6 | /**
7 | * @author linroid
8 | * @since 01/02/2017
9 | */
10 | class CloudFavorite {
11 | var name: String = ""
12 | var path: String = ""
13 | var packageName: String = ""
14 |
15 | @Ignore
16 | var tree: ImageTree? = null
17 |
18 | constructor(avObj: AVObject) {
19 | name = avObj.getString("name")
20 | path = avObj.getString("path")
21 | packageName = avObj.getString("packageName")
22 | }
23 |
24 | constructor()
25 |
26 | fun toAVObject(name: String): AVObject {
27 | val obj = AVObject(name)
28 | obj.put("name", name)
29 | obj.put("path", path)
30 | obj.put("packageName", packageName)
31 | return obj
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/CloudScanPath.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.avos.avoscloud.AVObject
4 |
5 | /**
6 | * @author linroid
7 | * @since 10/02/2017
8 | */
9 | class CloudScanPath(val avObj: AVObject) {
10 |
11 | var path: String
12 | get() = avObj.getString("path")
13 | set(value) = avObj.put("path", value)
14 |
15 | var packageName: String
16 | get() = avObj.getString("packageName")
17 | set(value) = avObj.put("packageName", value)
18 |
19 | override fun toString(): String {
20 | return "[CloudScanPath]${avObj.toString()}"
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/Favorite.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.avos.avoscloud.AVObject
4 | import com.orm.dsl.Ignore
5 | import com.orm.dsl.MultiUnique
6 | import com.orm.dsl.Table
7 |
8 | /**
9 | * @author linroid
10 | * @since 01/02/2017
11 | */
12 | @MultiUnique("path, packageName")
13 | @Table
14 | class Favorite {
15 | var id: Long? = null
16 | var name: String = ""
17 | var path: String = ""
18 | var packageName: String = ""
19 |
20 | @Ignore
21 | var tree: ImageTree? = null
22 |
23 | fun toAVObject(className: String): AVObject {
24 | val obj = AVObject(className)
25 | obj.put("name", name)
26 | obj.put("path", path)
27 | obj.put("packageName", packageName)
28 | return obj
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/Image.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.linroid.viewit.utils.RootUtils
4 | import paperparcel.PaperParcel
5 | import paperparcel.PaperParcelable
6 | import java.io.File
7 |
8 | /**
9 | * @author linroid
10 | * @since 08/01/2017
11 | */
12 | @PaperParcel
13 | data class Image(
14 | val source: File,
15 | val size: Long,
16 | val lastModified: Long,
17 | val type: ImageType,
18 | var mountFile: File? = null) : PaperParcelable {
19 |
20 | companion object {
21 | @JvmField val CREATOR = PaperParcelImage.CREATOR
22 | }
23 |
24 | val path: String
25 | get() = source.absolutePath
26 |
27 | fun mimeType() = type.mime
28 | fun file(): File? {
29 | if (mountFile != null) {
30 | return mountFile
31 | }
32 | if (RootUtils.isRootFile(source)) {
33 | return mountFile
34 | }
35 | return source
36 | }
37 |
38 | fun postfix(): String = type.postfix
39 |
40 | override fun equals(other: Any?): Boolean {
41 | if (other == null) {
42 | return false
43 | }
44 | if (other !is Image) {
45 | return false
46 | }
47 | return source == other.source
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/ImageType.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.bumptech.glide.load.resource.bitmap.ImageHeaderParser
4 |
5 | /**
6 | * @author linroid @gmail.com>
7 | * *
8 | * @since 23/01/2017
9 | */
10 | enum class ImageType constructor(val value: Int, val mime: String, val postfix: String) {
11 | /**
12 | * GIF type.
13 | */
14 | GIF(0, "image/gif", "gif"),
15 |
16 | /**
17 | * JPG type.
18 | */
19 | JPEG(1, "image/jpeg", "jpg"),
20 |
21 | /**
22 | * PNG type with alpha.
23 | */
24 | PNG_A(2, "image/png", "png"),
25 |
26 | /**
27 | * PNG type without alpha.
28 | */
29 | PNG(3, "image/png", "png"),
30 |
31 | /**
32 | * Unrecognized type.
33 | */
34 | UNKNOWN(-1, "", "");
35 |
36 |
37 | companion object {
38 |
39 | fun from(typeVal: Int): ImageType {
40 | when (typeVal) {
41 | 0 -> return GIF
42 | 1 -> return JPEG
43 | 2 -> return PNG_A
44 | 3 -> return PNG
45 | else -> {
46 | return UNKNOWN
47 | }
48 | }
49 | }
50 |
51 | fun from(type: ImageHeaderParser.ImageType): ImageType {
52 | when (type) {
53 | ImageHeaderParser.ImageType.GIF -> return GIF
54 | ImageHeaderParser.ImageType.JPEG -> return JPEG
55 | ImageHeaderParser.ImageType.PNG_A -> return PNG_A
56 | ImageHeaderParser.ImageType.PNG -> return PNG
57 | else -> {
58 | return UNKNOWN
59 | }
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/model/ScanPath.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.model
2 |
3 | import com.avos.avoscloud.AVObject
4 | import com.orm.dsl.Table
5 |
6 | /**
7 | * @author linroid
8 | * @since 10/02/2017
9 | */
10 | @Table
11 | class ScanPath {
12 | val id: Long? = null
13 | var path: String = ""
14 | var packageName: String = ""
15 |
16 | fun toAVObject(name: String): AVObject {
17 | val obj = AVObject(name)
18 | obj.put("path", path)
19 | obj.put("packageName", packageName)
20 | return obj
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/ImageRepoManager.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo
2 |
3 | import android.content.Context
4 | import android.content.pm.ApplicationInfo
5 | import com.linroid.viewit.utils.MOUNTS_CACHE_DIR
6 | import com.linroid.viewit.utils.daemon
7 | import timber.log.Timber
8 | import java.io.File
9 | import java.util.*
10 |
11 | /**
12 | * @author linroid
13 | * @since 29/01/2017
14 | */
15 | class ImageRepoManager(val context: Context) {
16 | private val cacheDir: File = File(context.cacheDir, MOUNTS_CACHE_DIR)
17 |
18 | private val repos = HashMap()
19 |
20 | init {
21 | cleanAsync()
22 | }
23 |
24 | fun getRepo(appInfo: ApplicationInfo): ImageRepo {
25 | if (repos.containsKey(appInfo.packageName)) {
26 | return repos[appInfo.packageName]!!
27 | } else {
28 | val repo = ImageRepo(context, File(cacheDir, appInfo.packageName), appInfo)
29 | repos[appInfo.packageName] = repo
30 | return repo
31 | }
32 | }
33 |
34 | fun removeRepo(appInfo: ApplicationInfo): ImageRepo? {
35 | val repo = repos.remove(appInfo.packageName)
36 | repo?.cleanAsync()
37 | return repo
38 | }
39 |
40 | fun cleanAsync() {
41 | daemon {
42 | Timber.w("cleanup all mounted files")
43 | if (cacheDir.exists()) {
44 | cacheDir.deleteRecursively()
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/cloud/CloudFavoriteRepo.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.cloud
2 |
3 | import android.content.pm.ApplicationInfo
4 | import cn.leancloud.rx.RxLeanCloud
5 | import com.avos.avoscloud.AVObject
6 | import com.avos.avoscloud.AVQuery
7 | import com.linroid.viewit.data.model.CloudFavorite
8 | import com.linroid.viewit.data.model.Favorite
9 | import rx.Observable
10 | import rx.schedulers.Schedulers
11 | import java.util.*
12 |
13 | /**
14 | * @author linroid
15 | * @since 06/02/2017
16 | */
17 | class CloudFavoriteRepo {
18 |
19 | fun list(appInfo: ApplicationInfo): Observable> {
20 | val query = AVQuery("CloudFavorite")
21 | .whereEqualTo("packageName", appInfo.packageName)
22 | return RxLeanCloud.find(query)
23 | .map { objs ->
24 | val favorites = ArrayList()
25 | objs.forEach {
26 | favorites.add(CloudFavorite(it))
27 | }
28 | return@map favorites.toList()
29 | }.subscribeOn(Schedulers.io())
30 | }
31 |
32 | fun upload(data: Favorite, appInfo: ApplicationInfo): Observable {
33 | val avObj = data.toAVObject("Favorite")
34 | return RxLeanCloud.save(avObj)
35 | .map { CloudFavorite(avObj) }
36 | .subscribeOn(Schedulers.io())
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/cloud/CloudPathRepo.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.cloud
2 |
3 | import android.content.pm.ApplicationInfo
4 | import cn.leancloud.rx.RxLeanCloud
5 | import com.avos.avoscloud.AVObject
6 | import com.avos.avoscloud.AVQuery
7 | import com.linroid.viewit.data.model.CloudScanPath
8 | import com.linroid.viewit.data.model.ScanPath
9 | import rx.Observable
10 | import rx.schedulers.Schedulers
11 | import java.util.*
12 |
13 | /**
14 | * @author linroid
15 | * @since 11/02/2017
16 | */
17 | class CloudPathRepo {
18 | fun upload(data: ScanPath, appInfo: ApplicationInfo): Observable {
19 | val obj = data.toAVObject("ScanPath")
20 | return RxLeanCloud.save(obj)
21 | .map { CloudScanPath(obj) }
22 | .subscribeOn(Schedulers.io())
23 | }
24 |
25 | fun list(appInfo: ApplicationInfo): Observable> {
26 | val query = AVQuery("CloudScanPath")
27 | .whereEqualTo("packageName", appInfo.packageName)
28 | return RxLeanCloud.find(query)
29 | .map { objs ->
30 | val paths = ArrayList()
31 | objs.forEach {
32 | paths.add(CloudScanPath(it))
33 | }
34 | return@map paths.toList()
35 | }.subscribeOn(Schedulers.io())
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/local/AppUsageRepo.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.local
2 |
3 | import android.content.pm.ApplicationInfo
4 | import com.linroid.viewit.data.model.AppUsage
5 | import com.orm.SugarRecord
6 | import com.orm.util.NamingHelper
7 | import rx.Observable
8 | import rx.schedulers.Schedulers
9 | import rx.subjects.BehaviorSubject
10 |
11 | /**
12 | * @author linroid
13 | * @since 16/02/2017
14 | */
15 | class AppUsageRepo {
16 | private val eventBus: BehaviorSubject = BehaviorSubject.create(DBEvent.DEFAULT)
17 |
18 | fun findOrCreate(appInfo: ApplicationInfo): Observable {
19 | return find(appInfo)
20 | .map { found ->
21 | if (found != null) {
22 | return@map found
23 | }
24 | val usage = AppUsage()
25 | usage.packageName = appInfo.packageName
26 | SugarRecord.save(usage)
27 | return@map usage
28 | }
29 | }
30 |
31 | fun find(appInfo: ApplicationInfo): Observable {
32 | return Observable.just(appInfo)
33 | .map {
34 | val result = SugarRecord.find(AppUsage::class.java,
35 | "package_name = ? ", appInfo.packageName)
36 | return@map result.firstOrNull()
37 | }
38 | .subscribeOn(Schedulers.io())
39 | }
40 |
41 | fun listTop(count: Int): Observable> {
42 | return Observable.just(count)
43 | .map {
44 | SugarRecord.findWithQuery(AppUsage::class.java,
45 | "SELECT * FROM ${NamingHelper.toSQLName(AppUsage::class.java)} ORDER BY COUNT DESC LIMIT $count")
46 | }
47 | .subscribeOn(Schedulers.io())
48 | }
49 |
50 | fun visitApp(appInfo: ApplicationInfo): Observable {
51 | return findOrCreate(appInfo).map {
52 | it.count++
53 | SugarRecord.update(it)
54 | eventBus.onNext(DBEvent.UPDATE)
55 | return@map it
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/local/DBEvent.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.local
2 |
3 | /**
4 | * @author linroid
5 | * @since 15/02/2017
6 | */
7 | enum class DBEvent {
8 | DEFAULT, INSERT, DELETE, UPDATE
9 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/local/FavoriteRepo.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.local
2 |
3 | import android.content.pm.ApplicationInfo
4 | import com.linroid.viewit.data.model.Favorite
5 | import com.linroid.viewit.utils.PathUtils
6 | import com.orm.SugarRecord
7 | import rx.Observable
8 | import rx.schedulers.Schedulers
9 | import rx.subjects.BehaviorSubject
10 |
11 | /**
12 | * @author linroid
13 | * @since 01/02/2017
14 | */
15 | class FavoriteRepo() {
16 | private val eventBus: BehaviorSubject = BehaviorSubject.create(DBEvent.DEFAULT)
17 |
18 | fun find(path: String, appInfo: ApplicationInfo): Observable {
19 | return eventBus
20 | .map {
21 | val result = SugarRecord.find(Favorite::class.java,
22 | "path = ? and package_name = ? ", path, appInfo.packageName)
23 | return@map result.firstOrNull()
24 | }
25 | .subscribeOn(Schedulers.io())
26 | }
27 |
28 | fun listWithChangeObserver(appInfo: ApplicationInfo): Observable> {
29 | return eventBus
30 | .map {
31 | SugarRecord.find(Favorite::class.java,
32 | "package_name = ?", appInfo.packageName)
33 | }
34 | .subscribeOn(Schedulers.io())
35 | }
36 |
37 | fun list(appInfo: ApplicationInfo): Observable> {
38 | return Observable.just(appInfo)
39 | .map {
40 | SugarRecord.find(Favorite::class.java,
41 | "package_name = ?", appInfo.packageName)
42 | }
43 | .subscribeOn(Schedulers.io())
44 | }
45 |
46 | fun create(appInfo: ApplicationInfo, path: String, name: String): Observable {
47 | return Observable
48 | .create {
49 | val favorite = Favorite()
50 | favorite.name = name
51 | favorite.packageName = appInfo.packageName
52 | favorite.path = PathUtils.formatToVariable(path, appInfo)
53 | SugarRecord.save(favorite)
54 | it.onNext(favorite)
55 | eventBus.onNext(DBEvent.INSERT)
56 | it.onCompleted()
57 | }
58 | .subscribeOn(Schedulers.io())
59 | }
60 |
61 | fun delete(favorite: Favorite, appInfo: ApplicationInfo): Observable {
62 | return Observable
63 | .create {
64 | val result = SugarRecord.delete(favorite)
65 | if (result) {
66 | eventBus.onNext(DBEvent.DELETE)
67 | }
68 | it.onNext(result)
69 | it.onCompleted()
70 | }
71 | .subscribeOn(Schedulers.io())
72 | }
73 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/data/repo/local/PathRepo.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.data.repo.local
2 |
3 | import android.content.pm.ApplicationInfo
4 | import com.linroid.viewit.data.model.ScanPath
5 | import com.linroid.viewit.utils.PathUtils
6 | import com.orm.SugarRecord
7 | import rx.Observable
8 | import rx.schedulers.Schedulers
9 | import rx.subjects.BehaviorSubject
10 |
11 | /**
12 | * @author linroid
13 | * @since 10/02/2017
14 | */
15 | class PathRepo {
16 | private val eventBus: BehaviorSubject = BehaviorSubject.create(DBEvent.DEFAULT)
17 |
18 | fun find(path: String, appInfo: ApplicationInfo): Observable {
19 | return eventBus
20 | .map {
21 | val result = SugarRecord.find(ScanPath::class.java,
22 | "path = ? and package_name = ? ", path, appInfo.packageName)
23 | return@map result.firstOrNull()
24 | }
25 | .subscribeOn(Schedulers.io())
26 | }
27 |
28 | fun listWithChangObserver(appInfo: ApplicationInfo): Observable> {
29 | return eventBus
30 | .map {
31 | SugarRecord.find(ScanPath::class.java,
32 | "package_name = ?", appInfo.packageName)
33 | }
34 | .subscribeOn(Schedulers.io())
35 | }
36 |
37 | fun list(appInfo: ApplicationInfo): Observable> {
38 | return Observable.just(appInfo)
39 | .map {
40 | SugarRecord.find(ScanPath::class.java,
41 | "package_name = ?", it.packageName)
42 | }
43 | .subscribeOn(Schedulers.io())
44 | }
45 |
46 | fun create(appInfo: ApplicationInfo, path: String): Observable {
47 | return Observable
48 | .create {
49 | val scanPath = ScanPath()
50 | scanPath.packageName = appInfo.packageName
51 | scanPath.path = PathUtils.formatToVariable(path, appInfo)
52 | SugarRecord.save(scanPath)
53 | eventBus.onNext(DBEvent.INSERT)
54 | it.onNext(scanPath)
55 | it.onCompleted()
56 | }
57 | .subscribeOn(Schedulers.io())
58 | }
59 |
60 | fun delete(scanPath: ScanPath): Observable {
61 | return Observable
62 | .create {
63 | val result = SugarRecord.delete(scanPath)
64 | if (result) {
65 | eventBus.onNext(DBEvent.DELETE)
66 | }
67 | it.onNext(result)
68 | it.onCompleted()
69 | }
70 | .subscribeOn(Schedulers.io())
71 | }
72 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/GalleryGraph.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc
2 |
3 | import com.linroid.viewit.ioc.module.GalleryModule
4 | import com.linroid.viewit.ioc.quailifer.ActivityScope
5 | import com.linroid.viewit.ui.favorite.CreateFavoriteFragment
6 | import com.linroid.viewit.ui.gallery.GalleryActivity
7 | import com.linroid.viewit.ui.gallery.SummaryFragment
8 | import com.linroid.viewit.ui.gallery.TreeViewerFragment
9 | import dagger.Component
10 |
11 | /**
12 | * @author linroid
13 | * @since 24/01/2017
14 | */
15 | @ActivityScope
16 | @Component(
17 | modules = arrayOf(GalleryModule::class),
18 | dependencies = arrayOf(GlobalGraph::class)
19 | )
20 | interface GalleryGraph {
21 | fun inject(activity: GalleryActivity)
22 | fun inject(fragment: TreeViewerFragment)
23 | fun inject(fragment: SummaryFragment)
24 | fun inject(fragment: CreateFavoriteFragment)
25 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/GlobalGraph.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc
2 |
3 | import android.content.Context
4 | import android.content.SharedPreferences
5 | import com.linroid.rxshell.RxShell
6 | import com.linroid.viewit.App
7 | import com.linroid.viewit.data.repo.ImageRepo
8 | import com.linroid.viewit.data.repo.ImageRepoManager
9 | import com.linroid.viewit.data.repo.cloud.CloudFavoriteRepo
10 | import com.linroid.viewit.data.repo.local.FavoriteRepo
11 | import com.linroid.viewit.ioc.module.AndroidModule
12 | import com.linroid.viewit.ioc.module.DataModule
13 | import com.linroid.viewit.ioc.module.PrefModule
14 | import com.linroid.viewit.ioc.module.RepoModule
15 | import com.linroid.viewit.ioc.quailifer.Root
16 | import com.linroid.viewit.ui.home.HomeActivity
17 | import com.linroid.viewit.ui.path.PathManagerActivity
18 | import com.linroid.viewit.utils.PREF_FILTER_SIZE
19 | import com.linroid.viewit.utils.PREF_SORT_TYPE
20 | import com.linroid.viewit.utils.RxOnce
21 | import com.linroid.viewit.utils.pref.LongPreference
22 | import dagger.Component
23 | import javax.inject.Named
24 | import javax.inject.Singleton
25 |
26 | /**
27 | * @author linroid
28 | * @since 07/01/2017
29 | */
30 | @Singleton
31 | @Component(modules = arrayOf(AndroidModule::class, DataModule::class, RepoModule::class, PrefModule::class))
32 | interface GlobalGraph {
33 | fun inject(app: App)
34 | fun inject(activity: HomeActivity)
35 | fun inject(imageRepo: ImageRepo)
36 | fun inject(rxOnce: RxOnce)
37 | fun inject(activity: PathManagerActivity)
38 |
39 | fun context(): Context
40 | @Root fun rootRxShell(): RxShell
41 | fun rxShell(): RxShell
42 | fun repoManager(): ImageRepoManager
43 | fun sharedPreferences(): SharedPreferences
44 | // fun realm(): Realm
45 | fun dbRepo(): FavoriteRepo
46 |
47 | fun netRepo(): CloudFavoriteRepo
48 |
49 | @Named(PREF_FILTER_SIZE)
50 | fun filterSizePref(): LongPreference
51 |
52 | @Named(PREF_SORT_TYPE)
53 | fun sortTypePref(): LongPreference
54 |
55 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/ViewerGraph.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc
2 |
3 | import com.linroid.viewit.ioc.module.ViewerModule
4 | import com.linroid.viewit.ioc.quailifer.ActivityScope
5 | import com.linroid.viewit.ui.viewer.ImageViewerActivity
6 | import com.linroid.viewit.ui.viewer.ImageViewerFragment
7 | import dagger.Component
8 |
9 | /**
10 | * @author linroid
11 | * @since 24/01/2017
12 | */
13 | @ActivityScope
14 | @Component(
15 | modules = arrayOf(ViewerModule::class),
16 | dependencies = arrayOf(GlobalGraph::class)
17 | )
18 | interface ViewerGraph {
19 | fun inject(activity: ImageViewerActivity)
20 | fun inject(fragment: ImageViewerFragment)
21 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/module/AndroidModule.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.module
2 |
3 | import android.content.Context
4 | import android.content.SharedPreferences
5 | import android.content.pm.PackageManager
6 | import android.content.res.Resources
7 | import android.preference.PreferenceManager
8 | import com.linroid.viewit.App
9 | import dagger.Module
10 | import dagger.Provides
11 | import javax.inject.Singleton
12 |
13 | /**
14 | * @author linroid
15 | * @since 07/01/2017
16 | */
17 | @Module
18 | class AndroidModule(val app: App) {
19 | @Provides
20 | fun provideApp(): App = app;
21 |
22 | @Provides
23 | fun provideApplicationContext(): Context = app;
24 |
25 | @Singleton
26 | @Provides
27 | fun provideResources(context: Context): Resources = context.resources;
28 |
29 | @Provides
30 | fun providePackageManager(context: Context): PackageManager = context.packageManager
31 |
32 | @Provides
33 | @Singleton
34 | fun provideSharedPreference(context: Context): SharedPreferences {
35 | return PreferenceManager.getDefaultSharedPreferences(context)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/module/GalleryModule.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.module
2 |
3 | import android.content.pm.ApplicationInfo
4 | import com.linroid.viewit.data.repo.ImageRepo
5 | import com.linroid.viewit.data.repo.ImageRepoManager
6 | import com.linroid.viewit.ioc.quailifer.ActivityScope
7 | import com.linroid.viewit.ui.gallery.GalleryActivity
8 | import dagger.Module
9 | import dagger.Provides
10 | import java.util.*
11 |
12 | /**
13 | * @author linroid
14 | * @since 24/01/2017
15 | */
16 | @Module
17 | class GalleryModule(val activity: GalleryActivity, val info: ApplicationInfo) {
18 | @Provides
19 | @ActivityScope
20 | fun provideInfo(): ApplicationInfo = info
21 |
22 | @Provides
23 | @ActivityScope
24 | fun provideGalleryActivity(): GalleryActivity = activity;
25 |
26 | @Provides
27 | @ActivityScope
28 | fun provideImages(): MutableList = ArrayList()
29 |
30 | @Provides
31 | @ActivityScope
32 | fun provideRepo(repoManager: ImageRepoManager): ImageRepo {
33 | return repoManager.getRepo(info)
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/module/PrefModule.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.module
2 |
3 | import android.content.SharedPreferences
4 | import com.linroid.viewit.data.repo.ImageRepo.Companion.SORT_BY_PATH
5 | import com.linroid.viewit.utils.PREF_FILTER_SIZE
6 | import com.linroid.viewit.utils.PREF_SORT_TYPE
7 | import com.linroid.viewit.utils.pref.LongPreference
8 | import dagger.Module
9 | import dagger.Provides
10 | import javax.inject.Named
11 | import javax.inject.Singleton
12 |
13 | /**
14 | * @author linroid
15 | * @since 27/01/2017
16 | */
17 | @Module
18 | class PrefModule {
19 | @Provides
20 | @Singleton
21 | @Named(PREF_SORT_TYPE)
22 | fun provideSortTypePref(pref: SharedPreferences): LongPreference {
23 | return LongPreference(pref, PREF_SORT_TYPE, SORT_BY_PATH)
24 | }
25 |
26 | @Provides
27 | @Singleton
28 | @Named(PREF_FILTER_SIZE)
29 | fun provideFilterSizePref(pref: SharedPreferences): LongPreference {
30 | return LongPreference(pref, PREF_FILTER_SIZE, 0)
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/module/RepoModule.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.module
2 |
3 | import android.content.Context
4 | import com.google.gson.Gson
5 | import com.linroid.viewit.data.repo.ImageRepoManager
6 | import com.linroid.viewit.data.repo.cloud.CloudFavoriteRepo
7 | import com.linroid.viewit.data.repo.cloud.CloudPathRepo
8 | import com.linroid.viewit.data.repo.local.AppUsageRepo
9 | import com.linroid.viewit.data.repo.local.FavoriteRepo
10 | import com.linroid.viewit.data.repo.local.ImageTreeCacheRepo
11 | import com.linroid.viewit.data.repo.local.PathRepo
12 | import dagger.Module
13 | import dagger.Provides
14 | import javax.inject.Singleton
15 |
16 | /**
17 | * @author linroid
18 | * @since 08/01/2017
19 | */
20 | @Module
21 | class RepoModule {
22 | @Singleton @Provides
23 | fun provideImageRepoManager(context: Context): ImageRepoManager {
24 | return ImageRepoManager(context)
25 | }
26 |
27 | @Singleton
28 | @Provides
29 | fun provideFavoriteRepo(): FavoriteRepo {
30 | return FavoriteRepo()
31 | }
32 |
33 | @Singleton
34 | @Provides
35 | fun provideCloudFavoriteRepo(): CloudFavoriteRepo {
36 | return CloudFavoriteRepo()
37 | }
38 |
39 | @Singleton
40 | @Provides
41 | fun provideScanPathRepo(): PathRepo {
42 | return PathRepo()
43 | }
44 |
45 | @Singleton
46 | @Provides
47 | fun provideCloudPathRepo(): CloudPathRepo {
48 | return CloudPathRepo()
49 | }
50 |
51 | @Singleton
52 | @Provides
53 | fun provideAppUsageRepo(): AppUsageRepo {
54 | return AppUsageRepo()
55 | }
56 |
57 | @Singleton
58 | @Provides
59 | fun provideImageTreeCacheRepo(gson: Gson, context: Context): ImageTreeCacheRepo {
60 | return ImageTreeCacheRepo(gson, context)
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/module/ViewerModule.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.module
2 |
3 | import android.content.pm.ApplicationInfo
4 | import com.linroid.viewit.data.repo.ImageRepo
5 | import com.linroid.viewit.data.repo.ImageRepoManager
6 | import com.linroid.viewit.ioc.quailifer.ActivityScope
7 | import com.linroid.viewit.ui.viewer.ImageViewerActivity
8 | import dagger.Module
9 | import dagger.Provides
10 | import rx.Observable
11 |
12 | /**
13 | * @author linroid
14 | * @since 24/01/2017
15 | */
16 | @Module
17 | class ViewerModule(val activity: ImageViewerActivity, val appInfo: ApplicationInfo) {
18 | @Provides
19 | @ActivityScope
20 | fun provideImageViewerActivity(): ImageViewerActivity = activity;
21 |
22 | @Provides
23 | @ActivityScope
24 | fun provideAppInfo(): ApplicationInfo = appInfo;
25 |
26 | @Provides
27 | @ActivityScope
28 | fun provideObservable(imageRepo: ImageRepo): Observable = imageRepo.registerImageEvent()
29 |
30 | @Provides
31 | @ActivityScope
32 | fun provideRepo(repoManager: ImageRepoManager): ImageRepo {
33 | return repoManager.getRepo(appInfo)
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/quailifer/ActivityScope.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.quailifer
2 |
3 | import javax.inject.Scope
4 |
5 | /**
6 | * @author linroid
7 | * @since 24/01/2017
8 | */
9 | @Scope
10 | annotation class ActivityScope
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/quailifer/ImageScope.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.quailifer
2 |
3 | import javax.inject.Scope
4 |
5 | /**
6 | * @author linroid
7 | * @since 24/01/2017
8 | */
9 | @Scope
10 | annotation class ImageScope
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ioc/quailifer/Root.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ioc.quailifer
2 |
3 | import javax.inject.Qualifier
4 |
5 | /**
6 | * @author linroid
7 | * @since 09/02/2017
8 | */
9 | @Qualifier
10 | @Retention(AnnotationRetention.SOURCE)
11 | @MustBeDocumented
12 | annotation class Root
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui
2 |
3 | import android.os.Bundle
4 | import android.support.annotation.CallSuper
5 | import android.support.annotation.LayoutRes
6 | import android.support.annotation.StringRes
7 | import android.support.v4.app.NavUtils
8 | import android.support.v7.widget.Toolbar
9 | import android.view.Menu
10 | import android.view.MenuItem
11 | import android.widget.Toast
12 | import com.avos.avoscloud.AVAnalytics
13 | import com.avos.avoscloud.feedback.FeedbackAgent
14 | import com.linroid.viewit.R
15 | import com.linroid.viewit.utils.EVENT_CLICK_FEEDBACK
16 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity
17 |
18 | /**
19 | * @author linroid
20 | * @since 07/01/2017
21 | */
22 |
23 | abstract class BaseActivity : RxAppCompatActivity() {
24 | var toolbar: Toolbar? = null
25 | @CallSuper
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 | setContentView(provideContentLayoutId())
29 | toolbar = findViewById(R.id.toolbar) as? Toolbar
30 | if (toolbar != null) {
31 | setSupportActionBar(toolbar)
32 | }
33 | val parent = NavUtils.getParentActivityName(this)
34 | if (parent != null && parent.isEmpty().not()) {
35 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
36 | }
37 | }
38 |
39 | override fun onPause() {
40 | super.onPause()
41 | AVAnalytics.onPause(this)
42 | }
43 |
44 | override fun onResume() {
45 | super.onResume()
46 | AVAnalytics.onResume(this)
47 | }
48 |
49 | @LayoutRes
50 | abstract fun provideContentLayoutId(): Int
51 |
52 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
53 | menuInflater.inflate(R.menu.feedback, menu)
54 | return super.onCreateOptionsMenu(menu)
55 | }
56 |
57 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
58 | when (item.itemId) {
59 | android.R.id.home -> {
60 | onBackPressed()
61 | return true
62 | }
63 | R.id.action_feedback -> {
64 | AVAnalytics.onEvent(this, EVENT_CLICK_FEEDBACK)
65 | val agent = FeedbackAgent(this);
66 | agent.startDefaultThreadActivity();
67 | }
68 | }
69 | return super.onOptionsItemSelected(item)
70 | }
71 |
72 | fun toastShort(msg: String) {
73 | Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
74 | }
75 |
76 | fun toastShort(@StringRes msgResId: Int) {
77 | Toast.makeText(this, msgResId, Toast.LENGTH_SHORT).show()
78 | }
79 |
80 | fun toastLong(msg: String) {
81 | Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
82 | }
83 |
84 | fun toastLong(@StringRes msgResId: Int) {
85 | Toast.makeText(this, msgResId, Toast.LENGTH_LONG).show()
86 | }
87 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/BaseDialogFragment.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui
2 |
3 | import com.trello.rxlifecycle.components.support.RxAppCompatDialogFragment
4 |
5 | /**
6 | * @author linroid
7 | * @since 09/02/2017
8 | */
9 | abstract class BaseDialogFragment : RxAppCompatDialogFragment() {
10 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/BaseFragment.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui
2 |
3 | import android.os.Bundle
4 | import android.support.annotation.LayoutRes
5 | import android.support.annotation.StringRes
6 | import android.support.v7.app.ActionBar
7 | import android.support.v7.app.AppCompatActivity
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.Toast
12 | import com.trello.rxlifecycle.components.support.RxFragment
13 |
14 | /**
15 | * @author linroid
16 | * @since 11/01/2017
17 | */
18 | abstract class BaseFragment : RxFragment() {
19 |
20 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
21 | return inflater.inflate(provideLayoutId(), container, false)
22 | }
23 |
24 | @LayoutRes
25 | abstract fun provideLayoutId(): Int
26 |
27 | protected fun supportInvalidateOptionsMenu() {
28 | activity.supportInvalidateOptionsMenu()
29 | }
30 |
31 | protected fun getSupportActionBar(): ActionBar? {
32 | if (activity != null && activity is AppCompatActivity) {
33 | return (activity as AppCompatActivity).supportActionBar
34 | }
35 | return null
36 | }
37 |
38 |
39 | protected fun toastShort(msg: String) {
40 | if (activity != null) {
41 | Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show()
42 | }
43 | }
44 |
45 | protected fun toastShort(@StringRes msgResId: Int) {
46 | if (activity != null) {
47 | Toast.makeText(activity, msgResId, Toast.LENGTH_SHORT).show()
48 | }
49 | }
50 |
51 | protected fun toastLong(msg: String) {
52 | if (activity != null) {
53 | Toast.makeText(activity, msg, Toast.LENGTH_LONG).show()
54 | }
55 | }
56 |
57 | protected fun toastLong(@StringRes msgResId: Int) {
58 | if (activity != null) {
59 | Toast.makeText(activity, msgResId, Toast.LENGTH_LONG).show()
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/BaseListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui
2 |
3 | import android.os.Bundle
4 | import android.support.v4.widget.SwipeRefreshLayout
5 | import android.support.v7.widget.RecyclerView
6 | import butterknife.bindView
7 | import com.linroid.viewit.R
8 |
9 | /**
10 | * @author linroid
11 | * @since 10/02/2017
12 | */
13 | abstract class BaseListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshListener {
14 |
15 | val recyclerView: RecyclerView by bindView(R.id.recyclerView)
16 | val refresher: SwipeRefreshLayout by bindView(R.id.refresher)
17 |
18 | final override fun provideContentLayoutId(): Int = R.layout.activity_base_list
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | refresher.setOnRefreshListener(this)
23 | refresher.isEnabled = false
24 | setupRecyclerView(recyclerView)
25 | if (refresher.isEnabled) {
26 | refresher.isRefreshing = true
27 | }
28 | onRefresh()
29 | }
30 |
31 | abstract override fun onRefresh()
32 |
33 | abstract fun setupRecyclerView(recyclerView: RecyclerView)
34 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/ImmersiveActivity.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui
2 |
3 | import android.os.Build
4 | import android.os.Bundle
5 | import android.view.MotionEvent
6 | import android.view.View
7 | import android.view.View.*
8 | import timber.log.Timber
9 |
10 | /**
11 | * 沉浸模式的 Activity
12 | * 如果继承这个 Activity,主题需要使用 @style/AppTheme.Immersive
13 | *
14 | * @author linroid
15 | * @since 25/01/2017
16 | */
17 | abstract class ImmersiveActivity : BaseActivity() {
18 | /**
19 | * the number of milliseconds to wait after
20 | * user interaction before hiding the system UI.
21 | */
22 | private val AUTO_HIDE_DELAY_MILLIS = 3000L
23 |
24 | private val ACTION_BAR_HIDE_DELAY_MILLIS = 300L
25 |
26 | private lateinit var decorView: View
27 |
28 | private val delayHideCallback = Runnable { hide() }
29 | private val delayHideActionBarCallback = Runnable { supportActionBar?.hide() }
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | decorView = window.decorView;
34 | decorView.setOnSystemUiVisibilityChangeListener {
35 | Timber.v("height changed:${decorView.height}, visibility:$it")
36 | }
37 | setImmersiveMode()
38 | }
39 |
40 | private fun setImmersiveMode() {
41 | var uiOptions = decorView.systemUiVisibility
42 | if (Build.VERSION.SDK_INT >= 19) {
43 | uiOptions = uiOptions or SYSTEM_UI_FLAG_IMMERSIVE_STICKY
44 | }
45 | uiOptions = uiOptions or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
46 | uiOptions = uiOptions or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
47 | // uiOptions = uiOptions or SYSTEM_UI_FLAG_LOW_PROFILE
48 | decorView.systemUiVisibility = uiOptions
49 | }
50 |
51 | override fun onWindowFocusChanged(hasFocus: Boolean) {
52 | super.onWindowFocusChanged(hasFocus)
53 | }
54 |
55 | override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
56 | if (ev.actionMasked == MotionEvent.ACTION_DOWN) {
57 | if (componentsHidden()) {
58 | show();
59 | return true
60 | }
61 | }
62 | delayHide()
63 | return super.dispatchTouchEvent(ev)
64 | }
65 |
66 | fun toggle() {
67 | if (componentsHidden()) {
68 | show()
69 | } else {
70 | hide()
71 | }
72 | }
73 |
74 | fun delayHide() {
75 | decorView.removeCallbacks(delayHideCallback)
76 | decorView.postDelayed(delayHideCallback, AUTO_HIDE_DELAY_MILLIS)
77 | }
78 |
79 | fun pauseHide() {
80 | decorView.removeCallbacks(delayHideCallback)
81 | }
82 |
83 | protected fun componentsHidden(): Boolean {
84 | return supportActionBar?.isShowing?.not() ?: true
85 | }
86 |
87 | private fun hide() {
88 | var uiOptions = decorView.systemUiVisibility
89 | uiOptions = uiOptions or SYSTEM_UI_FLAG_HIDE_NAVIGATION
90 | uiOptions = uiOptions or SYSTEM_UI_FLAG_FULLSCREEN
91 | decorView.systemUiVisibility = uiOptions
92 | decorView.postDelayed(delayHideActionBarCallback, ACTION_BAR_HIDE_DELAY_MILLIS)
93 | shouldHideComponents()
94 | }
95 |
96 | private fun show() {
97 | var uiOptions = decorView.systemUiVisibility
98 | uiOptions = uiOptions and SYSTEM_UI_FLAG_HIDE_NAVIGATION.inv()
99 | uiOptions = uiOptions and SYSTEM_UI_FLAG_FULLSCREEN.inv()
100 | decorView.systemUiVisibility = uiOptions
101 | supportActionBar?.show()
102 | decorView.removeCallbacks(delayHideActionBarCallback)
103 | shouldShowComponents()
104 | delayHide()
105 | }
106 |
107 | override fun onPause() {
108 | super.onPause()
109 | pauseHide()
110 | }
111 |
112 | override fun onResume() {
113 | super.onResume()
114 | delayHide()
115 | }
116 |
117 | override fun onTouchEvent(event: MotionEvent?): Boolean {
118 | return super.onTouchEvent(event)
119 | }
120 |
121 | abstract protected fun shouldHideComponents()
122 | abstract protected fun shouldShowComponents()
123 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/about/Developer.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.about
2 |
3 | import me.drakeet.support.about.Contributor
4 |
5 | /**
6 | * @author linroid
7 | * @since 30/01/2017
8 | */
9 |
10 | class Developer(avatarResId: Int, name: String, desc: String, val page: String) : Contributor(avatarResId, name, desc) {}
11 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/about/DeveloperViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.about
2 |
3 | import android.content.Intent
4 | import android.net.Uri
5 | import android.support.v7.widget.RecyclerView
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import android.widget.ImageView
10 | import android.widget.TextView
11 | import com.avos.avoscloud.AVAnalytics
12 | import com.linroid.viewit.utils.EVENT_CLICK_ABOUT_DEVELOPER
13 | import me.drakeet.multitype.ItemViewProvider
14 | import me.drakeet.support.about.R
15 |
16 | /**
17 | * @author linroid
18 | * @since 30/01/2017
19 | */
20 | class DeveloperViewProvider : ItemViewProvider() {
21 |
22 | override fun onCreateViewHolder(
23 | inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
24 | val root = inflater.inflate(R.layout.about_page_item_contributor, parent, false)
25 | return ViewHolder(root)
26 | }
27 |
28 |
29 | override fun onBindViewHolder(
30 | holder: ViewHolder, developer: Developer) {
31 | holder.avatar.setImageResource(developer.avatarResId)
32 | holder.name.text = developer.name
33 | holder.desc.text = developer.desc
34 | holder.itemView.setOnClickListener {
35 | AVAnalytics.onEvent(it.context, EVENT_CLICK_ABOUT_DEVELOPER)
36 | val intent = Intent(Intent.ACTION_VIEW)
37 | intent.data = Uri.parse(developer.page)
38 | it.context.startActivity(intent)
39 | }
40 | }
41 |
42 |
43 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
44 |
45 | var avatar: ImageView = itemView.findViewById(R.id.avatar) as ImageView
46 | var name: TextView = itemView.findViewById(R.id.name) as TextView
47 | var desc: TextView = itemView.findViewById(R.id.desc) as TextView
48 | lateinit var url: String
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/CloudFavoriteViewerFragment.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.os.Bundle
5 | import com.linroid.viewit.data.model.CloudFavorite
6 | import com.linroid.viewit.utils.ARG_IMAGE_TREE_PATH
7 | import com.linroid.viewit.utils.PathUtils
8 |
9 | /**
10 | * @author linroid
11 | * @since 05/02/2017
12 | */
13 | class CloudFavoriteViewerFragment : TreeViewerFragment() {
14 | companion object {
15 | fun newInstance(cloudFavorite: CloudFavorite, appInfo: ApplicationInfo): CloudFavoriteViewerFragment {
16 | val args = Bundle()
17 | args.putString(ARG_IMAGE_TREE_PATH, PathUtils.formatToDevice(cloudFavorite.path, appInfo))
18 | val fragment = CloudFavoriteViewerFragment()
19 | fragment.arguments = args
20 | return fragment
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/FavoriteViewerFragment.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.os.Bundle
5 | import com.linroid.viewit.data.model.Favorite
6 | import com.linroid.viewit.utils.ARG_IMAGE_TREE_PATH
7 | import com.linroid.viewit.utils.PathUtils
8 |
9 | /**
10 | * @author linroid
11 | * @since 05/02/2017
12 | */
13 | class FavoriteViewerFragment : TreeViewerFragment() {
14 | companion object {
15 | fun newInstance(favorite: Favorite, appInfo: ApplicationInfo): FavoriteViewerFragment {
16 | val args = Bundle()
17 | args.putString(ARG_IMAGE_TREE_PATH, PathUtils.formatToDevice(favorite.path, appInfo))
18 | val fragment = FavoriteViewerFragment()
19 | fragment.arguments = args
20 | return fragment
21 | }
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/GalleryViewerFragment.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery
2 |
3 | import android.content.DialogInterface
4 | import android.os.Bundle
5 | import android.support.v7.app.AlertDialog
6 | import android.view.Menu
7 | import android.view.MenuInflater
8 | import android.view.MenuItem
9 | import android.view.View
10 | import com.avos.avoscloud.AVAnalytics
11 | import com.linroid.viewit.R
12 | import com.linroid.viewit.data.model.Favorite
13 | import com.linroid.viewit.ui.favorite.CreateFavoriteFragment
14 | import com.linroid.viewit.utils.ARG_IMAGE_TREE_PATH
15 | import com.linroid.viewit.utils.EVENT_ADD_FAVORITE
16 | import com.linroid.viewit.utils.EVENT_DELETE_FAVORITE
17 | import com.linroid.viewit.utils.PathUtils
18 | import com.trello.rxlifecycle.kotlin.bindToLifecycle
19 | import rx.android.schedulers.AndroidSchedulers
20 | import timber.log.Timber
21 |
22 | /**
23 | * @author linroid
24 | * @since 05/02/2017
25 | */
26 | abstract class GalleryViewerFragment : GalleryChildFragment() {
27 | private var favorite: Favorite? = null
28 | protected lateinit var path: String
29 |
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | path = arguments!!.getString(ARG_IMAGE_TREE_PATH)!!
34 | }
35 |
36 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
37 | super.onViewCreated(view, savedInstanceState)
38 |
39 | favoriteRepo.find(PathUtils.formatToVariable(path, appInfo), appInfo)
40 | .bindToLifecycle(this)
41 | .observeOn(AndroidSchedulers.mainThread())
42 | .subscribe({
43 | favorite = it
44 | supportInvalidateOptionsMenu()
45 | }, { error ->
46 | Timber.e(error)
47 | })
48 | }
49 |
50 | override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
51 | super.onCreateOptionsMenu(menu, inflater)
52 | inflater.inflate(R.menu.gallery_viewer, menu)
53 | menu.findItem(R.id.action_create_favorite)?.isVisible = favorite == null
54 | menu.findItem(R.id.action_delete_favorite)?.isVisible = favorite != null
55 | }
56 |
57 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
58 | when (item.itemId) {
59 | R.id.action_create_favorite -> {
60 | AVAnalytics.onEvent(context, EVENT_ADD_FAVORITE, appInfo.packageName)
61 | showCreateFavoriteDialog()
62 | return true
63 | }
64 | R.id.action_delete_favorite -> {
65 | AVAnalytics.onEvent(context, EVENT_DELETE_FAVORITE, appInfo.packageName)
66 | alertDeleteFavorite()
67 | return true
68 | }
69 | }
70 | return super.onOptionsItemSelected(item)
71 | }
72 |
73 | private fun showCreateFavoriteDialog() {
74 | CreateFavoriteFragment.newInstance(activity, path, appInfo)
75 | .show(childFragmentManager, "create_favorite:" + path)
76 | }
77 |
78 | private fun alertDeleteFavorite() {
79 | AlertDialog.Builder(activity)
80 | .setMessage(R.string.alert_delete_favorite)
81 | .setNegativeButton(android.R.string.cancel, null)
82 | .setPositiveButton(android.R.string.ok, { dialogInterface: DialogInterface, i: Int ->
83 | performDeleteFavorite()
84 | })
85 | .show()
86 | }
87 |
88 | private fun performDeleteFavorite() {
89 | if (favorite != null) {
90 | favoriteRepo.delete(favorite!!, appInfo)
91 | .observeOn(AndroidSchedulers.mainThread())
92 | .subscribe({
93 | if (it) {
94 | toastShort(R.string.msg_operate_success)
95 | }
96 | })
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/ImageSelectProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery
2 |
3 | import com.linroid.viewit.data.model.Image
4 |
5 | /**
6 | * @author linroid
7 | * @since 16/03/2017
8 | */
9 | interface ImageSelectProvider {
10 | fun selectAll(items: List?)
11 | fun unSelectAll()
12 | fun filter(filters: List?)
13 | fun selectedItems(): Set
14 | fun reset()
15 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/Category.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.view.View
4 | import me.drakeet.multitype.MultiTypeAdapter
5 | import timber.log.Timber
6 | import java.util.*
7 | import kotlin.properties.Delegates
8 | import kotlin.reflect.KProperty
9 |
10 | /**
11 | * @author linroid
12 | * @since 31/01/2017
13 | */
14 | open class Category(
15 | prev: Category<*>?,
16 | private val adapter: MultiTypeAdapter,
17 | private var listItems: ArrayList,
18 | var label: CharSequence,
19 | var action: CharSequence? = null,
20 | var actionClickListener: View.OnClickListener? = null,
21 | val alwaysShow: Boolean = false // 不管 items.size 是否大于0都显示
22 | ) {
23 |
24 | private var itemCount = 0
25 |
26 |
27 | var position: Int by Delegates.observable(-1) { prop: KProperty<*>, old: Int, new: Int ->
28 | if (next != null) {
29 | updateNext()
30 | }
31 | }
32 |
33 | private fun updateNext() {
34 | if (next != null) {
35 | next!!.position = position + displayedCount(items)
36 | }
37 | }
38 |
39 | fun invalidate() {
40 | adapter.notifyItemRangeChanged(position + 1, displayedCount(items))
41 | }
42 |
43 | private fun displayedCount(_items: List?) = if (_items == null || _items.isEmpty()) 0 else _items.size + 1
44 |
45 | var items: List? by Delegates.observable(null) { prop: KProperty<*>, oldVal: List?, newVal: List? ->
46 | Timber.d("update category[$label] items(size=${newVal?.size ?: 0})")
47 | val oldCount = itemCount
48 | val newCount = newVal?.size ?: 0
49 | val begin = position + 1
50 | if (oldCount > 0 || alwaysShow) {
51 | val oldEnd = Math.min(begin + oldCount + 1, listItems.size);
52 | if (oldEnd >= begin) {
53 | Timber.d("remove items: $begin..$oldEnd, total:${listItems.size}")
54 | listItems.subList(begin, oldEnd).clear()
55 | Timber.d("after removed, total:${listItems.size}")
56 | adapter.notifyItemRangeRemoved(begin, oldCount + 1)
57 | }
58 | }
59 | if (newCount > 0 || alwaysShow) {
60 | Timber.d("add category[$label] at:$begin with $newCount items")
61 | listItems.add(begin, this)
62 | listItems.addAll(begin + 1, newVal!!)
63 | adapter.notifyItemRangeInserted(begin, newCount + 1)
64 | }
65 | itemCount = newCount
66 | updateNext()
67 | listeners.forEach {
68 | it.onChanged(oldVal, newVal)
69 | }
70 | }
71 |
72 | var next: Category<*>? = null
73 |
74 | init {
75 | if (prev != null) {
76 | prev.next = this
77 | prev.updateNext()
78 | }
79 | if (prev == null) {
80 | position = -1
81 | }
82 | }
83 |
84 | private var listeners = HashSet>()
85 |
86 | fun registerChangedListener(listener: OnItemsChangedListener) {
87 | listeners.add(listener)
88 | }
89 |
90 | fun unregisterChangedListener(listener: OnItemsChangedListener) {
91 | listItems.remove(listener)
92 | }
93 |
94 | interface OnItemsChangedListener {
95 | fun onChanged(oldVal: List?, newVal: List?)
96 | }
97 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/CategoryViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import butterknife.bindView
9 | import com.linroid.viewit.R
10 | import me.drakeet.multitype.ItemViewProvider
11 |
12 | /**
13 | * @author linroid
14 | * @since 31/01/2017
15 | */
16 | class CategoryViewProvider : ItemViewProvider, CategoryViewProvider.ViewHolder>() {
17 | override fun onBindViewHolder(holder: ViewHolder, category: Category<*>) {
18 | holder.labelTV.text = category.label
19 | if (category.action.isNullOrEmpty()) {
20 | holder.actionBtn.visibility = View.GONE
21 | holder.actionBtn.setOnClickListener(null)
22 | } else {
23 | holder.actionBtn.visibility = View.VISIBLE
24 | holder.actionBtn.text = category.action
25 | holder.actionBtn.setOnClickListener(category.actionClickListener)
26 | }
27 | }
28 |
29 | override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
30 | return ViewHolder(inflater.inflate(R.layout.item_category, parent, false))
31 | }
32 |
33 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
34 | val labelTV: TextView by bindView(R.id.label)
35 | val actionBtn: TextView by bindView(R.id.action)
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/CloudFavoriteViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.view.View
5 | import com.avos.avoscloud.AVAnalytics
6 | import com.linroid.viewit.data.model.CloudFavorite
7 | import com.linroid.viewit.data.model.ImageTree
8 | import com.linroid.viewit.data.repo.ImageRepo
9 | import com.linroid.viewit.ui.gallery.GalleryActivity
10 | import com.linroid.viewit.utils.EVENT_CLICK_CLOUD_FAVORITE
11 | import com.linroid.viewit.utils.EVENT_CLICK_FAVORITE
12 |
13 | /**
14 | * @author linroid
15 | * @since 07/02/2017
16 | */
17 | class CloudFavoriteViewProvider(activity: GalleryActivity, appInfo: ApplicationInfo, imageRepo: ImageRepo)
18 | : TreeViewProvider(activity, appInfo, imageRepo) {
19 | override fun onClick(it: View, data: CloudFavorite) {
20 | AVAnalytics.onEvent(activity, EVENT_CLICK_CLOUD_FAVORITE, mapOf("name" to data.name, "packageName" to appInfo.packageName))
21 | activity.visitCloudFavorite(data)
22 | }
23 |
24 | override fun obtainTree(data: CloudFavorite): ImageTree? {
25 | return data.tree
26 | }
27 |
28 | override fun obtainName(data: CloudFavorite): CharSequence = data.name
29 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/FavoriteViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.content.pm.ApplicationInfo
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 | import android.widget.Toast
10 | import butterknife.bindView
11 | import com.avos.avoscloud.AVAnalytics
12 | import com.linroid.viewit.R
13 | import com.linroid.viewit.data.model.Favorite
14 | import com.linroid.viewit.data.model.ImageTree
15 | import com.linroid.viewit.data.repo.ImageRepo
16 | import com.linroid.viewit.ui.gallery.GalleryActivity
17 | import com.linroid.viewit.utils.EVENT_CLICK_FAVORITE
18 | import com.linroid.viewit.utils.EVENT_CLICK_LAUNCH_APP
19 | import com.linroid.viewit.utils.unsubscribeIfNotNull
20 | import com.linroid.viewit.widget.ThumbnailView
21 | import com.trello.rxlifecycle.kotlin.bindToLifecycle
22 | import me.drakeet.multitype.ItemViewProvider
23 | import rx.Observable
24 | import rx.Subscription
25 | import rx.android.schedulers.AndroidSchedulers
26 | import timber.log.Timber
27 | import java.util.concurrent.TimeUnit
28 |
29 | /**
30 | * @author linroid
31 | * @since 30/01/2017
32 | */
33 | class FavoriteViewProvider(val activity: GalleryActivity, val appInfo: ApplicationInfo, val imageRepo: ImageRepo)
34 | : ItemViewProvider() {
35 |
36 |
37 | override fun onBindViewHolder(holder: ViewHolder, favorite: Favorite) {
38 | holder.nameTV.text = favorite.name
39 | holder.itemView.setOnClickListener({
40 | if (favorite.tree != null) {
41 | activity.visitTree(favorite.tree!!)
42 | }
43 | })
44 | holder.loadImages(imageRepo, favorite.tree)
45 | holder.itemView.setOnClickListener {
46 | AVAnalytics.onEvent(activity, EVENT_CLICK_FAVORITE)
47 | activity.viewFavorite(favorite)
48 | }
49 | holder.itemView.setOnLongClickListener {
50 | if (favorite.tree != null) {
51 | Toast.makeText(holder.itemView.context, favorite.tree!!.dir, Toast.LENGTH_LONG).show()
52 | }
53 | true
54 | }
55 | val count = favorite.tree?.allImagesCount() ?: 0
56 | holder.imagesCountView.text = holder.itemView.context.getString(R.string.label_images_count, count)
57 | }
58 |
59 | override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
60 | return ViewHolder(inflater.inflate(R.layout.item_image_tree, parent, false))
61 | }
62 |
63 |
64 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
65 | val nameTV: TextView by bindView(R.id.name)
66 | val thumbnailView: ThumbnailView by bindView(R.id.thumbnail)
67 | val imagesCountView: TextView by bindView(R.id.images_count)
68 |
69 | var subscription: Subscription? = null
70 |
71 | fun loadImages(imageRepo: ImageRepo, tree: ImageTree?) {
72 | subscription.unsubscribeIfNotNull()
73 | thumbnailView.clear()
74 | if (tree == null) {
75 | return
76 | }
77 | subscription = Observable.from(tree.thumbnailImages)
78 | .delaySubscription(1, TimeUnit.SECONDS)
79 | .flatMap {
80 | if (it.file() == null) {
81 | return@flatMap imageRepo.mountImage(it)
82 | } else {
83 | return@flatMap Observable.just(it)
84 | }
85 | }
86 | .toList()
87 | .observeOn(AndroidSchedulers.mainThread())
88 | .bindToLifecycle(thumbnailView)
89 | .subscribe({
90 | thumbnailView.setImages(it)
91 | }, { error ->
92 | Timber.e(error)
93 | })
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/ImageCategory.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import com.linroid.viewit.data.model.Image
4 | import me.drakeet.multitype.MultiTypeAdapter
5 | import java.util.*
6 |
7 | /**
8 | * @author linroid
9 | * @since 28/02/2017
10 | */
11 | class ImageCategory(prev: Category<*>?,
12 | adapter: MultiTypeAdapter,
13 | listItems: ArrayList,
14 | label: CharSequence) : Category(prev, adapter, listItems, label, null, null, true) {
15 |
16 | var totalCount: Int = 0
17 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/ImageTreeViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.view.View
5 | import com.avos.avoscloud.AVAnalytics
6 | import com.linroid.viewit.data.model.ImageTree
7 | import com.linroid.viewit.data.repo.ImageRepo
8 | import com.linroid.viewit.ui.gallery.GalleryActivity
9 | import com.linroid.viewit.utils.EVENT_CLICK_CLOUD_FAVORITE
10 | import com.linroid.viewit.utils.EVENT_CLICK_TREE
11 | import com.linroid.viewit.utils.FormatUtils
12 | import com.linroid.viewit.utils.PathUtils
13 |
14 | /**
15 | * @author linroid
16 | * @since 30/01/2017
17 | */
18 | class ImageTreeViewProvider(activity: GalleryActivity, val visitPath: String, appInfo: ApplicationInfo, imageRepo: ImageRepo)
19 | : TreeViewProvider(activity, appInfo, imageRepo) {
20 |
21 | override fun onClick(it: View, data: ImageTree) {
22 | AVAnalytics.onEvent(activity, EVENT_CLICK_TREE, mapOf("path" to data.dir, "packageName" to appInfo.packageName))
23 | activity.visitTree(data)
24 | }
25 |
26 | override fun obtainTree(data: ImageTree): ImageTree = data
27 |
28 | override fun obtainName(data: ImageTree): CharSequence = FormatUtils.formatPath(PathUtils.relative(visitPath, data.dir), appInfo)
29 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/gallery/provider/TreeViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.gallery.provider
2 |
3 | import android.content.pm.ApplicationInfo
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 | import android.widget.Toast
10 | import butterknife.bindView
11 | import com.linroid.viewit.R
12 | import com.linroid.viewit.data.model.ImageTree
13 | import com.linroid.viewit.data.repo.ImageRepo
14 | import com.linroid.viewit.ui.gallery.GalleryActivity
15 | import com.linroid.viewit.utils.unsubscribeIfNotNull
16 | import com.linroid.viewit.widget.ThumbnailView
17 | import com.trello.rxlifecycle.kotlin.bindToLifecycle
18 | import me.drakeet.multitype.ItemViewProvider
19 | import rx.Observable
20 | import rx.Subscription
21 | import rx.android.schedulers.AndroidSchedulers
22 | import timber.log.Timber
23 | import java.util.concurrent.TimeUnit
24 |
25 | /**
26 | * @author linroid
27 | * @since 30/01/2017
28 | */
29 | abstract class TreeViewProvider(val activity: GalleryActivity, val appInfo: ApplicationInfo, val imageRepo: ImageRepo)
30 | : ItemViewProvider() {
31 |
32 |
33 | override fun onBindViewHolder(holder: TreeViewHolder, data: T) {
34 | holder.nameTV.text = obtainName(data)
35 | val tree = obtainTree(data)
36 | holder.itemView.setOnClickListener({
37 | if (tree != null) {
38 | activity.visitTree(tree)
39 | }
40 | })
41 | holder.loadImages(imageRepo, tree)
42 | holder.itemView.setOnClickListener {
43 | onClick(it, data)
44 | }
45 | holder.itemView.setOnLongClickListener {
46 | if (tree != null) {
47 | Toast.makeText(holder.itemView.context, tree.dir, Toast.LENGTH_LONG).show()
48 | }
49 | return@setOnLongClickListener true
50 | }
51 | val count = tree?.allImagesCount() ?: 0
52 | holder.imagesCountView.text = holder.itemView.context.getString(R.string.label_images_count, count)
53 | }
54 |
55 | protected abstract fun onClick(it: View, data: T)
56 |
57 | protected abstract fun obtainTree(data: T): ImageTree?
58 |
59 | protected abstract fun obtainName(data: T): CharSequence
60 |
61 | override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): TreeViewHolder {
62 | return TreeViewHolder(inflater.inflate(R.layout.item_image_tree, parent, false))
63 | }
64 |
65 | class TreeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
66 | val nameTV: TextView by bindView(R.id.name)
67 | val thumbnailView: ThumbnailView by bindView(R.id.thumbnail)
68 | val imagesCountView: TextView by bindView(R.id.images_count)
69 |
70 | var subscription: Subscription? = null
71 |
72 | fun loadImages(imageRepo: ImageRepo, tree: ImageTree?) {
73 | subscription.unsubscribeIfNotNull()
74 | thumbnailView.clear()
75 | if (tree == null) {
76 | return
77 | }
78 | subscription = Observable.from(tree.thumbnailImages)
79 | .delaySubscription(1, TimeUnit.SECONDS)
80 | .flatMap {
81 | if (it.file() == null) {
82 | return@flatMap imageRepo.mountImage(it)
83 | } else {
84 | return@flatMap Observable.just(it)
85 | }
86 | }
87 | .toList()
88 | .observeOn(AndroidSchedulers.mainThread())
89 | .bindToLifecycle(thumbnailView)
90 | .subscribe({
91 | thumbnailView.setImages(it)
92 | }, { error ->
93 | Timber.e(error)
94 | })
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/home/AppViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.home
2 |
3 | import android.content.DialogInterface
4 | import android.content.pm.ApplicationInfo
5 | import android.content.pm.PackageManager
6 | import android.support.v7.app.AlertDialog
7 | import android.support.v7.widget.RecyclerView
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.ImageView
12 | import android.widget.TextView
13 | import android.widget.Toast
14 | import butterknife.bindView
15 | import com.avos.avoscloud.AVAnalytics
16 | import com.linroid.viewit.R
17 | import com.linroid.viewit.data.repo.local.AppUsageRepo
18 | import com.linroid.viewit.ui.BaseActivity
19 | import com.linroid.viewit.ui.gallery.GalleryActivity
20 | import com.linroid.viewit.utils.EVENT_CLICK_APP
21 | import com.linroid.viewit.utils.RootUtils
22 | import com.linroid.viewit.utils.RxOnce
23 | import com.trello.rxlifecycle.kotlin.bindToLifecycle
24 | import me.drakeet.multitype.ItemViewProvider
25 | import rx.Observable
26 | import rx.android.schedulers.AndroidSchedulers
27 | import rx.schedulers.Schedulers
28 | import timber.log.Timber
29 |
30 | /**
31 | * @author linroid
32 | * @since 07/01/2017
33 | */
34 | internal class AppViewProvider(val activity: BaseActivity, val usageRepo: AppUsageRepo) : ItemViewProvider() {
35 |
36 | val packageManager: PackageManager = activity.packageManager
37 |
38 | override fun onCreateViewHolder(
39 | inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
40 | return ViewHolder(inflater.inflate(R.layout.item_app, parent, false))
41 | }
42 |
43 | override fun onBindViewHolder(holder: ViewHolder, info: ApplicationInfo) {
44 | val label = packageManager.getApplicationLabel(info)
45 | holder.name.text = label
46 | holder.root.setOnClickListener { view ->
47 | AVAnalytics.onEvent(view.context, EVENT_CLICK_APP, info.packageName)
48 | usageRepo.visitApp(info).subscribe {
49 | Timber.i("visitApp: $it")
50 | }
51 | RxOnce.app("require_root_prompt").subscribe({
52 | if (it) {
53 | showRequireRootPromptDialog(info)
54 | } else {
55 | GalleryActivity.navTo(activity, info)
56 | }
57 | })
58 | }
59 | holder.root.setOnLongClickListener {
60 | Toast.makeText(holder.root.context, label, Toast.LENGTH_SHORT).show()
61 | true
62 | }
63 | Observable.just(info)
64 | .map { packageManager.getApplicationIcon(info) }
65 | .subscribeOn(Schedulers.io())
66 | .bindToLifecycle(holder.icon)
67 | .observeOn(AndroidSchedulers.mainThread())
68 | .subscribe { holder.icon.setImageDrawable(it) }
69 | }
70 |
71 | private fun showRequireRootPromptDialog(info: ApplicationInfo) {
72 | AlertDialog.Builder(activity)
73 | .setTitle(R.string.title_dialog_require_root_prompt)
74 | .setMessage(if (RootUtils.isRootAvailable()) R.string.msg_dialog_require_root else R.string.msg_dialog_no_root)
75 | .setPositiveButton(android.R.string.ok, { dialogInterface: DialogInterface, i: Int ->
76 | GalleryActivity.navTo(activity, info)
77 | })
78 | .show()
79 | }
80 |
81 | internal class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
82 | val name: TextView by bindView(R.id.name)
83 | val icon: ImageView by bindView(R.id.icon)
84 | val root: View by bindView(R.id.root)
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/path/provider/BuildInPathViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.path.provider
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import butterknife.bindView
9 | import com.linroid.viewit.R
10 | import me.drakeet.multitype.ItemViewProvider
11 |
12 | /**
13 | * @author linroid
14 | * @since 12/02/2017
15 | */
16 | class BuildInPathViewProvider : ItemViewProvider() {
17 | override fun onBindViewHolder(holder: ViewHolder, path: BuildInPath) {
18 | holder.nameTV.text = path.name
19 | }
20 |
21 | override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
22 | return ViewHolder(inflater.inflate(R.layout.item_build_in_path, parent, false))
23 | }
24 |
25 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
26 | val nameTV: TextView by bindView(R.id.name)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/path/provider/BuiltInPath.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.path.provider
2 |
3 | /**
4 | * @author linroid
5 | * @since 12/02/2017
6 | */
7 | data class BuildInPath(val name: String)
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/path/provider/CloudScanPathViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.path.provider
2 |
3 | import android.content.pm.ApplicationInfo
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 | import butterknife.bindView
10 |
11 | import com.linroid.viewit.R
12 | import com.linroid.viewit.data.model.CloudScanPath
13 | import com.linroid.viewit.utils.PathUtils
14 |
15 | import me.drakeet.multitype.ItemViewProvider
16 |
17 | /**
18 | * @author linroid
19 | * @since 12/02/2017
20 | */
21 | class CloudScanPathViewProvider(val appInfo: ApplicationInfo) : ItemViewProvider() {
22 |
23 | override fun onCreateViewHolder(
24 | inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
25 | val root = inflater.inflate(R.layout.item_cloud_scan_path, parent, false)
26 | return ViewHolder(root)
27 | }
28 |
29 | override fun onBindViewHolder(holder: ViewHolder, cloudScanPath: CloudScanPath) {
30 | holder.nameTV.text = PathUtils.formatToDevice(cloudScanPath.path, appInfo)
31 | }
32 |
33 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
34 | val nameTV: TextView by bindView(R.id.name)
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/path/provider/ScanPathViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.path.provider
2 |
3 | import android.content.pm.ApplicationInfo
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 | import butterknife.bindView
10 | import com.avos.avoscloud.AVAnalytics
11 |
12 | import com.linroid.viewit.R
13 | import com.linroid.viewit.data.model.ScanPath
14 | import com.linroid.viewit.utils.EVENT_CLICK_PATH_DELETE
15 | import com.linroid.viewit.utils.EVENT_CLICK_PATH_EDIT
16 | import com.linroid.viewit.utils.PathUtils
17 |
18 | import me.drakeet.multitype.ItemViewProvider
19 |
20 | /**
21 | * @author linroid
22 | * @since 12/02/2017
23 | */
24 | class ScanPathViewProvider(val appInfo: ApplicationInfo, val listener: OnDeleteScanPathListener) : ItemViewProvider() {
25 | var deleteMode = false
26 |
27 | override fun onCreateViewHolder(
28 | inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
29 | val root = inflater.inflate(R.layout.item_scan_path, parent, false)
30 | return ViewHolder(root)
31 | }
32 |
33 | override fun onBindViewHolder(holder: ViewHolder, scanPath: ScanPath) {
34 | holder.nameTV.text = PathUtils.formatToDevice(scanPath.path, appInfo)
35 | holder.deleteBtn.visibility = if (deleteMode) View.VISIBLE else View.GONE
36 | holder.deleteBtn.setOnClickListener {
37 | AVAnalytics.onEvent(it.context, EVENT_CLICK_PATH_DELETE)
38 | listener.onDeleteScanPath(scanPath)
39 | }
40 | }
41 |
42 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
43 | val nameTV: TextView by bindView(R.id.name)
44 | val deleteBtn: TextView by bindView(R.id.btn_delete)
45 | }
46 |
47 | interface OnDeleteScanPathListener {
48 | fun onDeleteScanPath(scanPath: ScanPath)
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/viewer/ImageDetailDialog.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.viewer
2 |
3 | import android.app.Dialog
4 | import android.os.Bundle
5 | import android.support.v4.app.FragmentManager
6 | import android.support.v7.app.AlertDialog
7 | import android.support.v7.widget.LinearLayoutManager
8 | import android.support.v7.widget.RecyclerView
9 | import android.text.format.Formatter
10 | import android.view.LayoutInflater
11 | import android.view.View
12 | import com.linroid.viewit.R
13 | import com.linroid.viewit.data.model.Image
14 | import com.linroid.viewit.ui.BaseDialogFragment
15 | import com.linroid.viewit.utils.ARG_IMAGE
16 | import me.drakeet.multitype.Items
17 | import me.drakeet.multitype.MultiTypeAdapter
18 | import java.text.SimpleDateFormat
19 | import java.util.*
20 |
21 | /**
22 | * @author linroid
23 | * @since 28/02/2017
24 | */
25 | class ImageDetailDialog : BaseDialogFragment() {
26 | companion object {
27 | fun show(image: Image, fm: FragmentManager) {
28 | val args = Bundle()
29 | args.putParcelable(ARG_IMAGE, image);
30 | val dialog = ImageDetailDialog()
31 | dialog.arguments = args
32 | dialog.show(fm, "image-detail-${image.path}")
33 | }
34 | }
35 |
36 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
37 | val image: Image = arguments.getParcelable(ARG_IMAGE)
38 | val inflater = LayoutInflater.from(context)
39 | val view = inflater.inflate(R.layout.dialog_image_detail, null)
40 | setupView(view, image)
41 | return AlertDialog.Builder(context)
42 | .setTitle(R.string.title_dialog_image_detail)
43 | .setView(view)
44 | .setNegativeButton(android.R.string.ok, null)
45 | .create()
46 | }
47 |
48 | private fun setupView(view: View, image: Image) {
49 | val recyclerView = view.findViewById(R.id.recyclerView) as RecyclerView
50 | recyclerView.layoutManager = LinearLayoutManager(context)
51 | val items = Items()
52 | val adapter = MultiTypeAdapter(items)
53 | adapter.register(ImageProperty::class.java, ImagePropertyViewProvider())
54 | items.add(ImageProperty("路径", image.path))
55 | items.add(ImageProperty("类型", image.type.mime))
56 | items.add(ImageProperty("大小", Formatter.formatShortFileSize(context, image.size)))
57 | // items.add(ImageProperty("尺寸", image.))
58 | val dateFormatter = SimpleDateFormat("yyyy/MM/dd hh:mm", Locale.getDefault())
59 | items.add(ImageProperty("时间", dateFormatter.format(Date(image.lastModified))))
60 | recyclerView.adapter = adapter
61 | adapter.notifyDataSetChanged()
62 | }
63 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/viewer/ImageProperty.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.viewer
2 |
3 | /**
4 | * @author linroid
5 | * @since 01/03/2017
6 | */
7 | data class ImageProperty(val name: String, val value: String)
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/viewer/ImagePropertyViewProvider.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.viewer
2 |
3 | import android.support.v7.widget.RecyclerView
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import butterknife.bindView
9 | import com.linroid.viewit.R
10 | import me.drakeet.multitype.ItemViewProvider
11 |
12 | /**
13 | * @author linroid @gmail.com>
14 | * @since 01/03/2017
15 | */
16 | class ImagePropertyViewProvider : ItemViewProvider() {
17 |
18 | override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
19 | val root = inflater.inflate(R.layout.item_image_property, parent, false)
20 | return ViewHolder(root)
21 | }
22 |
23 | override fun onBindViewHolder(holder: ViewHolder, imageProperty: ImageProperty) {
24 | holder.nameTV.text = imageProperty.name
25 | holder.valueTV.text = imageProperty.value
26 | }
27 |
28 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
29 | val nameTV: TextView by bindView(R.id.prop_name)
30 | val valueTV: TextView by bindView(R.id.prop_value)
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/ui/viewer/ImageViewerPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.ui.viewer
2 |
3 | import android.support.v4.app.Fragment
4 | import android.support.v4.app.FragmentManager
5 | import android.support.v4.app.FragmentStatePagerAdapter
6 | import android.support.v4.view.PagerAdapter
7 | import android.view.ViewGroup
8 | import com.linroid.viewit.data.model.Image
9 |
10 | /**
11 | * @author linroid
12 | * @since 20/01/2017
13 | */
14 | class ImageViewerPagerAdapter(fm: FragmentManager, val images: List?) : FragmentStatePagerAdapter(fm) {
15 | override fun getItem(position: Int): Fragment {
16 | return ImageViewerFragment.newInstance()
17 | }
18 |
19 | override fun getCount(): Int {
20 | return images?.size ?: 0
21 | }
22 |
23 | override fun getItemPosition(item: Any?): Int {
24 | return PagerAdapter.POSITION_NONE
25 | }
26 |
27 | override fun instantiateItem(container: ViewGroup, position: Int): Any {
28 | val fragment = super.instantiateItem(container, position) as ImageViewerFragment
29 | fragment.updateImage(images!![position])
30 | return fragment
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/AndroidNavUtil.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.content.pm.ApplicationInfo
6 | import android.net.Uri
7 | import android.provider.Settings
8 |
9 | /**
10 | * @author linroid
11 | * @since 10/02/2017
12 | */
13 | object AndroidNavUtil {
14 | /**
15 | * 启动其他应用
16 | */
17 | fun launchApp(context: Context, appInfo: ApplicationInfo) {
18 | val intent = context.packageManager.getLaunchIntentForPackage(appInfo.packageName)
19 | context.startActivity(intent)
20 | }
21 |
22 | /**
23 | * 打开应用信息
24 | */
25 | fun openAppDetail(context: Context, appInfo: ApplicationInfo) {
26 | val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
27 | intent.data = Uri.parse("package:" + appInfo.packageName)
28 | context.startActivity(intent)
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/AndroidUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.content.res.Resources
4 | import android.util.TypedValue
5 |
6 | /**
7 | * @author linroid
8 | * @since 31/01/2017
9 | */
10 | object AndroidUtils {
11 | fun dp(dp: Float): Float {
12 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Resources.getSystem().displayMetrics)
13 | }
14 |
15 | fun sp(dp: Float): Float {
16 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, dp, Resources.getSystem().displayMetrics)
17 | }
18 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/FileUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import okio.Okio
4 | import java.io.File
5 |
6 | /**
7 | * @author linroid
8 | * @since 25/01/2017
9 | */
10 | object FileUtils {
11 | fun copyFile(file: File, desFile: File) {
12 | val source = Okio.buffer(Okio.source(file))
13 | val sink = Okio.buffer(Okio.sink(desFile))
14 | source.readAll(sink)
15 | source.close()
16 | sink.close()
17 | }
18 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/FormatUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.content.pm.PackageInfo
5 | import android.graphics.Typeface
6 | import android.os.Environment
7 | import android.text.SpannableStringBuilder
8 | import android.text.Spanned
9 | import android.text.style.StyleSpan
10 | import com.linroid.viewit.App
11 | import com.linroid.viewit.R
12 | import java.io.File
13 |
14 | /**
15 | * @author linroid
16 | * @since 31/01/2017
17 | */
18 | object FormatUtils {
19 | fun formatPath(path: String?, appInfo: ApplicationInfo): CharSequence {
20 | if (path == null) {
21 | return ""
22 | }
23 | val context = App.get()
24 |
25 | if (path == File.separator) {
26 | return context.getString(R.string.path_format_root)
27 | }
28 | val packInfo: PackageInfo = context.packageManager.getPackageInfo(appInfo.packageName, 0)
29 | val internalDataDir = packInfo.applicationInfo.dataDir
30 | val externalDataDir = PathUtils.append(context.externalCacheDir.parentFile.parent, appInfo.packageName)
31 | val sdcardDir = Environment.getExternalStorageDirectory().absolutePath
32 |
33 | if (path.startsWith(internalDataDir)) {
34 | val ssb = SpannableStringBuilder(context.getString(R.string.path_format_internal_data))
35 | ssb.setSpan(StyleSpan(Typeface.BOLD), 0, ssb.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
36 | ssb.append(path.substringAfter(internalDataDir))
37 | return ssb
38 | } else if (path.startsWith(externalDataDir)) {
39 | val ssb = SpannableStringBuilder(context.getString(R.string.path_format_external_data))
40 | ssb.setSpan(StyleSpan(Typeface.BOLD), 0, ssb.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
41 | ssb.append(path.substringAfter(externalDataDir))
42 | return ssb
43 | } else if (path.startsWith(sdcardDir)) {
44 | val ssb = SpannableStringBuilder(context.getString(R.string.path_format_sdcard))
45 | ssb.setSpan(StyleSpan(Typeface.BOLD), 0, ssb.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
46 | ssb.append(path.substringAfter(sdcardDir))
47 | return ssb
48 | }
49 | return path
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/ImageMIME.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import com.bumptech.glide.load.resource.bitmap.ImageHeaderParser
4 | import com.linroid.viewit.data.model.ImageType
5 | import timber.log.Timber
6 | import java.io.File
7 | import java.io.FileInputStream
8 | import java.io.InputStream
9 |
10 | /**
11 | * @author linroid
12 | * @since 08/01/2017
13 | */
14 | object ImageMIME {
15 | fun isImage(file: File): Boolean = isImage(FileInputStream(file))
16 | fun isImage(inputStream: InputStream): Boolean {
17 | try {
18 | val parser = ImageHeaderParser(inputStream)
19 | return parser.type != ImageHeaderParser.ImageType.UNKNOWN
20 |
21 | // val isFile = isValidPNG(inputStream) || isValidJPEG(inputStream, source.length())
22 | // inputStream.close()
23 | // return isFile
24 | } catch (error: Exception) {
25 | Timber.e(error, "failed to read source")
26 | return false
27 | } finally {
28 | inputStream.close()
29 | }
30 | }
31 |
32 | fun getImageType(file: File): ImageType = getImageType(FileInputStream(file))
33 | fun getImageType(inputStream: InputStream): ImageType {
34 | var type = ImageHeaderParser.ImageType.UNKNOWN
35 | try {
36 | val parser = ImageHeaderParser(inputStream)
37 | type = parser.type
38 | } catch (error: Exception) {
39 | Timber.e(error, "failed to read source")
40 | } finally {
41 | inputStream.close()
42 | }
43 | return ImageType.from(type)
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/OSUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.os.Build
4 |
5 |
6 | /**
7 | * @author linroid
8 | * @since 23/01/2017
9 | */
10 | object OSUtils {
11 | fun getSupportedAbis(): Array {
12 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
13 | return arrayOf(Build.CPU_ABI, Build.CPU_ABI2)
14 | } else {
15 | return Build.SUPPORTED_ABIS
16 | }
17 | }
18 |
19 | fun findPreferAbi(supportAbis: Array, dir: Array): String? {
20 | supportAbis.forEach { support ->
21 | dir.forEach {
22 | if (support == it) {
23 | return it
24 | }
25 | }
26 | }
27 | return null
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/PathUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.content.pm.PackageInfo
5 | import android.os.Environment
6 | import com.linroid.viewit.App
7 | import com.linroid.viewit.R
8 | import java.io.File
9 |
10 | /**
11 | * @author linroid
12 | * @since 30/01/2017
13 | */
14 | object PathUtils {
15 | /**
16 | * 给路径添加一个子路径
17 | */
18 | fun append(dir: String, sub: String): String {
19 | if (dir.endsWith(File.separator)) {
20 | return dir + sub
21 | } else {
22 | return dir + File.separator + sub
23 | }
24 | }
25 |
26 | fun parent(path: String): String {
27 | return path.substringBeforeLast(File.separator)
28 | }
29 |
30 | fun relative(parent: String, path: String): String {
31 | if (parent == File.separator) {
32 | return path
33 | }
34 | val p = path.substringAfter(parent)
35 | if (p.startsWith(File.separatorChar)) {
36 | return p.substringAfter(File.separator)
37 | }
38 | return p
39 | }
40 |
41 | fun name(path: String): String {
42 | if (path.endsWith(File.separator)) {
43 | return path.substringBeforeLast(File.separator).substringAfterLast(File.separator)
44 | } else {
45 | return path.substringAfterLast(File.separator)
46 | }
47 | }
48 |
49 | fun formatToVariable(path: String, appInfo: ApplicationInfo): String {
50 | val context = App.get()
51 |
52 | val packInfo: PackageInfo = context.packageManager.getPackageInfo(appInfo.packageName, 0)
53 | val internalDataDir = packInfo.applicationInfo.dataDir
54 | val externalDataDir = PathUtils.append(context.externalCacheDir.parentFile.parent, appInfo.packageName)
55 | val sdcardDir = Environment.getExternalStorageDirectory().absolutePath
56 |
57 | if (path.startsWith(internalDataDir)) {
58 | return path.replaceFirst(internalDataDir, INTERNAL_DATA_DIR)
59 | } else if (path.startsWith(externalDataDir)) {
60 | return path.replaceFirst(externalDataDir, EXTERNAL_DATA_DIR)
61 | } else if (path.startsWith(sdcardDir)) {
62 | return path.replaceFirst(sdcardDir, SDCARD_DIR)
63 | }
64 | return path
65 | }
66 |
67 | /**
68 | * 格式化为设备的绝对路径
69 | */
70 | fun formatToDevice(path: String, appInfo: ApplicationInfo): String {
71 | val context = App.get()
72 | if (path == File.separator) {
73 | return context.getString(R.string.path_format_root)
74 | }
75 | val packInfo: PackageInfo = context.packageManager.getPackageInfo(appInfo.packageName, 0)
76 | if (path.startsWith(INTERNAL_DATA_DIR)) {
77 | val internalDataDir = packInfo.applicationInfo.dataDir
78 | return path.replace(INTERNAL_DATA_DIR, internalDataDir)
79 | } else if (path.startsWith(EXTERNAL_DATA_DIR)) {
80 | val externalDataDir = PathUtils.append(context.externalCacheDir.parentFile.parent, appInfo.packageName)
81 | return path.replace(EXTERNAL_DATA_DIR, externalDataDir)
82 | } else if (path.startsWith(SDCARD_DIR)) {
83 | val sdcardDir = Environment.getExternalStorageDirectory().absolutePath
84 | return path.replace(SDCARD_DIR, sdcardDir)
85 | }
86 | return path
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/RootUtils.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.os.Environment
4 | import java.io.BufferedReader
5 | import java.io.File
6 | import java.io.InputStreamReader
7 |
8 |
9 | /**
10 | * @author linroid
11 | * @since 08/01/2017
12 | */
13 | object RootUtils {
14 | /**
15 | * 手机是否ROOT
16 | */
17 | private val rooted: Boolean by lazy {
18 | return@lazy checkRootMethod1() || checkRootMethod2() || checkRootMethod3()
19 | }
20 |
21 | /**
22 | * 判断手机是否ROOT
23 | */
24 | fun isRootAvailable(): Boolean {
25 | return rooted
26 | }
27 |
28 | private fun checkRootMethod1(): Boolean {
29 | val buildTags = android.os.Build.TAGS
30 | return buildTags != null && buildTags.contains("test-keys")
31 | }
32 |
33 | private fun checkRootMethod2(): Boolean {
34 | val paths = arrayOf("/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su", "/su/bin/su")
35 | return paths.any { File(it).exists() }
36 | }
37 |
38 | private fun checkRootMethod3(): Boolean {
39 | var process: Process? = null
40 | try {
41 | process = Runtime.getRuntime().exec(arrayOf("/system/xbin/which", "su"))
42 | val line = BufferedReader(InputStreamReader(process!!.inputStream))
43 | if (line.readLine() != null) return true
44 | return false
45 | } catch (t: Throwable) {
46 | return false
47 | } finally {
48 | process?.destroy()
49 | }
50 | }
51 |
52 |
53 | fun isRootFile(path: String): Boolean {
54 | return !path.startsWith(Environment.getExternalStorageDirectory().absolutePath)
55 | }
56 |
57 | fun isRootFile(file: File): Boolean {
58 | return !file.absolutePath.startsWith(Environment.getExternalStorageDirectory().absolutePath)
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/RxOnce.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.content.Context
4 | import com.linroid.viewit.App
5 | import rx.Observable
6 | import java.util.*
7 |
8 | /**
9 | * @author linroid
10 | * @since 27/01/2017
11 | */
12 | object RxOnce {
13 | /**
14 | * 已运行的次数
15 | */
16 | private val processMap = HashMap()
17 |
18 | init {
19 | App.graph.inject(this)
20 | }
21 |
22 | /**
23 | * 整个 APP 生命周期中
24 | */
25 | fun app(key: String, maxTimes: Int = 1): Observable {
26 | val pref = App.get().getSharedPreferences("once", Context.MODE_PRIVATE)
27 | return Observable.just(key)
28 | .map { pref.getInt(key, 0) + 1 }
29 | .doOnNext {
30 | if (it <= maxTimes) {
31 | pref.edit().putInt(key, it).apply()
32 | }
33 | }
34 | .map { it <= maxTimes }
35 | }
36 |
37 | /**
38 | * 进程的生命周期中
39 | */
40 | fun process(key: String, maxTimes: Int = 1): Observable {
41 | return Observable.just(key)
42 | .map { (processMap[key] ?: 0) + 1 }
43 | .filter { it <= maxTimes }
44 | .doOnNext { processMap.put(key, it) }
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/arguments.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | /**
4 | * @author linroid
5 | * @since 24/01/2017
6 | */
7 | const val ARG_APP_INFO: String = "app_info";
8 | const val ARG_POSITION: String = "position";
9 | const val ARG_IMAGE: String = "image";
10 | const val ARG_IMAGE_TREE_PATH: String = "image_tree_path"
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/constans.kt:
--------------------------------------------------------------------------------
1 |
2 | package com.linroid.viewit.utils
3 |
4 | import com.linroid.viewit.BuildConfig
5 |
6 | /**
7 | * @author linroid
8 | * @since 21/01/2017
9 | */
10 | const val BINARY_SEARCH_IMAGE = "search_image"
11 | const val BINARY_DIRECTORY = "exec"
12 | const val FILE_PROVIDER = "${BuildConfig.APPLICATION_ID}.provider"
13 |
14 | const val PREF_SORT_TYPE = "sort_type"
15 | const val PREF_FILTER_SIZE = "filter_size"
16 |
17 | const val THUMBNAIL_MAX_COUNT = 4;
18 | //
19 | //val APP_EXTERNAL_PATHS = mapOf(
20 | // "com.tencent.mm" to arrayListOf("Tencent/MicroMsg"),
21 | // "com.tencent.mobileqq" to arrayListOf("Tencent/QQ_Favorite", "Tencent/MobileQQ", "Tencent/QQ_Images", "Tencent/QQfile_recv")
22 | //)
23 |
24 | const val EXTERNAL_DATA_DIR = "\$EXTERNAL"
25 | const val INTERNAL_DATA_DIR = "\$INTERNAL"
26 | const val SDCARD_DIR = "\$SDCARD"
27 |
28 | const val MOUNTS_CACHE_DIR = "mounts"
29 |
30 | const val ALIPAY_QRCODE = "https://qr.alipay.com/FKX07663WOC6MMNPVVXVEE"
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/daemon.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import rx.Observable
4 | import rx.schedulers.Schedulers
5 | import timber.log.Timber
6 |
7 | /**
8 | * @author linroid
9 | * @since 04/03/2017
10 | */
11 | fun daemon(body: () -> Unit) {
12 | Observable.create {
13 | body()
14 | it.onNext(null)
15 | it.onCompleted()
16 | }.observeOn(Schedulers.io()).subscribe({}, { error -> Timber.e(error, "daemon error") })
17 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/events.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | /**
4 | * @author linroid
5 | * @since 04/03/2017
6 | */
7 |
8 | const val EVENT_CLICK_PATH_SETTINGS = "CLICK_PATH_SETTINGS"
9 | const val EVENT_CLICK_PATH_SETTINGS_NO_IMAGE = "CLICK_PATH_SETTINGS_NO_IMAGE"
10 | const val EVENT_CLICK_PATH_EDIT = "CLICK_PATH_EDIT"
11 | const val EVENT_CLICK_PATH_DELETE = "CLICK_PATH_DELETE"
12 | const val EVENT_CLICK_PATH_ADD = "CLICK_PATH_ADD"
13 |
14 | const val EVENT_SORT_IMAGE = "SORT_IMAGE"
15 | const val EVENT_FILTER_IMAGE = "FILTER_IMAGE"
16 |
17 | const val EVENT_CLICK_IMAGE_SORT = "CLICK_IMAGE_SORT"
18 | const val EVENT_CLICK_IMAGE_FILTER = "CLICK_IMAGE_FILTER"
19 |
20 | const val EVENT_CLICK_JUMP_TO_IMAGES = "CLICK_JUMP_TO_IMAGES"
21 |
22 | const val EVENT_LIST_APP = "LIST_APP"
23 |
24 | const val EVENT_SCAN_IMAGE = "SCAN_IMAGE"
25 | const val EVENT_DELETE_FAVORITE = "DELETE_FAVORITE"
26 | const val EVENT_ADD_FAVORITE = "ADD_FAVORITE"
27 | const val EVENT_SAVE_FAVORITE = "SAVE_FAVORITE"
28 |
29 |
30 | const val EVENT_CLICK_IMAGE_DETAIL = "CLICK_IMAGE_DETAIL"
31 | const val EVENT_SHARE_IMAGE = "SHARE_IMAGE"
32 | const val EVENT_DELETE_IMAGE = "DELETE_IMAGE"
33 | const val EVENT_SAVE_IMAGE = "SAVE_IMAGE"
34 |
35 |
36 | const val EVENT_CLICK_APP = "CLICK_APP"
37 | const val EVENT_CLICK_APP_DETAIL = "CLICK_APP_DETAIL"
38 | const val EVENT_CLICK_LAUNCH_APP = "CLICK_LAUNCH_APP"
39 | const val EVENT_CLICK_FAVORITE = "CLICK_FAVORITE"
40 | const val EVENT_CLICK_CLOUD_FAVORITE = "CLICK_CLOUD_FAVORITE"
41 | const val EVENT_CLICK_TREE = "CLICK_TREE"
42 | const val EVENT_VIEW_IMAGE = "VIEW_IMAGE"
43 |
44 | const val EVENT_CLICK_FEEDBACK = "CLICK_FEEDBACK"
45 |
46 | // 关于页面
47 | const val EVENT_CLICK_ABOUT = "CLICK_ABOUT"
48 | const val EVENT_CLICK_ABOUT_DONATE = "CLICK_ABOUT_DONATE"
49 | const val EVENT_CLICK_ABOUT_DEVELOPER = "CLICK_ABOUT_DEVELOPER"
50 | const val EVENT_CLICK_ABOUT_SHARE = "CLICK_ABOUT_SHARE"
51 | const val EVENT_CLICK_ABOUT_OPENSOURCE = "CLICK_ABOUT_OPENSOURCE"
52 |
53 |
54 | const val EVENT_BATCH_SHARE_IMAGE = "BATCH_SHARE_IMAGE"
55 | const val EVENT_BATCH_DELETE_IMAGE = "BATCH_DELETE_IMAGE"
56 | const val EVENT_BATCH_SAVE_IMAGE = "BATCH_SAVE_IMAGE"
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/extensions.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | import android.view.View
4 | import android.view.ViewGroup
5 | import rx.Observable
6 | import rx.Subscription
7 | import rx.android.schedulers.AndroidSchedulers
8 |
9 | /**
10 | * @author linroid
11 | * @since 07/01/2017
12 | */
13 | fun Subscription?.unsubscribeIfNotNull() {
14 | if (this != null && !this.isUnsubscribed) {
15 | this.unsubscribe()
16 | }
17 | }
18 |
19 | fun Observable.onMain(): Observable {
20 | return this.observeOn(AndroidSchedulers.mainThread())
21 | }
22 |
23 |
24 | fun View.removeFromParent() {
25 | if (this.parent != null && this.parent is ViewGroup) {
26 | (this.parent as ViewGroup).removeView(this)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/pref/BasePreference.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils.pref
2 |
3 | import android.content.SharedPreferences
4 | import rx.Observable
5 | import rx.lang.kotlin.PublishSubject
6 | import rx.subjects.PublishSubject
7 |
8 | /**
9 | * @author linroid
10 | * @since 27/01/2017
11 | */
12 | abstract class BasePreference(protected val pref: SharedPreferences, protected val key: String, protected val defaultVal: T) {
13 | private var cachedValue: T? = null
14 | private var subject: PublishSubject? = null
15 | fun get(): T {
16 | if (cachedValue == null) {
17 | cachedValue = getVal()
18 | }
19 | return cachedValue!!
20 | }
21 |
22 | fun set(value: T) {
23 | cachedValue = value
24 | val editor = pref.edit()
25 | setVal(editor, value)
26 | editor.apply()
27 | subject?.onNext(value)
28 | }
29 |
30 | fun listen(): Observable {
31 | if (subject == null) {
32 | subject = PublishSubject()
33 | }
34 | return subject!!
35 | }
36 |
37 | abstract protected fun getVal(): T
38 | abstract protected fun setVal(editor: SharedPreferences.Editor, value: T)
39 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/pref/BooleanPreference.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils.pref
2 |
3 | import android.content.SharedPreferences
4 |
5 | /**
6 | * @author linroid
7 | * @since 27/01/2017
8 | */
9 | class BooleanPreference(pref: SharedPreferences, key: String, defaultVal: Boolean) : BasePreference(pref, key, defaultVal) {
10 | override fun getVal(): Boolean {
11 | return pref.getBoolean(key, defaultVal)
12 | }
13 |
14 | override fun setVal(editor: SharedPreferences.Editor, value: Boolean) {
15 | editor.putBoolean(key, value)
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/pref/LongPreference.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils.pref
2 |
3 | import android.content.SharedPreferences
4 |
5 | /**
6 | * @author linroid
7 | * @since 27/01/2017
8 | */
9 | class LongPreference(pref: SharedPreferences, key: String, defaultVal: Long) : BasePreference(pref, key, defaultVal) {
10 | override fun getVal(): Long {
11 | return pref.getLong(key, defaultVal)
12 | }
13 |
14 | override fun setVal(editor: SharedPreferences.Editor, value: Long) {
15 | editor.putLong(key, value)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/utils/versions.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.utils
2 |
3 | /**
4 | * @author linroid
5 | * @since 07/02/2017
6 | */
7 | const val DB_VERSION = 1L
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/AnimatedImageView.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Animatable
5 | import android.graphics.drawable.AnimationDrawable
6 | import android.util.AttributeSet
7 | import android.widget.ImageView
8 |
9 | /**
10 | * @author linroid
11 | * @since 28/01/2017
12 | */
13 | class AnimatedImageView : ImageView, Animatable {
14 |
15 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
16 | init()
17 | }
18 |
19 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
20 | init()
21 | }
22 |
23 | constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
24 | init()
25 | }
26 |
27 | private fun init() {
28 | }
29 |
30 | override fun isRunning(): Boolean {
31 | val src = drawable
32 | if (src is AnimationDrawable) {
33 | return src.isRunning
34 | }
35 | return false
36 | }
37 |
38 | override fun start() {
39 | val src = drawable
40 | if (src is AnimationDrawable) {
41 | src.start()
42 | }
43 | }
44 |
45 | override fun stop() {
46 | val src = drawable
47 | if (src is AnimationDrawable) {
48 | src.stop()
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/AnimatedScrollView.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Animatable
5 | import android.util.AttributeSet
6 | import android.widget.ImageView
7 |
8 | /**
9 | * @author linroid
10 | * @since 28/01/2017
11 | */
12 | class AnimatedScrollView : ImageView, Animatable {
13 |
14 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
15 | init()
16 | }
17 |
18 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
19 | init()
20 | }
21 |
22 | constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
23 | init()
24 | }
25 |
26 | private fun init() {
27 | }
28 |
29 | override fun isRunning(): Boolean {
30 | return true
31 | }
32 |
33 | override fun start() {
34 | }
35 |
36 | override fun stop() {
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/AnimatedSetView.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget
2 |
3 | import android.content.Context
4 | import android.graphics.drawable.Animatable
5 | import android.util.AttributeSet
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.FrameLayout
9 |
10 | /**
11 | * @author linroid
12 | * @since 28/01/2017
13 | */
14 | class AnimatedSetView : FrameLayout, Animatable {
15 |
16 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
17 | init()
18 | }
19 |
20 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
21 | init()
22 | }
23 |
24 | constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
25 | init()
26 | }
27 |
28 | private fun init() {
29 | }
30 |
31 | override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams?) {
32 | if ((child is Animatable).not()) {
33 | throw IllegalArgumentException("not support none Animatable View")
34 | }
35 | super.addView(child, index, params)
36 | }
37 |
38 | override fun isRunning(): Boolean {
39 | return (0..childCount-1)
40 | .map { getChildAt(it) as Animatable }
41 | .any { it.isRunning }
42 | }
43 |
44 | override fun start() {
45 | (0..childCount-1)
46 | .map {
47 | getChildAt(it) as Animatable
48 | }
49 | .forEach { it.start() }
50 | }
51 |
52 | override fun stop() {
53 | (0..childCount-1)
54 | .map { getChildAt(it) as Animatable }
55 | .forEach { it.stop() }
56 | }
57 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/InsetsFrameLayout.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget
2 |
3 | import android.content.Context
4 | import android.support.v4.view.ViewCompat
5 | import android.util.AttributeSet
6 | import android.widget.FrameLayout
7 | import timber.log.Timber
8 |
9 | /**
10 | * @author linroid
11 | * @since 25/01/2017
12 | */
13 | class InsetsFrameLayout : FrameLayout {
14 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
15 | init()
16 | }
17 |
18 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
19 | init()
20 | }
21 |
22 | constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
23 | init()
24 | }
25 |
26 | private fun init() {
27 | clipToPadding = false
28 | fitsSystemWindows = true
29 | ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
30 | Timber.i(insets.toString())
31 | setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop, insets.systemWindowInsetRight, insets.systemWindowInsetBottom);
32 | return@setOnApplyWindowInsetsListener insets.consumeSystemWindowInsets()
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/PaddingBackgroundColorSpan.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.Paint
5 | import android.graphics.Rect
6 | import android.text.style.LineBackgroundSpan
7 |
8 | /**
9 | * @author linroid
10 | * @since 31/01/2017
11 | */
12 | class PaddingBackgroundColorSpan(private val backgroundColor: Int, private val padding: Int) : LineBackgroundSpan {
13 | private val paddingRect: Rect = Rect()
14 |
15 | override fun drawBackground(c: Canvas, paint: Paint,
16 | left: Int, right: Int, top: Int, baseline: Int, bottom: Int,
17 | text: CharSequence, start: Int, end: Int, lnum: Int) {
18 | val textWidth = Math.round(paint.measureText(text, start, end))
19 | val paintColor = paint.color
20 | // Draw the background
21 | paddingRect.set(left - padding,
22 | top - if (lnum == 0) padding / 2 else -(padding / 2),
23 | left + textWidth + padding,
24 | bottom + padding / 2)
25 | paint.color = backgroundColor
26 | c.drawRect(paddingRect, paint)
27 | paint.color = paintColor
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/SquareImageView.java:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.widget.AppCompatImageView;
6 | import android.util.AttributeSet;
7 |
8 | /**
9 | * @author linroid
10 | * @since 08/01/2017
11 | */
12 | public class SquareImageView extends AppCompatImageView {
13 | public SquareImageView(Context context) {
14 | super(context);
15 | }
16 |
17 | public SquareImageView(Context context, @Nullable AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public SquareImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
22 | super(context, attrs, defStyleAttr);
23 | }
24 |
25 | @Override
26 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
27 | int widthMode = MeasureSpec.getMode(widthMeasureSpec);
28 | int heightMode = MeasureSpec.getMode(heightMeasureSpec);
29 | if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
30 | int width = MeasureSpec.getSize(widthMeasureSpec);
31 | int height = width;
32 | if (heightMode == MeasureSpec.AT_MOST) {
33 | height = Math.min(height, MeasureSpec.getSize(heightMeasureSpec));
34 | }
35 | setMeasuredDimension(width, height);
36 | } else {
37 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/divider/CategoryItemDecoration.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget.divider
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.Rect
5 | import android.graphics.drawable.Drawable
6 | import android.support.v4.content.ContextCompat
7 | import android.support.v4.view.ViewCompat
8 | import android.support.v7.widget.RecyclerView
9 | import android.view.View
10 | import com.linroid.viewit.R
11 | import com.linroid.viewit.utils.AndroidUtils
12 |
13 | /**
14 | * @author linroid
15 | * @since 12/02/2017
16 | */
17 | class CategoryItemDecoration : RecyclerView.ItemDecoration {
18 | var drawable: Drawable? = null
19 | var offset = 0 // 偏移量,覆盖住分割线
20 |
21 | constructor(recyclerView: RecyclerView) : super() {
22 | init(recyclerView, ContextCompat.getDrawable(recyclerView.context, R.drawable.bg_category_divider))
23 | }
24 |
25 | constructor(recyclerView: RecyclerView, divider: Drawable) : super() {
26 | init(recyclerView, divider)
27 | }
28 |
29 | private fun init(recyclerView: RecyclerView, divider: Drawable) {
30 | this.drawable = divider
31 | this.offset = -AndroidUtils.dp(1F).toInt()
32 | }
33 |
34 | override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
35 | val left = parent.paddingLeft
36 | val right = parent.width - parent.paddingRight
37 |
38 | val childCount = parent.childCount
39 | for (i in 0..childCount - 1) {
40 | val child = parent.getChildAt(i)
41 | if (canDrawAt(parent, child)) {
42 | val params = child.layoutParams as RecyclerView.LayoutParams
43 | val bottom = child.top - params.topMargin + Math.round(ViewCompat.getTranslationY(child)) + offset
44 | val top = bottom - drawable!!.intrinsicHeight
45 | drawable!!.setBounds(left, top, right, bottom)
46 | drawable!!.draw(c)
47 | }
48 | }
49 | }
50 |
51 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
52 | if (canDrawAt(parent, view)) {
53 | outRect.set(0, drawable!!.intrinsicHeight + offset, 0, 0)
54 | } else {
55 | super.getItemOffsets(outRect, view, parent, state)
56 | }
57 | }
58 |
59 | private fun canDrawAt(parent: RecyclerView, view: View): Boolean {
60 | // val viewHolder = parent.findViewHolderForLayoutPosition(parent.getChildAdapterPosition(view))
61 | if (drawable != null && view.id == R.id.category_view && parent.getChildAdapterPosition(view) > 0) {
62 | return true
63 | }
64 | return false
65 |
66 | }
67 | }
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/linroid/viewit/widget/divider/DividerDecoration.kt:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit.widget.divider
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Rect
6 | import android.graphics.drawable.Drawable
7 | import android.support.annotation.DrawableRes
8 | import android.support.v4.content.ContextCompat
9 | import android.support.v4.view.ViewCompat
10 | import android.support.v7.widget.LinearLayoutManager
11 | import android.support.v7.widget.RecyclerView
12 | import android.view.View
13 | import com.linroid.viewit.R
14 |
15 | /**
16 | * @author linroid
17 | * @since 12/02/2017
18 | */
19 | class DividerDecoration : RecyclerView.ItemDecoration {
20 |
21 | var divider: Drawable? = null
22 | private var orientation: Int = 0
23 |
24 | constructor(context: Context, orientation: Int) {
25 | divider = ContextCompat.getDrawable(context, R.drawable.base_divider)
26 | this.orientation = orientation
27 | }
28 |
29 | constructor(context: Context, orientation: Int, @DrawableRes resId: Int) {
30 | divider = ContextCompat.getDrawable(context, resId) ?: ContextCompat.getDrawable(context, R.drawable.base_divider)
31 | this.orientation = orientation
32 | }
33 |
34 | constructor(context: Context, orientation: Int, drawable: Drawable?) {
35 | divider = drawable ?: ContextCompat.getDrawable(context, R.drawable.base_divider)
36 | this.orientation = orientation
37 | }
38 |
39 | override fun onDraw(c: Canvas, parent: RecyclerView) {
40 | if (orientation == VERTICAL_LIST) {
41 | drawVertical(c, parent)
42 | } else {
43 | drawHorizontal(c, parent)
44 | }
45 | }
46 |
47 | fun drawVertical(c: Canvas, parent: RecyclerView) {
48 | val left = parent.paddingLeft
49 | val right = parent.width - parent.paddingRight
50 |
51 | val childCount = parent.childCount
52 | for (i in 0..childCount - 1) {
53 | val child = parent.getChildAt(i)
54 | if (canDrawAt(parent, child)) {
55 | val params = child.layoutParams as RecyclerView.LayoutParams
56 | val top = child.bottom + params.bottomMargin + Math.round(ViewCompat.getTranslationY(child))
57 | val bottom = top + divider!!.intrinsicHeight
58 | divider!!.setBounds(left, top, right, bottom)
59 | divider!!.draw(c)
60 | }
61 | }
62 | }
63 |
64 | fun drawHorizontal(c: Canvas, parent: RecyclerView) {
65 | val top = parent.paddingTop
66 | val bottom = parent.height - parent.paddingBottom
67 |
68 | val childCount = parent.childCount
69 | for (i in 0..childCount - 1) {
70 | val child = parent.getChildAt(i)
71 | if (canDrawAt(parent, child)) {
72 | val params = child.layoutParams as RecyclerView.LayoutParams
73 | val left = child.right + params.rightMargin + Math.round(ViewCompat.getTranslationX(child))
74 | val right = left + divider!!.intrinsicHeight
75 | divider!!.setBounds(left, top, right, bottom)
76 | divider!!.draw(c)
77 | }
78 | }
79 | }
80 |
81 | private fun canDrawAt(recyclerView: RecyclerView, child: View): Boolean {
82 | return child.id != R.id.category_view
83 | }
84 |
85 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
86 | if (canDrawAt(parent, view)) {
87 | if (orientation == VERTICAL_LIST) {
88 | outRect.set(0, 0, 0, divider!!.intrinsicHeight)
89 | } else {
90 | outRect.set(0, 0, divider!!.intrinsicWidth, 0)
91 | }
92 | }
93 | }
94 |
95 | companion object {
96 | val HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL
97 | val VERTICAL_LIST = LinearLayoutManager.VERTICAL
98 | }
99 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/fragment_none.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_create_new_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_create_new_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_filter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_sd_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_sd_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_sort.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_star.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_star_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-hdpi/ic_star_border.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_create_new_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_create_new_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_filter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_sd_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_sd_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_sort.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_star.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_star_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-mdpi/ic_star_border.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/bg_btn_delete_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
-
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/avatar.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/avatar.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/cloud.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_01.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_02.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_03.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_04.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_05.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/dinosaur_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/dinosaur_06.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_create_new_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_create_new_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_eye.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_filter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_sd_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_sd_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_sort.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_star.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_star_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/ic_star_border.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xhdpi/line.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/bg_category_divider.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/bg_category_divider.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_create_new_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_create_new_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_filter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_sd_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_sd_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_sort.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_star.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_star_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxhdpi/ic_star_border.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_create_new_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_create_new_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_filter.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_folder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_save.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_sd_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_sd_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_sort.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_star.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_star_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable-xxxhdpi/ic_star_border.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/anim_dinosaur.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/base_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_delete_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_viewer_options_mask.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_viewer_toolbar_mask.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_widget_multi_operations.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/emoji_sleepy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/drawable/emoji_sleepy.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/about_page_main_activity.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
41 |
42 |
47 |
48 |
51 |
52 |
56 |
57 |
58 |
59 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_base_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
16 |
17 |
18 |
22 |
23 |
27 |
28 |
34 |
35 |
41 |
42 |
48 |
49 |
55 |
56 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
21 |
22 |
29 |
30 |
38 |
39 |
43 |
44 |
48 |
49 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_image_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_image_tree.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_image_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_summary.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_app.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
22 |
23 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_build_in_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
25 |
26 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_cloud_scan_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
24 |
25 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
25 |
26 |
32 |
33 |
45 |
46 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image_property.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
23 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_image_tree.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
26 |
27 |
35 |
36 |
47 |
48 |
49 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_scan_path.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_dialog_create_favorite.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_no_image_found.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
28 |
29 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/widget_image_multi_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
22 |
23 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/about.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/favorite_create.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/feedback.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/gallery_summary.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/gallery_tree_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/gallery_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/home.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/image_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/image_multi_actions.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/image_sort.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/image_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/path_manager.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 看应用
4 | 关于
5 | 允许
6 | 拒绝
7 | 显示 %1$d 张图片,过滤了 %2$d张:)
8 | 扫描中…
9 | 不再申请 Storage 权限
10 | :(\\n发生了一个错误: %1$s
11 | 详细信息
12 | 没有存储卡
13 | 图片成功保存到:%1$s
14 | 删除图片成功
15 | 删除图片失败
16 | 分享到
17 | 删除这张图片可能导致「%1$s」运行异常,请谨慎操作!
18 | 仍然删除
19 | 查看应用信息
20 | 排序
21 | 查看
22 | 警告⚠
23 | 按路径
24 | 按文件大小
25 | 按时间
26 | :( 发生了一个错误: %1$s
27 | 扫描完成,未找到图片:(
28 | %1$d/%2$d 张
29 | %1$d 张
30 | 0 张
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #24a060
4 | #24a060
5 | #FF4081
6 | #24a060
7 |
8 | #F7F7F7
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
21 |
22 |
30 |
31 |
34 |
35 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
41 |
42 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/linroid/viewit/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.linroid.viewit;
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 | ext.kotlin_version = '1.1.1'
5 | ext.support_version = '25.2.0'
6 | ext.retrofit_version = '2.1.0'
7 | ext.permissionsdispatcher_version = '2.3.0'
8 | ext.anko_version = '0.9.1'
9 |
10 | repositories {
11 | jcenter()
12 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
13 | maven { url "http://dl.bintray.com/piasy/maven" }
14 | maven { url "https://jitpack.io" }
15 | maven { url "http://mvn.leancloud.cn/nexus/content/repositories/releases" }
16 | maven { url "http://maven.bughd.com/public" }
17 | maven { url 'https://maven.fabric.io/public' }
18 | maven { url 'http://oss.sonatype.org/content/repositories/snapshots'}
19 | }
20 |
21 | dependencies {
22 | classpath 'com.android.tools.build:gradle:2.3.0'
23 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
24 | classpath 'im.fir:gradle-fir-publisher:1.0.7'
25 | classpath 'io.fabric.tools:gradle:1.22.1'
26 | }
27 | }
28 |
29 | allprojects {
30 | repositories {
31 | jcenter()
32 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
33 | maven { url "http://dl.bintray.com/piasy/maven" }
34 | maven { url "https://jitpack.io" }
35 | maven { url "http://mvn.leancloud.cn/nexus/content/repositories/releases" }
36 | maven { url "http://maven.bughd.com/public" }
37 | maven { url 'https://maven.fabric.io/public' }
38 | maven { url 'http://oss.sonatype.org/content/repositories/snapshots'}
39 | }
40 | }
41 |
42 | task clean(type: Delete) {
43 | delete rootProject.buildDir
44 | }
45 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this source.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx2560M
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | org.gradle.parallel=true
18 | android.useDeprecatedNdk=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linroid/ViewIt/e5ee27e2047c5cf37f3222d679df6faee0509d02/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-3.3-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
--------------------------------------------------------------------------------