remove ASM handling

This commit is contained in:
adbenitez 2025-03-13 17:22:53 +01:00
parent 2e1a40b606
commit 218295c4f3
5 changed files with 4 additions and 89 deletions

View file

@ -150,7 +150,6 @@ public class DcMsg {
public native String getWebxdcHref (); public native String getWebxdcHref ();
public native boolean isForwarded (); public native boolean isForwarded ();
public native boolean isInfo (); public native boolean isInfo ();
public native boolean isSetupMessage ();
public native boolean hasHtml (); public native boolean hasHtml ();
public native String getSetupCodeBegin (); public native String getSetupCodeBegin ();
public native String getVideochatUrl (); public native String getVideochatUrl ();

View file

@ -294,7 +294,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
else if (type==DcMsg.DC_MSG_AUDIO || type==DcMsg.DC_MSG_VOICE) { else if (type==DcMsg.DC_MSG_AUDIO || type==DcMsg.DC_MSG_VOICE) {
return dcMsg.isOutgoing()? MESSAGE_TYPE_AUDIO_OUTGOING : MESSAGE_TYPE_AUDIO_INCOMING; return dcMsg.isOutgoing()? MESSAGE_TYPE_AUDIO_OUTGOING : MESSAGE_TYPE_AUDIO_INCOMING;
} }
else if (type==DcMsg.DC_MSG_FILE && !dcMsg.isSetupMessage()) { else if (type==DcMsg.DC_MSG_FILE) {
return dcMsg.isOutgoing()? MESSAGE_TYPE_DOCUMENT_OUTGOING : MESSAGE_TYPE_DOCUMENT_INCOMING; return dcMsg.isOutgoing()? MESSAGE_TYPE_DOCUMENT_OUTGOING : MESSAGE_TYPE_DOCUMENT_INCOMING;
} }
else if (type==DcMsg.DC_MSG_IMAGE || type==DcMsg.DC_MSG_GIF || type==DcMsg.DC_MSG_VIDEO) { else if (type==DcMsg.DC_MSG_IMAGE || type==DcMsg.DC_MSG_GIF || type==DcMsg.DC_MSG_VIDEO) {

View file

@ -25,8 +25,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -37,12 +35,10 @@ import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ActionMode; import androidx.appcompat.view.ActionMode;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -725,80 +721,6 @@ public class ConversationFragment extends MessageSelectorFragment
Util.runOnAnyBackgroundThread(() -> dcContext.markseenMsgs(ids)); Util.runOnAnyBackgroundThread(() -> dcContext.markseenMsgs(ids));
} }
void querySetupCode(final DcMsg dcMsg, String[] preload)
{
if( !dcMsg.isSetupMessage()) {
return;
}
View gl = View.inflate(getActivity(), R.layout.setup_code_grid, null);
final EditText[] editTexts = {
gl.findViewById(R.id.setupCode0), gl.findViewById(R.id.setupCode1), gl.findViewById(R.id.setupCode2),
gl.findViewById(R.id.setupCode3), gl.findViewById(R.id.setupCode4), gl.findViewById(R.id.setupCode5),
gl.findViewById(R.id.setupCode6), gl.findViewById(R.id.setupCode7), gl.findViewById(R.id.setupCode8)
};
AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity());
builder1.setView(gl);
editTexts[0].setText(dcMsg.getSetupCodeBegin());
editTexts[0].setSelection(editTexts[0].getText().length());
for( int i = 0; i < 9; i++ ) {
if( preload != null && i < preload.length ) {
editTexts[i].setText(preload[i]);
editTexts[i].setSelection(editTexts[i].getText().length());
}
editTexts[i].addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if( s.length()==4 ) {
for ( int i = 0; i < 8; i++ ) {
if( editTexts[i].hasFocus() && editTexts[i+1].getText().length()<4 ) {
editTexts[i+1].requestFocus();
break;
}
}
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
builder1.setTitle(getActivity().getString(R.string.autocrypt_continue_transfer_title));
builder1.setMessage(getActivity().getString(R.string.autocrypt_continue_transfer_please_enter_code));
builder1.setNegativeButton(android.R.string.cancel, null);
builder1.setCancelable(false); // prevent the dialog from being dismissed accidentally (when the dialog is closed, the setup code is gone forever and the user has to create a new setup message)
builder1.setPositiveButton(android.R.string.ok, (dialog, which) -> {
String setup_code = "";
final String[] preload1 = new String[9];
for ( int i = 0; i < 9; i++ ) {
preload1[i] = editTexts[i].getText().toString();
setup_code += preload1[i];
}
boolean success = dcContext.continueKeyTransfer(dcMsg.getId(), setup_code);
AlertDialog.Builder builder2 = new AlertDialog.Builder(getActivity());
builder2.setTitle(getActivity().getString(R.string.autocrypt_continue_transfer_title));
builder2.setMessage(getActivity().getString(success? R.string.autocrypt_continue_transfer_succeeded : R.string.autocrypt_bad_setup_code));
if( success ) {
builder2.setPositiveButton(android.R.string.ok, null);
}
else {
builder2.setNegativeButton(android.R.string.cancel, null);
builder2.setPositiveButton(R.string.autocrypt_continue_transfer_retry, (dialog1, which1) -> querySetupCode(dcMsg, preload1));
}
builder2.show();
});
builder1.show();
}
private class ConversationFragmentItemClickListener implements ItemClickListener { private class ConversationFragmentItemClickListener implements ItemClickListener {
@Override @Override
@ -818,9 +740,6 @@ public class ConversationFragment extends MessageSelectorFragment
actionMode.setTitleOptionalHint(false); // the title represents important information, also indicating implicitly, more items can be selected actionMode.setTitleOptionalHint(false); // the title represents important information, also indicating implicitly, more items can be selected
} }
} }
else if(messageRecord.isSetupMessage()) {
querySetupCode(messageRecord,null);
}
else if (messageRecord.getType()==DcMsg.DC_MSG_VIDEOCHAT_INVITATION) { else if (messageRecord.getType()==DcMsg.DC_MSG_VIDEOCHAT_INVITATION) {
new VideochatUtil().join(getActivity(), messageRecord.getId()); new VideochatUtil().join(getActivity(), messageRecord.getId());
} }

View file

@ -390,7 +390,7 @@ public class ConversationItem extends BaseConversationItem
} }
private boolean hasDocument(DcMsg dcMsg) { private boolean hasDocument(DcMsg dcMsg) {
return dcMsg.getType()==DcMsg.DC_MSG_FILE && !dcMsg.isSetupMessage(); return dcMsg.getType()==DcMsg.DC_MSG_FILE;
} }
private void setBodyText(DcMsg messageRecord) { private void setBodyText(DcMsg messageRecord) {
@ -399,11 +399,7 @@ public class ConversationItem extends BaseConversationItem
String text = messageRecord.getText(); String text = messageRecord.getText();
if (messageRecord.isSetupMessage()) { if (text.isEmpty()) {
bodyText.setText(context.getString(R.string.autocrypt_asm_click_body));
bodyText.setVisibility(View.VISIBLE);
}
else if (text.isEmpty()) {
bodyText.setVisibility(View.GONE); bodyText.setVisibility(View.GONE);
} }
else { else {

View file

@ -876,6 +876,7 @@
<string name="autocrypt_send_asm_explain_after">Your setup has been sent to yourself. Switch to the other device and open the setup message. You should be asked for a setup code. Enter the following digits:</string> <string name="autocrypt_send_asm_explain_after">Your setup has been sent to yourself. Switch to the other device and open the setup message. You should be asked for a setup code. Enter the following digits:</string>
<string name="autocrypt_prefer_e2ee">Prefer End-To-End Encryption</string> <string name="autocrypt_prefer_e2ee">Prefer End-To-End Encryption</string>
<string name="autocrypt_asm_subject">Autocrypt Setup Message</string> <string name="autocrypt_asm_subject">Autocrypt Setup Message</string>
<!-- deprecated -->
<string name="autocrypt_asm_general_body">This is the Autocrypt Setup Message used to transfer your end-to-end setup between clients.\n\nTo decrypt and use your setup, open the message in an Autocrypt-compliant client and enter the setup code presented on the generating device.</string> <string name="autocrypt_asm_general_body">This is the Autocrypt Setup Message used to transfer your end-to-end setup between clients.\n\nTo decrypt and use your setup, open the message in an Autocrypt-compliant client and enter the setup code presented on the generating device.</string>
<string name="autocrypt_asm_click_body">This is the Autocrypt Setup Message used to transfer your end-to-end setup between clients.\n\nTo decrypt and use your setup, tap or click on this message.</string> <string name="autocrypt_asm_click_body">This is the Autocrypt Setup Message used to transfer your end-to-end setup between clients.\n\nTo decrypt and use your setup, tap or click on this message.</string>
<string name="autocrypt_continue_transfer_title">Autocrypt Setup Message</string> <string name="autocrypt_continue_transfer_title">Autocrypt Setup Message</string>