diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d4a6ac839..e7b23b935 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -147,7 +147,17 @@ + android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"> + + + + + + + + + + diff --git a/jni/messenger-backend b/jni/messenger-backend index b9733fadf..e7c29efd2 160000 --- a/jni/messenger-backend +++ b/jni/messenger-backend @@ -1 +1 @@ -Subproject commit b9733fadf44f34cc74a4f2330c5062c825acae7a +Subproject commit e7c29efd29c4827dafe7ba42404fc599b2534f90 diff --git a/res/layout/registration_activity.xml b/res/layout/registration_activity.xml index 4f079e297..0cc2d337e 100644 --- a/res/layout/registration_activity.xml +++ b/res/layout/registration_activity.xml @@ -27,49 +27,37 @@ android:orientation="vertical" app:layout_constraintGuide_end="16dp" /> - - - + + + + + + + + + + + + + + android:layout_height="28dp" /> - + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/fab_spacer"> + + + outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security" /> + app:layout_constraintTop_toBottomOf="@id/sub_header" /> + app:layout_constraintTop_toBottomOf="@id/sub_header" /> - + + + + + - + + + + + + + + + + + + + + + + - + + + + diff --git a/res/menu/chat_background.xml b/res/menu/chat_background.xml new file mode 100644 index 000000000..e9e02026b --- /dev/null +++ b/res/menu/chat_background.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/res/menu/registration.xml b/res/menu/registration.xml new file mode 100644 index 000000000..4ce88f579 --- /dev/null +++ b/res/menu/registration.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index dd1a4da4a..32c8ed105 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -303,12 +303,12 @@ Blocked contacts Remove profile photo? https://delta.chat/en/help - Password and account settings Who can see this information? Your profile picture and name will be shown alongside your messages when communicating with other users. Already sent information can not be deleted or removed. Your name Status text + Sent with my Delta Chat Messenger: https://delta.chat Enter key sends Pressing the Enter key will send text messages @@ -552,7 +552,7 @@ Group name Remove Save - Show QR verify code + Show QR invite code Show QR invite code Add contact required @@ -589,15 +589,15 @@ - Do you want to join the verified group \"%1$s\"? + Do you want to join the group \"%1$s\"? - Start chatting with \"%1$s\"? + Chat with %1$s? - Contact \"%1$s\" verified. Start chatting? + Chat with %1$s? QR invite code - Scan this to join the verified group \"%1$s\". + Scan this to join the group \"%1$s\". diff --git a/src/com/b44t/messenger/DcContext.java b/src/com/b44t/messenger/DcContext.java index 765873b10..383a84b1a 100644 --- a/src/com/b44t/messenger/DcContext.java +++ b/src/com/b44t/messenger/DcContext.java @@ -55,6 +55,13 @@ public class DcContext { public final static int DC_QR_URL = 332; public final static int DC_QR_ERROR = 400; + public final static int DC_LP_IMAP_SOCKET_STARTTLS = 0x100; + public final static int DC_LP_IMAP_SOCKET_SSL = 0x200; + public final static int DC_LP_IMAP_SOCKET_PLAIN = 0x400; + public final static int DC_LP_SMTP_SOCKET_STARTTLS = 0x10000; + public final static int DC_LP_SMTP_SOCKET_SSL = 0x20000; + public final static int DC_LP_SMTP_SOCKET_PLAIN = 0x40000; + public DcContext(String osName) { handleEvent(0,0,0); // call handleEvent() to make sure it is not optimized away and JNI won't find it contextCPtr = createContextCPtr(osName); diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 5f01d1df6..1839cda91 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -181,8 +181,13 @@ public class ConversationFragment extends Fragment } }else{ String name = getListAdapter().getChatName(); - String message = getString(R.string.chat_no_messages_hint, name, name); - noMessageTextView.setText(message); + if(dcContext.getChat((int)threadId).isSelfTalk()) { + noMessageTextView.setText(R.string.chat_no_messages); + } + else { + String message = getString(R.string.chat_no_messages_hint, name, name); + noMessageTextView.setText(message); + } } } diff --git a/src/org/thoughtcrime/securesms/CreateProfileActivity.java b/src/org/thoughtcrime/securesms/CreateProfileActivity.java index b3c892507..54692bf61 100644 --- a/src/org/thoughtcrime/securesms/CreateProfileActivity.java +++ b/src/org/thoughtcrime/securesms/CreateProfileActivity.java @@ -453,8 +453,7 @@ public class CreateProfileActivity extends BaseActionBarActivity { if (result) { if (captureFile != null) captureFile.delete(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) handleFinishedLollipop(); - else handleFinishedLegacy(); + handleFinishedLegacy(); } else { Toast.makeText(CreateProfileActivity.this, R.string.error, Toast.LENGTH_LONG).show(); } @@ -480,32 +479,4 @@ public class CreateProfileActivity extends BaseActionBarActivity { if (nextIntent != null) startActivity(nextIntent); finish(); } - - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) - private void handleFinishedLollipop() { - int[] revealLocation = new int[2]; - - reveal.getLocationInWindow(revealLocation); - - Animator animation = ViewAnimationUtils.createCircularReveal(reveal, reveal.getWidth(), 0, 0f, (float) Math.max(reveal.getWidth(), reveal.getHeight())); - animation.setDuration(500); - animation.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) {} - - @Override - public void onAnimationEnd(Animator animation) { - if (nextIntent != null) startActivity(nextIntent); - finish(); - } - - @Override - public void onAnimationCancel(Animator animation) {} - @Override - public void onAnimationRepeat(Animator animation) {} - }); - - reveal.setVisibility(View.VISIBLE); - animation.start(); - } } diff --git a/src/org/thoughtcrime/securesms/NewConversationActivity.java b/src/org/thoughtcrime/securesms/NewConversationActivity.java index 74e0b311f..6190d8fc5 100644 --- a/src/org/thoughtcrime/securesms/NewConversationActivity.java +++ b/src/org/thoughtcrime/securesms/NewConversationActivity.java @@ -19,7 +19,10 @@ package org.thoughtcrime.securesms; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.net.MailTo; +import android.net.Uri; import android.os.Bundle; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -40,12 +43,41 @@ public class NewConversationActivity extends ContactSelectionActivity { @SuppressWarnings("unused") private static final String TAG = NewConversationActivity.class.getSimpleName(); + private static final String MAILTO = "mailto"; @Override public void onCreate(Bundle bundle, boolean ready) { super.onCreate(bundle, ready); assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); + handleIntent(); + } + + private void handleIntent() { + Intent intent = getIntent(); + String action = intent.getAction(); + if(Intent.ACTION_VIEW.equals(action) || Intent.ACTION_SENDTO.equals(action)) { + try { + Uri uri = intent.getData(); + if(uri != null) { + String scheme = uri.getScheme(); + if(scheme != null && scheme.equals(MAILTO) ) { + MailTo mailto = MailTo.parse(uri.toString()); + String recipientsList = mailto.getTo(); + if(recipientsList != null && !recipientsList.isEmpty()) { + String[] recipientsArray = recipientsList.split(","); + if (recipientsArray.length >= 1) { + String recipient = recipientsArray[0]; + onContactSelected(DcContact.DC_CONTACT_ID_NEW_CONTACT, recipient); + } + } + } + } + } + catch(Exception e) { + Log.e(TAG, "start activity from external 'mailto:' link failed", e); + } + } } @Override diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index bd0f5020b..d2e22bc06 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -9,10 +9,15 @@ import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.constraint.Group; import android.support.design.widget.TextInputEditText; +import android.support.v7.app.ActionBar; import android.text.TextUtils; import android.util.Patterns; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.ImageView; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -56,6 +61,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve private ProgressDialog progressDialog; private boolean gmailDialogShown; + MenuItem loginMenuItem; + Spinner imapSecurity; + Spinner smtpSecurity; @Override public void onCreate(Bundle bundle) { @@ -66,6 +74,30 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve DcHelper.getContext(this).eventCenter.addObserver(this, DcContext.DC_EVENT_CONFIGURE_PROGRESS); } + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + MenuInflater inflater = this.getMenuInflater(); + menu.clear(); + inflater.inflate(R.menu.registration, menu); + loginMenuItem = menu.findItem(R.id.do_register); + super.onPrepareOptionsMenu(menu); + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == R.id.do_register) { + onLogin(); + return true; + } else if (id == android.R.id.home) { + // handle close button click here + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + @Override public void onDestroy() { super.onDestroy(); @@ -82,19 +114,29 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve passwordInput = findViewById(R.id.password_text); advancedGroup = findViewById(R.id.advanced_group); advancedIcon = findViewById(R.id.advanced_icon); - CircularProgressButton loginButton = findViewById(R.id.register_button); +// CircularProgressButton loginButton = findViewById(R.id.register_button); TextView advancedTextView = findViewById(R.id.advanced_text); TextInputEditText imapServerInput = findViewById(R.id.imap_server_text); TextInputEditText imapPortInput = findViewById(R.id.imap_port_text); TextInputEditText smtpServerInput = findViewById(R.id.smtp_server_text); TextInputEditText smtpPortInput = findViewById(R.id.smtp_port_text); + imapSecurity = findViewById(R.id.imap_security); + smtpSecurity = findViewById(R.id.smtp_security); + + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setTitle(R.string.login_header); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp); + } + emailInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.EMAIL)); imapServerInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.SERVER)); imapPortInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.PORT)); smtpServerInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.SERVER)); smtpPortInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.PORT)); - loginButton.setOnClickListener(l -> onLogin()); +// loginButton.setOnClickListener(l -> onLogin()); advancedTextView.setOnClickListener(l -> onAdvancedSettings()); advancedIcon.setOnClickListener(l -> onAdvancedSettings()); advancedIcon.setRotation(45); @@ -107,11 +149,25 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve imapServerInput.setText(DcHelper.get(this, CONFIG_MAIL_SERVER)); imapPortInput.setText(DcHelper.get(this, CONFIG_MAIL_PORT)); TextInputEditText smtpLoginInput = findViewById(R.id.smtp_login_text); - TextInputEditText smtpPasswordInput = findViewById(R.id.smtp_port_text); + TextInputEditText smtpPasswordInput = findViewById(R.id.smtp_password_text); smtpLoginInput.setText(DcHelper.get(this, CONFIG_SEND_USER)); smtpPasswordInput.setText(DcHelper.get(this, CONFIG_SEND_PASSWORD)); smtpServerInput.setText(DcHelper.get(this, CONFIG_SEND_SERVER)); smtpPortInput.setText(DcHelper.get(this, CONFIG_SEND_PORT)); + + int server_flags = DcHelper.getInt(this, "server_flags", 0); + + int sel = 0; + if((server_flags&DcContext.DC_LP_IMAP_SOCKET_SSL)!=0) sel = 1; + if((server_flags&DcContext.DC_LP_IMAP_SOCKET_STARTTLS)!=0) sel = 2; + if((server_flags&DcContext.DC_LP_IMAP_SOCKET_PLAIN)!=0) sel = 3; + imapSecurity.setSelection(sel); + + sel = 0; + if((server_flags&DcContext.DC_LP_SMTP_SOCKET_SSL)!=0) sel = 1; + if((server_flags&DcContext.DC_LP_SMTP_SOCKET_STARTTLS)!=0) sel = 2; + if((server_flags&DcContext.DC_LP_SMTP_SOCKET_PLAIN)!=0) sel = 3; + smtpSecurity.setSelection(sel); } } @@ -218,15 +274,24 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve } private void setupConfig() { - setConfig(R.id.email_text, "addr"); - setConfig(R.id.password_text, "mail_pw"); - setConfig(R.id.imap_server_text, "mail_server"); - setConfig(R.id.imap_port_text, "mail_port"); - setConfig(R.id.imap_login_text, "mail_user"); - setConfig(R.id.smtp_server_text, "send_server"); - setConfig(R.id.smtp_port_text, "send_port"); - setConfig(R.id.smtp_login_text, "send_user"); - setConfig(R.id.smtp_password_text, "send_pw"); + setConfig(R.id.email_text, "addr", true); + setConfig(R.id.password_text, "mail_pw", false); + setConfig(R.id.imap_server_text, "mail_server", true); + setConfig(R.id.imap_port_text, "mail_port", true); + setConfig(R.id.imap_login_text, "mail_user", false); + setConfig(R.id.smtp_server_text, "send_server", true); + setConfig(R.id.smtp_port_text, "send_port", true); + setConfig(R.id.smtp_login_text, "send_user", false); + setConfig(R.id.smtp_password_text, "send_pw", false); + + int server_flags = 0; + if(imapSecurity.getSelectedItemPosition()==1) server_flags |= DcContext.DC_LP_IMAP_SOCKET_SSL; + if(imapSecurity.getSelectedItemPosition()==2) server_flags |= DcContext.DC_LP_IMAP_SOCKET_STARTTLS; + if(imapSecurity.getSelectedItemPosition()==3) server_flags |= DcContext.DC_LP_IMAP_SOCKET_PLAIN; + if(smtpSecurity.getSelectedItemPosition()==1) server_flags |= DcContext.DC_LP_SMTP_SOCKET_SSL; + if(smtpSecurity.getSelectedItemPosition()==2) server_flags |= DcContext.DC_LP_SMTP_SOCKET_STARTTLS; + if(smtpSecurity.getSelectedItemPosition()==3) server_flags |= DcContext.DC_LP_SMTP_SOCKET_PLAIN; + DcHelper.getContext(this).setConfigInt("server_flags", server_flags); // calling configure() results in // receiving multiple DC_EVENT_CONFIGURE_PROGRESS events @@ -234,12 +299,13 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve DcHelper.getContext(this).configure(); } - private void setConfig(@IdRes int viewId, String configTarget) { + private void setConfig(@IdRes int viewId, String configTarget, boolean doTrim) { TextInputEditText view = findViewById(viewId); - String value = view.getText().toString().trim(); - if (!value.isEmpty()) { - DcHelper.getContext(this).setConfig(configTarget, value); + String value = view.getText().toString(); + if(doTrim) { + value = value.trim(); } + DcHelper.getContext(this).setConfig(configTarget, value.isEmpty()? null : value); } private void stopLoginProcess() { diff --git a/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java b/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java index 6840e5063..17ea1a60c 100644 --- a/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java +++ b/src/org/thoughtcrime/securesms/preferences/ChatBackgroundActivity.java @@ -74,8 +74,8 @@ public class ChatBackgroundActivity extends BaseActionBarActivity { public boolean onPrepareOptionsMenu(Menu menu) { MenuInflater inflater = this.getMenuInflater(); menu.clear(); - inflater.inflate(R.menu.group_create, menu); - acceptMenuItem = menu.findItem(R.id.menu_create_group); + inflater.inflate(R.menu.chat_background, menu); + acceptMenuItem = menu.findItem(R.id.apply_background); acceptMenuItem.setEnabled(false); super.onPrepareOptionsMenu(menu); return true; @@ -85,7 +85,7 @@ public class ChatBackgroundActivity extends BaseActionBarActivity { public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); - if (id == R.id.menu_create_group) { + if (id == R.id.apply_background) { // handle confirmation button click here Context context = getApplicationContext(); if(imageUri != null){