diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 07922780..814c37a1 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -986,6 +986,10 @@ "name": "Bypass Camera Roll Limit", "description": "Increases the maximum amount of media you can send from the camera roll" }, + "custom_self_destruct_snap_delay": { + "name": "Custom Self Destruct Snap Delay", + "description": "Gives more options for the self-destruct timer when sending a Snap" + }, "composer_console": { "name": "Composer Console", "description": "Allows you to execute JavaScript code in Composer (arm64 only)" diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt index c00e18fd..fb5de705 100644 --- a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt +++ b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt @@ -27,6 +27,7 @@ class Experimental : ConfigContainer() { class ComposerHooksConfig: ConfigContainer(hasGlobalState = true) { val showFirstCreatedUsername = boolean("show_first_created_username") val bypassCameraRollLimit = boolean("bypass_camera_roll_limit") + val customSelfDestructSnapDelay = boolean("custom_self_destruct_snap_delay") val composerConsole = boolean("composer_console") val composerLogs = boolean("composer_logs") } diff --git a/composer/src/main/ts/main.ts b/composer/src/main/ts/main.ts index a53f2c26..afcb27e2 100644 --- a/composer/src/main/ts/main.ts +++ b/composer/src/main/ts/main.ts @@ -4,6 +4,7 @@ import { modules } from "./types"; import "./modules/operaDownloadButton"; import "./modules/firstCreatedUsername"; import "./modules/bypassCameraRollSelectionLimit"; +import "./modules/selfDestructSnapDelay"; try { @@ -21,12 +22,13 @@ try { } try { m.init(); + console.debug(`module ${m.name} initialized`); } catch (e) { console.error(`failed to initialize module ${m.name}`, e, e.stack); } }); - console.log("modules loaded!"); + console.debug("modules loaded!"); } catch (e) { log("error", "Failed to load composer modules\n" + e + "\n" + e.stack) } diff --git a/composer/src/main/ts/modules/selfDestructSnapDelay.ts b/composer/src/main/ts/modules/selfDestructSnapDelay.ts new file mode 100644 index 00000000..68ded6ac --- /dev/null +++ b/composer/src/main/ts/modules/selfDestructSnapDelay.ts @@ -0,0 +1,47 @@ +import { defineModule } from "../types"; +import { interceptComponent } from "../utils"; + +export default defineModule({ + name: "Self Destruct Snap Delay", + enabled: config => config.customSelfDestructSnapDelay, + init() { + interceptComponent( + 'snap_editor_timer_tool/src/TimerPickerView', + 'TimerPickerView', + { + "": (args: any[], superCall: () => void) => { + if (args[1].options[0] == 30) { + args[1].style = 0; // seconds format + + args[1].options = [ + 5, // 5 seconds + 10, // 10 seconds + 20, // 20 seconds + 30, // 30 seconds + 60, // 1 minute + 120, // 2 minutes + 180, // 3 minutes + 240, // 4 minutes + 300, // 5 minutes + 600, // 10 minutes + 900, // 15 minutes + 1200, // 20 minutes + 1800, // 30 minutes + 3600, // 1 hour + 7200, // 2 hours + 10800, // 3 hours + 14400, // 4 hours + 21600, // 6 hours + 28800, // 8 hours + 43200, // 12 hours + 86400, // 1 day + 172800, // 2 days + ] + } + + superCall(); + } + } + ) + } +}); \ No newline at end of file diff --git a/composer/src/main/ts/types.ts b/composer/src/main/ts/types.ts index 9c3189f6..e19a40c8 100644 --- a/composer/src/main/ts/types.ts +++ b/composer/src/main/ts/types.ts @@ -3,6 +3,7 @@ export interface Config { readonly bypassCameraRollLimit: boolean readonly showFirstCreatedUsername: boolean readonly composerLogs: boolean + readonly customSelfDestructSnapDelay: boolean } export interface FriendInfo { diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ComposerHooks.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ComposerHooks.kt index b340b197..badd56f0 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ComposerHooks.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ComposerHooks.kt @@ -120,7 +120,8 @@ class ComposerHooks: Feature("ComposerHooks") { "operaDownloadButton" to context.config.downloader.operaDownloadButton.get(), "bypassCameraRollLimit" to config.bypassCameraRollLimit.get(), "showFirstCreatedUsername" to config.showFirstCreatedUsername.get(), - "composerLogs" to config.composerLogs.get() + "composerLogs" to config.composerLogs.get(), + "customSelfDestructSnapDelay" to config.customSelfDestructSnapDelay.get(), )) }