Commit dd4fad1a authored by Lucas Liu's avatar Lucas Liu

ParserActivity bug fixes.

parent 49a3cfdc
......@@ -51,7 +51,7 @@
android:theme="@style/PopupTheme"
android:excludeFromRecents="true"
android:taskAffinity=""
android:launchMode="singleInstance">
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
......
......@@ -43,24 +43,38 @@ import android.content.{DialogInterface, Intent}
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.nfc.{NdefMessage, NfcAdapter}
import android.os.Bundle
import android.support.v7.app.{AlertDialog, AppCompatActivity}
import android.text.TextUtils
import android.view.WindowManager
import com.github.shadowsocks.utils.Parser
class ParserActivity extends AppCompatActivity {
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
handledSharedIntent()
}
override def onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
handledSharedIntent()
}
def handledSharedIntent() {
val intent = getIntent()
val sharedStr = intent.getAction match {
case Intent.ACTION_VIEW => intent.getData.toString
case NfcAdapter.ACTION_NDEF_DISCOVERED =>
val rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)
if (rawMsgs != null && rawMsgs.nonEmpty)
new String(rawMsgs(0).asInstanceOf[NdefMessage].getRecords()(0).getPayload) else null
new String(rawMsgs(0).asInstanceOf[NdefMessage].getRecords()(0).getPayload)
else null
case _ => null
}
if (TextUtils.isEmpty(sharedStr)) return
val profiles = Parser.findAll(sharedStr)
val profiles = Parser.findAll(sharedStr).toList
if (profiles.isEmpty) {
finish()
return
......
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