Fix #982
This commit is contained in:
@@ -295,7 +295,7 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
|
||||
case R.id.fab_qrcode_add =>
|
||||
menu.toggle(false)
|
||||
val intent = new Intent(this, classOf[ScannerActivity])
|
||||
startActivityForResult(intent, REQUEST_QRCODE)
|
||||
startActivity(intent)
|
||||
case R.id.fab_nfc_add =>
|
||||
menu.toggle(true)
|
||||
val dialog = new AlertDialog.Builder(ProfileManagerActivity.this)
|
||||
@@ -385,14 +385,6 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
|
||||
super.onDestroy
|
||||
}
|
||||
|
||||
override def onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
|
||||
if (requestCode == REQUEST_QRCODE && resultCode == Activity.RESULT_OK) {
|
||||
val contents = data.getStringExtra("uri")
|
||||
if (!TextUtils.isEmpty(contents))
|
||||
Parser.findAll(contents).foreach(app.profileManager.createProfile)
|
||||
}
|
||||
}
|
||||
|
||||
override def onBackPressed() {
|
||||
if (menu.isOpened) menu.close(true) else super.onBackPressed()
|
||||
}
|
||||
|
||||
@@ -8,8 +8,11 @@ import android.support.v4.app.ActivityCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.text.TextUtils
|
||||
import android.widget.Toast
|
||||
import com.google.zxing.Result
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.github.shadowsocks.utils.Parser
|
||||
import me.dm7.barcodescanner.zxing.ZXingScannerView
|
||||
|
||||
object ScannerActivity {
|
||||
@@ -73,9 +76,9 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
|
||||
}
|
||||
|
||||
override def handleResult(rawResult: Result) = {
|
||||
val intent = new Intent()
|
||||
intent.putExtra("uri", rawResult.getText)
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
val uri = rawResult.getText
|
||||
if (!TextUtils.isEmpty(uri))
|
||||
Parser.findAll(uri).foreach(app.profileManager.createProfile)
|
||||
navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user