Skip to content

Commit b8902a5

Browse files
authored
feat: gallery - Extend the automatic deletion time for trash bin to 365 days (#1453)
1 parent f8504f4 commit b8902a5

5 files changed

Lines changed: 28 additions & 0 deletions

File tree

library/core/src/main/res/values-zh-rCN/strings_app.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,8 @@
11181118
<string name="gallery_backup_server_xiaomi">小米云服务</string>
11191119
<string name="gallery_backup_server_google">Google</string>
11201120
<string name="gallery_backup_server_onedrive">Google 与 OneDrive</string>
1121+
<string name="gallery_longer_trashbin_time">延长最近删除内容保留时间至 365 天</string>
1122+
<string name="gallery_longer_trashbin_time_desc">实验性功能,仅支持中国大陆用户</string>
11211123
<!--MIUI 安全组件-->
11221124
<string name="guard_provider_hyperos">系统安全组件</string>
11231125
<string name="guard_provider_disable_upload_applist">阻止自动上传已安装应用列表</string>

library/core/src/main/res/values/strings_app.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,8 @@
10691069
<string name="gallery_backup_server_xiaomi">Xiaomi Cloud</string>
10701070
<string name="gallery_backup_server_google">Google</string>
10711071
<string name="gallery_backup_server_onedrive">Google &amp; OneDrive</string>
1072+
<string name="gallery_longer_trashbin_time">Extend the automatic deletion time for trash bin to 365 days</string>
1073+
<string name="gallery_longer_trashbin_time_desc">Experimental feature. Only for China Mainland users.</string>
10721074
<!--System security components-->
10731075
<string name="guard_provider_hyperos">System security components</string>
10741076
<string name="guard_provider_disable_upload_applist">Prevent automatic upload of installed app list</string>

library/core/src/main/res/xml/gallery.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
android:key="prefs_key_gallery_enable_ocr_form"
5151
android:title="@string/gallery_enable_ocr_form" />
5252

53+
<SwitchPreference
54+
android:defaultValue="false"
55+
android:key="prefs_key_gallery_longer_trashbin_time"
56+
android:summary="@string/gallery_longer_trashbin_time_desc"
57+
android:title="@string/gallery_longer_trashbin_time" />
58+
5359
</PreferenceCategory>
5460

5561
<PreferenceCategory android:title="@string/recommend">

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/app/Gallery.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
import com.sevtinge.hyperceiler.hook.module.rules.gallery.EnablePdf;
3030
import com.sevtinge.hyperceiler.hook.module.rules.gallery.EnablePhotoMovie;
3131
import com.sevtinge.hyperceiler.hook.module.rules.gallery.EnableVideoPost;
32+
import com.sevtinge.hyperceiler.hook.module.rules.gallery.LongerTrashbinTime;
3233
import com.sevtinge.hyperceiler.hook.module.rules.gallery.UnPrivacyWatermark;
3334

3435
@HookBase(targetPackage = "com.miui.gallery")
3536
public class Gallery extends BaseModule {
3637

3738
@Override
3839
public void handleLoadPackage() {
40+
initHook(new LongerTrashbinTime(), mPrefsMap.getBoolean("gallery_longer_trashbin_time"));
3941
initHook(new UnPrivacyWatermark(), mPrefsMap.getBoolean("gallery_enable_un_privacy_watermark"));
4042
initHook(new EnableHdrEnhance(), mPrefsMap.getBoolean("gallery_enable_hdr_enhanced"));
4143
initHook(new EnablePdf(), mPrefsMap.getBoolean("gallery_enable_pdf"));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.sevtinge.hyperceiler.hook.module.rules.gallery;
2+
3+
import com.sevtinge.hyperceiler.hook.module.base.BaseHook;
4+
5+
public class LongerTrashbinTime extends BaseHook {
6+
@Override
7+
public void init() throws NoSuchMethodException {
8+
findAndHookConstructor("com.miui.gallery.trash.TrashUtils$UserInfo", String.class, String.class, String.class, long.class, long.class, long.class, long.class, new MethodHook(){
9+
@Override
10+
protected void before(MethodHookParam param) throws Throwable {
11+
param.args[3] = 31536000000L;
12+
param.args[6] = 31536000000L;
13+
}
14+
});
15+
}
16+
}

0 commit comments

Comments
 (0)