add intent filter for shadowsocks URI #51

This commit is contained in:
Max Lv
2013-12-01 14:56:15 +08:00
parent 1907ac2fef
commit 9511a616e9
10 changed files with 203 additions and 79 deletions
@@ -30,7 +30,7 @@ object Key {
object Scheme {
val APP = "app://"
val PROFILE = "profile://"
val SHADOW = "shadow:"
val SS = "ss"
}
object State {
@@ -4,14 +4,14 @@ import com.github.shadowsocks.database.Profile
import android.net.Uri
import android.util.{Log, Base64}
object ShadowParser {
object Parser {
val TAG = "ShadowParser"
def parse (data: String): Option[Profile] = {
try {
Log.d(TAG, data)
val uri = Uri.parse(data.trim)
if (uri.isOpaque && uri.getScheme == "shadow") {
val encoded = data.replace("shadow:", "")
if (uri.isOpaque && uri.getScheme == Scheme.SS) {
val encoded = data.replace(Scheme.SS + ":", "")
val content = new String(Base64.decode(encoded, Base64.NO_PADDING), "UTF-8")
val info = content.split('@')
val encinfo = info(0).split(':')