allow verification of own omemo keys via uri
This commit is contained in:
parent
fecc34431c
commit
12463911f1
|
@ -194,6 +194,7 @@
|
|||
android:launchMode="singleTop" />
|
||||
<activity
|
||||
android:name=".ui.EditAccountActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
|
|
|
@ -164,16 +164,16 @@ public class FileBackend {
|
|||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + app + "/Backup/";
|
||||
}
|
||||
|
||||
private static Bitmap rotate(Bitmap bitmap, int degree) {
|
||||
private static Bitmap rotate(final Bitmap bitmap, final int degree) {
|
||||
if (degree == 0) {
|
||||
return bitmap;
|
||||
}
|
||||
int w = bitmap.getWidth();
|
||||
int h = bitmap.getHeight();
|
||||
Matrix mtx = new Matrix();
|
||||
mtx.postRotate(degree);
|
||||
Bitmap result = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
final int w = bitmap.getWidth();
|
||||
final int h = bitmap.getHeight();
|
||||
final Matrix matrix = new Matrix();
|
||||
matrix.postRotate(degree);
|
||||
final Bitmap result = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
|
||||
if (!bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -23,11 +23,14 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
|
@ -693,12 +696,18 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
} catch (final IllegalArgumentException | NullPointerException ignored) {
|
||||
this.jidToEdit = null;
|
||||
}
|
||||
if (jidToEdit != null && intent.getData() != null && intent.getBooleanExtra("scanned", false)) {
|
||||
final XmppUri uri = new XmppUri(intent.getData());
|
||||
if (xmppConnectionServiceBound) {
|
||||
processFingerprintVerification(uri, false);
|
||||
final Uri data = intent.getData();
|
||||
final XmppUri xmppUri = data == null ? null : new XmppUri(data);
|
||||
final boolean scanned = intent.getBooleanExtra("scanned", false);
|
||||
if (jidToEdit != null && xmppUri != null && xmppUri.hasFingerprints()) {
|
||||
if (scanned) {
|
||||
if (xmppConnectionServiceBound) {
|
||||
processFingerprintVerification(xmppUri, false);
|
||||
} else {
|
||||
this.pendingUri = xmppUri;
|
||||
}
|
||||
} else {
|
||||
this.pendingUri = uri;
|
||||
displayVerificationWarningDialog(xmppUri);
|
||||
}
|
||||
}
|
||||
boolean init = intent.getBooleanExtra("init", false);
|
||||
|
@ -735,6 +744,28 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
}
|
||||
}
|
||||
|
||||
private void displayVerificationWarningDialog(final XmppUri xmppUri) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.verify_omemo_keys);
|
||||
View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);
|
||||
final CheckBox isTrustedSource = view.findViewById(R.id.trusted_source);
|
||||
TextView warning = view.findViewById(R.id.warning);
|
||||
warning.setText(R.string.verifying_omemo_keys_trusted_source_account);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.continue_btn, (dialog, which) -> {
|
||||
if (isTrustedSource.isChecked()) {
|
||||
processFingerprintVerification(xmppUri, false);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> finish());
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setOnCancelListener(d -> finish());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(final Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -749,7 +780,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
||||
public void onSaveInstanceState(@NonNull final Bundle savedInstanceState) {
|
||||
if (mAccount != null) {
|
||||
savedInstanceState.putString("account", mAccount.getJid().asBareJid().toEscapedString());
|
||||
savedInstanceState.putBoolean("initMode", mInitMode);
|
||||
|
|
|
@ -622,6 +622,8 @@
|
|||
<string name="pref_clean_private_storage_summary">Clean private storage where files are kept (They can be re-downloaded from the server)</string>
|
||||
<string name="i_followed_this_link_from_a_trusted_source">I followed this link from a trusted source</string>
|
||||
<string name="verifying_omemo_keys_trusted_source">You are about to verify the OMEMO keys of %1$s after clicking a link. This is only secure if you followed this link from a trusted source where only %2$s could have published this link.</string>
|
||||
<string name="verifying_omemo_keys_trusted_source_account">You are about to verify the OMEMO keys of your own account. This is only secure if you followed this link from a trusted source where only you could have published this link.</string>
|
||||
<string name="continue_btn">Continue</string>
|
||||
<string name="verify_omemo_keys">Verify OMEMO keys</string>
|
||||
<string name="show_inactive_devices">Show inactive</string>
|
||||
<string name="hide_inactive_devices">Hide inactive</string>
|
||||
|
|
Loading…
Reference in a new issue