Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0542d913f2 | ||
|
|
746254bb7e |
@@ -37,6 +37,7 @@ import java.lang.ref.SoftReference
|
||||
import android.os.Build
|
||||
import android.annotation.TargetApi
|
||||
import android.util.Log
|
||||
import go.Seq
|
||||
import org.jetbrains.anko.doAsync
|
||||
|
||||
class V2RayVpnService : VpnService() {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.v2ray.ang.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextUtils
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.google.gson.Gson
|
||||
import com.v2ray.ang.AppConfig
|
||||
import com.v2ray.ang.R
|
||||
import com.v2ray.ang.extension.defaultDPreference
|
||||
@@ -12,6 +14,7 @@ import com.v2ray.ang.util.AngConfigManager
|
||||
import com.v2ray.ang.util.Utils
|
||||
import kotlinx.android.synthetic.main.activity_server2.*
|
||||
import org.jetbrains.anko.*
|
||||
import java.lang.Exception
|
||||
|
||||
|
||||
class Server2Activity : BaseActivity() {
|
||||
@@ -50,7 +53,7 @@ class Server2Activity : BaseActivity() {
|
||||
*/
|
||||
fun bindingServer(vmess: AngConfig.VmessBean): Boolean {
|
||||
et_remarks.text = Utils.getEditable(vmess.remarks)
|
||||
tv_content.text = defaultDPreference.getPrefString(AppConfig.ANG_CONFIG + edit_guid, "")
|
||||
tv_content.text = Editable.Factory.getInstance().newEditable(defaultDPreference.getPrefString(AppConfig.ANG_CONFIG + edit_guid, ""))
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -66,21 +69,40 @@ class Server2Activity : BaseActivity() {
|
||||
* save server config
|
||||
*/
|
||||
fun saveServer(): Boolean {
|
||||
var saveSuccess: Boolean
|
||||
val vmess = configs.vmess[edit_index]
|
||||
|
||||
vmess.remarks = et_remarks.text.toString()
|
||||
|
||||
if (TextUtils.isEmpty(vmess.remarks)) {
|
||||
toast(R.string.server_lab_remarks)
|
||||
return false
|
||||
saveSuccess = false
|
||||
}
|
||||
|
||||
|
||||
if (AngConfigManager.addCustomServer(vmess, edit_index) == 0) {
|
||||
toast(R.string.toast_success)
|
||||
saveSuccess = true
|
||||
} else {
|
||||
toast(R.string.toast_failure)
|
||||
saveSuccess = false
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Gson().fromJson<Object>(tv_content.text.toString(), Object::class.java)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toast(R.string.toast_malformed_josn)
|
||||
saveSuccess = false
|
||||
}
|
||||
|
||||
if (saveSuccess) {
|
||||
//update config
|
||||
defaultDPreference.setPrefString(AppConfig.ANG_CONFIG + edit_guid, tv_content.text.toString())
|
||||
finish()
|
||||
return true
|
||||
} else {
|
||||
toast(R.string.toast_failure)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,20 +68,15 @@
|
||||
android:text="@string/server_lab_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
||||
|
||||
<TextView
|
||||
<EditText
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/layout_margin_top_height"
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/layout_margin_top_height"
|
||||
android:layout_marginBottom="@dimen/layout_margin_top_height"
|
||||
android:orientation="vertical" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
@@ -184,5 +184,6 @@
|
||||
<string name="summary_pref_proxy_sharing_enabled">绑定代理入口ip到0.0.0.0</string>
|
||||
<string name="toast_warning_pref_proxysharing">其他设备可以使用socks/http协议通过您的IP地址连接到代理\nHttp 代理: http://您的ip:10809\nSocks 代理: socks(4/5)://您的ip:10808\n仅在受信任的网络中启用以避免未经授权的连接</string>
|
||||
<string name="toast_warning_pref_proxysharing_short">代理共享已启用,请确保处于受信网络</string>
|
||||
<string name="toast_malformed_josn">配置格式错误</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -186,4 +186,5 @@
|
||||
<string name="summary_pref_proxy_sharing_enabled">綁定代理入口ip到0.0.0.0</string>
|
||||
<string name="toast_warning_pref_proxysharing">其他設備可以使用socks/http協議通過您的IP地址連接到代理\nHttp 代理: http://您的ip:10809\nSocks 代理: socks(4/5)://您的ip:10808\n僅在受信任的網絡中啟用以避免未經授權的連接</string>
|
||||
<string name="toast_warning_pref_proxysharing_short">代理共享已啟用,請確保處於受信網絡</string>
|
||||
<string name="toast_malformed_josn">配置格式錯誤</string>
|
||||
</resources>
|
||||
|
||||
@@ -185,5 +185,6 @@
|
||||
<string name="summary_pref_proxy_sharing_enabled">Bind inbound to 0.0.0.0</string>
|
||||
<string name="toast_warning_pref_proxysharing">Other devices can connect to proxy by your ip address through socks/http protocol\nHttp Proxy: http://yourIP:10809\nSocks Proxy: socks(4/5)://yourIP:10808\nOnly enable in trusted network to avoid unauthorized connection</string>
|
||||
<string name="toast_warning_pref_proxysharing_short">Proxy sharing enabled\nMake sure you are in a trusted network</string>
|
||||
<string name="toast_malformed_josn">Config malformed</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user