mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-28 06:05:08 +03:00
* Fixes #30, added quick settings icon. * Added saving of enabled state, added some fixes and refactorings. * Fixed a bug with turning on/off the VPN. * Fixed possibility to add duplicate servers in DNS settings.
This commit is contained in:
parent
ee81f4e902
commit
aa94ccad26
12 changed files with 441 additions and 60 deletions
|
@ -11,7 +11,9 @@ import android.widget.TextView
|
|||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.edit
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.preference.PreferenceManager
|
||||
import eu.neilalexander.yggdrasil.PacketTunnelProvider.Companion.STATE_INTENT
|
||||
import mobile.Mobile
|
||||
import org.json.JSONArray
|
||||
|
@ -76,6 +78,8 @@ class MainActivity : AppCompatActivity() {
|
|||
startService(intent)
|
||||
}
|
||||
}
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this.baseContext)
|
||||
preferences.edit(commit = true) { putBoolean(PREF_KEY_ENABLED, isChecked) }
|
||||
}
|
||||
|
||||
val enableYggdrasilPanel = findViewById<TableRow>(R.id.enableYggdrasilPanel)
|
||||
|
@ -123,7 +127,8 @@ class MainActivity : AppCompatActivity() {
|
|||
LocalBroadcastManager.getInstance(this).registerReceiver(
|
||||
receiver, IntentFilter(STATE_INTENT)
|
||||
)
|
||||
val preferences = androidx.preference.PreferenceManager.getDefaultSharedPreferences(this.baseContext)
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this.baseContext)
|
||||
enabledSwitch.isChecked = preferences.getBoolean(PREF_KEY_ENABLED, false)
|
||||
val serverString = preferences.getString(KEY_DNS_SERVERS, "")
|
||||
if (serverString!!.isNotEmpty()) {
|
||||
val servers = serverString.split(",")
|
||||
|
@ -149,7 +154,6 @@ class MainActivity : AppCompatActivity() {
|
|||
when (intent.getStringExtra("type")) {
|
||||
"state" -> {
|
||||
enabledLabel.text = if (intent.getBooleanExtra("started", false)) {
|
||||
enabledSwitch.isChecked = true
|
||||
var count = 0
|
||||
if (intent.hasExtra("dht")) {
|
||||
val dht = intent.getStringExtra("dht")
|
||||
|
@ -166,7 +170,6 @@ class MainActivity : AppCompatActivity() {
|
|||
getString(R.string.main_enabled)
|
||||
}
|
||||
} else {
|
||||
enabledSwitch.isChecked = false
|
||||
enabledLabel.setTextColor(Color.GRAY)
|
||||
getString(R.string.main_disabled)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue