Commit 76ac5caa authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added a dialog shown when the app doesn't have access to the vpn yet and an...

Added a dialog shown when the app doesn't have access to the vpn yet and an overlay seems to be active

Implements #143
parent 66e796ce
......@@ -8,6 +8,7 @@ import android.net.Uri
import android.net.VpnService
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
......@@ -19,14 +20,11 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.frostnerd.dnstunnelproxy.DnsServerInformation
import com.frostnerd.general.service.isServiceRunning
import com.frostnerd.smokescreen.R
import com.frostnerd.smokescreen.*
import com.frostnerd.smokescreen.activity.SpeedTestActivity
import com.frostnerd.smokescreen.dialog.ServerChoosalDialog
import com.frostnerd.smokescreen.getPreferences
import com.frostnerd.smokescreen.registerLocalReceiver
import com.frostnerd.smokescreen.service.Command
import com.frostnerd.smokescreen.service.DnsVpnService
import com.frostnerd.smokescreen.unregisterLocalReceiver
import kotlinx.android.synthetic.main.fragment_main.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
......@@ -80,6 +78,30 @@ class MainFragment : Fragment() {
}
updateVpnIndicators()
}
startButton.setOnTouchListener { _, event ->
if(proxyRunning || proxyStarting) {
false
} else {
if(event.flags and MotionEvent.FLAG_WINDOW_IS_OBSCURED != 0) {
if(event.action == MotionEvent.ACTION_UP) {
if(VpnService.prepare(context!!) != null) {
showInfoTextDialog(context!!,
getString(R.string.dialog_overlaydetected_title),
getString(R.string.dialog_overlaydetected_message),
positiveButton = null,
negativeButton = null,
neutralButton = getString(android.R.string.ok) to { dialog, _ ->
dialog.dismiss()
startVpn()
proxyStarting = true
}
)
true
} else false
} else false
}else false
}
}
speedTest.setOnClickListener {
startActivity(Intent(context!!, SpeedTestActivity::class.java))
}
......
......@@ -152,4 +152,7 @@
<string name="dialog_servicekilled_message">The app detected that it wasn\'t stopped properly the last time it was active. This strongly indicates that your system chose to force stop the app without any possibility for the app to restart itself.\n\nOn most devices you have a few options to prevent or at least delay the system from stopping the app.\nYou can for example disable battery optimizations for the app in the system settings or avoid clearing the app from the list of recents.\n\nIf you chose to ignore this you won\'t see this dialog again. You can read more and receive tips for solving this with the button below (opens an external website in your browser).</string>
<string name="dialog_servicekilled_more_info">More information</string>
<string name="dialog_overlaydetected_title">System-wide overlay detected</string>
<string name="dialog_overlaydetected_message">There seems to be a system-wide overlay (e.g. a chat bubble, color- or nightfilter) active. Most device don\'t allow you to enable a VPN in this case.\n\nIf you can\'t click OK in the next dialog please disable the overlay.</string>
</resources>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment