From ee81f4e902824a5da3413a9f22213528e2e260c8 Mon Sep 17 00:00:00 2001 From: Revertron <105154+Revertron@users.noreply.github.com> Date: Wed, 16 Nov 2022 22:08:28 +0100 Subject: [PATCH] UI fixes, DNS infos. (#31) --- .../eu/neilalexander/yggdrasil/DnsActivity.kt | 25 ++++-- .../neilalexander/yggdrasil/MainActivity.kt | 5 ++ .../neilalexander/yggdrasil/PeersActivity.kt | 9 ++ app/src/main/res/layout/activity_dns.xml | 9 +- app/src/main/res/layout/activity_main.xml | 88 +++---------------- app/src/main/res/layout/activity_peers.xml | 21 +---- app/src/main/res/layout/activity_settings.xml | 14 +-- app/src/main/res/layout/dns_server_usable.xml | 23 ++--- app/src/main/res/layout/peers_configured.xml | 26 +++--- app/src/main/res/values-ru/strings.xml | 4 + app/src/main/res/values/strings.xml | 4 + app/src/main/res/values/styles.xml | 23 +++++ 12 files changed, 103 insertions(+), 148 deletions(-) create mode 100644 app/src/main/res/values/styles.xml diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt index 8b2b5e7..6262d7b 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt @@ -13,7 +13,6 @@ import com.google.android.material.textfield.TextInputEditText const val KEY_DNS_SERVERS = "dns_servers" const val KEY_ENABLE_CHROME_FIX = "enable_chrome_fix" -const val DEFAULT_DNS_SERVERS = "302:7991::53,302:db60::53,300:6223::53,301:1088::53" class DnsActivity : AppCompatActivity() { private lateinit var config: ConfigurationProxy @@ -28,6 +27,8 @@ class DnsActivity : AppCompatActivity() { private lateinit var servers: MutableList private lateinit var preferences: SharedPreferences + private lateinit var defaultDnsServers: HashMap> + @SuppressLint("ApplySharedPref") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -36,6 +37,15 @@ class DnsActivity : AppCompatActivity() { config = ConfigurationProxy(applicationContext) inflater = LayoutInflater.from(this) + val descriptionRevertron = getString(R.string.dns_server_info_revertron) + // Here we can add some other DNS servers in a future + defaultDnsServers = hashMapOf( + "302:7991::53" to Pair(getString(R.string.location_amsterdam), descriptionRevertron), + "302:db60::53" to Pair(getString(R.string.location_prague), descriptionRevertron), + "300:6223::53" to Pair(getString(R.string.location_bratislava), descriptionRevertron), + "301:1088::53" to Pair(getString(R.string.location_buffalo), descriptionRevertron), + ) + serversTableLayout = findViewById(R.id.configuredDnsTableLayout) serversTableLabel = findViewById(R.id.configuredDnsLabel) serversTableHint = findViewById(R.id.configuredDnsHint) @@ -70,6 +80,11 @@ class DnsActivity : AppCompatActivity() { } } + val enableChromeFixPanel = findViewById(R.id.enableChromeFixPanel) + enableChromeFixPanel.setOnClickListener { + enableChromeFix.toggle() + } + preferences = androidx.preference.PreferenceManager.getDefaultSharedPreferences(this.baseContext) val serverString = preferences.getString(KEY_DNS_SERVERS, "") servers = if (serverString!!.isNotEmpty()) { @@ -132,10 +147,10 @@ class DnsActivity : AppCompatActivity() { @SuppressLint("ApplySharedPref") private fun updateUsableServers() { val usableTableLayout: TableLayout = findViewById(R.id.usableDnsTableLayout) - val defaultServers = DEFAULT_DNS_SERVERS.split(",") - defaultServers.forEach { - val server = it + defaultDnsServers.forEach { + val server = it.key + val infoPair = it.value val view = inflater.inflate(R.layout.dns_server_usable, null) view.findViewById(R.id.serverValue).text = server val addButton = view.findViewById(R.id.addButton) @@ -152,7 +167,7 @@ class DnsActivity : AppCompatActivity() { view.setOnLongClickListener { val builder: AlertDialog.Builder = AlertDialog.Builder(this) builder.setTitle(getString(R.string.dns_server_info_dialog_title)) - builder.setMessage(getText(R.string.dns_server_info_revertron)) + builder.setMessage("${infoPair.first}\n\n${infoPair.second}") builder.setPositiveButton(getString(R.string.ok)) { dialog, _ -> dialog.dismiss() } diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt index d33d4ac..613d254 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt @@ -78,6 +78,11 @@ class MainActivity : AppCompatActivity() { } } + val enableYggdrasilPanel = findViewById(R.id.enableYggdrasilPanel) + enableYggdrasilPanel.setOnClickListener { + enabledSwitch.toggle() + } + peersRow.isClickable = true peersRow.setOnClickListener { val intent = Intent(this, PeersActivity::class.java) diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt index 5664fdc..2f5acce 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt @@ -54,6 +54,15 @@ class PeersActivity : AppCompatActivity() { multicastListenSwitch.isChecked = config.multicastListen multicastBeaconSwitch.isChecked = config.multicastBeacon + val multicastBeaconPanel = findViewById(R.id.enableMulticastBeaconPanel) + multicastBeaconPanel.setOnClickListener { + multicastBeaconSwitch.toggle() + } + val multicastListenPanel = findViewById(R.id.enableMulticastListenPanel) + multicastListenPanel.setOnClickListener { + multicastListenSwitch.toggle() + } + addPeerButton = findViewById(R.id.addPeerButton) addPeerButton.setOnClickListener { val view = inflater.inflate(R.layout.dialog_addpeer, null) diff --git a/app/src/main/res/layout/activity_dns.xml b/app/src/main/res/layout/activity_dns.xml index 132f2a0..eb00e02 100644 --- a/app/src/main/res/layout/activity_dns.xml +++ b/app/src/main/res/layout/activity_dns.xml @@ -194,13 +194,8 @@ android:showDividers="middle"> + android:id="@+id/enableChromeFixPanel" + style="@style/SelectableSwitchItemStyle"> + android:id="@+id/enableYggdrasilPanel" + style="@style/SelectableSwitchItemStyle"> - + @@ -160,15 +148,7 @@ android:paddingBottom="2pt" android:showDividers="middle"> - + - + - + + style="@style/SelectableItemStyle"> + style="@style/SelectableItemStyle"> + style="@style/SelectableItemStyle"> - + + android:id="@+id/enableMulticastBeaconPanel" + style="@style/SelectableSwitchItemStyle"> + android:id="@+id/enableMulticastListenPanel" + style="@style/SelectableSwitchItemStyle"> - + + style="@style/SelectableItemStyle"> - - + app:layout_constraintTop_toTopOf="parent" /> - - - + app:layout_constraintTop_toTopOf="parent" /> Ваш публичный ключ идентифицирует вас в сети. Его распространение безопасно. Сбросить настройки Сброс создаст полностью новые настройки. Это изменит ваш публичный ключ и адрес IP. + Амстердам, Нидерланды + Прага, Чехия + Братислава, Словакия + Баффало, США \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b169d7..109b144 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,4 +65,8 @@ Your public key forms your identity on the network. It is safe to be shared. Reset configuration Resetting will overwrite with newly generated configuration. Your public keys and IP address on the network will change. + Amsterdam, NL + Prague, CZ + Bratislava, SK + Buffalo, US \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..a5123f8 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file