mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
tweak ConversationListActivity and RelayListActivity
don't relay in onActivityResult
This commit is contained in:
@@ -114,6 +114,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
/** used to store temporarily scanned QR to pass it back to QrCodeHandler when ScreenLockUtil is used */
|
||||
private String qrData = null;
|
||||
private ActivityResultLauncher<Intent> relayLockLauncher;
|
||||
private ActivityResultLauncher<Intent> qrScannerLauncher;
|
||||
|
||||
/** used to store temporarily profile ID to delete after authorization is granted via ScreenLockUtil */
|
||||
private int deleteProfileId = 0;
|
||||
@@ -151,6 +152,16 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
}
|
||||
}
|
||||
);
|
||||
qrScannerLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(result.getResultCode(), result.getData());
|
||||
qrData = scanResult.getContents();
|
||||
new QrCodeHandler(this).handleQrData(qrData, SecurejoinSource.Scan, SecurejoinUiPath.QrIcon, relayLockLauncher);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
addDeviceMessages(getIntent().getBooleanExtra(FROM_WELCOME, false));
|
||||
if (getIntent().getIntExtra(ACCOUNT_ID_EXTRA, -1) <= 0) {
|
||||
@@ -480,7 +491,10 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
startActivity(new Intent(this, ApplicationPreferencesActivity.class));
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_qr) {
|
||||
new IntentIntegrator(this).setCaptureActivity(QrActivity.class).initiateScan();
|
||||
Intent intent = new IntentIntegrator(this)
|
||||
.setCaptureActivity(QrActivity.class)
|
||||
.createScanIntent();
|
||||
qrScannerLauncher.launch(intent);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_global_map) {
|
||||
WebxdcActivity.openMaps(this, 0);
|
||||
@@ -684,18 +698,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
refreshTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode != RESULT_OK) return;
|
||||
|
||||
if (requestCode == IntentIntegrator.REQUEST_CODE) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(resultCode, data);
|
||||
qrData = scanResult.getContents();
|
||||
new QrCodeHandler(this).handleQrData(qrData, SecurejoinSource.Scan, SecurejoinUiPath.QrIcon, relayLockLauncher);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
||||
|
||||
@@ -51,6 +51,7 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
/** QR provided via Intent extras needs to be saved to pass it to QrCodeHandler when authorization finishes */
|
||||
private String qrData = null;
|
||||
private ActivityResultLauncher<Intent> screenLockLauncher;
|
||||
private ActivityResultLauncher<Intent> qrScannerLauncher;
|
||||
|
||||
/** Relay selected for context menu via onRelayLongClick() */
|
||||
private EnteredLoginParam contextMenuRelay = null;
|
||||
@@ -60,6 +61,15 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_relay_list);
|
||||
|
||||
qrScannerLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(result.getResultCode(), result.getData());
|
||||
new QrCodeHandler(this).handleOnlyAddRelayQr(scanResult.getContents(), null);
|
||||
}
|
||||
}
|
||||
);
|
||||
screenLockLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
@@ -103,7 +113,11 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
}
|
||||
|
||||
fabAdd.setOnClickListener(v -> {
|
||||
new IntentIntegrator(this).setCaptureActivity(QrActivity.class).addExtra(QrActivity.EXTRA_SCAN_RELAY, true).initiateScan();
|
||||
Intent intent = new IntentIntegrator(this)
|
||||
.setCaptureActivity(QrActivity.class)
|
||||
.addExtra(QrActivity.EXTRA_SCAN_RELAY, true)
|
||||
.createScanIntent();
|
||||
qrScannerLauncher.launch(intent);
|
||||
});
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
@@ -239,15 +253,6 @@ public class RelayListActivity extends BaseActionBarActivity
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && requestCode == IntentIntegrator.REQUEST_CODE) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(resultCode, data);
|
||||
new QrCodeHandler(this).handleOnlyAddRelayQr(scanResult.getContents(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(@NonNull DcEvent event) {
|
||||
int eventId = event.getId();
|
||||
|
||||
Reference in New Issue
Block a user