Renamed KeyServers to KeyAddresses, properly use defaults.

This commit is contained in:
Felix Ableitner 2016-04-07 20:39:22 +02:00
parent b3212bf3f4
commit 97e70c2092
5 changed files with 8 additions and 9 deletions

View file

@ -74,7 +74,7 @@ class FirstStartActivity extends AppCompatActivity with OnEditorActionListener w
.putBoolean(KeyNotificationSoundsOn, DefaultNotificationSoundsOn)
.putString(KeyScanInterval, DefaultScanInterval.toString)
.putString(KeyMaxConnections, DefaultMaxConnections.toString)
.putString(KeyServers, DefaultServers)
.putString(KeyAddresses, DefaultAddresses)
.apply()
startMainActivity()

View file

@ -53,7 +53,7 @@ class SettingsFragment extends PreferenceFragment with OnSharedPreferenceChangeL
case KeyUserName | KeyUserStatus =>
val ui = new UserInfo(prefs.getString(KeyUserName, ""), prefs.getString(KeyUserStatus, ""))
activity.database.get.getContacts.foreach(c => activity.service.get.sendTo(c.address, ui))
case KeyServers =>
case KeyAddresses =>
val intent = new Intent(getActivity, classOf[ChatService])
intent.setAction(ChatService.ActionNetworkChanged)
getActivity.startService(intent)

View file

@ -19,14 +19,14 @@ object SettingsInterface {
/**
* NOTE: Stored as comma separated string.
*/
val KeyServers = "servers"
val KeyAddresses = "servers"
val DefaultUserStatus = "Let's chat!"
val DefaultScanInterval = 15
val DefaultNotificationSoundsOn = true
val DefaultMaxConnections = 1000000
// When updating this, be sure to adjust the code in [[InternetInterface.create]].
val DefaultServers = Set("ensichat.nutomic.com:26344").mkString(", ")
val DefaultAddresses = Set("ensichat.nutomic.com:26344").mkString(", ")
}

View file

@ -39,9 +39,9 @@ class InternetInterface(connectionHandler: ConnectionHandler, crypto: Crypto,
* Initializes and starts discovery and listening.
*/
override def create(): Unit = {
val servers = settings.get(SettingsInterface.KeyServers, "")
.replace("46.101.249.188:26344", SettingsInterface.DefaultServers)
settings.put(SettingsInterface.KeyServers, servers)
val servers = settings.get(SettingsInterface.KeyAddresses, SettingsInterface.DefaultAddresses)
.replace("46.101.249.188:26344", SettingsInterface.DefaultAddresses)
settings.put(SettingsInterface.KeyAddresses, servers)
FutureHelper {
serverThread.start()
@ -58,7 +58,7 @@ class InternetInterface(connectionHandler: ConnectionHandler, crypto: Crypto,
}
private def openAllConnections(maxConnections: Int): Unit = {
val addresses = settings.get(SettingsInterface.KeyServers, "")
val addresses = settings.get(SettingsInterface.KeyAddresses, SettingsInterface.DefaultAddresses)
.split(",")
.map(_.trim())

View file

@ -40,7 +40,6 @@ object Main extends App with CallbackInterface {
KeyFolder.mkdirs()
Log.setLogInstance(logInstance)
sys.addShutdownHook(connectionHandler.stop())
settings.put(KeyServers, DefaultServers)
val parser = new OptionParser[Config]("ensichat") {
head("ensichat")