Skip to content

Commit de6cf9d

Browse files
madeyekaneawk
authored andcommitted
Fix #982
# Conflicts: # src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala
1 parent 1c3b3c2 commit de6cf9d

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Diff for: src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala

+1-10
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
295295
case R.id.fab_qrcode_add =>
296296
menu.toggle(false)
297297
val intent = new Intent(this, classOf[ScannerActivity])
298-
startActivityForResult(intent, REQUEST_QRCODE)
298+
startActivity(intent)
299299
case R.id.fab_nfc_add =>
300300
menu.toggle(true)
301301
val dialog = new AlertDialog.Builder(ProfileManagerActivity.this)
@@ -389,15 +389,6 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
389389
super.onDestroy
390390
}
391391

392-
override def onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
393-
if (requestCode == REQUEST_QRCODE && resultCode == Activity.RESULT_OK) {
394-
val contents = data.getStringExtra("uri")
395-
if (!TextUtils.isEmpty(contents))
396-
Parser.findAll_ssr(contents).foreach(app.profileManager.createProfile)
397-
Parser.findAll(contents).foreach(app.profileManager.createProfile)
398-
}
399-
}
400-
401392
override def onBackPressed() {
402393
if (menu.isOpened) menu.close(true) else super.onBackPressed()
403394
}

Diff for: src/main/scala/com/github/shadowsocks/ScannerActivity.scala

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import android.support.v4.app.ActivityCompat
88
import android.support.v4.content.ContextCompat
99
import android.support.v7.app.AppCompatActivity
1010
import android.support.v7.widget.Toolbar
11+
import android.text.TextUtils
1112
import android.widget.Toast
1213
import com.google.zxing.Result
14+
import com.github.shadowsocks.ShadowsocksApplication.app
15+
import com.github.shadowsocks.utils.Parser
1316
import me.dm7.barcodescanner.zxing.ZXingScannerView
1417

1518
object ScannerActivity {
@@ -73,9 +76,10 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
7376
}
7477

7578
override def handleResult(rawResult: Result) = {
76-
val intent = new Intent()
77-
intent.putExtra("uri", rawResult.getText)
78-
setResult(Activity.RESULT_OK, intent)
79+
val uri = rawResult.getText
80+
if (!TextUtils.isEmpty(uri))
81+
Parser.findAll(uri).foreach(app.profileManager.createProfile)
82+
Parser.findAll_ssr(uri).foreach(app.profileManager.createProfile)
7983
navigateUp()
8084
}
8185
}

0 commit comments

Comments
 (0)