diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt index 8a3be9e0..2012818a 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt @@ -94,7 +94,7 @@ object AppConfig { // subscription settings const val SUBSCRIPTION_AUTO_UPDATE = "pref_auto_update_subscription" const val SUBSCRIPTION_AUTO_UPDATE_INTERVAL = "pref_auto_update_interval" - const val DEFAULT_UPDATE_INTERVAL = "1440" // 24 hours - const val UPDATE_TASK_NAME = "subscription-updater" + const val SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL = "1440" // 24 hours + const val SUBSCRIPTION_UPDATE_TASK_NAME = "subscription_updater" } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SettingsActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SettingsActivity.kt index e2420ce3..70da3308 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SettingsActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SettingsActivity.kt @@ -14,13 +14,10 @@ import androidx.work.multiprocess.RemoteWorkManager import com.v2ray.ang.AngApplication import com.v2ray.ang.AppConfig import com.v2ray.ang.R -import com.v2ray.ang.dto.AngConfig import com.v2ray.ang.service.SubscriptionUpdater import com.v2ray.ang.util.Utils import com.v2ray.ang.viewmodel.SettingsViewModel -import java.sql.Time import java.util.concurrent.TimeUnit -import kotlin.time.toDuration class SettingsActivity : BaseActivity() { private val settingsViewModel: SettingsViewModel by viewModels() @@ -81,7 +78,7 @@ class SettingsActivity : BaseActivity() { autoUpdateInterval?.setOnPreferenceChangeListener { _, any -> val nval = any as String autoUpdateInterval?.summary = - if (TextUtils.isEmpty(nval) or (nval.toLong() < 15)) AppConfig.DEFAULT_UPDATE_INTERVAL else nval + if (TextUtils.isEmpty(nval) or (nval.toLong() < 15)) AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL else nval configureUpdateTask(nval.toLong()) false } @@ -180,7 +177,7 @@ class SettingsActivity : BaseActivity() { httpPort?.summary = defaultSharedPreferences.getString(AppConfig.PREF_HTTP_PORT, AppConfig.PORT_HTTP) updateMux(defaultSharedPreferences.getBoolean(AppConfig.PREF_MUX_ENABLED, false)) muxXudpConcurrency?.summary = defaultSharedPreferences.getString(AppConfig.PREF_MUX_XUDP_CONCURRENCY, "8") - autoUpdateInterval?.summary = defaultSharedPreferences.getString(AppConfig.SUBSCRIPTION_AUTO_UPDATE_INTERVAL,AppConfig.DEFAULT_UPDATE_INTERVAL) + autoUpdateInterval?.summary = defaultSharedPreferences.getString(AppConfig.SUBSCRIPTION_AUTO_UPDATE_INTERVAL,AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL) if (TextUtils.isEmpty(remoteDnsString)) { remoteDnsString = AppConfig.DNS_AGENT @@ -233,9 +230,9 @@ class SettingsActivity : BaseActivity() { private fun configureUpdateTask(interval: Long) { val rw = RemoteWorkManager.getInstance(AngApplication.application) - rw.cancelUniqueWork(AppConfig.UPDATE_TASK_NAME) + rw.cancelUniqueWork(AppConfig.SUBSCRIPTION_UPDATE_TASK_NAME) rw.enqueueUniquePeriodicWork( - AppConfig.UPDATE_TASK_NAME, + AppConfig.SUBSCRIPTION_UPDATE_TASK_NAME, ExistingPeriodicWorkPolicy.UPDATE, PeriodicWorkRequest.Builder( SubscriptionUpdater.UpdateTask::class.java, @@ -255,7 +252,8 @@ class SettingsActivity : BaseActivity() { private fun cancelUpdateTask() { val rw = RemoteWorkManager.getInstance(AngApplication.application) - rw.cancelUniqueWork(AppConfig.UPDATE_TASK_NAME) + rw.cancelUniqueWork(AppConfig.SUBSCRIPTION_UPDATE_TASK_NAME) + } private fun updateMux(enabled: Boolean) { val defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt index 0d34c0bb..4fa407e8 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt @@ -40,6 +40,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application AppConfig.PREF_V2RAY_ROUTING_AGENT, AppConfig.PREF_V2RAY_ROUTING_BLOCKED, AppConfig.PREF_V2RAY_ROUTING_DIRECT, + AppConfig.SUBSCRIPTION_AUTO_UPDATE_INTERVAL, AppConfig.PREF_MUX_XUDP_QUIC, -> { settingsStorage?.encode(key, sharedPreferences.getString(key, "")) } @@ -53,6 +54,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application AppConfig.PREF_BYPASS_APPS, AppConfig.PREF_CONFIRM_REMOVE, AppConfig.PREF_START_SCAN_IMMEDIATE, + AppConfig.SUBSCRIPTION_AUTO_UPDATE, AppConfig.PREF_MUX_ENABLED, -> { settingsStorage?.encode(key, sharedPreferences.getBoolean(key, false)) } diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 6214b267..4e792fd1 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -172,6 +172,10 @@ Promotion Promotion,click for details(Donation can be removed) + Automatic update subscriptions + Update your subscriptions automatically with an interval in background + Subscription Auto Update Interval (Minutes) + Log Level Mode Click me for more help @@ -190,7 +194,7 @@ remarks Optional URL enable update - Auto update + Automatic update Update subscription Tcping all configuration Real delay all configuration diff --git a/V2rayNG/app/src/main/res/xml/pref_settings.xml b/V2rayNG/app/src/main/res/xml/pref_settings.xml index a14314d5..21c1751d 100644 --- a/V2rayNG/app/src/main/res/xml/pref_settings.xml +++ b/V2rayNG/app/src/main/res/xml/pref_settings.xml @@ -2,10 +2,10 @@ + android:defaultValue="true" + android:key="pref_sniffing_enabled" + android:summary="@string/summary_pref_sniffing_enabled" + android:title="@string/title_pref_sniffing_enabled" /> + android:key="pref_local_dns_enabled" + android:summary="@string/summary_pref_local_dns_enabled" + android:title="@string/title_pref_local_dns_enabled" /> + android:key="pref_fake_dns_enabled" + android:summary="@string/summary_pref_fake_dns_enabled" + android:title="@string/title_pref_fake_dns_enabled" /> + android:key="pref_local_dns_port" + android:summary="10853" + android:inputType="number" + android:title="@string/title_pref_local_dns_port" /> + android:key="pref_vpn_dns" + android:summary="@string/summary_pref_remote_dns" + android:title="@string/title_pref_vpn_dns" /> @@ -78,6 +78,18 @@ + + + + + + android:key="pref_domestic_dns" + android:summary="@string/summary_pref_domestic_dns" + android:title="@string/title_pref_domestic_dns" /> - - - - - - - - - - - - - - - - - - + android:title="@string/title_mode" /> - - + \ No newline at end of file