├── .gitignore
├── .idea
├── aws.xml
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── dictionaries
│ ├── admin.xml
│ ├── sjk.xml
│ └── win10.xml
├── git_toolbox_prj.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── intellij-javadocs-4.0.1.xml
├── jarRepositories.xml
├── kotlinc.xml
├── migrations.xml
├── misc.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── sjk
│ │ └── deleterecentpictures
│ │ ├── activity
│ │ ├── common
│ │ │ └── ImageLongClickDialog.kt
│ │ ├── image
│ │ │ ├── ImageActivity.kt
│ │ │ └── ImageActivityViewPagerAdapter.kt
│ │ ├── main
│ │ │ ├── MainActivity.kt
│ │ │ ├── MainActivityViewPagerAdapter.kt
│ │ │ └── ScrollButtonManager.kt
│ │ └── settings
│ │ │ └── SettingsActivity.kt
│ │ ├── bean
│ │ ├── DeletedImageInfoBean.kt
│ │ ├── ImageDetailBean.kt
│ │ └── ImageInfoBean.kt
│ │ ├── common
│ │ ├── ActivityManager.kt
│ │ ├── App.kt
│ │ ├── BaseActivity.kt
│ │ ├── Const.kt
│ │ ├── DataSource.kt
│ │ ├── Event.kt
│ │ ├── GlobalData.kt
│ │ ├── ImageLoadManager.kt
│ │ ├── Input.kt
│ │ ├── Logger.kt
│ │ ├── Output.kt
│ │ ├── RecentImages.kt
│ │ ├── RecycleBinManager.kt
│ │ └── Switch.kt
│ │ ├── service
│ │ ├── ImageWidgetService.kt
│ │ └── QuickSettingOpenService.kt
│ │ ├── utils
│ │ ├── AlertDialogUtil.kt
│ │ ├── ApkUtil.kt
│ │ ├── ClipboardUtil.kt
│ │ ├── DensityUtil.kt
│ │ ├── FileUtil.kt
│ │ ├── ImageScannerUtil.kt
│ │ ├── PermissionUtil.kt
│ │ ├── QRCodeUtil.kt
│ │ ├── ShellUtil.kt
│ │ ├── ShortcutUtil.kt
│ │ ├── TimeUtil.kt
│ │ └── TransformUtil.kt
│ │ └── widget
│ │ └── ImageWidget.kt
│ └── res
│ ├── drawable-night-v31
│ └── dialog_background.xml
│ ├── drawable-v21
│ ├── app_widget_background.xml
│ └── app_widget_inner_view_background.xml
│ ├── drawable-v31
│ └── dialog_background.xml
│ ├── drawable
│ ├── activity_main_background.xml
│ ├── arrow_left.xml
│ ├── arrow_right.xml
│ ├── dialog_background.xml
│ ├── divider.xml
│ ├── ic_close.xml
│ ├── ic_delete_image.xml
│ ├── ic_image.xml
│ ├── ic_info.xml
│ ├── ic_launcher_foreground.xml
│ ├── ic_refresh.xml
│ ├── ic_settings.xml
│ └── ic_undo.xml
│ ├── layout
│ ├── activity_image.xml
│ ├── activity_main.xml
│ ├── activity_main_multi_window.xml
│ ├── activity_settings2.xml
│ ├── image_widget.xml
│ ├── layout_deleted_snackbar_buttons.xml
│ ├── layout_main_view_pager_item.xml
│ └── layout_view_pager_item.xml
│ ├── menu
│ └── menu_main_activity.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values-en
│ ├── arrays.xml
│ └── strings.xml
│ ├── values-night-v31
│ ├── colors.xml
│ └── themes.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-v31
│ ├── colors.xml
│ ├── styles.xml
│ └── themes.xml
│ ├── values
│ ├── arrays.xml
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ ├── styles.xml
│ └── themes.xml
│ ├── xml-v31
│ └── image_widget_info.xml
│ └── xml
│ ├── data_extraction_rules.xml
│ ├── file_paths.xml
│ ├── image_widget_info.xml
│ └── root_preferences.xml
├── build.gradle
├── docs
└── images
│ └── previews
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ └── 4.png
├── 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/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | /app/release/
16 | /.idea/
17 | /.kotlin
18 |
--------------------------------------------------------------------------------
/.idea/aws.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/dictionaries/admin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | infos
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/dictionaries/sjk.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | baos
5 | charlist
6 | constraintlayout
7 | coolapk
8 | coolmarket
9 | deleterecent
10 | fileprovider
11 | logd
12 | msgs
13 | tencent
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/dictionaries/win10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | dcim
5 | deleterecentpictures
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/git_toolbox_prj.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/intellij-javadocs-4.0.1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UPDATE
6 | false
7 | true
8 |
9 | FIELD
10 | METHOD
11 | TYPE
12 |
13 |
14 | DEFAULT
15 | PUBLIC
16 | PROTECTED
17 |
18 |
19 |
20 |
21 |
22 | ^.*(public|protected|private)*.+interface\s+\w+.*
23 | /**\n
24 | * The interface ${name}.\n
25 | <#if element.typeParameters?has_content> * \n
26 | </#if>
27 | <#list element.typeParameters as typeParameter>
28 | * @param <${typeParameter.name}> the type parameter\n
29 | </#list>
30 | */
31 |
32 |
33 | ^.*(public|protected|private)*.+enum\s+\w+.*
34 | /**\n
35 | * The enum ${name}.\n
36 | */
37 |
38 |
39 | ^.*(public|protected|private)*.+class\s+\w+.*
40 | /**\n
41 | * The type ${name}.\n
42 | <#if element.typeParameters?has_content> * \n
43 | </#if>
44 | <#list element.typeParameters as typeParameter>
45 | * @param <${typeParameter.name}> the type parameter\n
46 | </#list>
47 | */
48 |
49 |
50 | .+
51 | /**\n
52 | * The type ${name}.\n
53 | */
54 |
55 |
56 |
57 |
58 | .+
59 | /**\n
60 | * Instantiates a new ${name}.\n
61 | <#if element.parameterList.parameters?has_content>
62 | *\n
63 | </#if>
64 | <#list element.parameterList.parameters as parameter>
65 | * @param ${parameter.name} the ${paramNames[parameter.name]}\n
66 | </#list>
67 | <#if element.throwsList.referenceElements?has_content>
68 | *\n
69 | </#if>
70 | <#list element.throwsList.referenceElements as exception>
71 | * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
72 | </#list>
73 | */
74 |
75 |
76 |
77 |
78 | ^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+
79 | /**\n
80 | * Gets ${partName}.\n
81 | <#if element.typeParameters?has_content> * \n
82 | </#if>
83 | <#list element.typeParameters as typeParameter>
84 | * @param <${typeParameter.name}> the type parameter\n
85 | </#list>
86 | <#if element.parameterList.parameters?has_content>
87 | *\n
88 | </#if>
89 | <#list element.parameterList.parameters as parameter>
90 | * @param ${parameter.name} the ${paramNames[parameter.name]}\n
91 | </#list>
92 | <#if isNotVoid>
93 | *\n
94 | * @return the ${partName}\n
95 | </#if>
96 | <#if element.throwsList.referenceElements?has_content>
97 | *\n
98 | </#if>
99 | <#list element.throwsList.referenceElements as exception>
100 | * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
101 | </#list>
102 | */
103 |
104 |
105 | ^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+
106 | /**\n
107 | * Sets ${partName}.\n
108 | <#if element.typeParameters?has_content> * \n
109 | </#if>
110 | <#list element.typeParameters as typeParameter>
111 | * @param <${typeParameter.name}> the type parameter\n
112 | </#list>
113 | <#if element.parameterList.parameters?has_content>
114 | *\n
115 | </#if>
116 | <#list element.parameterList.parameters as parameter>
117 | * @param ${parameter.name} the ${paramNames[parameter.name]}\n
118 | </#list>
119 | <#if isNotVoid>
120 | *\n
121 | * @return the ${partName}\n
122 | </#if>
123 | <#if element.throwsList.referenceElements?has_content>
124 | *\n
125 | </#if>
126 | <#list element.throwsList.referenceElements as exception>
127 | * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
128 | </#list>
129 | */
130 |
131 |
132 | ^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+
133 | /**\n
134 | * The entry point of application.\n
135 |
136 | <#if element.parameterList.parameters?has_content>
137 | *\n
138 | </#if>
139 | * @param ${element.parameterList.parameters[0].name} the input arguments\n
140 | <#if element.throwsList.referenceElements?has_content>
141 | *\n
142 | </#if>
143 | <#list element.throwsList.referenceElements as exception>
144 | * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
145 | </#list>
146 | */
147 |
148 |
149 | .+
150 | /**\n
151 | * ${name}<#if isNotVoid> ${return}</#if>.\n
152 | <#if element.typeParameters?has_content> * \n
153 | </#if>
154 | <#list element.typeParameters as typeParameter>
155 | * @param <${typeParameter.name}> the type parameter\n
156 | </#list>
157 | <#if element.parameterList.parameters?has_content>
158 | *\n
159 | </#if>
160 | <#list element.parameterList.parameters as parameter>
161 | * @param ${parameter.name} the ${paramNames[parameter.name]}\n
162 | </#list>
163 | <#if isNotVoid>
164 | *\n
165 | * @return the ${return}\n
166 | </#if>
167 | <#if element.throwsList.referenceElements?has_content>
168 | *\n
169 | </#if>
170 | <#list element.throwsList.referenceElements as exception>
171 | * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
172 | </#list>
173 | */
174 |
175 |
176 |
177 |
178 | ^.*(public|protected|private)*.+static.*(\w\s\w)+.+
179 | /**\n
180 | * The constant ${element.getName()}.\n
181 | */
182 |
183 |
184 | ^.*(public|protected|private)*.*(\w\s\w)+.+
185 | /**\n
186 | <#if element.parent.isInterface()>
187 | * The constant ${element.getName()}.\n
188 | <#else>
189 | * The ${name}.\n
190 | </#if> */
191 |
192 |
193 | .+
194 | /**\n
195 | <#if element.parent.isEnum()>
196 | *${name} ${typeName}.\n
197 | <#else>
198 | * The ${name}.\n
199 | </#if>*/
200 |
201 |
202 |
203 |
204 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 |
8 | true
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 删除最近图片
2 |
3 | 
4 | 
5 | 
6 | 
7 | 
8 |
9 | 删除手机里最近的图片,包括但不限于截图、照片等,只要图片被系统媒体扫描后就能显示。解决不小心保存图片、截屏、拍照等问题。建议配合悬浮球、侧边栏等类型的APP使用,或者利用状态栏中的快速磁贴打开。
10 |
11 | ### 支持系统
12 | Android 6.0(SdkVersion 23)及以上
13 |
14 | ### 功能
15 | + 支持图片切换
16 | + 支持大图模式查看
17 | + 支持查看图片信息
18 | + 支持用其他应用打开以及分享
19 | + 支持二维码识别
20 | + 多选删除
21 | + 允许自定义查找路径
22 | + 支持GIF播放和超大图查看
23 | + 支持从快速设置磁贴
24 | + 支持暗色模式
25 | + 使用Material You,支持Monet取色
26 | + 支持在最近运行任务中隐藏
27 | + 【实验性】支持多窗口模式(小窗和分屏等)下特有的布局
28 | + 【实验性】支持临时的撤销删除功能
29 |
30 | ### 预览图
31 |
32 |
33 |
34 |
35 |
36 | ### 下载
37 | [https://github.com/1045290202/DeleteRecentPictures/releases/latest](https://github.com/1045290202/DeleteRecentPictures/releases/latest)
38 |
39 | ### 开源库
40 | + [ZoomImage](https://github.com/panpf/zoomimage)
41 | + [ZXing](https://github.com/zxing/zxing)
42 | + [RikkaX](https://github.com/RikkaApps/RikkaX)
43 | + [Apache Commons IO](https://github.com/apache/commons-io)
44 |
45 | -------
46 |
47 | 在酷安上关注开发者: *[@来一斤BUG](https://www.coolapk.com/u/458995)*
48 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "kotlin-android"
3 |
4 | android {
5 | compileSdk 35
6 | defaultConfig {
7 | applicationId "com.sjk.deleterecentpictures"
8 | minSdkVersion 23
9 | targetSdkVersion 35
10 | versionCode 51
11 | versionName "3.2.6"
12 | // testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled true
17 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
18 | }
19 | }
20 | compileOptions {
21 | sourceCompatibility = JavaVersion.VERSION_21
22 | targetCompatibility = JavaVersion.VERSION_21
23 | }
24 | buildscript {
25 |
26 | }
27 | lintOptions {
28 | checkReleaseBuilds false
29 | abortOnError false
30 | }
31 | namespace "com.sjk.deleterecentpictures"
32 | buildFeatures {
33 | viewBinding true
34 | buildConfig true
35 | }
36 | }
37 |
38 | repositories {
39 | maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
40 | mavenCentral()
41 | }
42 |
43 | configurations.configureEach {
44 | exclude group: "androidx.appcompat", module: "appcompat"
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(dir: "libs", include: ["*.jar"])
49 | // implementation "androidx.appcompat:appcompat:1.6.1"
50 | // implementation "androidx.constraintlayout:constraintlayout:2.1.4"
51 | // testImplementation "junit:junit:4.12"
52 | // androidTestImplementation "androidx.test.ext:junit:1.1.1"
53 | // androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
54 | // implementation "com.google.android.material:material:1.9.0"
55 |
56 | //AndPermission
57 | // implementation "com.yanzhenjie:permission:2.0.3"
58 | // implementation "com.github.chrisbanes:PhotoView:2.3.0"
59 | implementation "androidx.preference:preference-ktx:1.2.1"
60 | implementation "androidx.core:core-ktx:1.15.0"
61 | implementation "androidx.annotation:annotation-jvm:1.9.1"
62 | //noinspection GradleDependency
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
64 | // implementation "com.zxy.android:tiny:1.1.0"
65 | // implementation "com.davemorrissey.labs:subsampling-scale-image-view:3.10.0"
66 | // implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.22"
67 | implementation "com.google.zxing:core:3.5.3"
68 | // implementation "com.github.piasy:BigImageViewer:1.8.1"
69 | // implementation "com.github.piasy:GlideImageLoader:1.8.1"
70 | // implementation "com.github.piasy:GlideImageViewFactory:1.8.1"
71 |
72 | implementation "dev.rikka.rikkax.appcompat:appcompat:1.6.1"
73 | implementation "dev.rikka.rikkax.material:material-preference:2.0.0"
74 |
75 | implementation "io.github.panpf.zoomimage:zoomimage-view-glide:1.1.1"
76 |
77 | implementation "commons-io:commons-io:2.16.1"
78 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
11 |
14 |
15 |
16 |
30 |
36 |
42 |
43 |
44 |
45 |
46 |
47 |
55 |
62 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
95 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/activity/common/ImageLongClickDialog.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.activity.common
2 |
3 | import android.app.Activity
4 | import android.content.DialogInterface
5 | import com.google.android.material.dialog.MaterialAlertDialogBuilder
6 | import com.sjk.deleterecentpictures.R
7 | import com.sjk.deleterecentpictures.common.App
8 | import com.sjk.deleterecentpictures.common.logD
9 |
10 | class ImageLongClickDialog(activityContext: Activity, filePath: String?) {
11 |
12 | private val activityContext: Activity
13 | private val filePath: String?
14 |
15 | companion object {
16 | const val TAG: String = "ImageLongClickDialog"
17 |
18 | fun build(
19 | activityContext: Activity? = App.activityManager.currentActivity,
20 | filePath: String?
21 | ): ImageLongClickDialog? {
22 | if (activityContext == null) {
23 | return null
24 | }
25 | return ImageLongClickDialog(activityContext, filePath)
26 | }
27 | }
28 |
29 | init {
30 | this.activityContext = activityContext
31 | this.filePath = filePath
32 | }
33 |
34 | fun show() {
35 | val itemStrings: Array =
36 | App.const.IMAGE_LONG_CLICK_DIALOG_ITEMS.map { App.resources.getString(it) }
37 | .toTypedArray()
38 | val alertDialog = MaterialAlertDialogBuilder(this.activityContext)
39 | .setTitle(App.resources.getString(R.string.choose_your_action))
40 | .setItems(itemStrings) { dialogInterface: DialogInterface, i: Int ->
41 | this.onImageLongClickDialogItemClick(dialogInterface, i, this.filePath)
42 | }
43 | .setNegativeButton(App.resources.getString(R.string.cancel)) { dialog: DialogInterface, _: Int -> dialog.cancel() }
44 | .create()
45 | alertDialog.window?.setBackgroundDrawableResource(R.drawable.dialog_background)
46 | alertDialog.show()
47 | }
48 |
49 | private fun onImageLongClickDialogItemClick(
50 | dialogInterface: DialogInterface,
51 | i: Int,
52 | filePath: String?
53 | ) {
54 | logD(TAG, "点击item $i")
55 | when (i) {
56 | 0 -> {
57 | if (!App.output.openByOtherApp(filePath)) {
58 | App.output.showToast(App.resources.getString(R.string.failed_to_invoke_open_method))
59 | }
60 | }
61 |
62 | 1 -> {
63 | if (!App.output.shareToOtherApp(filePath)) {
64 | App.output.showToast(App.resources.getString(R.string.failed_to_invoke_sharing_method))
65 | }
66 | }
67 |
68 | 2 -> {
69 | val discern = Thread {
70 | val content: String? = App.qrCodeUtil.decodeQRCode(filePath)
71 |
72 | App.activityManager.currentActivity?.runOnUiThread {
73 | if (content == null) {
74 | App.output.showToast(App.resources.getString(R.string.barcode_or_qrcode_not_found))
75 | return@runOnUiThread
76 | }
77 | val alertDialog = MaterialAlertDialogBuilder(this.activityContext)
78 | .setTitle(App.resources.getString(R.string.recognized_content))
79 | .setMessage("$content")
80 | .setNegativeButton(App.resources.getString(R.string.cancel)) { dialogInterface: DialogInterface, i: Int ->
81 | dialogInterface.cancel()
82 | }
83 | .setNeutralButton(App.resources.getString(R.string.copy)) { dialogInterface: DialogInterface, i: Int ->
84 | App.clipboardUtil.setText(content)
85 | App.output.showToast(App.resources.getString(R.string.copied))
86 | }
87 | .setPositiveButton(App.resources.getString(R.string.open_with_browser)) { dialogInterface: DialogInterface, i: Int ->
88 | if (!App.output.openLinkWithBrowser(content)) {
89 | App.output.showToast(App.resources.getString(R.string.open_failed))
90 | }
91 | }
92 | .create()
93 |
94 | alertDialog.window?.setBackgroundDrawableResource(R.drawable.dialog_background)
95 | alertDialog.show()
96 | App.alertDialogUtil.enableMessageSelection(alertDialog)
97 | }
98 | }
99 | discern.start()
100 | }
101 |
102 | else -> {
103 |
104 | }
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/activity/image/ImageActivity.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.activity.image
2 |
3 | import android.os.Build
4 | import android.os.Bundle
5 | import android.view.View
6 | import android.view.WindowManager.LayoutParams
7 | import androidx.activity.OnBackPressedCallback
8 | import androidx.viewpager2.widget.ViewPager2
9 | import com.sjk.deleterecentpictures.R
10 | import com.sjk.deleterecentpictures.common.BaseActivity
11 |
12 | class ImageActivity : BaseActivity() {
13 | private val viewPagerAdapter = ImageActivityViewPagerAdapter()
14 | private lateinit var viewPager: ViewPager2
15 |
16 | companion object {
17 | private const val TAG = "ImageActivity"
18 | }
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 |
23 | this.setFullScreen()
24 | this.setContentView(R.layout.activity_image)
25 |
26 | this.init()
27 |
28 | this.onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
29 | override fun handleOnBackPressed() {
30 | if (this@ImageActivity.viewPagerAdapter.isCurrentScaleOne()) {
31 | this@ImageActivity.supportFinishAfterTransition()
32 | return
33 | }
34 | this@ImageActivity.viewPagerAdapter.resetImageScaleWithAnimation()
35 | }
36 | })
37 | }
38 |
39 | private fun init() {
40 | // val imagePath: String? = this.getGlobalData("currentImagePath", null) as String?
41 | this.viewPagerAdapter.imageInfos = this.getDataSource().getRecentImageInfos()
42 | this.viewPager = this.findViewById(R.id.viewPager)
43 | this.viewPager.adapter = viewPagerAdapter
44 | this.viewPager.setCurrentItem(this.getDataSource().getCurrentImageInfoIndex(), false)
45 | this.viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
46 | override fun onPageSelected(position: Int) {
47 | super.onPageSelected(position)
48 | this@ImageActivity.getInput().setCurrentImagePathIndex(position)
49 |
50 | if (this@ImageActivity.getDataSource().getRecentImageInfos().size == 0) {
51 | this@ImageActivity.getInput().setCurrentImagePathIndex(0)
52 | return
53 | }
54 | }
55 | })
56 | }
57 |
58 | private fun setFullScreen() {
59 | this.window.clearFlags(
60 | LayoutParams.FLAG_TRANSLUCENT_STATUS or
61 | LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
62 | ) // 允许页面可以拉伸到顶部状态栏并且定义顶部状态栏透名
63 | this.window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
64 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or // 设置全屏显示
65 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
66 | this.window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
67 | // window.setStatusBarColor(Color.TRANSPARENT); //设置状态栏为透明
68 | // window.navigationBarColor = Color.parseColor("#44000000") //设置虚拟键为透明
69 |
70 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // 强制在屏幕安全区域显示内容(刘海屏等等)
71 | val lp = this.window.attributes
72 | lp.layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
73 | this.window.attributes = lp
74 | }
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/activity/image/ImageActivityViewPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.activity.image
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.RecyclerView
7 | import com.github.panpf.zoomimage.ZoomImageView
8 | import com.github.panpf.zoomimage.util.IntOffsetCompat
9 | import com.sjk.deleterecentpictures.R
10 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
11 | import com.sjk.deleterecentpictures.common.App
12 | import kotlinx.coroutines.DelicateCoroutinesApi
13 | import kotlinx.coroutines.GlobalScope
14 | import kotlinx.coroutines.launch
15 |
16 |
17 | class ImageActivityViewPagerAdapter :
18 | RecyclerView.Adapter() {
19 | private val viewPagerViewHolders: MutableList = ArrayList()
20 | private val attachedViewHolders: MutableSet = mutableSetOf()
21 | var imageInfos: List = ArrayList()
22 |
23 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder {
24 | val viewPagerViewHolder = ViewPagerViewHolder(
25 | LayoutInflater.from(parent.context)
26 | .inflate(R.layout.layout_view_pager_item, parent, false)
27 | )
28 | viewPagerViewHolders.add(viewPagerViewHolder)
29 | return viewPagerViewHolder
30 | }
31 |
32 | override fun onBindViewHolder(
33 | holder: ViewPagerViewHolder,
34 | position: Int,
35 | ) {
36 | holder.imageInfo = imageInfos[position]
37 | }
38 |
39 | override fun onViewDetachedFromWindow(holder: ViewPagerViewHolder) {
40 | super.onViewDetachedFromWindow(holder)
41 |
42 | this.attachedViewHolders.remove(holder)
43 | App.imageLoadManger.clearImageView(App.applicationContext, holder.imageView)
44 | }
45 |
46 | override fun onViewAttachedToWindow(holder: ViewPagerViewHolder) {
47 | super.onViewAttachedToWindow(holder)
48 |
49 | this.attachedViewHolders.add(holder)
50 | if (holder.imageInfo?.uri == null) {
51 | return
52 | }
53 | App.imageLoadManger.loadImageToImageView(
54 | App.applicationContext,
55 | holder.imageInfo!!,
56 | holder.imageView,
57 | )
58 | // holder.imageView.setImageURI(holder.imageInfo?.uri)
59 | }
60 |
61 | override fun getItemCount(): Int {
62 | return this.imageInfos.size
63 | }
64 |
65 | fun isCurrentScaleOne(): Boolean {
66 | for (it in this@ImageActivityViewPagerAdapter.attachedViewHolders) {
67 | // 判断x就行了,暂时没有xy缩放不一致的情况
68 | if (it.imageView.zoomable.transformState.value.scaleX != 1f) {
69 | return false
70 | }
71 | }
72 | return true
73 | }
74 |
75 | @OptIn(DelicateCoroutinesApi::class)
76 | fun resetImageScaleWithAnimation() {
77 | GlobalScope.launch {
78 | this@ImageActivityViewPagerAdapter.attachedViewHolders.forEach {
79 | it.imageView.zoomable.scale(
80 | 1f,
81 | IntOffsetCompat.Zero,
82 | true,
83 | // ZoomAnimationSpec(400),
84 | )
85 | }
86 | }
87 | }
88 |
89 | }
90 |
91 | class ViewPagerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
92 | val imageView: ZoomImageView = itemView.findViewById(R.id.imageView)
93 | val preventClickLeftView: View = itemView.findViewById(R.id.preventClickLeftView)
94 | val preventClickRightView: View = itemView.findViewById(R.id.preventClickRightView)
95 | var imageInfo: ImageInfoBean? = null
96 |
97 | init {
98 | this.imageView.scrollBar = null
99 | this.imageView.setOnLongClickListener {
100 | App.output.showImageLongClickDialog(this.imageInfo!!.path)
101 |
102 | return@setOnLongClickListener true
103 | }
104 | this.imageView.setOnClickListener {
105 | (this.itemView.context as ImageActivity).onBackPressedDispatcher.onBackPressed()
106 | }
107 | // this.preventClickLeftView.setOnClickListener {
108 | //
109 | // }
110 | this.preventClickLeftView.setOnLongClickListener {
111 | return@setOnLongClickListener true
112 | }
113 | // this.preventClickRightView.setOnClickListener {
114 | //
115 | // }
116 | this.preventClickRightView.setOnLongClickListener {
117 | return@setOnLongClickListener true
118 | }
119 | //
120 | // val gestureDetector =
121 | // GestureDetector(itemView.context, object : GestureDetector.SimpleOnGestureListener() {
122 | //// override fun onFling(
123 | //// e1: MotionEvent?,
124 | //// e2: MotionEvent,
125 | //// velocityX: Float,
126 | //// velocityY: Float
127 | //// ): Boolean {
128 | //// App.output.showToast("onFling$velocityY")
129 | //// imageView.post {
130 | //// if (velocityX > 0) {
131 | //// (itemView.context as ImageActivity).onBackPressedDispatcher.onBackPressed()
132 | //// }
133 | //// }
134 | //// return super.onFling(e1, e2, velocityX, velocityY)
135 | //// }
136 | //
137 | // override fun onScroll(
138 | // e1: MotionEvent?,
139 | // e2: MotionEvent,
140 | // distanceX: Float,
141 | // distanceY: Float
142 | // ): Boolean {
143 | // if (imageView.zoomable.transformState.value.scaleX != 1f) {
144 | // return super.onScroll(e1, e2, distanceX, distanceY)
145 | // }
146 | // // 判断是不是双指
147 | // if (e1!!.pointerCount >= 2) {
148 | // return super.onScroll(e1, e2, distanceX, distanceY)
149 | // }
150 | // App.output.showToast("滑动$distanceY")
151 | // imageView.post {
152 | // if (distanceY > 0) {
153 | // (itemView.context as ImageActivity).onBackPressedDispatcher.onBackPressed()
154 | // }
155 | // }
156 | // return true
157 | // }
158 | // })
159 | //
160 | // this.imageView.setOnTouchListener { _, event ->
161 | // gestureDetector.onTouchEvent(event)
162 | // false
163 | // }
164 | }
165 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/activity/main/MainActivityViewPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.activity.main
2 |
3 | import android.content.Intent
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.Button
8 | import android.widget.CompoundButton
9 | import androidx.core.app.ActivityOptionsCompat
10 | import androidx.recyclerview.widget.RecyclerView
11 | import com.github.panpf.zoomimage.ZoomImageView
12 | import com.google.android.material.checkbox.MaterialCheckBox
13 | import com.sjk.deleterecentpictures.R
14 | import com.sjk.deleterecentpictures.activity.image.ImageActivity
15 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
16 | import com.sjk.deleterecentpictures.common.App
17 | import com.sjk.deleterecentpictures.common.Event
18 |
19 | class MainActivityViewPagerAdapter(val mainActivity: MainActivity) :
20 | RecyclerView.Adapter() {
21 |
22 | companion object {
23 | private const val TAG = "MainActivityViewPagerAdapter"
24 | lateinit var instance: MainActivityViewPagerAdapter
25 | }
26 |
27 | private var viewPagerViewHolders: MutableList = ArrayList()
28 | var imageInfos: MutableList = ArrayList()
29 | var imageChecks: MutableList = ArrayList()
30 | val event: Event = App.newEvent
31 |
32 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewPagerViewHolder {
33 | instance = this
34 | val view = LayoutInflater.from(parent.context)
35 | .inflate(R.layout.layout_main_view_pager_item, parent, false)
36 | val viewPagerViewHolder = ViewPagerViewHolder(this.mainActivity, view)
37 | viewPagerViewHolders.add(viewPagerViewHolder)
38 | return viewPagerViewHolder
39 | }
40 |
41 | override fun onBindViewHolder(holder: ViewPagerViewHolder, position: Int) {
42 | if (this.imageChecks.size > 0) {
43 | holder.isChecked = if (position < this.imageInfos.size) this.imageChecks[position] else false
44 | }
45 | holder.imageInfo = if (position < this.imageInfos.size) {
46 | this.imageInfos[position]
47 | } else {
48 | null
49 | }
50 | }
51 |
52 | override fun onViewDetachedFromWindow(holder: ViewPagerViewHolder) {
53 | super.onViewDetachedFromWindow(holder)
54 |
55 | App.imageLoadManger.clearImageView(App.applicationContext, holder.imageView)
56 | }
57 |
58 | override fun onViewAttachedToWindow(holder: ViewPagerViewHolder) {
59 | super.onViewAttachedToWindow(holder)
60 |
61 | if (holder.imageInfo?.uri == null) {
62 | holder.checkBox.visibility = View.GONE
63 | holder.imageView.visibility = View.GONE
64 | holder.emptyView.visibility = View.VISIBLE
65 | return
66 | }
67 | holder.checkBox.visibility = View.VISIBLE
68 | holder.checkBox.isChecked = holder.isChecked
69 | holder.imageView.visibility = View.VISIBLE
70 | holder.emptyView.visibility = View.GONE
71 | App.imageLoadManger.loadImageToImageView(
72 | App.applicationContext,
73 | holder.imageInfo!!,
74 | holder.imageView,
75 | false,
76 | )
77 | }
78 |
79 | override fun getItemCount(): Int {
80 | return this.imageInfos.size + 1
81 | }
82 |
83 | fun setHolderChecked(position: Int, isChecked: Boolean) {
84 | this.viewPagerViewHolders[position].run {
85 | this.checkBox.isChecked = isChecked
86 | this.isChecked = isChecked
87 | }
88 | }
89 |
90 | fun setAllHolderChecked(isChecked: Boolean) {
91 | this.viewPagerViewHolders.forEachIndexed { index: Int, viewPagerViewHolder: ViewPagerViewHolder ->
92 | this.setHolderChecked(index, isChecked)
93 | }
94 | }
95 |
96 | }
97 |
98 | class ViewPagerViewHolder(val mainActivity: MainActivity, itemView: View) : RecyclerView.ViewHolder(itemView) {
99 | val checkBox: MaterialCheckBox = itemView.findViewById(R.id.checkbox)
100 | val imageView: ZoomImageView = itemView.findViewById(R.id.imageView)
101 | val emptyView: View = itemView.findViewById(R.id.emptyView)
102 | val detailsButton: Button = itemView.findViewById(R.id.imageDetailsButton)
103 | private val openImageActivityButton =
104 | itemView.findViewById(R.id.openImageActivityButton)
105 | var imageInfo: ImageInfoBean? = null
106 | var isChecked: Boolean = false
107 |
108 | init {
109 | this.imageView.scrollBar = null
110 | this.openImageActivityButton.setOnClickListener {
111 | if (this.imageInfo?.uri == null) {
112 | return@setOnClickListener
113 | }
114 | val options = ActivityOptionsCompat.makeSceneTransitionAnimation(
115 | this.mainActivity,
116 | this.mainActivity.findViewById(R.id.imageAnimationView),
117 | "image"
118 | )
119 | val intent = Intent(itemView.context, ImageActivity::class.java)
120 | itemView.context.startActivity(intent, options.toBundle())
121 | }
122 | this.openImageActivityButton.setOnLongClickListener {
123 | if (this.imageInfo?.uri == null) {
124 | return@setOnLongClickListener true
125 | }
126 |
127 | App.output.showImageLongClickDialog(this.imageInfo!!.path)
128 |
129 | return@setOnLongClickListener true
130 | }
131 | this.checkBox.setOnCheckedChangeListener { buttonView: CompoundButton, isChecked: Boolean ->
132 | if (this.imageInfo?.uri == null) {
133 | return@setOnCheckedChangeListener
134 | }
135 |
136 | if (App.dataSource.getCurrentImageInfo() != this.imageInfo) {
137 | return@setOnCheckedChangeListener
138 | }
139 | this.isChecked = isChecked
140 | MainActivityViewPagerAdapter.instance.imageChecks[App.dataSource.getCurrentImageInfoIndex()] =
141 | isChecked
142 | }
143 | this.checkBox.setOnLongClickListener {
144 | if (this.imageInfo?.uri == null) {
145 | return@setOnLongClickListener true
146 | }
147 |
148 | MainActivityViewPagerAdapter.instance.setAllHolderChecked(false)
149 | App.input.setAllImageChecksFalse()
150 | App.output.showToast(App.applicationContext.getString(R.string.all_selected_images_deselected))
151 | true
152 | }
153 | this.detailsButton.setOnClickListener {
154 | if (this.imageInfo?.uri == null) {
155 | return@setOnClickListener
156 | }
157 | App.output.showImageDetailsDialog(this.imageInfo)
158 | }
159 | }
160 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/activity/main/ScrollButtonManager.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.activity.main
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.MotionEvent
5 | import android.widget.Button
6 | import com.sjk.deleterecentpictures.R
7 | import com.sjk.deleterecentpictures.common.Const
8 | import com.sjk.deleterecentpictures.common.logD
9 | import java.util.Timer
10 | import java.util.TimerTask
11 |
12 | object ScrollButtonManager {
13 | private const val TAG = "ScrollButtonManager"
14 |
15 | private lateinit var mainActivity: MainActivity
16 | // private var autoScrollStopped = true
17 | private var autoScrollTimer: Timer? = null
18 |
19 | fun init(activity: MainActivity) {
20 | this.mainActivity = activity
21 | this.initNextButtonEvent()
22 | this.initPreviousButtonEvent()
23 | }
24 |
25 | fun stopAutoScroll() {
26 | this.autoScrollTimer?.cancel()
27 | this.autoScrollTimer = null
28 | }
29 |
30 | /**
31 | * 开始往后自动滚动
32 | */
33 | fun startAutoScrollNext() {
34 | logD(TAG, "startAutoScrollNext")
35 | this.stopAutoScroll()
36 | this.autoScrollTimer = Timer()
37 | this.autoScrollTimer!!.schedule(object : TimerTask() {
38 | override fun run() {
39 | this@ScrollButtonManager.mainActivity.runOnUiThread {
40 | this@ScrollButtonManager.mainActivity.jumpToNextImage()
41 | }
42 | }
43 | }, Const.AUTO_SCROLL_DELAY, Const.AUTO_SCROLL_INTERVAL)
44 | }
45 |
46 | /**
47 | * 开始往前自动滚动
48 | */
49 | fun startAutoScrollPrevious() {
50 | logD(TAG, "startAutoScrollPrevious")
51 | this.stopAutoScroll()
52 | this.autoScrollTimer = Timer()
53 | this.autoScrollTimer!!.schedule(object : TimerTask() {
54 | override fun run() {
55 | this@ScrollButtonManager.mainActivity.runOnUiThread {
56 | this@ScrollButtonManager.mainActivity.jumpToPreviousImage()
57 | }
58 | }
59 | }, Const.AUTO_SCROLL_DELAY, Const.AUTO_SCROLL_INTERVAL)
60 | }
61 |
62 | @SuppressLint("ClickableViewAccessibility")
63 | private fun initNextButtonEvent() {
64 | var startTime = 0L
65 |
66 | val nextButton = this.mainActivity.findViewById(R.id.nextButton)
67 | // nextButton.setOnClickListener {
68 | // this@ScrollButtonManager.mainActivity.jumpToNextImage()
69 | // }
70 | nextButton.setOnTouchListener { view, motionEvent ->
71 | when (motionEvent.action and MotionEvent.ACTION_MASK) {
72 | MotionEvent.ACTION_DOWN -> {
73 | startTime = System.currentTimeMillis()
74 | this.startAutoScrollNext()
75 | }
76 |
77 | MotionEvent.ACTION_CANCEL,
78 | MotionEvent.ACTION_UP,
79 | -> {
80 | this.stopAutoScroll()
81 | if (System.currentTimeMillis() - startTime < Const.AUTO_SCROLL_DELAY) {
82 | this.mainActivity.jumpToNextImage()
83 | }
84 | startTime = System.currentTimeMillis()
85 | }
86 |
87 | else -> {
88 | }
89 | }
90 | false
91 | }
92 | }
93 |
94 | @SuppressLint("ClickableViewAccessibility")
95 | private fun initPreviousButtonEvent() {
96 | var startTime = 0L
97 |
98 | val previousButton = this.mainActivity.findViewById(R.id.previousButton)
99 | // previousButton.setOnClickListener {
100 | // this.mainActivity.jumpToPreviousImage()
101 | // }
102 | previousButton.setOnTouchListener { view, motionEvent ->
103 | when (motionEvent.action and MotionEvent.ACTION_MASK) {
104 | MotionEvent.ACTION_DOWN -> {
105 | startTime = System.currentTimeMillis()
106 | this.startAutoScrollPrevious()
107 | }
108 |
109 | MotionEvent.ACTION_CANCEL,
110 | MotionEvent.ACTION_UP,
111 | -> {
112 | this.stopAutoScroll()
113 | if (System.currentTimeMillis() - startTime < Const.AUTO_SCROLL_DELAY) {
114 | this.mainActivity.jumpToPreviousImage()
115 | }
116 | startTime = System.currentTimeMillis()
117 | }
118 |
119 | else -> {
120 | }
121 | }
122 | false
123 | }
124 | }
125 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/bean/DeletedImageInfoBean.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.bean
2 |
3 | import java.io.File
4 |
5 | data class DeletedImageInfoBean(
6 | val oldFile: File,
7 | val newFile: File,
8 | val info: ImageInfoBean?,
9 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/bean/ImageDetailBean.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.bean
2 |
3 | data class ImageDetailBean(
4 | val data: String,
5 | val dateAdded: Long,
6 | val dateModified: Long,
7 | val displayName: String,
8 | val mimeType: String,
9 | val size: Long,
10 | val width: Int,
11 | val height: Int,
12 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/bean/ImageInfoBean.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.bean
2 |
3 | import android.net.Uri
4 | import java.io.Serializable
5 |
6 | data class ImageInfoBean(
7 | val path: String? = null,
8 | @Transient val uri: Uri? = null,
9 | val id: Long? = null,
10 | val dateAdded: Long? = null,
11 | val dateModified: Long? = null,
12 | val mimeType: String? = null,
13 | ): Serializable
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/ActivityManager.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.app.Activity
4 | import java.util.Stack
5 |
6 | object ActivityManager {
7 |
8 | // 活动栈
9 | private val activityStack: Stack = Stack()
10 |
11 | val currentActivity: Activity?
12 | get() {
13 | return this.activityStack.lastElement()
14 | }
15 |
16 | /**
17 | * 将活动压入栈中
18 | */
19 | fun push(activity: Activity) {
20 | this.activityStack.push(activity)
21 | }
22 |
23 | /**
24 | * 将活动从栈中弹出
25 | */
26 | fun pop() {
27 | this.activityStack.pop()
28 | }
29 |
30 | /**
31 | * 将活动从栈中移除
32 | */
33 | fun remove(activity: Activity) {
34 | this.activityStack.remove(activity)
35 | }
36 |
37 | /**
38 | * 结束指定的活动
39 | */
40 | fun finish(activity: Activity) {
41 | activity.finish()
42 | }
43 |
44 | /**
45 | * 结束所有活动
46 | */
47 | fun finishAll() {
48 | for (activity in this.activityStack) {
49 | activity?.finish()
50 | }
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/App.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import android.content.res.Resources
6 | import com.google.android.material.color.DynamicColors
7 | import com.sjk.deleterecentpictures.utils.*
8 |
9 |
10 | class App : Application() {
11 |
12 | companion object {
13 | lateinit var applicationContext: Context
14 | lateinit var resources: Resources
15 |
16 | val dataSource: DataSource
17 | get() {
18 | return DataSource
19 | }
20 | val output: Output
21 | get() {
22 | return Output
23 | }
24 | val input: Input
25 | get() {
26 | return Input
27 | }
28 | val const: Const
29 | get() {
30 | return Const
31 | }
32 | val switch: Switch
33 | get() {
34 | return Switch
35 | }
36 | val globalData: GlobalData
37 | get() {
38 | return GlobalData
39 | }
40 | val apkUtil: ApkUtil
41 | get() {
42 | return ApkUtil
43 | }
44 | val clipboardUtil: ClipboardUtil
45 | get() {
46 | return ClipboardUtil
47 | }
48 | val densityUtil: DensityUtil
49 | get() {
50 | return DensityUtil
51 | }
52 | val fileUtil: FileUtil
53 | get() {
54 | return FileUtil
55 | }
56 | val imageScannerUtil: ImageScannerUtil
57 | get() {
58 | return ImageScannerUtil
59 | }
60 | val qrCodeUtil: QRCodeUtil
61 | get() {
62 | return QRCodeUtil
63 | }
64 | val recentImages: RecentImages
65 | get() {
66 | return RecentImages
67 | }
68 | val shellUtil: ShellUtil
69 | get() {
70 | return ShellUtil
71 | }
72 | val activityManager: ActivityManager
73 | get() {
74 | return ActivityManager
75 | }
76 | val recycleBinManager: RecycleBinManager
77 | get() {
78 | return RecycleBinManager
79 | }
80 | val alertDialogUtil: AlertDialogUtil
81 | get() {
82 | return AlertDialogUtil
83 | }
84 | val timeUtil: TimeUtil
85 | get() {
86 | return TimeUtil
87 | }
88 | val imageLoadManger: ImageLoadManager
89 | get() {
90 | return ImageLoadManager
91 | }
92 | val newEvent: Event
93 | get() {
94 | return Event()
95 | }
96 | }
97 |
98 | override fun onCreate() {
99 | super.onCreate()
100 | App.applicationContext = this.applicationContext
101 | App.resources = this.resources
102 |
103 | DynamicColors.applyToActivitiesIfAvailable(this)
104 | recycleBinManager.clearRecycleBin()
105 | }
106 |
107 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 |
6 | open class BaseActivity : AppCompatActivity() {
7 |
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | App.activityManager.push(this)
11 | }
12 |
13 | override fun onResume() {
14 | super.onResume()
15 | }
16 |
17 | override fun onDestroy() {
18 | super.onDestroy()
19 | App.activityManager.remove(this)
20 | }
21 |
22 | protected fun getOutput(): Output {
23 | return App.output
24 | }
25 |
26 | protected fun getInput(): Input {
27 | return App.input
28 | }
29 |
30 | protected fun getDataSource(): DataSource {
31 | return App.dataSource
32 | }
33 |
34 | protected fun getGlobalData(key: String, default: Any?): Any? {
35 | return App.globalData.getData(key, default)
36 | }
37 |
38 | protected fun setGlobalData(key: String, value: Any?) {
39 | App.globalData.setData(key, value)
40 | }
41 |
42 | protected fun removeGlobalData(key: String) {
43 | App.globalData.removeData(key)
44 | }
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/Const.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import com.sjk.deleterecentpictures.R
4 |
5 | object Const {
6 | const val DEFAULT_NUMBER_OF_PICTURES = 10
7 | val IMAGE_LONG_CLICK_DIALOG_ITEMS: Array = arrayOf(
8 | R.string.open_method,
9 | R.string.share,
10 | R.string.barcode_or_qrcode_recognition
11 | )
12 | // 自动滚动的时间间隔
13 | const val AUTO_SCROLL_INTERVAL = 300L
14 | // 自动滚动的延迟时间
15 | const val AUTO_SCROLL_DELAY = 1000L
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/DataSource.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.content.Context
4 | import android.content.SharedPreferences
5 | import android.os.Environment
6 | import androidx.preference.PreferenceManager
7 | import com.sjk.deleterecentpictures.R
8 | import com.sjk.deleterecentpictures.bean.ImageDetailBean
9 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
10 |
11 | object DataSource {
12 |
13 | val context: Context
14 | get() {
15 | return App.applicationContext
16 | }
17 |
18 | fun getSP(): SharedPreferences {
19 | return PreferenceManager.getDefaultSharedPreferences(this.context)
20 | }
21 |
22 | fun getNumberOfPictures(): Int {
23 | val str = this.getSP().getString("numberOfPictures", App.const.DEFAULT_NUMBER_OF_PICTURES.toString())
24 | var numberOfPictures: Int = try {
25 | if (str == null || str == "") App.const.DEFAULT_NUMBER_OF_PICTURES else str.toInt()
26 | } catch (e: NumberFormatException) {
27 | App.const.DEFAULT_NUMBER_OF_PICTURES
28 | }
29 | if (numberOfPictures == 0) {
30 | numberOfPictures = Const.DEFAULT_NUMBER_OF_PICTURES
31 | }
32 | return numberOfPictures
33 | }
34 |
35 | fun getSelection(): MutableSet {
36 | val selectionList: MutableSet = mutableSetOf()
37 | this.context.let {
38 | val strings = it.resources.getStringArray(R.array.path_values)
39 | // Log.d(TAG, "read: " + sp.getString("path", strings[0]));
40 | when (this.getSP().getString("path", strings[0])) {
41 | strings[0] -> {
42 | }
43 | strings[1] -> {
44 | selectionList.add(App.imageScannerUtil.screenshotsPath)
45 | }
46 | strings[2] -> {
47 | val externalFilesDir = Environment.getExternalStorageDirectory()
48 | if (externalFilesDir == null) {
49 | App.output.showToast(this.context.getString(R.string.use_default_selection_because_error))
50 | } else {
51 | val paths = this.getSP().getString("customizePath", "")!!.split("|")
52 | for (path in paths) {
53 | if (path.isEmpty()) {
54 | continue
55 | }
56 | selectionList.add("${externalFilesDir.absolutePath}/$path")
57 | }
58 | }
59 | }
60 |
61 | else -> {}
62 | }
63 | }
64 | return selectionList
65 | }
66 |
67 | fun getSimplifiedPathInExternalStorage(imageInfo: ImageInfoBean?): String? {
68 | return App.fileUtil.getSimplifiedPathInExternalStorage(imageInfo?.path)
69 | }
70 |
71 | fun getFileNameByPath(imageInfo: ImageInfoBean?): String? {
72 | return App.fileUtil.getFileNameByPath(imageInfo?.path)
73 | }
74 |
75 | fun getFileNameByPath(path: String?): String? {
76 | return App.fileUtil.getFileNameByPath(path)
77 | }
78 |
79 | /**
80 | * 获取最近图片的信息
81 | */
82 | fun getRecentImageInfos(): MutableList {
83 | return App.recentImages.imageInfos
84 | }
85 |
86 | fun getCurrentImageInfo(): ImageInfoBean? {
87 | return App.recentImages.currentImageInfo
88 | }
89 |
90 | fun getCurrentImageInfoIndex(): Int {
91 | return App.recentImages.currentImageInfoIndex
92 | }
93 |
94 | fun getImageChecks(): MutableList {
95 | return App.recentImages.imageChecks
96 | }
97 |
98 | fun getAllCheckedImageInfos(): MutableList {
99 | val checkedImagePaths: MutableList = ArrayList()
100 | for ((index, imageCheck) in this.getImageChecks().withIndex()) {
101 | if (!imageCheck) {
102 | continue
103 | }
104 | checkedImagePaths.add(this.getRecentImageInfos()[index])
105 | }
106 | return checkedImagePaths
107 | }
108 |
109 | fun getNavigationBarHeight(): Int {
110 | val resourceId: Int = this.context.resources.getIdentifier("navigation_bar_height", "dimen", "android")
111 | return this.context.resources.getDimensionPixelSize(resourceId)
112 | }
113 |
114 | fun getSortOrder(): String {
115 | var sorterOrderType: String = App.imageScannerUtil.DATE_MODIFIED
116 |
117 | this.context.let {
118 | val strings = it.resources.getStringArray(R.array.sort_order)
119 | when (this.getSP().getString("sortOrder", strings[0])) {
120 | strings[0] -> {
121 | sorterOrderType = App.imageScannerUtil.DATE_MODIFIED
122 | }
123 | strings[1] -> {
124 | sorterOrderType = App.imageScannerUtil.DATE_ADDED
125 | }
126 | }
127 | }
128 |
129 | return sorterOrderType
130 | }
131 |
132 | /**
133 | * 获取当前屏幕的旋转方向
134 | */
135 | fun getCurrentScreenOrientation(): Int {
136 | return App.resources.configuration.orientation
137 | }
138 |
139 | /**
140 | * 获取图片的详细信息
141 | */
142 | fun getImageDetails(imageInfoBean: ImageInfoBean?): ImageDetailBean? {
143 | if (imageInfoBean?.id == null) {
144 | return null
145 | }
146 | return App.imageScannerUtil.getImageDetails(App.applicationContext, imageInfoBean.id)
147 | }
148 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/Event.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 |
4 | class Event {
5 | private val events: MutableMap) -> Unit> = mutableMapOf()
6 |
7 | fun addEventListener(event: String, callback: (args: Array) -> Unit) {
8 | this.events[event] = callback
9 | }
10 |
11 | fun removeEventListener(event: String) {
12 | this.events.remove(event)
13 | }
14 |
15 | fun fireEvent(event: String, vararg args: Any?) {
16 | this.events[event]?.invoke(args.toList().toTypedArray())
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/GlobalData.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | object GlobalData {
4 | private const val TAG: String = "GlobalData"
5 | private var data: MutableMap = mutableMapOf()
6 |
7 |
8 | fun setData(key: String, value: Any?) {
9 | this.data[key] = value
10 | }
11 |
12 | fun getData(key: String, default: Any?): Any? {
13 | if (this.data[key] == null) {
14 | return default
15 | }
16 | return this.data[key]
17 | }
18 |
19 | fun removeData(key: String) {
20 | this.data.remove(key)
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/ImageLoadManager.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.content.Context
4 | import com.bumptech.glide.Glide
5 | import com.github.panpf.zoomimage.ZoomImageView
6 | import com.github.panpf.zoomimage.subsampling.ImageSource
7 | import com.github.panpf.zoomimage.subsampling.fromContent
8 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
9 |
10 | object ImageLoadManager {
11 |
12 | /**
13 | * 加载图片到图片控件
14 | */
15 | fun loadImageToImageView(context: Context, imageInfo: ImageInfoBean, imageView: ZoomImageView?, useSubsampling: Boolean = true) {
16 | if (imageView == null || imageInfo.uri == null) {
17 | return
18 | }
19 |
20 | if (useSubsampling) {
21 | // 设置子采样图片源
22 | imageView.setSubsamplingImage(ImageSource.fromContent(context, imageInfo.uri))
23 | }
24 | // 利用 Glide 加载较模糊的缩略图
25 | Glide.with(context)
26 | .load(imageInfo.uri)
27 | .skipMemoryCache(true)
28 | .into(imageView)
29 | }
30 |
31 | /**
32 | * 清除图片控件的图片
33 | */
34 | fun clearImageView(context: Context, imageView: ZoomImageView?) {
35 | if (imageView == null) {
36 | return
37 | }
38 |
39 | Glide.with(context)
40 | .clear(imageView)
41 |
42 | // imageView.setSubsamplingImage()
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/Input.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import com.sjk.deleterecentpictures.R
4 |
5 | object Input {
6 | fun setCurrentImagePathIndex(index: Int) {
7 | App.recentImages.currentImageInfoIndex = index
8 | }
9 |
10 | fun setAllImageChecksFalse() {
11 | App.recentImages.imageChecks.run {
12 | for (index in this.indices) {
13 | this[index] = false
14 | }
15 | }
16 | }
17 |
18 | fun copyCurrentImagePath(): Boolean {
19 | if (App.dataSource.getCurrentImageInfo()?.path == null) {
20 | App.output.showToast(App.resources.getString(R.string.no_path))
21 | return false
22 | }
23 |
24 | App.clipboardUtil.setText(App.dataSource.getCurrentImageInfo()!!.path!!)
25 | App.output.showToast(App.resources.getString(R.string.copied))
26 | return true
27 | }
28 |
29 | fun copyCurrentImageName(): Boolean {
30 | if (App.dataSource.getCurrentImageInfo()?.path == null) {
31 | App.output.showToast(App.resources.getString(R.string.no_path))
32 | return false
33 | }
34 |
35 | App.clipboardUtil.setText(App.dataSource.getFileNameByPath(App.dataSource.getCurrentImageInfo())!!)
36 | App.output.showToast(App.resources.getString(R.string.copied))
37 | return true
38 | }
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/Logger.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.util.Log
4 | import java.text.SimpleDateFormat
5 | import java.util.*
6 |
7 | fun logV(tag: String, msg: String) {
8 | Logger.v(tag, msg)
9 | }
10 |
11 | fun logD(tag: String, msg: String) {
12 | Logger.d(tag, msg)
13 | }
14 |
15 | fun logI(tag: String, msg: String) {
16 | Logger.i(tag, msg)
17 | }
18 |
19 | fun logW(tag: String, msg: String) {
20 | Logger.w(tag, msg)
21 | }
22 |
23 | fun logE(tag: String, msg: String) {
24 | Logger.e(tag, msg)
25 | }
26 |
27 | fun log(vararg msgs: Any?) {
28 | Logger.log(*msgs)
29 | }
30 |
31 | private object Logger {
32 | var df: SimpleDateFormat = SimpleDateFormat("[yyyy-MM-dd HH:mm:ss.SSS]", Locale.getDefault())
33 |
34 | private fun getLogTime(): String {
35 | if (!App.switch.ENABLE_LOG_TIME) {
36 | return ""
37 | }
38 |
39 | return this.df.format(Date())
40 | }
41 |
42 |
43 | fun v(tag: String, msg: String) {
44 | if (!App.switch.ENABLE_LOG) {
45 | return
46 | }
47 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.VERBOSE] == false) {
48 | return
49 | }
50 | Log.v("v ${this.getLogTime()}$tag", msg)
51 | }
52 |
53 | fun d(tag: String, msg: String) {
54 | if (!App.switch.ENABLE_LOG) {
55 | return
56 | }
57 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.DEBUG] == false) {
58 | return
59 | }
60 | Log.d("d ${this.getLogTime()}$tag", msg)
61 | }
62 |
63 | fun i(tag: String, msg: String) {
64 | if (!App.switch.ENABLE_LOG) {
65 | return
66 | }
67 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.INFO] == false) {
68 | return
69 | }
70 | Log.i("i ${this.getLogTime()}$tag", msg)
71 | }
72 |
73 | fun w(tag: String, msg: String) {
74 | if (!App.switch.ENABLE_LOG) {
75 | return
76 | }
77 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.WARN] == false) {
78 | return
79 | }
80 | Log.w("w ${this.getLogTime()}$tag", msg)
81 | }
82 |
83 | fun e(tag: String, msg: String) {
84 | if (!App.switch.ENABLE_LOG) {
85 | return
86 | }
87 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.ERROR] == false) {
88 | return
89 | }
90 | Log.e("e ${this.getLogTime()}$tag", msg)
91 | }
92 |
93 | fun log(vararg msgs: Any?) {
94 | if (!App.switch.ENABLE_LOG) {
95 | return
96 | }
97 | if (App.switch.ENABLE_LOG_LEVELS[LoggerLevelEnum.LOG] == false) {
98 | return
99 | }
100 | val stringBuilder = StringBuilder()
101 | for ((index, msg) in msgs.withIndex()) {
102 | if (index != 0){
103 | stringBuilder.append(" ")
104 | }
105 | stringBuilder.append(msg.toString())
106 | }
107 | println("${this.getLogTime()}$stringBuilder")
108 | }
109 | }
110 |
111 | enum class LoggerLevelEnum(val index: Int) {
112 | VERBOSE(1),
113 | DEBUG(2),
114 | INFO(3),
115 | WARN(4),
116 | ERROR(5),
117 | LOG(6);
118 |
119 | companion object {
120 | fun getEnumByValue(what: Int): LoggerLevelEnum? {
121 | for (value in values()) {
122 | if (value.index == what) {
123 | return value
124 | }
125 | }
126 | return null
127 | }
128 | }
129 |
130 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/RecentImages.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
4 |
5 | object RecentImages {
6 | val imageInfos: MutableList = ArrayList()
7 | var currentImageInfoIndex: Int = 0
8 |
9 | val currentImageInfo: ImageInfoBean?
10 | get() {
11 | if (this.currentImageInfoIndex >= this.imageInfos.size || this.currentImageInfoIndex < 0) {
12 | return null
13 | }
14 |
15 | return this.imageInfos[this.currentImageInfoIndex]
16 | }
17 |
18 | val currentImagePath: String?
19 | get() {
20 | return this.currentImageInfo?.path
21 | }
22 |
23 | val imageChecks: MutableList = ArrayList()
24 |
25 | fun clearImagePaths() {
26 | this.imageInfos.clear()
27 | }
28 |
29 | fun resetCurrentImagePathIndex() {
30 | this.currentImageInfoIndex = 0
31 | }
32 |
33 | fun clearImageChecks() {
34 | this.imageChecks.clear()
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/RecycleBinManager.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | import android.content.ContentResolver
4 | import android.content.ContentValues
5 | import android.content.Context
6 | import android.media.MediaScannerConnection
7 | import android.net.Uri
8 | import android.provider.MediaStore
9 | import com.sjk.deleterecentpictures.bean.DeletedImageInfoBean
10 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
11 | import com.sjk.deleterecentpictures.R
12 | import java.io.File
13 |
14 | /**
15 | * 回收站管理器,用于删除图片后将图片移动到回收站,并且可以从回收站恢复图片
16 | */
17 | object RecycleBinManager {
18 |
19 | val recyclePath: String
20 | get() {
21 | return App.applicationContext.getExternalFilesDir("recycle")!!.absolutePath
22 | }
23 |
24 | var deletedImageInfo: DeletedImageInfoBean? = null
25 |
26 | /**
27 | * 在内部存储中创建回收站文件夹
28 | */
29 | fun createRecycleBinFolder(): Boolean {
30 | return App.fileUtil.createFolder(this.recyclePath)
31 | }
32 |
33 | fun createNoMediaFile(): Boolean {
34 | return App.fileUtil.createFile("${this.recyclePath}/.nomedia")
35 | }
36 |
37 | /**
38 | * 删除回收站内的旧图片
39 | */
40 | fun deleteOldImageInRecycleBin(): Boolean {
41 | if (this.deletedImageInfo == null) {
42 | return false
43 | }
44 | val deleted = App.fileUtil.deleteFile(this.deletedImageInfo!!.newFile)
45 | this.deletedImageInfo = null
46 | return deleted
47 | }
48 |
49 | /**
50 | * 清空回收站
51 | */
52 | fun clearRecycleBin(): Boolean {
53 | val folderPath = this.recyclePath
54 | val excludes = setOf(".nomedia")
55 | if (this.deletedImageInfo?.newFile?.name != null) {
56 | excludes.plus(this.deletedImageInfo!!.newFile.name)
57 | }
58 |
59 | val folder = File(folderPath)
60 | if (!folder.exists()) {
61 | return true
62 | }
63 |
64 | if (!folder.isDirectory) {
65 | return false
66 | }
67 |
68 | val files = folder.listFiles() ?: return true
69 |
70 | Thread {
71 | Thread.sleep(1000)
72 | for (file in files) {
73 | if (excludes.contains(file.name)) { // 不删除 .nomedia 文件和最新删除的图片,最新删除的图片单独处理是为了防止异步操作出问题
74 | continue
75 | }
76 | file.delete()
77 | }
78 | }.start()
79 | return true
80 | }
81 |
82 | /**
83 | * 将图片移动到回收站
84 | */
85 | fun moveToRecycleBin(imageInfo: ImageInfoBean?): Boolean {
86 | if (imageInfo?.path == null) {
87 | return false
88 | }
89 | val recycleBinFolderCreated = this.createRecycleBinFolder()
90 | if (!recycleBinFolderCreated) {
91 | App.output.showToast(App.applicationContext.getString(R.string.recycle_bin_created_failed))
92 | return false
93 | }
94 | val noMediaFileCreated = this.createNoMediaFile()
95 | if (!noMediaFileCreated) {
96 | App.output.showToast(App.applicationContext.getString(R.string.recycle_bin_created_failed))
97 | return false
98 | }
99 | // 移动图片,新名称为:原名称_时间戳
100 | val oldFile = File(imageInfo.path)
101 | val newFile = File("${this.recyclePath}/${System.currentTimeMillis()}_${oldFile.name}")
102 | if (!App.fileUtil.existsFile(oldFile)) {
103 | return false
104 | }
105 | if (!App.fileUtil.moveFile(oldFile, newFile)) {
106 | return false
107 | }
108 | this.deletedImageInfo = DeletedImageInfoBean(oldFile, newFile, imageInfo)
109 | return true
110 | }
111 |
112 | /**
113 | * 从回收站恢复图片
114 | */
115 | fun recover(
116 | onSuccess: ((path: String, uri: Uri) -> Unit)? = null,
117 | onFailed: (() -> Unit)? = null
118 | ) {
119 | if (this.deletedImageInfo == null) {
120 | onFailed?.invoke()
121 | return
122 | }
123 | val oldFile = this.deletedImageInfo!!.oldFile
124 | val newFile = this.deletedImageInfo!!.newFile
125 | if (!App.fileUtil.existsFile(newFile)) {
126 | onFailed?.invoke()
127 | return
128 | }
129 | if (!App.fileUtil.moveFile(newFile, oldFile)) {
130 | onFailed?.invoke()
131 | return
132 | }
133 |
134 | // 更新媒体库
135 | MediaScannerConnection.scanFile(
136 | App.applicationContext,
137 | arrayOf(oldFile.absolutePath),
138 | null
139 | ) { path, uri ->
140 | onSuccess?.invoke(path, uri)
141 | }
142 | // this.updateMediaScan(App.context, this.deletedImageInfo!!.info, onSuccess, onFailed)
143 | this.deletedImageInfo = null
144 | }
145 |
146 | fun updateMediaScan(
147 | context: Context,
148 | imageInfo: ImageInfoBean?,
149 | onSuccess: ((path: String, uri: Uri) -> Unit)? = null,
150 | onFailed: (() -> Unit)? = null
151 | ) {
152 | if (imageInfo?.uri == null || imageInfo.path == null) {
153 | onFailed?.invoke()
154 | return
155 | }
156 |
157 | val contentResolver: ContentResolver = context.contentResolver
158 | val contentValues = ContentValues().apply {
159 | put(MediaStore.Images.Media.DATE_MODIFIED, imageInfo.dateModified)
160 | put(MediaStore.Images.Media.DATE_ADDED, imageInfo.dateAdded)
161 | }
162 |
163 | val uri: Uri = MediaStore.Files.getContentUri("external")
164 | val selection = "${MediaStore.Files.FileColumns.DATA}=?"
165 | val selectionArgs = arrayOf(imageInfo.path)
166 |
167 | val updatedRows = contentResolver.update(uri, contentValues, selection, selectionArgs)
168 |
169 | if (updatedRows == 0) {
170 | contentValues.put(MediaStore.Files.FileColumns.DATA, imageInfo.path)
171 | contentResolver.insert(uri, contentValues)
172 | }
173 | onSuccess?.invoke(imageInfo.path, imageInfo.uri)
174 | }
175 |
176 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/common/Switch.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.common
2 |
3 | object Switch {
4 | const val ENABLE_LOG: Boolean = true
5 | val ENABLE_LOG_LEVELS: Map = mapOf(
6 | LoggerLevelEnum.VERBOSE to true,
7 | LoggerLevelEnum.DEBUG to true,
8 | LoggerLevelEnum.INFO to true,
9 | LoggerLevelEnum.WARN to true,
10 | LoggerLevelEnum.ERROR to true,
11 | LoggerLevelEnum.LOG to true
12 | )
13 | const val ENABLE_LOG_TIME = true
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/service/ImageWidgetService.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.service
2 |
3 | import android.app.Notification
4 | import android.app.NotificationChannel
5 | import android.app.NotificationManager
6 | import android.app.Service
7 | import android.appwidget.AppWidgetManager
8 | import android.content.BroadcastReceiver
9 | import android.content.Context
10 | import android.content.Intent
11 | import android.os.Build
12 | import android.os.IBinder
13 | import android.text.TextUtils
14 | import android.widget.RemoteViews
15 | import androidx.core.app.NotificationCompat
16 | import com.sjk.deleterecentpictures.R
17 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
18 | import com.sjk.deleterecentpictures.common.App
19 | import com.sjk.deleterecentpictures.common.logD
20 |
21 | class ImageWidgetService : Service() {
22 | companion object {
23 | private const val TAG = "ImageWidgetService"
24 | }
25 |
26 | private var receiver: BroadcastReceiver? = null
27 |
28 | override fun onCreate() {
29 | super.onCreate()
30 |
31 | logD(TAG, "onCreate")
32 |
33 | this.startForeground(1, this.createNotification())
34 |
35 | // this.receiver = object : BroadcastReceiver() {
36 | // override fun onReceive(context: Context?, intent: Intent?) {
37 | // if (context == null || intent == null) {
38 | // return
39 | // }
40 | // this@ImageWidgetService.deleteImage(context, intent.getLongExtra("imageId", -1L))
41 | // val appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)
42 | // val refreshIntent = Intent()
43 | // refreshIntent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
44 | // refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
45 | // context.sendBroadcast(refreshIntent)
46 | // }
47 | // }
48 | // val intentFilter = IntentFilter()
49 | // intentFilter.addAction("${this.applicationContext.packageName}.deleteImage")
50 | // this.registerReceiver(this.receiver, intentFilter)
51 | }
52 |
53 | override fun onDestroy() {
54 | super.onDestroy()
55 | // this.unregisterReceiver(this.receiver)
56 | }
57 |
58 | override fun onBind(p0: Intent?): IBinder? {
59 | return null
60 | }
61 |
62 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
63 | logD(TAG, "onStartCommand: $intent")
64 | if (intent == null) {
65 | return START_STICKY
66 | }
67 |
68 | val imageId = intent.getStringExtra("imageId")
69 | logD(TAG, "imageId: $imageId")
70 | // val imagePath = intent.getStringExtra("imagePath")
71 | // val imageIds = bundle?.getLongArray("imageIds")
72 | // val imageInfoBean = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
73 | // intent.getSerializableExtra("imageInfoBean", ImageInfoBean::class.java)
74 | // } else {
75 | // intent.getSerializableExtra("imageInfoBean") as ImageInfoBean
76 | // }
77 | this.deleteImage(this, imageId?.toLong() ?: -1)
78 | val appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)
79 | // val refreshIntent = Intent()
80 | // refreshIntent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
81 | // refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
82 | // 发送到对应的widget
83 | // val pendingIntent = PendingIntent.getBroadcast(this, 0, refreshIntent, PendingIntent.FLAG_MUTABLE)
84 | val views = RemoteViews(this.packageName, R.layout.image_widget)
85 | val appWidgetManager = AppWidgetManager.getInstance(this)
86 | appWidgetManager.updateAppWidget(appWidgetIds, views)
87 |
88 | // 结束自己
89 | this.stopSelf()
90 |
91 | return START_STICKY
92 | }
93 |
94 | /**
95 | * 删除图片,返回成功或者失败
96 | */
97 | private fun deleteImage(context: Context, imageId: Long?): Boolean {
98 | if (imageId == -1L) {
99 | return false
100 | }
101 | return App.fileUtil.deleteImage(imageId, context)
102 | }
103 |
104 | /**
105 | * 删除图片,返回成功或者失败
106 | */
107 | private fun deleteImage(context: Context, imagePath: String?): Boolean {
108 | if (TextUtils.isEmpty(imagePath)) {
109 | return false
110 | }
111 | return App.fileUtil.deleteImage(imagePath, context)
112 | }
113 |
114 | private fun deleteImages(context: Context, imageIds: LongArray?) {
115 | if (imageIds == null) {
116 | return
117 | }
118 | for (imageId in imageIds) {
119 | this.deleteImage(context, imageId)
120 | }
121 | }
122 |
123 | private fun createNotification(): Notification {
124 | val channelId = "ForegroundServiceChannel"
125 | val channelName = "Foreground Service Channel"
126 |
127 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
128 | val channel = NotificationChannel(
129 | channelId,
130 | channelName,
131 | NotificationManager.IMPORTANCE_DEFAULT
132 | )
133 | val notificationManager =
134 | getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
135 | notificationManager.createNotificationChannel(channel)
136 | }
137 |
138 | val notificationBuilder = NotificationCompat.Builder(this, channelId)
139 | .setContentTitle("Foreground Service")
140 | .setContentText("Service is running in the foreground")
141 | .setSmallIcon(R.drawable.ic_image)
142 | .setPriority(NotificationCompat.PRIORITY_DEFAULT)
143 | .setCategory(NotificationCompat.CATEGORY_SERVICE)
144 | .setOngoing(true)
145 |
146 | return notificationBuilder.build()
147 | }
148 |
149 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/service/QuickSettingOpenService.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.service
2 |
3 | import android.annotation.SuppressLint
4 | import android.app.PendingIntent
5 | import android.content.Intent
6 | import android.os.Build
7 | import android.service.quicksettings.TileService
8 | import androidx.annotation.RequiresApi
9 | import com.sjk.deleterecentpictures.activity.main.MainActivity
10 |
11 | @RequiresApi(api = Build.VERSION_CODES.N)
12 | class QuickSettingOpenService : TileService() {
13 | private var intent: Intent? = null
14 |
15 | // 当用户从Edit栏添加到快速设定中调用
16 | override fun onTileAdded() {}
17 |
18 | // 当用户从快速设定栏中移除的时候调用
19 | override fun onTileRemoved() {}
20 |
21 | // 点击的时候
22 |
23 | @SuppressLint("StartActivityAndCollapseDeprecated")
24 | override fun onClick() {
25 | this.intent = Intent(this, MainActivity::class.java)
26 | this.intent!!.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
28 | val pendingIntent =
29 | PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
30 | this.startActivityAndCollapse(pendingIntent)
31 | } else {
32 | @Suppress("DEPRECATION")
33 | this.startActivityAndCollapse(this.intent)
34 | }
35 | }
36 |
37 | // 打开下拉菜单的时候调用,当快速设置按钮并没有在编辑栏拖到设置栏中不会调用
38 | // 在TleAdded之后会调用一次
39 | override fun onStartListening() {}
40 |
41 | // 关闭下拉菜单的时候调用,当快速设置按钮并没有在编辑栏拖到设置栏中不会调用
42 | // 在onTileRemoved移除之前也会调用移除
43 | override fun onStopListening() {}
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/AlertDialogUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.widget.TextView
4 | import androidx.appcompat.app.AlertDialog
5 | import android.widget.AdapterView
6 | import android.view.View
7 | import androidx.annotation.IdRes
8 |
9 | object AlertDialogUtil {
10 |
11 | /**
12 | * 允许弹窗文本选择
13 | */
14 | fun enableMessageSelection(
15 | alertDialog: AlertDialog,
16 | @IdRes messageTextViewId: Int = android.R.id.message,
17 | ) {
18 | alertDialog.window?.findViewById(messageTextViewId)?.setTextIsSelectable(true)
19 | }
20 |
21 | /**
22 | * 禁止弹窗文本选择
23 | */
24 | fun disableMessageSelection(
25 | alertDialog: AlertDialog,
26 | @IdRes messageTextViewId: Int = android.R.id.message,
27 | ) {
28 | alertDialog.window?.findViewById(messageTextViewId)?.setTextIsSelectable(false)
29 | }
30 |
31 | /**
32 | * 禁止点击弹窗列表项时自动关闭弹窗,同时覆盖默认的点击事件
33 | */
34 | fun disableAutoDismissWhenItemClick(
35 | alertDialog: AlertDialog,
36 | onItemClickListener: ((adapterView: AdapterView<*>, view: View, i: Int, l: Long) -> Unit)?,
37 | ) {
38 | alertDialog.listView.setOnItemClickListener { adapterView, view, i, l ->
39 | onItemClickListener?.invoke(adapterView, view, i, l)
40 | }
41 | }
42 |
43 | /**
44 | * 禁止点击弹窗列表项时自动关闭弹窗,同时覆盖默认的点击事件
45 | */
46 | fun disableAutoDismissWhenItemClick(
47 | alertDialog: AlertDialog,
48 | ) {
49 | alertDialog.listView.setOnItemClickListener { adapterView, view, i, l ->
50 |
51 | }
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/ApkUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageManager
5 | import android.os.Build
6 | import android.text.TextUtils
7 |
8 | object ApkUtil {
9 | fun checkApkExist(context: Context?, apkPackageName: String?): Boolean {
10 | return if (TextUtils.isEmpty(apkPackageName)) {
11 | false
12 | } else try {
13 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
14 | context?.packageManager?.getApplicationInfo(apkPackageName!!, PackageManager.MATCH_UNINSTALLED_PACKAGES)
15 | } else {
16 | context?.packageManager?.getApplicationInfo(apkPackageName!!, PackageManager.GET_UNINSTALLED_PACKAGES)
17 | }
18 | true
19 | } catch (e: PackageManager.NameNotFoundException) {
20 | false
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/ClipboardUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.content.ClipData
4 | import android.content.ClipboardManager
5 | import android.content.Context
6 | import com.sjk.deleterecentpictures.R
7 | import com.sjk.deleterecentpictures.common.App
8 |
9 | object ClipboardUtil {
10 | fun setText(text: String) {
11 | val clipboard = App.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
12 | val clip = ClipData.newPlainText(App.applicationContext.resources.getString(R.string.app_name), text)
13 | clipboard.setPrimaryClip(clip)
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/DensityUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.content.Context
4 |
5 | object DensityUtil {
6 | /**
7 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
8 | */
9 | fun dip2px(context: Context, dpValue: Float): Int {
10 | val scale = context.resources.displayMetrics.density
11 | return (dpValue * scale + 0.5f).toInt()
12 | }
13 |
14 | /**
15 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
16 | */
17 | fun px2dip(context: Context, pxValue: Float): Int {
18 | val scale = context.resources.displayMetrics.density
19 | return (pxValue / scale + 0.5f).toInt()
20 | }
21 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/FileUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.content.Context
4 | import android.os.Environment
5 | import android.provider.MediaStore
6 | import android.webkit.MimeTypeMap
7 | import com.sjk.deleterecentpictures.bean.ImageInfoBean
8 | import com.sjk.deleterecentpictures.common.App
9 | import org.apache.commons.io.FileUtils
10 | import java.io.File
11 | import java.io.IOException
12 |
13 |
14 | object FileUtil {
15 |
16 | fun existsFile(filePath: String?): Boolean {
17 | if (filePath == null) {
18 | return false
19 | }
20 |
21 | return this.existsFile(File(filePath))
22 | }
23 |
24 | fun existsFile(file: File): Boolean {
25 | return file.isFile && file.exists()
26 | }
27 |
28 | /**
29 | * 删除图片
30 | */
31 | fun deleteImage(imageInfo: ImageInfoBean?): Boolean {
32 | return this.deleteImage(imageInfo?.id)
33 | }
34 |
35 | /**
36 | * 用id删除图片
37 | */
38 | fun deleteImage(imageId: Long?, context: Context = App.applicationContext): Boolean {
39 | if (imageId == null) {
40 | return false
41 | }
42 | return context.contentResolver.delete(
43 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
44 | "${MediaStore.Images.Media._ID} = ?",
45 | arrayOf(imageId.toString())
46 | ) > 0
47 | }
48 |
49 | /**
50 | * 用路径删除图片
51 | */
52 | fun deleteImage(imagePath: String?, context: Context = App.applicationContext): Boolean {
53 | if (imagePath == null) {
54 | return false
55 | }
56 | return context.contentResolver.delete(
57 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
58 | "${MediaStore.Images.Media.DATA} = ?",
59 | arrayOf(imagePath)
60 | ) > 0
61 | }
62 |
63 | /**
64 | * 删除文件,不允许删除文件夹
65 | */
66 | fun deleteFile(file: File?): Boolean {
67 | if (file == null) {
68 | return false
69 | }
70 |
71 | if (!file.exists()) {
72 | return true
73 | }
74 |
75 | if (!file.isFile) {
76 | return false
77 | }
78 |
79 | return file.delete()
80 | }
81 |
82 | fun getSimplifiedPathInExternalStorage(completePath: String?): String? {
83 | if (completePath == null) {
84 | return null
85 | }
86 |
87 | val externalStorageDirectory: String =
88 | Environment.getExternalStorageDirectory().absolutePath
89 | if (completePath.indexOf(externalStorageDirectory) == 0) {
90 | return completePath.replaceFirst(externalStorageDirectory, "")
91 | }
92 | return completePath
93 | }
94 |
95 | fun getFileNameByPath(completePath: String?): String? {
96 | if (completePath == null) {
97 | return null
98 | }
99 |
100 | return File(completePath).name
101 | }
102 |
103 | fun getMimeType(url: String?): String? {
104 | var type: String? = null
105 | val extension = MimeTypeMap.getFileExtensionFromUrl(url)
106 | if (extension != null) {
107 | type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
108 | }
109 | return type
110 | }
111 |
112 | fun clearFolder(folderPath: String?, excludes: Set? = null): Boolean {
113 |
114 | if (folderPath == null) {
115 | return false
116 | }
117 |
118 | val folder = File(folderPath)
119 | if (!folder.exists()) {
120 | return true
121 | }
122 |
123 | if (!folder.isDirectory) {
124 | return false
125 | }
126 |
127 | val files = folder.listFiles() ?: return true
128 |
129 | for (file in files) {
130 | if (excludes != null && excludes.contains(file.name)) {
131 | continue
132 | }
133 | if (file.isDirectory) {
134 | this.clearFolder(file.absolutePath)
135 | } else {
136 | file.delete()
137 | }
138 | }
139 | return true
140 | }
141 |
142 | /**
143 | * 创建文件夹
144 | */
145 | fun createFolder(folderPath: String?): Boolean {
146 | if (folderPath == null) {
147 | return false
148 | }
149 |
150 | val folder = File(folderPath)
151 | if (folder.exists() && !folder.isDirectory) {
152 | folder.delete()
153 | }
154 | return if (folder.exists()) {
155 | true
156 | } else {
157 | folder.mkdirs()
158 | }
159 | }
160 |
161 | /**
162 | * 创建文件
163 | */
164 | fun createFile(filePath: String?): Boolean {
165 | if (filePath == null) {
166 | return false
167 | }
168 |
169 | val file = File(filePath)
170 | if (file.exists() && file.isDirectory) {
171 | file.delete()
172 | }
173 | return if (file.exists()) {
174 | true
175 | } else {
176 | try {
177 | file.createNewFile()
178 | } catch (e: Exception) {
179 | false
180 | }
181 | }
182 | }
183 |
184 | fun clearCacheFolder(): Boolean {
185 | return this.clearFolder(App.applicationContext.cacheDir.absolutePath)
186 | }
187 |
188 | /**
189 | * 移动文件
190 | */
191 | fun moveFile(srcFile: File, destFile: File): Boolean {
192 | return try {
193 | FileUtils.moveFile(srcFile, destFile)
194 | true
195 | } catch (e: IOException) {
196 | false
197 | }
198 | }
199 |
200 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/PermissionUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import android.Manifest
4 | import android.app.Activity
5 | import android.content.Intent
6 | import android.content.pm.PackageManager
7 | import android.net.Uri
8 | import android.os.Build
9 | import android.os.Environment
10 | import android.provider.Settings
11 | import androidx.annotation.RequiresApi
12 | import androidx.core.app.ActivityCompat
13 | import com.sjk.deleterecentpictures.BuildConfig
14 |
15 | object PermissionUtil {
16 | private val PERMISSIONS_STORAGE_V29 = arrayOf(
17 | Manifest.permission.READ_EXTERNAL_STORAGE,
18 | Manifest.permission.WRITE_EXTERNAL_STORAGE
19 | )
20 |
21 | /**
22 | * 检查是否完整授予存储权限
23 | */
24 | fun Activity.checkPermissionGranted(): Boolean {
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
26 | return Environment.isExternalStorageManager()
27 | } else {
28 | PERMISSIONS_STORAGE_V29.forEach {
29 | if (checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED) {
30 | return false
31 | }
32 | }
33 | return true
34 | }
35 | }
36 |
37 | /**
38 | * 依据不同安卓版本申请对应存储权限
39 | */
40 | fun Activity.requestPermission() {
41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
42 | requestPermissionV30()
43 | } else {
44 | requestPermissionV29()
45 | }
46 | }
47 |
48 | /**
49 | * API30+ 所有文件权限申请
50 | */
51 | @RequiresApi(Build.VERSION_CODES.R)
52 | fun Activity.requestPermissionV30() {
53 | val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
54 | intent.data = Uri.parse("package:${BuildConfig.APPLICATION_ID}")
55 | startActivity(intent)
56 | }
57 |
58 | /**
59 | * API29- 读写存储权限申请
60 | */
61 | fun Activity.requestPermissionV29() {
62 | ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE_V29, 0)
63 | }
64 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/QRCodeUtil.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * Description: 二维码工具类,使用了zxing库
3 | */
4 |
5 | package com.sjk.deleterecentpictures.utils
6 |
7 | import android.graphics.Bitmap
8 | import android.graphics.BitmapFactory
9 | import com.google.zxing.*
10 | import com.google.zxing.common.GlobalHistogramBinarizer
11 | import com.google.zxing.common.HybridBinarizer
12 | import java.io.FileInputStream
13 | import java.util.*
14 |
15 |
16 | object QRCodeUtil {
17 | private val hints: Map = EnumMap(DecodeHintType::class.java)
18 |
19 | /**
20 | * 二维码解码
21 | */
22 | fun decodeQRCode(filePath: String?): String? {
23 | return this.decodeQRCode(this.getDecodeAbleBitmap(filePath))
24 | }
25 |
26 | /**
27 | * 二维码解码
28 | */
29 | fun decodeQRCode(bitmap: Bitmap?): String? {
30 | if (bitmap == null) {
31 | return null
32 | }
33 |
34 | val width = bitmap.width
35 | val height = bitmap.height
36 | val pixels = IntArray(width * height)
37 | bitmap.getPixels(pixels, 0, width, 0, 0, width, height)
38 |
39 | var result: Result?
40 | val source: RGBLuminanceSource?
41 | var invertedSource: InvertedLuminanceSource? = null
42 | return try {
43 | source = RGBLuminanceSource(width, height, pixels)
44 | result = this.decodeQRCodeWithHybridBinarizer(source)
45 | if (result == null) {
46 | invertedSource = InvertedLuminanceSource(source)
47 | result = this.decodeQRCodeWithHybridBinarizer(invertedSource)
48 | }
49 | if (result == null) {
50 | result = this.decodeQRCodeWithGlobalHistogramBinarizer(source)
51 | }
52 | if (result == null) {
53 | result = this.decodeQRCodeWithGlobalHistogramBinarizer(invertedSource!!)
54 | }
55 | result?.text
56 | } catch (e: Exception) {
57 | e.printStackTrace()
58 | null
59 | }
60 | }
61 |
62 | private fun decodeQRCodeWithHybridBinarizer(source: LuminanceSource): Result? {
63 | return try {
64 | val binarizer = HybridBinarizer(source)
65 | val binaryBitmap = BinaryBitmap(binarizer)
66 | MultiFormatReader().decode(binaryBitmap, this.hints)
67 | } catch (e: Exception) {
68 | e.printStackTrace()
69 | null
70 | }
71 | }
72 |
73 | private fun decodeQRCodeWithGlobalHistogramBinarizer(source: LuminanceSource): Result? {
74 | return try {
75 | val binarizer = GlobalHistogramBinarizer(source)
76 | val binaryBitmap = BinaryBitmap(binarizer)
77 | MultiFormatReader().decode(binaryBitmap, this.hints)
78 | } catch (e: Exception) {
79 | e.printStackTrace()
80 | null
81 | }
82 | }
83 |
84 | private fun getDecodeAbleBitmap(filePath: String?): Bitmap? {
85 | return try {
86 | val fileInputStream = FileInputStream(filePath)
87 | BitmapFactory.decodeStream(fileInputStream)
88 | } catch (e: Exception) {
89 | null
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/ShellUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import com.sjk.deleterecentpictures.common.logE
4 |
5 | object ShellUtil {
6 | const val TAG: String = "ShellUtil"
7 |
8 | fun execDeleteFile(filePath: String): Boolean {
9 | return this.exec("rm -r $filePath")
10 | }
11 |
12 | fun exec(command: String?): Boolean {
13 | if (command == null) {
14 | return false
15 | }
16 |
17 | // var bufferedReader: BufferedReader? = null
18 | val runtime = Runtime.getRuntime()
19 | return try {
20 | //Process中封装了返回的结果和执行错误的结果
21 | val process = runtime.exec(command)
22 | /*bufferedReader = BufferedReader(InputStreamReader(process.inputStream))
23 | val stringBuffer = StringBuffer()
24 | val buff = CharArray(1024)
25 | var ch = 0
26 | while (bufferedReader.read(buff).also { ch = it } != -1) {
27 | stringBuffer.append(buff, 0, ch)
28 | }*/
29 | true
30 | } catch (e: Exception) {
31 | logE(TAG, e.stackTraceToString())
32 | false
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/ShortcutUtil.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * 已废弃
3 | */
4 |
5 | package com.sjk.deleterecentpictures.utils
6 |
7 | import android.app.PendingIntent
8 | import android.content.Context
9 | import android.content.Intent
10 | import android.content.pm.ShortcutInfo
11 | import android.content.pm.ShortcutManager
12 | import android.os.Build
13 | import com.sjk.deleterecentpictures.R
14 | import com.sjk.deleterecentpictures.activity.settings.SettingsActivity
15 |
16 | object ShortcutUtil {
17 | fun createLauncherShortcut(context: Context) {
18 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
19 | val shortcutManager = context.getSystemService(ShortcutManager::class.java)
20 | ?: return
21 | if (shortcutManager.isRequestPinShortcutSupported) {
22 | val intent = Intent(context, SettingsActivity::class.java)
23 | intent.action = Intent.ACTION_VIEW
24 | val pinShortcutInfo = ShortcutInfo.Builder(context, "delete-directly-shortcut")
25 | .setShortLabel(context.getString(R.string.delete_the_latest_pictures_directly))
26 | .setIntent(intent)
27 | .build()
28 | val pinnedShortcutCallbackIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo)
29 | val successCallback = PendingIntent.getBroadcast(context, 0,
30 | pinnedShortcutCallbackIntent, PendingIntent.FLAG_IMMUTABLE)
31 | shortcutManager.requestPinShortcut(pinShortcutInfo,
32 | successCallback.intentSender)
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/TimeUtil.kt:
--------------------------------------------------------------------------------
1 | package com.sjk.deleterecentpictures.utils
2 |
3 | import java.text.DateFormat
4 | import java.util.*
5 |
6 | object TimeUtil {
7 |
8 | /**
9 | * 将时间戳格式化为系统默认格式
10 | * @param timestamp 时间戳
11 | */
12 | fun formatTimestampToSystemDefaultFormat(timestamp: Long): String {
13 | val dateFormat = DateFormat.getDateTimeInstance()
14 | return dateFormat.format(Date(timestamp))
15 | }
16 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sjk/deleterecentpictures/utils/TransformUtil.kt:
--------------------------------------------------------------------------------
1 | /**
2 | * 已废弃
3 | */
4 |
5 | package com.sjk.deleterecentpictures.utils
6 |
7 | import android.graphics.Bitmap
8 | import android.graphics.BitmapFactory
9 | import java.io.ByteArrayOutputStream
10 |
11 |
12 | object TransformUtil {
13 | fun filePath2Bitmap(imagePath: String?): Bitmap? {
14 | val options = BitmapFactory.Options()
15 | options.inPreferredConfig = Bitmap.Config.RGB_565
16 | val bitmap = BitmapFactory.decodeFile(imagePath, options)
17 |
18 | val baos = ByteArrayOutputStream()
19 | val quality = 50
20 | bitmap.compress(Bitmap.CompressFormat.JPEG, quality, baos)
21 | bitmap.recycle()
22 | val bytes = baos.toByteArray()
23 | return BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
24 |
25 | // val options = BitmapFactory.Options()
26 | // options.inPreferredConfig = Bitmap.Config.RGB_565
27 | // return BitmapFactory.decodeFile(imagePath, options)
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-night-v31/dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/app_widget_background.xml:
--------------------------------------------------------------------------------
1 |
5 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/app_widget_inner_view_background.xml:
--------------------------------------------------------------------------------
1 |
5 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v31/dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/activity_main_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arrow_left.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arrow_right.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete_image.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_image.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_refresh.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_undo.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
26 |
27 |
31 |
32 |
37 |
38 |
43 |
44 |
59 |
60 |
68 |
69 |
70 |
73 |
74 |
80 |
81 |
82 |
86 |
87 |
98 |
99 |
110 |
111 |
112 |
113 |
114 |
115 |
120 |
121 |
126 |
127 |
138 |
139 |
149 |
150 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main_multi_window.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
25 |
26 |
32 |
33 |
38 |
39 |
54 |
55 |
63 |
64 |
65 |
68 |
69 |
75 |
76 |
77 |
81 |
82 |
93 |
94 |
105 |
106 |
107 |
108 |
109 |
114 |
115 |
120 |
121 |
132 |
133 |
143 |
144 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_settings2.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/image_widget.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
14 |
15 |
24 |
25 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
60 |
61 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_deleted_snackbar_buttons.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_main_view_pager_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
28 |
29 |
34 |
35 |
40 |
41 |
42 |
43 |
49 |
50 |
57 |
58 |
63 |
64 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_view_pager_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-en/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - The entire external storage directory
5 | - Screenshot directory
6 | - Customize
7 |
8 |
9 |
10 | - sdCard
11 | - screenshots
12 | - customize
13 |
14 |
15 |
16 | - 1
17 | - 2
18 |
19 |
20 |
21 | - Modification time (reverse order)
22 | - Add time (reverse order)
23 |
24 |
25 |
26 | - 1
27 | - 2
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Delete Recent Pictures
4 | Cancel
5 | Refresh
6 | Delete
7 | Settings
8 | The custom path needs to omit the external storage directory and fill in the complete path, such as: Pictures/
It is also compatible with wildcard characters in SQL statements: _ - Replaces only one character; % - Replaces one or more characters; [charlist] - Replace any single character in the character list; [^charlist] or [!charlist] - Replace any single character not in the character list; If you need to match _ and %, you can add a backslash (\\) in front of them. If you need to match \\, you need to enter \\\\
Click here to view a more detailed tutorial ]]>
9 | Current image path
10 | Image path is empty
11 | %1$s pictures will be deleted
12 | Please confirm whether to delete %1$s
13 | Please select your operation
14 | Failed to invoke open method
15 | Failed to invoke sharing method
16 | Barcode or qrcode not found
17 | Open failed
18 | Recognized content
19 | Open with browser
20 | Open method
21 | Share
22 | Barcode or qrcode recognition
23 | Not getting manage external storage permission
24 | No path
25 | Delete the latest pictures directly
26 | Searching…
27 | OK
28 | Disagree and exit
29 | Agree
30 | Close
31 | Copy
32 | Determine
33 | Prompt
34 | Copied
35 | General settings
36 | Query the path of the image
37 | Permission settings
38 | About
39 | Whether to close this application after deleting the picture
40 | If you do not close it, you can continue to delete pictures.
41 | Delete directly
42 | Whether to allow direct deletion by tapping the delete button (this option does not affect long press deletion and multi-select deletion)
43 | Number of single views
44 | Number of recent images in a single search
45 | The default is 10, leaving it blank or filling in 0 represents the default value.
46 | Sort order
47 | Custom path
48 | You need to omit the external storage directory, such as: Pictures/.\nYou can also search for pictures starting with a certain string in a certain directory, such as: DCIM/sc\nSupports multiple directories, use "|" (vertical bar symbol, Unicode encoding U+007C) to separate different paths
49 | Select path
50 | Custom path description
51 | Click to view
52 | Manage permissions for external storage
53 | Only Android 11 and above need to enable this permission
54 | Developer
55 | Visit this repository on Github
56 | User agreement
57 | Privacy policy
58 | About -> Access this project on github.]]>
59 | Storage permission not obtained
60 | Refresh successful
61 | Refresh successfully and return to the first picture
62 | Recycle bin created successfully
63 | Recycle bin created failed
64 | "%1$s" deleted
65 | Picture cannot be deleted
66 | Revoke
67 | All deleted
68 | Partial deletion failed
69 | Failed to delete all
70 | Unable to obtain picture information, deletion failed
71 | Experimental settings
72 | You can undo a picture that was deleted by mistake. When automatic shutdown is enabled, it cannot be revoked
73 | Undeleted
74 | Image details
75 | Path
76 | Name
77 | Size
78 | Width
79 | Height
80 | Mime type
81 | Added time
82 | Modified time
83 | :
84 | Unable to obtain external storage location, replace with default query
85 | All selected images deselected
86 | Settings reloaded
87 | No more
88 | There may be some display problems
89 | Use exclusive layouts in multi-window mode
90 | Grant permission
91 | File and Storage permission is required to read and manage pictures.
92 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night-v31/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:color/system_accent1_800
4 | @android:color/system_accent1_200
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night-v31/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
14 |
15 |
20 |
21 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v31/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:color/system_accent1_0
4 | @android:color/system_accent1_300
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v31/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 |
17 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v31/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - 整个外置存储目录
5 | - 截图目录
6 | - 自定义
7 |
8 |
9 |
10 | - sdCard
11 | - screenshots
12 | - customize
13 |
14 |
15 |
16 | - 1
17 | - 2
18 |
19 |
20 |
21 | - 修改时间(倒序)
22 | - 添加时间(倒序)
23 |
24 |
25 |
26 | - 1
27 | - 2
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ?attr/colorPrimary
4 | ?attr/colorPrimaryDark
5 | ?attr/colorAccent
6 | ?attr/colorSecondary
7 |
8 | #FFFFFF
9 | #64b5f6
10 | #FFE1F5FE
11 | #FF81D4FA
12 | #FF039BE5
13 | #FF01579B
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 280dp
3 |
4 |
8 | 0dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 删除最近图片
3 | 来一斤BUG
4 | 删除
5 | 取消
6 | 刷新
7 | 设置
8 | 好的
9 | 不同意且退出
10 | 同意
11 | 关闭
12 | 复制
13 | 确定
14 | 提示
15 | 已复制
16 |
17 |
18 |
19 |
20 | 一般设置
21 | 查询图片的路径
22 | 权限设置
23 | 关于
24 |
25 |
26 | 删除图片后是否关闭本应用
27 | 如不关闭可以继续删除图片
28 | 直接删除
29 | 是否允许轻触删除按钮直接删除(此选项不影响长按删除和多选删除)
30 | 单次查看数量
31 | 单次搜索最近图片的数量
32 | 默认为10,不填写或填0都代表默认值
33 | 排序方式
34 |
35 |
36 | 自定义路径
37 | 需要省略外置存储目录,如:Pictures/\n也可以搜索某一目录下以某字符串打头的图片,如:DCIM/sc\n支持多目录,不同路径之间使用“|”(竖线符号,Unicode编码U+007C)分割
38 | 选择路径
39 | 自定义路径说明
40 | 点击查看
41 |
42 |
43 | 所有文件访问权限
44 | 仅Android 11及以上需要开启这个权限
45 |
46 |
47 | 开发者
48 | 在Github上访问此仓库
49 | https://github.com/1045290202/DeleteRecentPictures
50 | 用户协议
51 | 隐私政策
52 |
53 |
54 |
55 | 关于 -> 在github上访问此项目 找到本应用的源代码。]]>
56 | 自定义路径需要省略外置存储目录,无需填写完整路径,如:Pictures/ 同时兼容了SQL语句中的通配符: _ —— 仅替代一个字符; % —— 替代一个或多个字符; [charlist] —— 替代字符列中的任何单一字符; [^charlist] 或[!charlist] —— 替代不在字符列中的任何单一字符; 如果需要匹配_和%,可以在他们前面添加反斜杠(\\),如果需要匹配\\,则需要输入\\\\
点此查看更详细的教程 ]]>
57 | 当前图片路径
58 | 图片路径为空
59 | \n\n
60 | 即将删除%1$s张图片
61 | 请确认是否删除 %1$s
62 | 请选择你的操作
63 | 唤起打开方式失败
64 | 唤起分享方式失败
65 | 未发现条形码(二维码)
66 | 打开失败
67 | 识别的内容
68 | 用浏览器打开
69 | 打开方式
70 | 分享
71 | 条形码(二维码)识别
72 | 未获取到所有文件访问权限
73 | 无路径
74 | 直接删除最新图片
75 | 查找中…
76 | 未获取到存储权限
77 | 刷新成功
78 | 刷新成功并返回第一张图片
79 | 创建回收站成功
80 | 创建回收站失败
81 | “%1$s”已删除
82 | 图片无法删除
83 | 撤销
84 | 已全部删除
85 | 部分删除失败
86 | 全部删除失败
87 | 没有获取到图片信息,删除失败
88 | 实验性设置
89 | 可以撤销误删除的一张图片。开启自动关闭的时候将无法撤销
90 | 撤销删除
91 | 图片详情
92 | 路径
93 | 名称
94 | 大小
95 | 宽度
96 | 高度
97 | 媒体类型
98 | 创建时间
99 | 修改时间
100 | :
101 | 无法获取外置存储位置, 替换为默认查询
102 | 已取消所有已选择图片
103 | 已重新加载设置
104 | 没有更多了
105 | 可能会出现一些显示上的问题
106 | 多窗口模式下使用专属的布局
107 | EXAMPLE
108 | Add widget
109 | This is an app widget description
110 | 授权提示
111 | 本软件需要您授权文件与存储的权限,以读取和管理图片。
112 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
20 |
21 |
32 |
33 |
42 |
43 |
54 |
55 |
59 |
60 |
61 |
62 |
63 |
64 |
67 |
68 |
73 |
74 |
77 |
78 |
85 |
86 |
90 |
91 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/xml-v31/image_widget_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
29 |
30 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/image_widget_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/root_preferences.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
70 |
71 |
76 |
77 |
81 |
82 |
83 |
84 |
85 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
105 |
106 |
107 |
108 |
109 |
115 |
116 |
122 |
123 |
127 |
128 |
129 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/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 = '2.0.21'
5 | repositories {
6 | google()
7 | mavenCentral()
8 | maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
9 |
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:8.10.0'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | mavenCentral()
24 | maven { url "https://jitpack.io" }
25 | }
26 | }
27 |
28 | tasks.register('clean', Delete) {
29 | delete rootProject.layout.buildDirectory
30 | }
31 |
--------------------------------------------------------------------------------
/docs/images/previews/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/docs/images/previews/1.png
--------------------------------------------------------------------------------
/docs/images/previews/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/docs/images/previews/2.png
--------------------------------------------------------------------------------
/docs/images/previews/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/docs/images/previews/3.png
--------------------------------------------------------------------------------
/docs/images/previews/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/docs/images/previews/4.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | android.nonTransitiveRClass=false
21 | android.nonFinalResIds=false
22 |
23 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1045290202/DeleteRecentPictures/e7fb132988a2a72acac65b39bebd7216f598b413/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright ? 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?,
36 | # ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?;
37 | # * compound commands having a testable exit status, especially ?case?;
38 | # * various built-in commands including ?command?, ?set?, and ?ulimit?.
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='DeleteRecentPictures'
3 |
--------------------------------------------------------------------------------