Merge tag '2.10.2' into develop

This commit is contained in:
genofire 2021-11-11 00:28:16 +01:00
commit fa1363cea0
15 changed files with 264 additions and 107 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
### Version 2.10.2
* Fix crash when rendering some quotes
* Fix crash in welcome screen
### Version 2.10.1 ### Version 2.10.1
* Fix issue with some videos not being compressed * Fix issue with some videos not being compressed

View File

@ -6,7 +6,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.0.2' classpath 'com.android.tools.build:gradle:7.0.3'
} }
} }
@ -64,15 +64,16 @@ dependencies {
implementation "com.wefika:flowlayout:0.4.1" implementation "com.wefika:flowlayout:0.4.1"
implementation 'com.otaliastudios:transcoder:0.10.4' implementation 'com.otaliastudios:transcoder:0.10.4'
implementation 'org.jxmpp:jxmpp-jid:1.0.1' implementation 'org.jxmpp:jxmpp-jid:1.0.2'
implementation 'org.osmdroid:osmdroid-android:6.1.10' implementation 'org.osmdroid:osmdroid-android:6.1.10'
implementation 'org.hsluv:hsluv:0.2' implementation 'org.hsluv:hsluv:0.2'
implementation 'org.conscrypt:conscrypt-android:2.5.2' implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation 'me.drakeet.support:toastcompat:1.1.0' implementation 'me.drakeet.support:toastcompat:1.1.0'
implementation "com.leinardi.android:speed-dial:2.0.1" implementation "com.leinardi.android:speed-dial:3.2.0"
implementation "com.squareup.retrofit2:retrofit:2.9.0" implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0" implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:okhttp:4.9.1" implementation "com.squareup.okhttp3:okhttp:4.9.2"
implementation 'com.google.guava:guava:30.1.1-android' implementation 'com.google.guava:guava:30.1.1-android'
quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.12.18' quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.12.18'
@ -92,8 +93,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 42022 versionCode 42023
versionName "2.10.1" versionName "2.10.2"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"
applicationId "eu.sum7.conversations" applicationId "eu.sum7.conversations"
resValue "string", "applicationId", applicationId resValue "string", "applicationId", applicationId
@ -266,7 +267,9 @@ android {
variant.outputs.each { output -> variant.outputs.each { output ->
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
if (baseAbiVersionCode != null) { if (baseAbiVersionCode != null) {
output.versionCodeOverride = (100 * variant.versionCode) + baseAbiVersionCode output.versionCodeOverride = (100 * project.android.defaultConfig.versionCode) + baseAbiVersionCode
} else {
output.versionCodeOverride = 100 * project.android.defaultConfig.versionCode
} }
} }

View File

@ -0,0 +1,2 @@
• Fix crash when rendering some quotes
• Fix crash in welcome screen

View File

@ -106,7 +106,8 @@ public class WelcomeActivity extends XmppActivity implements XmppConnectionServi
} }
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(final Intent intent) {
super.onNewIntent(intent);
if (intent != null) { if (intent != null) {
setIntent(intent); setIntent(intent);
} }

View File

@ -23,13 +23,13 @@ public class JabberIdContact extends AbstractPhoneContact {
ContactsContract.Data.LOOKUP_KEY, ContactsContract.Data.LOOKUP_KEY,
ContactsContract.CommonDataKinds.Im.DATA ContactsContract.CommonDataKinds.Im.DATA
}; };
private static final String SELECTION = ContactsContract.Data.MIMETYPE + "=? AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? or (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? and " + ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL + "=?))"; private static final String SELECTION = ContactsContract.Data.MIMETYPE + "=? AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? or (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? and lower(" + ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL + ")=?))";
private static final String[] SELECTION_ARGS = { private static final String[] SELECTION_ARGS = {
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE,
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER), String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER),
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM), String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM),
"XMPP" "xmpp"
}; };
private final Jid jid; private final Jid jid;

View File

@ -37,11 +37,14 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.MenuRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -51,6 +54,8 @@ import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.textfield.TextInputLayout;
import com.leinardi.android.speeddial.SpeedDialActionItem;
import com.leinardi.android.speeddial.SpeedDialView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -266,8 +271,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
setSupportActionBar(binding.toolbar); setSupportActionBar(binding.toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
binding.speedDial.inflate(R.menu.start_conversation_fab_submenu); inflateFab(binding.speedDial, R.menu.start_conversation_fab_submenu);
binding.tabLayout.setupWithViewPager(binding.startConversationViewPager); binding.tabLayout.setupWithViewPager(binding.startConversationViewPager);
binding.startConversationViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { binding.startConversationViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override @Override
@ -338,6 +342,21 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}); });
} }
private void inflateFab(final SpeedDialView speedDialView, final @MenuRes int menuRes) {
speedDialView.clearActionItems();
final PopupMenu popupMenu = new PopupMenu(this, new View(this));
popupMenu.inflate(menuRes);
final Menu menu = popupMenu.getMenu();
for (int i = 0; i < menu.size(); i++) {
final MenuItem menuItem = menu.getItem(i);
final SpeedDialActionItem actionItem = new SpeedDialActionItem.Builder(menuItem.getItemId(), menuItem.getIcon())
.setLabel(menuItem.getTitle() != null ? menuItem.getTitle().toString() : null)
.setFabImageTintColor(ContextCompat.getColor(this, R.color.white))
.create();
speedDialView.addActionItem(actionItem);
}
}
public static boolean isValidJid(String input) { public static boolean isValidJid(String input) {
try { try {
Jid jid = Jid.ofEscaped(input); Jid jid = Jid.ofEscaped(input);

View File

@ -7,24 +7,39 @@ import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.databinding.ActivityUriHandlerBinding;
import eu.siacs.conversations.http.HttpConnectionManager;
import eu.siacs.conversations.persistance.DatabaseBackend; import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.QuickConversationsService;
import eu.siacs.conversations.utils.ProvisioningUtils; import eu.siacs.conversations.utils.ProvisioningUtils;
import eu.siacs.conversations.utils.SignupUtils; import eu.siacs.conversations.utils.SignupUtils;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.Jid;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.Request;
import okhttp3.Response;
public class UriHandlerActivity extends AppCompatActivity { public class UriHandlerActivity extends AppCompatActivity {
@ -34,7 +49,9 @@ public class UriHandlerActivity extends AppCompatActivity {
private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN = 0x6789; private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN = 0x6789;
private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN_AND_PROVISION = 0x6790; private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN_AND_PROVISION = 0x6790;
private static final Pattern V_CARD_XMPP_PATTERN = Pattern.compile("\nIMPP([^:]*):(xmpp:.+)\n"); private static final Pattern V_CARD_XMPP_PATTERN = Pattern.compile("\nIMPP([^:]*):(xmpp:.+)\n");
private boolean handled = false; private static final Pattern LINK_HEADER_PATTERN = Pattern.compile("<(.*?)>");
private ActivityUriHandlerBinding binding;
private Call call;
public static void scan(final Activity activity) { public static void scan(final Activity activity) {
scan(activity, false); scan(activity, false);
@ -77,9 +94,7 @@ public class UriHandlerActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_uri_handler);
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
setSupportActionBar(findViewById(R.id.toolbar));
} }
@Override @Override
@ -88,23 +103,17 @@ public class UriHandlerActivity extends AppCompatActivity {
handleIntent(getIntent()); handleIntent(getIntent());
} }
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putBoolean("handled", this.handled);
super.onSaveInstanceState(savedInstanceState);
}
@Override @Override
public void onNewIntent(final Intent intent) { public void onNewIntent(final Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
handleIntent(intent); handleIntent(intent);
} }
private void handleUri(Uri uri) { private boolean handleUri(final Uri uri) {
handleUri(uri, false); return handleUri(uri, false);
} }
private void handleUri(Uri uri, final boolean scanned) { private boolean handleUri(final Uri uri, final boolean scanned) {
final Intent intent; final Intent intent;
final XmppUri xmppUri = new XmppUri(uri); final XmppUri xmppUri = new XmppUri(uri);
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true); final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true);
@ -114,19 +123,22 @@ public class UriHandlerActivity extends AppCompatActivity {
final Jid jid = xmppUri.getJid(); final Jid jid = xmppUri.getJid();
if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) { if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
if (jid.getEscapedLocal() != null && accounts.contains(jid.asBareJid())) { if (jid.getEscapedLocal() != null && accounts.contains(jid.asBareJid())) {
Toast.makeText(this, R.string.account_already_exists, Toast.LENGTH_LONG).show(); showError(R.string.account_already_exists);
return; return false;
} }
intent = SignupUtils.getTokenRegistrationIntent(this, jid, preAuth); intent = SignupUtils.getTokenRegistrationIntent(this, jid, preAuth);
startActivity(intent); startActivity(intent);
return; return true;
} }
if (accounts.size() == 0 && xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter(XmppUri.PARAMETER_IBR))) { if (accounts.size() == 0 && xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter(XmppUri.PARAMETER_IBR))) {
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preAuth); intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preAuth);
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString()); intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
startActivity(intent); startActivity(intent);
return; return true;
} }
} else if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
showError(R.string.account_registrations_are_not_supported);
return false;
} }
if (accounts.size() == 0) { if (accounts.size() == 0) {
@ -134,15 +146,14 @@ public class UriHandlerActivity extends AppCompatActivity {
intent = SignupUtils.getSignUpIntent(this); intent = SignupUtils.getSignUpIntent(this);
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString()); intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
startActivity(intent); startActivity(intent);
return true;
} else { } else {
Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); showError(R.string.invalid_jid);
return false;
} }
return;
} }
if (xmppUri.isAction(XmppUri.ACTION_MESSAGE)) { if (xmppUri.isAction(XmppUri.ACTION_MESSAGE)) {
final Jid jid = xmppUri.getJid(); final Jid jid = xmppUri.getJid();
final String body = xmppUri.getBody(); final String body = xmppUri.getBody();
@ -177,11 +188,57 @@ public class UriHandlerActivity extends AppCompatActivity {
intent.putExtra("scanned", scanned); intent.putExtra("scanned", scanned);
intent.setData(uri); intent.setData(uri);
} else { } else {
Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show(); showError(R.string.invalid_jid);
return; return false;
}
startActivity(intent);
return true;
} }
startActivity(intent); private void checkForLinkHeader(final HttpUrl url) {
Log.d(Config.LOGTAG, "checking for link header on " + url);
this.call = HttpConnectionManager.OK_HTTP_CLIENT.newCall(new Request.Builder()
.url(url)
.head()
.build());
this.call.enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.d(Config.LOGTAG, "unable to check HTTP url", e);
showError(R.string.no_xmpp_adddress_found);
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) {
if (response.isSuccessful()) {
final String linkHeader = response.header("Link");
if (linkHeader != null && processLinkHeader(linkHeader)) {
return;
}
}
showError(R.string.no_xmpp_adddress_found);
}
});
}
private boolean processLinkHeader(final String header) {
final Matcher matcher = LINK_HEADER_PATTERN.matcher(header);
if (matcher.find()) {
final String group = matcher.group();
final String link = group.substring(1, group.length() - 1);
if (handleUri(Uri.parse(link))) {
finish();
return true;
}
}
return false;
}
private void showError(@StringRes int error) {
this.binding.progress.setVisibility(View.INVISIBLE);
this.binding.error.setText(error);
this.binding.error.setVisibility(View.VISIBLE);
} }
private static Class<?> findShareViaAccountClass() { private static Class<?> findShareViaAccountClass() {
@ -192,29 +249,33 @@ public class UriHandlerActivity extends AppCompatActivity {
} }
} }
private void handleIntent(Intent data) { private void handleIntent(final Intent data) {
if (handled) { final String action = data == null ? null : data.getAction();
if (action == null) {
return; return;
} }
if (data == null || data.getAction() == null) { switch (action) {
finish(); case Intent.ACTION_MAIN:
return; binding.progress.setVisibility(call != null && !call.isCanceled() ? View.VISIBLE : View.INVISIBLE);
} break;
handled = true;
switch (data.getAction()) {
case Intent.ACTION_VIEW: case Intent.ACTION_VIEW:
case Intent.ACTION_SENDTO: case Intent.ACTION_SENDTO:
handleUri(data.getData()); if (handleUri(data.getData())) {
finish();
}
break; break;
case ACTION_SCAN_QR_CODE: case ACTION_SCAN_QR_CODE:
Intent intent = new Intent(this, ScanActivity.class); Log.d(Config.LOGTAG, "scan. allow=" + allowProvisioning());
startActivityForResult(intent, REQUEST_SCAN_QR_CODE); setIntent(createMainIntent());
return; startActivityForResult(new Intent(this, ScanActivity.class), REQUEST_SCAN_QR_CODE);
break;
}
} }
finish(); private Intent createMainIntent() {
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra(EXTRA_ALLOW_PROVISIONING, allowProvisioning());
return intent;
} }
private boolean allowProvisioning() { private boolean allowProvisioning() {
@ -226,6 +287,7 @@ public class UriHandlerActivity extends AppCompatActivity {
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
super.onActivityResult(requestCode, requestCode, intent); super.onActivityResult(requestCode, requestCode, intent);
if (requestCode == REQUEST_SCAN_QR_CODE && resultCode == RESULT_OK) { if (requestCode == REQUEST_SCAN_QR_CODE && resultCode == RESULT_OK) {
final boolean allowProvisioning = allowProvisioning();
final String result = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT); final String result = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
if (Strings.isNullOrEmpty(result)) { if (Strings.isNullOrEmpty(result)) {
finish(); finish();
@ -234,19 +296,35 @@ public class UriHandlerActivity extends AppCompatActivity {
if (result.startsWith("BEGIN:VCARD\n")) { if (result.startsWith("BEGIN:VCARD\n")) {
final Matcher matcher = V_CARD_XMPP_PATTERN.matcher(result); final Matcher matcher = V_CARD_XMPP_PATTERN.matcher(result);
if (matcher.find()) { if (matcher.find()) {
handleUri(Uri.parse(matcher.group(2)), true); if (handleUri(Uri.parse(matcher.group(2)), true)) {
}
finish(); finish();
}
} else {
showError(R.string.no_xmpp_adddress_found);
}
return; return;
} else if (QuickConversationsService.isConversations() && looksLikeJsonObject(result) && allowProvisioning()) { } else if (QuickConversationsService.isConversations() && looksLikeJsonObject(result) && allowProvisioning) {
ProvisioningUtils.provision(this, result); ProvisioningUtils.provision(this, result);
finish(); finish();
return; return;
} }
handleUri(Uri.parse(result), true); final Uri uri = Uri.parse(result.trim());
} if (allowProvisioning && "https".equalsIgnoreCase(uri.getScheme()) && !XmppUri.INVITE_DOMAIN.equalsIgnoreCase(uri.getHost())) {
final HttpUrl httpUrl = HttpUrl.parse(uri.toString());
if (httpUrl != null) {
checkForLinkHeader(httpUrl);
} else {
finish(); finish();
} }
} else if (handleUri(uri, true)) {
finish();
} else {
setIntent(new Intent(Intent.ACTION_VIEW, uri));
}
} else {
finish();
}
}
private static boolean looksLikeJsonObject(final String input) { private static boolean looksLikeJsonObject(final String input) {
final String trimmed = Strings.nullToEmpty(input).trim(); final String trimmed = Strings.nullToEmpty(input).trim();

View File

@ -368,9 +368,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
char current = body.length() > i ? body.charAt(i) : '\n'; char current = body.length() > i ? body.charAt(i) : '\n';
if (lineStart == -1) { if (lineStart == -1) {
if (previous == '\n') { if (previous == '\n') {
if ( if (i < body.length() && QuoteHelper.isPositionQuoteStart(body, i)) {
QuoteHelper.isPositionQuoteStart(body, i)
) {
// Line start with quote // Line start with quote
lineStart = i; lineStart = i;
if (quoteStart == -1) quoteStart = i; if (quoteStart == -1) quoteStart = i;

View File

@ -38,13 +38,13 @@ public class QuoteHelper {
} }
// 'Prequote' means anything we require or can accept in front of a QuoteChar // 'Prequote' means anything we require or can accept in front of a QuoteChar
public static boolean isPositionPrecededByPrequote(CharSequence body, int pos){ public static boolean isPositionPrecededByPreQuote(CharSequence body, int pos) {
return UIHelper.isPositionPrecededByLineStart(body, pos); return UIHelper.isPositionPrecededByLineStart(body, pos);
} }
public static boolean isPositionQuoteStart(CharSequence body, int pos) { public static boolean isPositionQuoteStart(CharSequence body, int pos) {
return (isPositionQuoteCharacter(body, pos) return (isPositionQuoteCharacter(body, pos)
&& isPositionPrecededByPrequote(body, pos) && isPositionPrecededByPreQuote(body, pos)
&& (UIHelper.isPositionFollowedByQuoteableCharacter(body, pos) && (UIHelper.isPositionFollowedByQuoteableCharacter(body, pos)
|| isPositionFollowedByQuoteChar(body, pos))); || isPositionFollowedByQuoteChar(body, pos)));
} }

View File

@ -21,6 +21,8 @@ import android.net.Uri;
import android.provider.OpenableColumns; import android.provider.OpenableColumns;
import android.util.Log; import android.util.Log;
import com.google.common.base.Strings;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -274,6 +276,8 @@ public final class MimeUtils {
add("image/ico", "ico"); add("image/ico", "ico");
add("image/ief", "ief"); add("image/ief", "ief");
add("image/heic", "heic"); add("image/heic", "heic");
add("image/heif", "heif");
add("image/avif", "avif");
// add ".jpg" first so it will be the default for guessExtensionFromMimeType // add ".jpg" first so it will be the default for guessExtensionFromMimeType
add("image/jpeg", "jpg"); add("image/jpeg", "jpg");
add("image/jpeg", "jpeg"); add("image/jpeg", "jpeg");
@ -587,15 +591,19 @@ public final class MimeUtils {
} }
public static String extractRelevantExtension(final String path, final boolean ignoreCryptoExtension) { public static String extractRelevantExtension(final String path, final boolean ignoreCryptoExtension) {
if (path == null || path.isEmpty()) { if (Strings.isNullOrEmpty(path)) {
return null; return null;
} }
String filename = path.substring(path.lastIndexOf('/') + 1).toLowerCase(); final String filenameQueryAnchor = path.substring(path.lastIndexOf('/') + 1);
int dotPosition = filename.lastIndexOf("."); final String filenameQuery = cutBefore(filenameQueryAnchor, '#');
final String filename = cutBefore(filenameQuery, '?');
final int dotPosition = filename.lastIndexOf('.');
if (dotPosition != -1) { if (dotPosition == -1) {
String extension = filename.substring(dotPosition + 1); return null;
}
final String extension = filename.substring(dotPosition + 1);
// we want the real file extension, not the crypto one // we want the real file extension, not the crypto one
if (ignoreCryptoExtension && Transferable.VALID_CRYPTO_EXTENSIONS.contains(extension)) { if (ignoreCryptoExtension && Transferable.VALID_CRYPTO_EXTENSIONS.contains(extension)) {
return extractRelevantExtension(filename.substring(0, dotPosition)); return extractRelevantExtension(filename.substring(0, dotPosition));
@ -603,6 +611,13 @@ public final class MimeUtils {
return extension; return extension;
} }
} }
return null;
private static String cutBefore(final String input, final char c) {
final int position = input.indexOf(c);
if (position > 0) {
return input.substring(0, position);
} else {
return input;
}
} }
} }

View File

@ -35,6 +35,8 @@ public class XmppUri {
private Map<String, String> parameters = Collections.emptyMap(); private Map<String, String> parameters = Collections.emptyMap();
private boolean safeSource = true; private boolean safeSource = true;
public static final String INVITE_DOMAIN = "conversations.im";
public XmppUri(final String uri) { public XmppUri(final String uri) {
try { try {
parse(Uri.parse(uri)); parse(Uri.parse(uri));
@ -136,10 +138,10 @@ public class XmppUri {
return; return;
} }
this.uri = uri; this.uri = uri;
String scheme = uri.getScheme(); final String scheme = uri.getScheme();
String host = uri.getHost(); final String host = uri.getHost();
List<String> segments = uri.getPathSegments(); List<String> segments = uri.getPathSegments();
if ("https".equalsIgnoreCase(scheme) && "conversations.im".equalsIgnoreCase(host)) { if ("https".equalsIgnoreCase(scheme) && INVITE_DOMAIN.equalsIgnoreCase(host)) {
if (segments.size() >= 2 && segments.get(1).contains("@")) { if (segments.size() >= 2 && segments.get(1).contains("@")) {
// sample : https://conversations.im/i/foo@bar.com // sample : https://conversations.im/i/foo@bar.com
try { try {

View File

@ -255,6 +255,7 @@ public class WebRTCWrapper {
rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp
rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN; rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.NEGOTIATE;
final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver); final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver);
if (peerConnection == null) { if (peerConnection == null) {
throw new InitializationException("Unable to create PeerConnection"); throw new InitializationException("Unable to create PeerConnection");

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorPrimaryDark"
android:padding="24dp">
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateTint="@color/white" />
<TextView
android:id="@+id/error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/progress"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:gravity="center_horizontal"
android:textAppearance="@style/TextAppearance.Conversations.Body2"
android:textColor="@color/white87"
android:visibility="invisible" />
</RelativeLayout>
</layout>

View File

@ -2,22 +2,22 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/discover_public_channels" android:id="@+id/discover_public_channels"
android:title="@string/discover_channels" android:icon="@drawable/ic_search_white_24dp"
android:icon="@drawable/ic_search_white_24dp"/> android:title="@string/discover_channels" />
<item <item
android:id="@+id/join_public_channel" android:id="@+id/join_public_channel"
android:title="@string/join_public_channel" android:icon="@drawable/ic_input_white_24dp"
android:icon="@drawable/ic_input_white_24dp"/> android:title="@string/join_public_channel" />
<item <item
android:id="@+id/create_public_channel" android:id="@+id/create_public_channel"
android:title="@string/create_public_channel" android:icon="@drawable/ic_public_white_24dp"
android:icon="@drawable/ic_public_white_24dp"/> android:title="@string/create_public_channel" />
<item <item
android:id="@+id/create_private_group_chat" android:id="@+id/create_private_group_chat"
android:title="@string/create_private_group_chat" android:icon="@drawable/ic_group_white_24dp"
android:icon="@drawable/ic_group_white_24dp"/> android:title="@string/create_private_group_chat" />
<item <item
android:id="@+id/create_contact" android:id="@+id/create_contact"
android:title="@string/add_contact" android:icon="@drawable/ic_person_white_48dp"
android:icon="@drawable/ic_person_white_48dp"/> android:title="@string/add_contact" />
</menu> </menu>

View File

@ -968,5 +968,7 @@
<string name="backup_started_message">The backup has been started. Youll get a notification once it has been completed.</string> <string name="backup_started_message">The backup has been started. Youll get a notification once it has been completed.</string>
<string name="unable_to_enable_video">Unable to enable video.</string> <string name="unable_to_enable_video">Unable to enable video.</string>
<string name="plain_text_document">Plain text document</string> <string name="plain_text_document">Plain text document</string>
<string name="account_registrations_are_not_supported">Account registrations are not supported</string>
<string name="no_xmpp_adddress_found">No XMPP address found</string>
</resources> </resources>