Commit 334cd5ea authored by Mygod's avatar Mygod

Fix issues with keeping compatibility with old databases

parent 94fad237
......@@ -148,7 +148,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
}
text1.text = item.formattedName
val t2 = ArrayList<String>()
if (item.name.isNotEmpty()) t2 += item.formattedAddress
if (!item.name.isNullOrEmpty()) t2 += item.formattedAddress
val id = PluginConfiguration(item.plugin ?: "").selected
if (id.isNotEmpty()) t2 += app.getString(R.string.profile_plugin, id)
if (t2.isEmpty()) text2.visibility = View.GONE else {
......
......@@ -34,7 +34,7 @@ class ProxyService : Service(), BaseService.Interface {
override val tag: String get() = "ShadowsocksProxyService"
override fun createNotification(): ServiceNotification =
ServiceNotification(this, data.profile!!.name, "service-proxy", true)
ServiceNotification(this, data.profile!!.formattedName, "service-proxy", true)
override fun onBind(intent: Intent): IBinder? = super.onBind(intent)
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int =
......
......@@ -33,7 +33,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
override val tag: String get() = "ShadowsocksTransproxyService"
override fun createNotification(): ServiceNotification =
ServiceNotification(this, data.profile!!.name, "service-transproxy", true)
ServiceNotification(this, data.profile!!.formattedName, "service-transproxy", true)
override fun onBind(intent: Intent): IBinder? = super.onBind(intent)
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int =
......
......@@ -77,7 +77,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
override val tag: String get() = "ShadowsocksVpnService"
override fun createNotification(): ServiceNotification =
ServiceNotification(this, data.profile!!.name, "service-vpn")
ServiceNotification(this, data.profile!!.formattedName, "service-vpn")
private var conn: ParcelFileDescriptor? = null
private var worker: ProtectWorker? = null
......
......@@ -84,7 +84,7 @@ class Profile {
var id: Int = 0
@DatabaseField
var name: String = ""
var name: String? = ""
@DatabaseField
var host: String = "198.199.101.152"
......@@ -135,7 +135,7 @@ class Profile {
var plugin: String? = null
val formattedAddress get() = (if (host.contains(":")) "[%s]:%d" else "%s:%d").format(host, remotePort)
val formattedName get() = if (name.isEmpty()) formattedAddress else name
val formattedName get() = if (name.isNullOrEmpty()) formattedAddress else name!!
fun toUri(): Uri {
val builder = Uri.Builder()
......@@ -147,7 +147,7 @@ class Profile {
val configuration = PluginConfiguration(plugin ?: "")
if (configuration.selected.isNotEmpty())
builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false))
if (name.isNotEmpty()) builder.fragment(name)
if (!name.isNullOrEmpty()) builder.fragment(name)
return builder.build()
}
override fun toString() = toUri().toString()
......
Markdown is supported
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