|  | @@ -62,6 +62,7 @@ import androidx.compose.material3.rememberModalBottomSheetState
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.Composable
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.CompositionLocalProvider
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.LaunchedEffect
 | 
	
		
			
				|  |  | +import androidx.compose.runtime.MutableState
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.getValue
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.livedata.observeAsState
 | 
	
		
			
				|  |  |  import androidx.compose.runtime.mutableStateOf
 | 
	
	
		
			
				|  | @@ -96,6 +97,7 @@ import androidx.core.content.ContextCompat.startActivity
 | 
	
		
			
				|  |  |  import androidx.lifecycle.viewmodel.compose.viewModel
 | 
	
		
			
				|  |  |  import androidx.navigation.NavHostController
 | 
	
		
			
				|  |  |  import androidx.navigation.compose.rememberNavController
 | 
	
		
			
				|  |  | +import com.vpn.fastestvpnservice.MainActivity
 | 
	
		
			
				|  |  |  import com.vpn.fastestvpnservice.R
 | 
	
		
			
				|  |  |  import com.vpn.fastestvpnservice.beans.Protocol
 | 
	
		
			
				|  |  |  import com.vpn.fastestvpnservice.beans.isDarkTheme
 | 
	
	
		
			
				|  | @@ -118,12 +120,17 @@ import de.blinkt.openvpn.core.App
 | 
	
		
			
				|  |  |  import kotlinx.coroutines.delay
 | 
	
		
			
				|  |  |  import kotlinx.coroutines.launch
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +var isSwitch: MutableState<Boolean> = mutableStateOf(false)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
 | 
	
		
			
				|  |  |  @Composable
 | 
	
		
			
				|  |  |  fun Settings(navHostController: NavHostController, activity: ComponentActivity) {
 | 
	
		
			
				|  |  |      val context = LocalContext.current
 | 
	
		
			
				|  |  | +    val basePreferenceHelper = BasePreferenceHelper(context)
 | 
	
		
			
				|  |  |      var isLaunched by remember { mutableStateOf(false) }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    isSwitch.value = basePreferenceHelper.getLaunchState()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      CompositionLocalProvider(
 | 
	
		
			
				|  |  |          LocalOverscrollConfiguration provides null
 | 
	
		
			
				|  |  |      ) {
 | 
	
	
		
			
				|  | @@ -401,19 +408,19 @@ fun ColumnScope.AddRowLaunchSwitch(
 | 
	
		
			
				|  |  |                  .align(Alignment.CenterVertically),
 | 
	
		
			
				|  |  |              color = Color.Transparent
 | 
	
		
			
				|  |  |          ) {
 | 
	
		
			
				|  |  | -            var isSwitch by remember { mutableStateOf(basePreferenceHelper.getLaunchState()) }
 | 
	
		
			
				|  |  | +//            var isSwitch by remember { mutableStateOf(basePreferenceHelper.getLaunchState()) }
 | 
	
		
			
				|  |  |              Switch(
 | 
	
		
			
				|  |  | -                checked = isSwitch,
 | 
	
		
			
				|  |  | +                checked = isSwitch.value,
 | 
	
		
			
				|  |  |                  onCheckedChange = { state ->
 | 
	
		
			
				|  |  |                      if (state) {
 | 
	
		
			
				|  |  |                          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && !Settings.canDrawOverlays(context)) {
 | 
	
		
			
				|  |  |                              onClick()
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  | -                            isSwitch = true
 | 
	
		
			
				|  |  | +                            isSwitch.value = true
 | 
	
		
			
				|  |  |                              basePreferenceHelper.saveLaunchState(true)
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      } else {
 | 
	
		
			
				|  |  | -                        isSwitch = false
 | 
	
		
			
				|  |  | +                        isSwitch.value = false
 | 
	
		
			
				|  |  |                          basePreferenceHelper.saveLaunchState(false)
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  },
 | 
	
	
		
			
				|  | @@ -535,7 +542,7 @@ fun ColumnScope.LaunchDialog(
 | 
	
		
			
				|  |  |                          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && !Settings.canDrawOverlays(context)) {
 | 
	
		
			
				|  |  |                              val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
 | 
	
		
			
				|  |  |                              intent.data = Uri.parse("package:${activity.packageName}")
 | 
	
		
			
				|  |  | -                            activity.startActivityForResult(intent, 12345)
 | 
	
		
			
				|  |  | +                            activity.startActivityForResult(intent, MainActivity.SCREEN_OVERLAY)
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          onCancel()
 |