diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt index f3f9ed8..bd50644 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/DnsActivity.kt @@ -57,7 +57,7 @@ class DnsActivity : AppCompatActivity() { addServerButton.setOnClickListener { val view = inflater.inflate(R.layout.dialog_add_dns_server, null) val input = view.findViewById(R.id.addDnsInput) - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.dns_add_server_dialog_title)) builder.setView(view) builder.setPositiveButton(getString(R.string.add)) { _, _ -> @@ -128,7 +128,7 @@ class DnsActivity : AppCompatActivity() { view.findViewById(R.id.deletePeerButton).tag = i view.findViewById(R.id.deletePeerButton).setOnClickListener { button -> - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.dns_remove_title, server)) builder.setPositiveButton(getString(R.string.remove)) { dialog, _ -> servers.removeAt(button.tag as Int) @@ -176,7 +176,7 @@ class DnsActivity : AppCompatActivity() { } } view.setOnLongClickListener { - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.dns_server_info_dialog_title)) builder.setMessage("${infoPair.first}\n\n${infoPair.second}") builder.setPositiveButton(getString(R.string.ok)) { dialog, _ -> diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/GlobalApplication.kt b/app/src/main/java/eu/neilalexander/yggdrasil/GlobalApplication.kt index 49a544b..0431d12 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/GlobalApplication.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/GlobalApplication.kt @@ -11,6 +11,7 @@ import androidx.core.app.NotificationCompat import androidx.preference.PreferenceManager const val PREF_KEY_ENABLED = "enabled" +const val PREF_KEY_PEERS_NOTE = "peers_note" const val MAIN_CHANNEL_ID = "Yggdrasil Service" class GlobalApplication: Application(), YggStateReceiver.StateReceiver { diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt index b672fa9..5597862 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt @@ -1,10 +1,12 @@ package eu.neilalexander.yggdrasil import android.app.Activity +import android.app.AlertDialog import android.content.* import android.graphics.Color import android.net.VpnService import android.os.Bundle +import android.view.ContextThemeWrapper import android.widget.Switch import android.widget.TextView import android.widget.Toast @@ -161,6 +163,7 @@ class MainActivity : AppCompatActivity() { } } enabledLabel.text = if (intent.getBooleanExtra("started", false)) { + showPeersNoteIfNeeded(peerState.length()) if (count == 0) { enabledLabel.setTextColor(Color.RED) getString(R.string.main_no_connectivity) @@ -188,4 +191,26 @@ class MainActivity : AppCompatActivity() { } } } + + private fun showPeersNoteIfNeeded(peerCount: Int) { + if (peerCount > 0) return + val preferences = PreferenceManager.getDefaultSharedPreferences(this@MainActivity.baseContext) + if (!preferences.getBoolean(PREF_KEY_PEERS_NOTE, false)) { + this@MainActivity.runOnUiThread { + val builder: AlertDialog.Builder = + AlertDialog.Builder(ContextThemeWrapper(this@MainActivity, R.style.YggdrasilDialogs)) + builder.setTitle(getString(R.string.main_add_some_peers_title)) + builder.setMessage(getString(R.string.main_add_some_peers_message)) + builder.setPositiveButton(getString(R.string.ok)) { dialog, _ -> + dialog.dismiss() + } + builder.show() + } + // Mark this note as shown + preferences.edit().apply { + putBoolean(PREF_KEY_PEERS_NOTE, true) + commit() + } + } + } } diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt index 1123bd1..70f1b4d 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt @@ -99,7 +99,7 @@ class PeersActivity : AppCompatActivity() { addPeerButton.setOnClickListener { val view = inflater.inflate(R.layout.dialog_addpeer, null) val input = view.findViewById(R.id.addPeerInput) - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.peers_add_peer)) builder.setView(view) builder.setPositiveButton(getString(R.string.peers_add)) { dialog, _ -> @@ -153,7 +153,7 @@ class PeersActivity : AppCompatActivity() { view.findViewById(R.id.deletePeerButton).tag = i view.findViewById(R.id.deletePeerButton).setOnClickListener { button -> - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.peers_remove_title, peer)) builder.setPositiveButton(getString(R.string.peers_remove)) { dialog, _ -> config.updateJSON { json -> diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt index 9bf662a..8e2e3d2 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt @@ -70,7 +70,7 @@ class SettingsActivity : AppCompatActivity() { resetConfigurationRow.setOnClickListener { val view = inflater.inflate(R.layout.dialog_resetconfig, null) - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) builder.setTitle(getString(R.string.settings_warning_title)) builder.setView(view) builder.setPositiveButton(getString(R.string.settings_reset)) { dialog, _ -> @@ -92,7 +92,7 @@ class SettingsActivity : AppCompatActivity() { findViewById(R.id.setKeysRow).setOnClickListener { val view = inflater.inflate(R.layout.dialog_set_keys, null) - val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog)) + val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.YggdrasilDialogs)) val privateKey = view.findViewById(R.id.private_key) builder.setTitle(getString(R.string.set_keys)) builder.setView(view) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ba34ea4..ff467ed 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -29,6 +29,8 @@ Нет пиров 1 пир %d пира/пиров + Внимание + Кажется, вы не добавили ни одного пира. Зайдите в раздел пиров и подключите один из списка публичных, чтобы подключиться к сети. Добавить пира в конфиг Добавить Убрать %s? diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4f74376..2c8e64a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,6 +5,7 @@ #FF3700B3 #FF03DAC5 #FF018786 + #5FBF9F #FF000000 #FFFFFFFF #F2F1F5 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f886f02..1bf73ec 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -29,6 +29,8 @@ No peers 1 peer %d peers + Note + It seems that you didn\'t configure any peers. Go to peers section and add one from public list to get connected. Add Configured Peer Add Remove %s? diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index ece6c2c..e48c592 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -18,4 +18,8 @@ @color/white @color/black + + \ No newline at end of file