Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Oct 22, 2024
2 parents 12ad3da + eaa6981 commit 91f8ce7
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,15 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
break;

case IntentIntegrator.REQUEST_CODE:
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanResult != null && scanResult.getFormatName() != null) {
setProviderFromQr(scanResult.getContents());
String qrRaw = data.getStringExtra(RegistrationQrActivity.QRDATA_EXTRA);
if (qrRaw == null) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanResult != null && scanResult.getFormatName() != null) {
qrRaw = scanResult.getContents();
}
}
if (qrRaw != null) {
setProviderFromQr(qrRaw);
}
break;
}
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/org/thoughtcrime/securesms/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,29 @@ else if (progress==1000/*done*/) {
@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(requestCode, resultCode, data);
if (scanResult == null || scanResult.getFormatName() == null) {
return; // aborted
String qrRaw = data.getStringExtra(RegistrationQrActivity.QRDATA_EXTRA);
if (qrRaw == null) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanResult == null || scanResult.getFormatName() == null) {
return; // aborted
}
qrRaw = scanResult.getContents();
}
String qrRaw = scanResult.getContents();
DcLot qrParsed = dcContext.checkQr(qrRaw);
switch (qrParsed.getState()) {
case DcContext.DC_QR_BACKUP:
case DcContext.DC_QR_BACKUP2:
new AlertDialog.Builder(this)
final String finalQrRaw = qrRaw;
new AlertDialog.Builder(this)
.setTitle(R.string.multidevice_receiver_title)
.setMessage(R.string.multidevice_receiver_scanning_ask)
.setPositiveButton(R.string.perm_continue, (dialog, which) -> startBackupTransfer(qrRaw))
.setPositiveButton(R.string.perm_continue, (dialog, which) -> startBackupTransfer(finalQrRaw))
.setNegativeButton(R.string.cancel, null)
.setCancelable(false)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void handleQrData(String rawString) {
break;

case DcContext.DC_QR_BACKUP:
case DcContext.DC_QR_BACKUP2:
builder.setTitle(R.string.multidevice_receiver_title);
builder.setMessage(activity.getString(R.string.multidevice_receiver_scanning_ask) + "\n\n" + activity.getString(R.string.multidevice_same_network_hint));
builder.setPositiveButton(R.string.perm_continue, (dialog, which) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.util.Util;

public class RegistrationQrActivity extends BaseActionBarActivity {

public static final String ADD_AS_SECOND_DEVICE_EXTRA = "add_as_second_device";
public static final String QRDATA_EXTRA = "qrdata";

private CaptureManager capture;

Expand Down Expand Up @@ -82,6 +84,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.troubleshooting:
DcHelper.openHelp(this, "#multiclient");
return true;
case R.id.menu_paste:
Intent intent = new Intent();
intent.putExtra(QRDATA_EXTRA, Util.getTextFromClipboard(this));
setResult(Activity.RESULT_OK, intent);
finish();
return true;
}

return false;
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/menu/registration_qr_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:title="@string/paste_from_clipboard"
android:id="@+id/menu_paste"
app:showAsAction="never"/>

<item android:title="@string/troubleshooting"
android:id="@+id/troubleshooting"
android:visible="false"
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
<item quantity="one">%d Nachricht</item>
<item quantity="other">%d Nachrichten</item>
</plurals>
<plurals name="n_reactions">
<item quantity="one">%d Reaktion</item>
<item quantity="other">%d Reaktionen</item>
</plurals>
<plurals name="n_members">
<item quantity="one">%d Mitglied</item>
<item quantity="other">%d Mitglieder</item>
Expand Down
Loading

0 comments on commit 91f8ce7

Please sign in to comment.