Commit 8b0b39cb authored by Max Lv's avatar Max Lv

fix #444

parent be8bc523
......@@ -25,13 +25,13 @@
<com.github.shadowsocks.preferences.NumberPickerPreference
app:min="1"
app:max="65535"
android:key="remotePort"
android:key="remotePortNum"
app:summary="@string/remote_port_summary"
android:title="@string/remote_port"/>
<com.github.shadowsocks.preferences.NumberPickerPreference
app:min="1025"
app:max="65535"
android:key="port"
android:key="localPortNum"
app:summary="@string/port_summary"
android:title="@string/port"/>
<com.github.shadowsocks.preferences.PasswordEditTextPreference
......
......@@ -166,6 +166,20 @@ class Shadowsocks
if (!ShadowsocksApplication.settings.getBoolean(ShadowsocksApplication.getVersionName, false)) {
ShadowsocksApplication.settings.edit.putBoolean(ShadowsocksApplication.getVersionName, true).apply()
recovery()
// Workaround that convert port(String) to port(Int)
val oldLocalPort = ShadowsocksApplication.settings.getString("port", "-1")
val oldRemotePort = ShadowsocksApplication.settings.getString("remotePort", "-1")
try {
if (oldLocalPort != "-1") {
ShadowsocksApplication.settings.edit.putInt(Key.localPort, oldLocalPort.toInt).commit()
}
if (oldRemotePort != "-1") {
ShadowsocksApplication.settings.edit.putInt(Key.remotePort, oldRemotePort.toInt).commit()
}
} catch {
case ex: Exception => // Ignore
}
}
}
......
......@@ -81,19 +81,22 @@ class DBHelper(val context: Context)
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN ipv6 SMALLINT;")
}
if (oldVersion < 12) {
profileDao.executeRawNoArgs("BEGIN TRANSACTION;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` RENAME TO `tmp`;")
onCreate(database, connectionSource)
TableUtils.createTable(connectionSource, classOf[Profile])
profileDao.executeRawNoArgs(
"INSERT INTO `profile`(id, name, host, localPort, remotePort, password, method, route, proxyApps, bypass," +
" udpdns, auth, ipv6, individual) " +
"SELECT id, name, host, localPort, remotePort, password, method, route, 1 - global, bypass, udpdns, auth," +
" ipv6, individual FROM `tmp`;")
profileDao.executeRawNoArgs("DROP TABLE `tmp`;")
profileDao.executeRawNoArgs("COMMIT;")
return
}
if (oldVersion < 13) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN tx LONG;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN rx LONG;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN date DATE;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN date VARCHAR;")
}
}
}
......
......@@ -82,8 +82,8 @@ object Key {
val proxy = "proxy"
val sitekey = "sitekey"
val encMethod = "encMethod"
val remotePort = "remotePort"
val localPort = "port"
val remotePort = "remotePortNum"
val localPort = "localPortNum"
}
object Scheme {
......
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