From 35f2a1079b7fafa6bbff60c27318bb79d7796b8d Mon Sep 17 00:00:00 2001 From: zarazaex69 Date: Sun, 24 May 2026 15:19:43 +0300 Subject: [PATCH] feat: add donate dialog shown on app startup --- .../main/java/xyz/zarazaex/olc/AppConfig.kt | 4 + .../java/xyz/zarazaex/olc/ui/MainActivity.kt | 63 +++ .../app/src/main/res/layout/dialog_donate.xml | 243 ++++++++++ .../app/src/main/res/values-ru/strings.xml | 12 + V2rayNG/app/src/main/res/values/strings.xml | 447 ++++++++++++++---- 5 files changed, 667 insertions(+), 102 deletions(-) create mode 100644 V2rayNG/app/src/main/res/layout/dialog_donate.xml diff --git a/V2rayNG/app/src/main/java/xyz/zarazaex/olc/AppConfig.kt b/V2rayNG/app/src/main/java/xyz/zarazaex/olc/AppConfig.kt index b166a47f..834d68d0 100644 --- a/V2rayNG/app/src/main/java/xyz/zarazaex/olc/AppConfig.kt +++ b/V2rayNG/app/src/main/java/xyz/zarazaex/olc/AppConfig.kt @@ -78,6 +78,10 @@ object AppConfig { const val PREF_DYNAMIC_COLORS = "pref_dynamic_colors" const val PREF_SUBSCRIPTIONS_BOTTOM = "pref_subscriptions_bottom" + /** Donate dialog flags. */ + const val PREF_DONATE_DIALOG_DISMISSED = "pref_donate_dialog_dismissed" + const val PREF_DONATE_DIALOG_POSTPONE_UNTIL = "pref_donate_dialog_postpone_until" + /** Cache keys. */ const val CACHE_SUBSCRIPTION_ID = "cache_subscription_id" diff --git a/V2rayNG/app/src/main/java/xyz/zarazaex/olc/ui/MainActivity.kt b/V2rayNG/app/src/main/java/xyz/zarazaex/olc/ui/MainActivity.kt index bc3b4bb1..32fe7918 100644 --- a/V2rayNG/app/src/main/java/xyz/zarazaex/olc/ui/MainActivity.kt +++ b/V2rayNG/app/src/main/java/xyz/zarazaex/olc/ui/MainActivity.kt @@ -199,6 +199,7 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect } checkForUpdatesOnStartup() + showDonateDialogIfNeeded() } private fun setupViewModel() { @@ -851,6 +852,68 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect } } + private fun showDonateDialogIfNeeded() { + if (MmkvManager.decodeSettingsBool(AppConfig.PREF_DONATE_DIALOG_DISMISSED)) return + val postponeUntil = MmkvManager.decodeSettingsLong(AppConfig.PREF_DONATE_DIALOG_POSTPONE_UNTIL, 0L) + if (System.currentTimeMillis() < postponeUntil) return + + // Откладываем на следующий тик, чтобы Activity полностью отрисовался + binding.root.post { showDonateDialog() } + } + + private fun showDonateDialog() { + val view = layoutInflater.inflate(R.layout.dialog_donate, null) + + val tonValue = view.findViewById(R.id.donate_ton_value) + val trcValue = view.findViewById(R.id.donate_trc_value) + val btcValue = view.findViewById(R.id.donate_btc_value) + + val openCard = View.OnClickListener { openUrl(getString(R.string.donate_card_link_url)) } + view.findViewById(R.id.donate_card_row).setOnClickListener(openCard) + view.findViewById(R.id.donate_card_open).setOnClickListener(openCard) + + view.findViewById(R.id.donate_ton_copy).setOnClickListener { + copyToClipboard(tonValue.text.toString()) + } + view.findViewById(R.id.donate_trc_copy).setOnClickListener { + copyToClipboard(trcValue.text.toString()) + } + view.findViewById(R.id.donate_btc_copy).setOnClickListener { + copyToClipboard(btcValue.text.toString()) + } + + MaterialAlertDialogBuilder(this) + .setTitle(R.string.donate_dialog_title) + .setView(view) + .setNegativeButton(R.string.donate_btn_dont_show) { dialog, _ -> + MmkvManager.encodeSettings(AppConfig.PREF_DONATE_DIALOG_DISMISSED, true) + dialog.dismiss() + } + .setPositiveButton(R.string.donate_btn_postpone) { dialog, _ -> + val postponeUntil = System.currentTimeMillis() + 24L * 60 * 60 * 1000 + MmkvManager.encodeSettings(AppConfig.PREF_DONATE_DIALOG_POSTPONE_UNTIL, postponeUntil) + dialog.dismiss() + } + .setCancelable(true) + .show() + } + + private fun copyToClipboard(text: String) { + val clipboard = getSystemService(android.content.Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager + clipboard.setPrimaryClip(android.content.ClipData.newPlainText("addr", text)) + toast(R.string.donate_toast_copied) + } + + private fun openUrl(url: String) { + try { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(intent) + } catch (e: Exception) { + Log.w("MainActivity", "Failed to open url: $url", e) + } + } + private fun delAllConfig() { MaterialAlertDialogBuilder(this).setMessage(R.string.del_config_comfirm) .setPositiveButton(android.R.string.ok) { _, _ -> diff --git a/V2rayNG/app/src/main/res/layout/dialog_donate.xml b/V2rayNG/app/src/main/res/layout/dialog_donate.xml new file mode 100644 index 00000000..172359b4 --- /dev/null +++ b/V2rayNG/app/src/main/res/layout/dialog_donate.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index 580de976..4226d513 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -678,4 +678,16 @@ WebDAV + + Поддержите нас + Карта + TON + TRC20 + BTC + Копировать + Открыть + Не показывать + Позже + Скопировано + diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 795455ce..a3ef4a84 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -1,22 +1,35 @@ - + olcng Switch Switch - First use of this feature, please use the app to add server + First use of this feature, please use the app to add server Open navigation drawer Close navigation drawer Data migration success! - forked from V2RayNG - developed by developers from Olc + forked from V2RayNG + developed by developers from Olc Stop service Data migration failed! Please pull down to refresh! Stop - Unable to obtain the permission - Unable to obtain the notification permission + Unable to obtain the permission + Unable to obtain the notification permission Click for more Start Services Stop Services @@ -30,19 +43,31 @@ Edit config Delete config Import from QRcode - Import from Clipboard + Import from Clipboard Import from locally - Add [Policy group] + Add [Policy group] Add [VMess] Add [VLESS] - Add [Shadowsocks] + Add [Shadowsocks] Add [SOCKS] Add [HTTP] Add [Trojan] - Add [Wireguard] - Add [Hysteria2] + Add [Wireguard] + Add [Hysteria2] Confirm delete ? - Please test before deleting! Confirm delete ? + Please test before deleting! Confirm delete ? remarks address port @@ -70,7 +95,10 @@ kcp seed gRPC serviceName TLS - Fingerprint + Fingerprint Alpn allowInsecure SNI @@ -88,8 +116,12 @@ SpiderX Mldsa65Verify SecretKey - Reserved(Optional, separated by commas) - Local address (optional IPv4/IPv6, separated by commas) + Reserved(Optional, separated by commas) + Local address (optional IPv4/IPv6, separated by commas) Mtu(optional, default 1420) Success Failure @@ -97,31 +129,53 @@ Incorrect protocol Decoding failed Select a config - Please install a File Manager. + Please install a File Manager. Customize config Invalid config Content - There is no data in the clipboard + There is no data in the clipboard Invalid URL - Please do not use the insecure HTTP protocol subscription address - Ensure inbounds port is consistent with the settings + Please do not use the insecure HTTP protocol subscription address + Ensure inbounds port is consistent with the settings Config malformed Host(SNI)(Optional) Action not allowed Obfs password - Port Hopping(will override the port) + Port Hopping(will override the port) Port Hopping Interval - Bandwidth down (Supported units: k/m/g/t) - Bandwidth up (Supported units: k/m/g/t) + Bandwidth down (Supported units: k/m/g/t) + Bandwidth up (Supported units: k/m/g/t) XHTTP Mode - XHTTP Extra raw JSON, format: { XHTTPObject } - finalMask raw JSON, format: { FinalMaskObject } + XHTTP Extra raw JSON, format: { XHTTPObject } + finalMask raw JSON, format: { FinalMaskObject } EchConfigList EchForceQuery - Certificate fingerprint (SHA-256) + Certificate fingerprint (SHA-256) - File copy failed, please use File Manager + File copy failed, please use File Manager Add asset Add files Add URL @@ -146,7 +200,9 @@ Import from Clipboard Раздельное туннелирование Включить - Выберите приложения, которые будут использовать VPN — остальные приложения, например банки, будут идти напрямую через ваш домашний интернет.\n\nВ режиме обхода всё зеркально — выбранные приложения не используют VPN. + Выберите приложения, которые будут использовать VPN — остальные приложения, например банки, будут идти напрямую через ваш домашний интернет.\n\nВ режиме обхода всё зеркально — выбранные приложения не используют VPN. Settings @@ -154,24 +210,44 @@ Core Settings VPN Settings Per-app proxy - General: Checked apps use proxy, unchecked apps connect directly; \nBypass mode: checked apps connect directly, unchecked apps use proxy. \nThe option to automatically select proxy applications is in the menu + General: Checked apps use proxy, unchecked apps connect directly; \nBypass mode: checked apps connect directly, unchecked apps use proxy. \nThe option to automatically select proxy applications is in the menu Auto connect at startup - Automatically connects to the selected server at startup, which may be unsuccessful + Automatically connects to the selected server at startup, which may be unsuccessful - Auto sort after testing - Test results may not be accurate; + Auto sort after testing + Test results may not be accurate; Show copy button - Show button to copy server configuration to clipboard + Show button to copy server configuration to clipboard Show server IP / host - Display the server IP address or host under the server name + Display the server IP address or host under the server name Mux Settings Enable Mux - Faster, but it may cause unstable connectivity\nCustomize how to handle TCP, UDP and QUIC below - TCP connections(range -1 to 1024) - XUDP connections(range -1 to 1024) - Handling of QUIC in mux tunnel + Faster, but it may cause unstable connectivity\nCustomize how to handle TCP, UDP and QUIC below + TCP connections(range -1 to 1024) + XUDP connections(range -1 to 1024) + Handling of QUIC in mux tunnel reject allow @@ -179,30 +255,46 @@ Enable speed display - Display current speed in the notification.\nNotification icon would change based on + Display current speed in the notification.\nNotification icon would change based on usage. Enable Sniffing - Try sniff domain from the packet (default on) + Try sniff domain from the packet (default on) Enable routeOnly - Use the sniffed domain name for routing only, and keep the target address as the IP address. + Use the sniffed domain name for routing only, and keep the target address as the IP address. Enable local DNS - DNS processed by core‘s DNS module (Recommended if you need routing bypassing LAN and mainland addresses) + DNS processed by core‘s DNS module (Recommended if you need routing bypassing LAN and mainland addresses) Enable fake DNS - Local DNS returns fake IP addresses (faster, but it may not work for some apps) + Local DNS returns fake IP addresses (faster, but it may not work for some apps) Prefer IPv6 - Enable IPv6 routes and Prefer IPv6 addresses + Enable IPv6 routes and Prefer IPv6 addresses - Remote DNS (udp/tcp/https/quic)(Optional) + Remote DNS (udp/tcp/https/quic)(Optional) DNS VPN DNS (only IPv4/v6) Does VPN bypass LAN - VPN Interface Address + VPN Interface Address VPN MTU (default 1500) @@ -210,21 +302,33 @@ Domestic DNS (Optional) DNS - DNS hosts (Format: domain:address,…) + DNS hosts (Format: domain:address,…) domain:address,… True delay test url Url - Current connection info test url + Current connection info test url Url - Allow connections from the LAN - Other devices can connect to proxy by your IP address through local proxy. Only enable in trusted networks to avoid unauthorized connections - Allow connections from the LAN. Make sure you are in a trusted network + Allow connections from the LAN + Other devices can connect to proxy by your IP address through local proxy. Only enable in trusted networks to avoid unauthorized connections + Allow connections from the LAN. Make sure you are in a trusted network allowInsecure - When TLS is selected, allow insecure connections by default + When TLS is selected, allow insecure connections by default Local proxy port Local proxy port @@ -233,23 +337,41 @@ Local DNS port Delete config confirmation - Whether deleting a config requires a second confirmation by the user + Whether deleting a config requires a second confirmation by the user - Start scanning immediately - Open the camera to scan immediately at startup, otherwise you can choose to scan the code or select a photo in the toolbar + Start scanning immediately + Open the camera to scan immediately at startup, otherwise you can choose to scan the code or select a photo in the toolbar - Append HTTP Proxy to VPN - HTTP proxy will be used directly from (browser/ some supported apps), without going through the virtual NIC device (Android 10+) + Append HTTP Proxy to VPN + HTTP proxy will be used directly from (browser/ some supported apps), without going through the virtual NIC device (Android 10+) - Enable double column display - The profile list is displayed in double columns, allowing more content to be displayed on the screen. You need to restart the application to take effect. + Enable double column display + The profile list is displayed in double columns, allowing more content to be displayed on the screen. You need to restart the application to take effect. Enable show all groups - Add an extra "All Tabs" page + Add an extra "All Tabs" page Feedback - Feedback enhancements or bugs to GitHub + Feedback enhancements or bugs to GitHub Join Telegram Group Telegram app not found Privacy policy @@ -261,25 +383,45 @@ Promotion - Automatic update subscriptions - Update your subscriptions automatically at set intervals in the background. Depending on the device, this feature may not always work - Auto Update Interval (Minutes, Min value 15) + Automatic update subscriptions + Update your subscriptions automatically at set intervals in the background. Depending on the device, this feature may not always work + Auto Update Interval (Minutes, Min value 15) Log Level - Outbound domain pre-resolve method + Outbound domain pre-resolve method Mode Click me for more help Language UI settings UI mode settings - Dynamic colors (Material You) - Use wallpaper-based colors (Android 12+). Requires app restart. - Subscriptions panel at the bottom - Move the subscription tabs below the server list + Dynamic colors (Material You) + Use wallpaper-based colors (Android 12+). Requires app restart. + Subscriptions panel at the bottom + Move the subscription tabs below the server list Enable Hev TUN Feature - When enabled, TUN will use hev-socks5-tunnel; otherwise, it will use xray-core. + When enabled, TUN will use hev-socks5-tunnel; otherwise, it will use xray-core. Hev Tun Log Level - Hev Tun read/write timeout (seconds) (tcp,udp default 300,60) + Hev Tun read/write timeout (seconds) (tcp,udp default 300,60) Restart required to apply changes Logcat @@ -298,9 +440,13 @@ Enable update Enable automatic update Allow insecure HTTP address - Previous proxy config remarks + Previous proxy config remarks Next proxy config remarks - The config remarks exist and are unique + The config remarks exist and are unique Update subscription Tcping config Real delay config @@ -308,17 +454,29 @@ Sorting by test results Filter config All - Delete %d duplicate configs + Delete %d duplicate configs Delete %d configs Import %d configs Export %d configs Update %d configs Updating… - Updated %1$d configs (%2$d success, %3$d failed, %4$d skipped) - No subscriptions - Selected server not found in current group - Unable to locate current view - Locate the selected config + Updated %1$d configs (%2$d success, %3$d failed, %4$d skipped) + No subscriptions + Selected server not found in current group + Unable to locate current view + Locate the selected config Start Service Confirm @@ -326,64 +484,117 @@ Domain strategy Routing Settings - Separated by commas(,), choose domain or ip + Separated by commas(,), choose domain or ip Save Clear Routing Rule Settings Add rule - Import predefined rulesets - Existing rulesets will be deleted, are you sure to continue? - Import ruleset from clipboard - Import ruleset from QRcode - Export ruleset to clipboard - Locked, keep this rule when import presets + Import predefined rulesets + Existing rulesets will be deleted, are you sure to continue? + Import ruleset from clipboard + Import ruleset from QRcode + Export ruleset to clipboard + Locked, keep this rule when import presets domain ip port - protocol - [http,tls,bittorrent] - network - [udp|tcp] - outboundTag + protocol + [http,tls,bittorrent] + network + [udp|tcp] + outboundTag Check Connectivity Testing… - Тестирование %d серверов… - Success: Connection took %dms - Fail to detect internet connection: %s + Тестирование %d серверов… + Success: Connection took %dms + Fail to detect internet connection: %s Internet Unavailable Error code: #%d - Connected, tap to check connection + Connected, tap to check connection Готово к подключению Updating profiles… Проверено %s - Subscription imported Successfully - Import subscription failed + Subscription imported Successfully + Import subscription failed Fragment Settings Fragment Packets Fragment Length (min-max) - Fragment Interval (min-max) + Fragment Interval (min-max) Enable Fragment Check for update - Already on the latest version + Already on the latest version New version found: %s Update now Check Pre-release Checking for update… Policy group type - From subscription group - Remarks regular filter + From subscription group + Remarks regular filter - Backup & Restore + Backup & Restore Backup config Restore config Share config WebDAV Settings - Please configure WebDAV first. + Please configure WebDAV first. WebDAV server URL Username Password @@ -451,4 +662,36 @@ WebDAV + + Поддержите нас + Карта + TON + TRC20 + BTC + pay.cloudtips.ru/p/28c476e5 + UQD_Qc2cxLGe1P4wANi46cKdEvvzyJRrJTYPvGX2KAZDnsDh + TYQqdACH5PrScvsMowSyS8JjaaF5wvFf5Q + bc1qvw0ts0jk5e5dfj9fdez76j9ck95lqz04fpf02a + Копировать + Открыть + https://pay.cloudtips.ru/p/28c476e5 + Не показывать + Позже + Скопировано +