in lack of confirm source dialog in account details only trust scanned uris

This commit is contained in:
Daniel Gultsch 2018-03-23 11:39:36 +01:00
parent ce867758d5
commit c41f574b1f
2 changed files with 19 additions and 21 deletions

View File

@ -3,7 +3,6 @@ package eu.siacs.conversations.ui;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -29,7 +28,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText; import android.widget.EditText;
@ -38,7 +36,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TableLayout; import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -67,7 +64,6 @@ import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.ui.adapter.PresenceTemplateAdapter; import eu.siacs.conversations.ui.adapter.PresenceTemplateAdapter;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.widget.DisabledActionModeCallback;
import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
@ -425,9 +421,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (requestCode == REQUEST_CHANGE_STATUS) { if (requestCode == REQUEST_CHANGE_STATUS) {
PresenceTemplate template = mPendingPresenceTemplate.pop(); PresenceTemplate template = mPendingPresenceTemplate.pop();
if (template != null && resultCode == Activity.RESULT_OK) { if (template != null && resultCode == Activity.RESULT_OK) {
generateSignature(data,template); generateSignature(data, template);
} else { } else {
Log.d(Config.LOGTAG,"pgp result not ok"); Log.d(Config.LOGTAG, "pgp result not ok");
} }
} }
} }
@ -638,26 +634,27 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
final Intent intent = getIntent();
final int theme = findTheme(); final int theme = findTheme();
if (this.mTheme != theme) { if (this.mTheme != theme) {
recreate(); recreate();
} else if (getIntent() != null) { } else if (intent != null) {
try { try {
this.jidToEdit = Jid.of(getIntent().getStringExtra("jid")); this.jidToEdit = Jid.of(intent.getStringExtra("jid"));
} catch (final IllegalArgumentException | NullPointerException ignored) { } catch (final IllegalArgumentException | NullPointerException ignored) {
this.jidToEdit = null; this.jidToEdit = null;
} }
if (jidToEdit != null && getIntent().getData() != null) { if (jidToEdit != null && intent.getData() != null && intent.getBooleanExtra("scanned", false)) {
final XmppUri uri = new XmppUri(getIntent().getData()); final XmppUri uri = new XmppUri(intent.getData());
if (xmppConnectionServiceBound) { if (xmppConnectionServiceBound) {
processFingerprintVerification(uri, false); processFingerprintVerification(uri, false);
} else { } else {
this.pendingUri = uri; this.pendingUri = uri;
} }
} }
boolean init = getIntent().getBooleanExtra("init", false); boolean init = intent.getBooleanExtra("init", false);
this.mInitMode = init || this.jidToEdit == null; this.mInitMode = init || this.jidToEdit == null;
this.messageFingerprint = getIntent().getStringExtra("fingerprint"); this.messageFingerprint = intent.getStringExtra("fingerprint");
if (!mInitMode) { if (!mInitMode) {
this.binding.accountRegisterNew.setVisibility(View.GONE); this.binding.accountRegisterNew.setVisibility(View.GONE);
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
@ -832,15 +829,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean manualStatus = sharedPreferences.getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence)); boolean manualStatus = sharedPreferences.getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
final DialogPresenceBinding binding = DataBindingUtil.inflate(getLayoutInflater(),R.layout.dialog_presence,null,false); final DialogPresenceBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_presence, null, false);
String current = mAccount.getPresenceStatusMessage(); String current = mAccount.getPresenceStatusMessage();
if (current != null && !current.trim().isEmpty()) { if (current != null && !current.trim().isEmpty()) {
binding.statusMessage.append(current); binding.statusMessage.append(current);
} }
setAvailabilityRadioButton(mAccount.getPresenceStatus(),binding); setAvailabilityRadioButton(mAccount.getPresenceStatus(), binding);
binding.show.setVisibility(manualStatus ? View.VISIBLE : View.GONE); binding.show.setVisibility(manualStatus ? View.VISIBLE : View.GONE);
List<PresenceTemplate> templates = xmppConnectionService.getPresenceTemplates(mAccount); List<PresenceTemplate> templates = xmppConnectionService.getPresenceTemplates(mAccount);
PresenceTemplateAdapter presenceTemplateAdapter = new PresenceTemplateAdapter(this,R.layout.simple_list_item,templates); PresenceTemplateAdapter presenceTemplateAdapter = new PresenceTemplateAdapter(this, R.layout.simple_list_item, templates);
binding.statusMessage.setAdapter(presenceTemplateAdapter); binding.statusMessage.setAdapter(presenceTemplateAdapter);
binding.statusMessage.setOnItemClickListener((parent, view, position, id) -> { binding.statusMessage.setOnItemClickListener((parent, view, position, id) -> {
PresenceTemplate template = (PresenceTemplate) parent.getItemAtPosition(position); PresenceTemplate template = (PresenceTemplate) parent.getItemAtPosition(position);
@ -848,9 +845,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}); });
builder.setTitle(R.string.edit_status_message_title); builder.setTitle(R.string.edit_status_message_title);
builder.setView(binding.getRoot()); builder.setView(binding.getRoot());
builder.setNegativeButton(R.string.cancel,null); builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.confirm, (dialog, which) -> { builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
PresenceTemplate template = new PresenceTemplate(getAvailabilityRadioButton(binding),binding.statusMessage.getText().toString().trim()); PresenceTemplate template = new PresenceTemplate(getAvailabilityRadioButton(binding), binding.statusMessage.getText().toString().trim());
if (mAccount.getPgpId() != 0 && hasPgp()) { if (mAccount.getPgpId() != 0 && hasPgp()) {
generateSignature(null, template); generateSignature(null, template);
} else { } else {
@ -864,7 +861,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
xmppConnectionService.getPgpEngine().generateSignature(intent, mAccount, template.getStatusMessage(), new UiCallback<String>() { xmppConnectionService.getPgpEngine().generateSignature(intent, mAccount, template.getStatusMessage(), new UiCallback<String>() {
@Override @Override
public void success(String signature) { public void success(String signature) {
xmppConnectionService.changeStatus(mAccount,template,signature); xmppConnectionService.changeStatus(mAccount, template, signature);
} }
@Override @Override
@ -1043,7 +1040,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mPgpFingerprint.setText(OpenPgpUtils.convertKeyIdToHex(pgpKeyId)); this.mPgpFingerprint.setText(OpenPgpUtils.convertKeyIdToHex(pgpKeyId));
this.mPgpFingerprint.setOnClickListener(openPgp); this.mPgpFingerprint.setOnClickListener(openPgp);
if ("pgp".equals(messageFingerprint)) { if ("pgp".equals(messageFingerprint)) {
this.getmPgpFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Highlight); this.getmPgpFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
} }
this.getmPgpFingerprintDesc.setOnClickListener(openPgp); this.getmPgpFingerprintDesc.setOnClickListener(openPgp);
this.mPgpDeleteFingerprintButton.setOnClickListener(delete); this.mPgpDeleteFingerprintButton.setOnClickListener(delete);
@ -1054,10 +1051,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (ownAxolotlFingerprint != null && Config.supportOmemo()) { if (ownAxolotlFingerprint != null && Config.supportOmemo()) {
this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE);
if (ownAxolotlFingerprint.equals(messageFingerprint)) { if (ownAxolotlFingerprint.equals(messageFingerprint)) {
this.mOwnFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Highlight); this.mOwnFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint_selected_message); this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint_selected_message);
} else { } else {
this.mOwnFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption); this.mOwnFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption);
this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint); this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint);
} }
this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2))); this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2)));

View File

@ -110,6 +110,7 @@ public class UriHandlerActivity extends AppCompatActivity {
intent.setAction(Intent.ACTION_VIEW); intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("jid", xmppUri.getJid().asBareJid().toString()); intent.putExtra("jid", xmppUri.getJid().asBareJid().toString());
intent.setData(uri); intent.setData(uri);
intent.putExtra("scanned", scanned);
} else if (xmppUri.isJidValid()) { } else if (xmppUri.isJidValid()) {
intent = new Intent(getApplicationContext(), StartConversationActivity.class); intent = new Intent(getApplicationContext(), StartConversationActivity.class);
intent.setAction(Intent.ACTION_VIEW); intent.setAction(Intent.ACTION_VIEW);