mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
fix: global overrides regression, support prompt bug
This commit is contained in:
@@ -198,7 +198,10 @@
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
|
||||
@@ -279,7 +279,7 @@ class MainActivity : AppCompatActivity() {
|
||||
append(context.getString(R.string.donation_prompt_suffix))
|
||||
}
|
||||
|
||||
LaunchedEffect(uiState.shouldShowDonationSnackbar) {
|
||||
LaunchedEffect(Unit) {
|
||||
if (
|
||||
uiState.shouldShowDonationSnackbar && !uiState.settings.alreadyDonated
|
||||
) {
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ class RestartReceiver : BroadcastReceiver() {
|
||||
tunnelManager.handleReboot()
|
||||
}
|
||||
Intent.ACTION_MY_PACKAGE_REPLACED -> {
|
||||
Timber.i("Restoring state on package upgrade")
|
||||
tunnelManager.handleRestore()
|
||||
logReader.deleteAndClearLogs()
|
||||
appStateRepository.setShouldShowDonationSnackbar(true)
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ class AutoTunnelService : LifecycleService() {
|
||||
return combine(
|
||||
settingsRepository.flow.map { it.appMode }.distinctUntilChanged(),
|
||||
autoTunnelRepository.get().flow,
|
||||
tunnelsRepository.flow.map { tunnels ->
|
||||
tunnelsRepository.userTunnelsFlow.map { tunnels ->
|
||||
// isActive is ignored for equality checks so user can manually toggle off
|
||||
// tunnel with auto-tunnel
|
||||
tunnels.map { it.copy(isActive = false) }
|
||||
|
||||
@@ -322,11 +322,11 @@ constructor(
|
||||
withContext(ioDispatcher) {
|
||||
val settings = settingsRepository.getGeneralSettings()
|
||||
val autoTunnelSettings = autoTunnelSettingsRepository.getAutoTunnelSettings()
|
||||
val tunnels = tunnelsRepository.getAll()
|
||||
val tunnels = tunnelsRepository.userTunnelsFlow.firstOrNull()
|
||||
if (autoTunnelSettings.isAutoTunnelEnabled)
|
||||
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
||||
if (settings.appMode == AppMode.LOCK_DOWN) handleLockDownModeInit()
|
||||
if (tunnels.any { it.isActive }) {
|
||||
if (tunnels?.any { it.isActive } == true) {
|
||||
if (settings.appMode == AppMode.VPN && !serviceManager.hasVpnPermission())
|
||||
return@withContext localErrorEvents.emit(null to NotAuthorized())
|
||||
when (settings.appMode) {
|
||||
@@ -350,7 +350,7 @@ constructor(
|
||||
withContext(ioDispatcher) {
|
||||
val settings = settingsRepository.getGeneralSettings()
|
||||
val autoTunnelSettings = autoTunnelSettingsRepository.getAutoTunnelSettings()
|
||||
val defaultTunnel = tunnelsRepository.getStartTunnel()
|
||||
val defaultTunnel = tunnelsRepository.getDefaultTunnel()
|
||||
if (autoTunnelSettings.startOnBoot)
|
||||
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
||||
if (settings.isRestoreOnBootEnabled) {
|
||||
|
||||
@@ -50,23 +50,27 @@ interface TunnelConfigDao {
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM tunnel_config
|
||||
ORDER BY
|
||||
CASE WHEN is_primary_tunnel = 1 THEN 0 ELSE 1 END,
|
||||
position ASC
|
||||
LIMIT 1"""
|
||||
SELECT * FROM tunnel_config
|
||||
WHERE name != '${TunnelConfig.GLOBAL_CONFIG_NAME}'
|
||||
ORDER BY
|
||||
CASE WHEN is_primary_tunnel = 1 THEN 0 ELSE 1 END,
|
||||
position ASC
|
||||
LIMIT 1
|
||||
"""
|
||||
)
|
||||
suspend fun getDefaultTunnel(): TunnelConfig?
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM tunnel_config
|
||||
ORDER BY
|
||||
CASE WHEN is_Active = 1 THEN 0
|
||||
WHEN is_primary_tunnel = 1 THEN 1
|
||||
ELSE 2 END,
|
||||
position ASC
|
||||
LIMIT 1"""
|
||||
SELECT * FROM tunnel_config
|
||||
WHERE name != '${TunnelConfig.GLOBAL_CONFIG_NAME}'
|
||||
ORDER BY
|
||||
CASE WHEN is_Active = 1 THEN 0
|
||||
WHEN is_primary_tunnel = 1 THEN 1
|
||||
ELSE 2 END,
|
||||
position ASC
|
||||
LIMIT 1
|
||||
"""
|
||||
)
|
||||
suspend fun getStartTunnel(): TunnelConfig?
|
||||
|
||||
|
||||
+2
@@ -55,6 +55,8 @@ class DataStoreAppStateRepository(
|
||||
pref[DataStoreManager.locationDisclosureShown] ?: false,
|
||||
isBatteryOptimizationDisableShown =
|
||||
pref[DataStoreManager.batteryDisableShown] ?: false,
|
||||
shouldShowDonationSnackbar =
|
||||
pref[DataStoreManager.shouldShowDonationSnackbar] ?: false,
|
||||
)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Timber.e(e)
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@ import androidx.compose.ui.unit.dp
|
||||
import com.zaneschepke.wireguardautotunnel.R
|
||||
|
||||
@Composable
|
||||
fun GettingStartedLabel(onClick: (url: String) -> Unit) {
|
||||
fun GettingStartedLabel(onClick: (url: String) -> Unit, modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
modifier = Modifier.padding(top = 100.dp).fillMaxSize(),
|
||||
modifier = modifier.padding(top = 100.dp).fillMaxSize(),
|
||||
) {
|
||||
val url = stringResource(id = R.string.docs_url)
|
||||
val gettingStarted = buildAnnotatedString {
|
||||
|
||||
+7
-1
@@ -59,7 +59,12 @@ fun TunnelList(
|
||||
flingBehavior = ScrollableDefaults.flingBehavior(),
|
||||
) {
|
||||
if (sharedState.tunnels.isEmpty()) {
|
||||
item { GettingStartedLabel(onClick = { context.openWebUrl(it) }) }
|
||||
item {
|
||||
GettingStartedLabel(
|
||||
onClick = { context.openWebUrl(it) },
|
||||
modifier = Modifier.animateItem(),
|
||||
)
|
||||
}
|
||||
}
|
||||
items(sharedState.tunnels, key = { it.id }) { tunnel ->
|
||||
val tunnelState =
|
||||
@@ -81,6 +86,7 @@ fun TunnelList(
|
||||
}
|
||||
|
||||
SurfaceRow(
|
||||
modifier = Modifier.animateItem(),
|
||||
leading = {
|
||||
Icon(
|
||||
Icons.Rounded.Circle,
|
||||
|
||||
@@ -434,7 +434,7 @@
|
||||
<string name="info">Info</string>
|
||||
<string name="already_donated">Already donated</string>
|
||||
<string name="already_donated_description">Disables future donation prompts</string>
|
||||
<string name="donation_prompt_prefix">Thanks for using WG Tunnel! If you can, please consider</string>
|
||||
<string name="donation_prompt_prefix">Thanks for using WG Tunnel! If you are able, please consider</string>
|
||||
<string name="donation_prompt_link">supporting the project</string>
|
||||
<string name="donation_prompt_suffix">to keep it free and improving.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user