From 73d66fd703c7edb2476ff0defad1608d974ff584 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 30 Apr 2019 10:45:25 +0200 Subject: [PATCH 1/9] go forward through cursor in message restore We have seen some weird CursorIndexNotFoundException that we were unable to reproduce. We assume that going forward (moveToNext()) through the cursor instead of (moveToPrevious() fixes that issue --- .../siacs/conversations/entities/Message.java | 40 +++++---------- .../persistance/DatabaseBackend.java | 49 +++---------------- 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index e960d62d3..02fa07818 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -3,7 +3,6 @@ package eu.siacs.conversations.entities; import android.content.ContentValues; import android.database.Cursor; import android.graphics.Color; -import android.support.annotation.ColorInt; import android.text.SpannableStringBuilder; import android.util.Log; @@ -181,35 +180,11 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable } public static Message fromCursor(Cursor cursor, Conversation conversation) { - Jid jid; - try { - String value = cursor.getString(cursor.getColumnIndex(COUNTERPART)); - if (value != null) { - jid = Jid.of(value); - } else { - jid = null; - } - } catch (IllegalArgumentException e) { - jid = null; - } catch (IllegalStateException e) { - return null; // message too long? - } - Jid trueCounterpart; - try { - String value = cursor.getString(cursor.getColumnIndex(TRUE_COUNTERPART)); - if (value != null) { - trueCounterpart = Jid.of(value); - } else { - trueCounterpart = null; - } - } catch (IllegalArgumentException e) { - trueCounterpart = null; - } return new Message(conversation, cursor.getString(cursor.getColumnIndex(UUID)), cursor.getString(cursor.getColumnIndex(CONVERSATION)), - jid, - trueCounterpart, + fromString(cursor.getString(cursor.getColumnIndex(COUNTERPART))), + fromString(cursor.getString(cursor.getColumnIndex(TRUE_COUNTERPART))), cursor.getString(cursor.getColumnIndex(BODY)), cursor.getLong(cursor.getColumnIndex(TIME_SENT)), cursor.getInt(cursor.getColumnIndex(ENCRYPTION)), @@ -229,6 +204,17 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable cursor.getInt(cursor.getColumnIndex(DELETED)) > 0); } + private static Jid fromString(String value) { + try { + if (value != null) { + return Jid.of(value); + } + } catch (IllegalArgumentException e) { + return null; + } + return null; + } + public static Message createStatusMessage(Conversation conversation, String body) { final Message message = new Message(conversation); message.setType(Message.TYPE_STATUS); diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index c893d80c9..b9d5d5bbe 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -28,10 +28,8 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -751,14 +749,15 @@ public class DatabaseBackend extends SQLiteOpenHelper { null, null, Message.TIME_SENT + " DESC", String.valueOf(limit)); } - if (cursor.getCount() > 0) { - cursor.moveToLast(); - do { - Message message = Message.fromCursor(cursor, conversation); + while (cursor.moveToNext()) { + try { + final Message message = Message.fromCursor(cursor, conversation); if (message != null) { - list.add(message); + list.add(0, message); } - } while (cursor.moveToPrevious()); + } catch (Exception e) { + Log.e(Config.LOGTAG,"unable to restore message"); + } } cursor.close(); return list; @@ -771,40 +770,6 @@ public class DatabaseBackend extends SQLiteOpenHelper { return db.rawQuery(SQL, new String[]{FtsUtils.toMatchString(term)}); } - public Iterable getMessagesIterable(final Conversation conversation) { - return () -> { - class MessageIterator implements Iterator { - private SQLiteDatabase db = getReadableDatabase(); - private String[] selectionArgs = {conversation.getUuid()}; - private Cursor cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION - + "=?", selectionArgs, null, null, Message.TIME_SENT - + " ASC", null); - - private MessageIterator() { - cursor.moveToFirst(); - } - - @Override - public boolean hasNext() { - return !cursor.isAfterLast(); - } - - @Override - public Message next() { - Message message = Message.fromCursor(cursor, conversation); - cursor.moveToNext(); - return message; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - return new MessageIterator(); - }; - } - public List markFileAsDeleted(final File file, final boolean internal) { SQLiteDatabase db = this.getReadableDatabase(); String selection; From 61604dedead6cb1c73467c36f260f0091987ab88 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 30 Apr 2019 11:23:15 +0200 Subject: [PATCH 2/9] jingle: send canditate error before fallback --- src/main/java/eu/siacs/conversations/Config.java | 2 +- .../eu/siacs/conversations/xmpp/jingle/JingleConnection.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index d95e4d906..da5cf4a81 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -122,7 +122,7 @@ public final class Config { public static final int EXPIRY_INTERVAL = 30 * 60 * 1000; // 30 minutes - public static final String ENABLED_CIPHERS[] = { + public static final String[] ENABLED_CIPHERS = { "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA256", diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 9e70f3e5f..843079aea 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -1003,16 +1003,17 @@ public class JingleConnection implements Transferable { } private void sendCandidateError() { + Log.d(Config.LOGTAG,"sending canditate error"); JinglePacket packet = bootstrapPacket("transport-info"); Content content = new Content(this.contentCreator, this.contentName); content.setTransportId(this.transportId); content.socks5transport().addChild("candidate-error"); packet.setContent(content); this.sentCandidate = true; + this.sendJinglePacket(packet); if (receivedCandidate && mJingleStatus == JINGLE_STATUS_ACCEPTED) { connect(); } - this.sendJinglePacket(packet); } public int getJingleStatus() { From 3d208e6e34c73c227c5fdbc2c10451c2bd2ecbd3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 1 May 2019 19:11:37 +0200 Subject: [PATCH 3/9] pulled translations from transifex --- src/conversations/res/values-eu/strings.xml | 9 +++++++++ src/conversations/res/values-pl/strings.xml | 9 +++++++++ src/conversations/res/values-pt-rBR/strings.xml | 7 ++++++- src/main/res/values-eu/strings.xml | 14 ++++++++++++-- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/conversations/res/values-eu/strings.xml create mode 100644 src/conversations/res/values-pl/strings.xml diff --git a/src/conversations/res/values-eu/strings.xml b/src/conversations/res/values-eu/strings.xml new file mode 100644 index 000000000..c41df2b88 --- /dev/null +++ b/src/conversations/res/values-eu/strings.xml @@ -0,0 +1,9 @@ + + + Hautatu zure XMPP hornitzailea + Erabili conversations.im + Kontu berria sortu + XMPP kontu bat badaukazu dagoeneko? Horrela izan daiteke beste XMPP aplikazio bat erabiltzen baduzu edo Conversations lehenago erabili baduzu. Bestela XMPP kontu berri bat sortu dezakezu oraintxe bertan.\nIradokizuna: email hornitzaile batzuek XMPP kontuak hornitzen dituzte ere. + XMPP hornitzailez independientea den bat-bateko mezularitza sare bat da. Aplikazio hau nahi duzun XMPP zerbitzariarekin erabili dezakezu.\nHala ere zure erosotasunerako conversations.im¹-en, Conversationsekin bereziki erabiltzeko egokia den hornitzaile batean, kontu bat sortzea erraz egin dugu. + + \ No newline at end of file diff --git a/src/conversations/res/values-pl/strings.xml b/src/conversations/res/values-pl/strings.xml new file mode 100644 index 000000000..5c9e961ce --- /dev/null +++ b/src/conversations/res/values-pl/strings.xml @@ -0,0 +1,9 @@ + + + Wybierz dostawcę XMPP + Użyj conversations.im + Stwórz nowe konto + Czy masz już konto XMPP? Tak może być jeśli używasz już innego klienta XMPP lub używałeś już Conversations. Jeśli nie możesz stworzyć nowe konto XMPP teraz.\nPodpowiedź: Niektórzy dostawcy poczty oferują również konta XMPP. + XMPP to niezależna od dostawcy sieć komunikacji błyskawicznej. Możesz użyć tego klienta z dowolnym serwerem XMPP.\nDla twojej wygody jednak ułatwiliśmy stworzenie konta na conversations.im¹; dostawcy specjalnie dostosowanego do pracy z Conversations. + + \ No newline at end of file diff --git a/src/conversations/res/values-pt-rBR/strings.xml b/src/conversations/res/values-pt-rBR/strings.xml index a2f903bdf..478f6ec85 100644 --- a/src/conversations/res/values-pt-rBR/strings.xml +++ b/src/conversations/res/values-pt-rBR/strings.xml @@ -1,4 +1,9 @@ Selecione o seu provedor XMPP - \ No newline at end of file + Usar o conversations.im + Criar uma nova conta + Você já possui uma conta XMPP? Esse pode ser o seu caso caso já esteja usando um outro cliente XMPP ou tenha usado o Conversations antes. Caso contrário, você pode criar uma nova conta XMPP agora.\nDica: alguns provedores de e-mail também fornecem contas XMPP. + O XMPP é uma rede de mensageria instantânea independente de provedor. Você pode usar esse cliente com qualquer servidor XMPP que você escolher.\nEntretanto, para sua conveniência, nós simplificamos o processo de criação de uma conta em conversations.im¹, um provedor especialmente configurado para se usar com o Conversations. + + \ No newline at end of file diff --git a/src/main/res/values-eu/strings.xml b/src/main/res/values-eu/strings.xml index 36a14c57d..2edec94ae 100644 --- a/src/main/res/values-eu/strings.xml +++ b/src/main/res/values-eu/strings.xml @@ -422,8 +422,8 @@ Kokapena erakutsi dezakeen aplikaziorik ez da aurkitu Kokapena Elkarrizketa itxi egin da - Talde pribatua utzi - Kanal publikoa utzi + Talde pribatua utzi da + Kanal publikoa utzi da Sistemaren CAtaz ez fidatu Ziurtagiri guztiak eskuz onartu behar dira Ziurtagiriak kendu @@ -852,4 +852,14 @@ Parte-hartzaileak bilatu Fitxategia handiegia da Erantsi + Kanalak aurkitu + Kanalak bilatu + Balizko pribatutasun urraketa! + search.jabbercat.org izeneko hirugarren zerbitzu bat erabiltzen du.

Ezaugarri hau erabiltzeak zure IP helbidea eta bilatutako testua zerbitzu horretara bidaltzea dakar. Ikusi beren pribatutasun politika informazio gehiago lortzeko.]]>
+ Badaukat kontu bat dagoeneko + Gehitu existitzen den kontu bat + Kontu berria erregistratu + Honek domeinu helbide baten itxura dauka + Gehitu hala ere + Honek kanal helbide baten itxura dauka From 818f2ab61c67649d076d4f7d899cf5eb4790d43d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 2 May 2019 20:09:16 +0200 Subject: [PATCH 4/9] fixed rare NPE cause by race --- .../eu/siacs/conversations/ui/widget/EditMessage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java index 1ce695ab3..342867576 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java @@ -87,16 +87,20 @@ public class EditMessage extends EmojiWrapperEditText { } private void triggerKeyboardEvents(final int length) { + final KeyboardListener listener = this.keyboardListener; + if (listener == null) { + return; + } this.mTypingHandler.removeCallbacks(mTypingTimeout); this.mTypingHandler.postDelayed(mTypingTimeout, Config.TYPING_TIMEOUT * 1000); if (!isUserTyping && length > 0) { this.isUserTyping = true; - this.keyboardListener.onTypingStarted(); + listener.onTypingStarted(); } else if (length == 0) { this.isUserTyping = false; - this.keyboardListener.onTextDeleted(); + listener.onTextDeleted(); } - this.keyboardListener.onTextChanged(); + listener.onTextChanged(); } public void setKeyboardListener(KeyboardListener listener) { From 82dcae59e3f150b033b4120680d71ac81b504686 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 2 May 2019 20:09:43 +0200 Subject: [PATCH 5/9] added language tag in channel search results --- .../http/services/MuclumbusService.java | 7 ++++ .../adapter/ChannelSearchResultAdapter.java | 11 +++++- .../conversations/utils/LanguageUtils.java | 28 +++++++++++++++ src/main/res/layout/search_result_item.xml | 35 +++++++++++++------ 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 src/main/java/eu/siacs/conversations/utils/LanguageUtils.java diff --git a/src/main/java/eu/siacs/conversations/http/services/MuclumbusService.java b/src/main/java/eu/siacs/conversations/http/services/MuclumbusService.java index 5ef557c0f..4f2b8f533 100644 --- a/src/main/java/eu/siacs/conversations/http/services/MuclumbusService.java +++ b/src/main/java/eu/siacs/conversations/http/services/MuclumbusService.java @@ -4,9 +4,11 @@ import com.google.common.base.Objects; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import eu.siacs.conversations.services.AvatarService; +import eu.siacs.conversations.utils.LanguageUtils; import eu.siacs.conversations.utils.UIHelper; import retrofit2.Call; import retrofit2.http.Body; @@ -35,6 +37,7 @@ public interface MuclumbusService { public String address; public String name; public String description; + public String language; public String getName() { return name; @@ -52,6 +55,10 @@ public interface MuclumbusService { } } + public String getLanguage() { + return LanguageUtils.convert(language); + } + @Override public int getAvatarBackgroundColor() { Jid room = getRoom(); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java index 7d1a7c873..03f09f70c 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java @@ -10,6 +10,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import java.util.Locale; + import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.SearchResultItemBinding; import eu.siacs.conversations.http.services.MuclumbusService; @@ -38,7 +40,7 @@ public class ChannelSearchResultAdapter extends ListAdapter listener.onChannelSearchResult(searchResult)); diff --git a/src/main/java/eu/siacs/conversations/utils/LanguageUtils.java b/src/main/java/eu/siacs/conversations/utils/LanguageUtils.java new file mode 100644 index 000000000..28cb44343 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/utils/LanguageUtils.java @@ -0,0 +1,28 @@ +package eu.siacs.conversations.utils; + +import com.google.common.collect.ImmutableMap; + +import java.util.Locale; +import java.util.Map; + +public class LanguageUtils { + + private static final Map LANGUAGE_MAP; + + static { + ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); + builder.put("german","de"); + builder.put("deutsch","de"); + builder.put("english","en"); + builder.put("russian","ru"); + LANGUAGE_MAP = builder.build(); + } + + public static String convert(final String in) { + if (in == null) { + return null; + } + final String out = LANGUAGE_MAP.get(in.toLowerCase(Locale.US)); + return out == null ? in : out; + } +} diff --git a/src/main/res/layout/search_result_item.xml b/src/main/res/layout/search_result_item.xml index 2d77be1fb..c006dabd8 100644 --- a/src/main/res/layout/search_result_item.xml +++ b/src/main/res/layout/search_result_item.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + app:riv_corner_radius="2dp" /> - + android:layout_marginLeft="@dimen/avatar_item_distance" + android:layout_toRightOf="@+id/avatar"> + android:textAppearance="@style/TextAppearance.Conversations.Subhead" + tools:text="Proosdy IM Chat trantu" /> + + + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + - + android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary" /> + \ No newline at end of file From ba327d8512a4b3f1c3bde5ef6135366108f6f680 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 3 May 2019 10:48:33 +0200 Subject: [PATCH 6/9] set own omemo devices to inactive after 14 days of inactivity; was 7 days --- src/main/java/eu/siacs/conversations/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index da5cf4a81..56615dc97 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -94,7 +94,7 @@ public final class Config { public static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000; - public static final long OMEMO_AUTO_EXPIRY = 7 * MILLISECONDS_IN_DAY; + public static final long OMEMO_AUTO_EXPIRY = 14 * MILLISECONDS_IN_DAY; public static final boolean REMOVE_BROKEN_DEVICES = false; public static final boolean OMEMO_PADDING = false; public static final boolean PUT_AUTH_TAG_INTO_KEY = true; From 8736db3bc46d1da2fafb1ba978a01c42b228a519 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 3 May 2019 10:48:51 +0200 Subject: [PATCH 7/9] pulled translations from transifex --- src/conversations/res/values-gl/strings.xml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/conversations/res/values-gl/strings.xml diff --git a/src/conversations/res/values-gl/strings.xml b/src/conversations/res/values-gl/strings.xml new file mode 100644 index 000000000..ab865b8b1 --- /dev/null +++ b/src/conversations/res/values-gl/strings.xml @@ -0,0 +1,9 @@ + + + Escolla o seu provedor XMPP + Utilizar conversations.im + Crear nova conta + Xa posúe unha conta XMPP? Este pode ser o caso se xa está a utilizar outro cliente XMPP ou utilizou Conversations previamente. Se non é así pode crear unha nova conta agora mesmo.\nTruco: Algúns provedores de correo tamén proporcionan contas XMPP. + XMPP é unha rede de mensaxería independente do provedor. Pode utilizar este cliente con calquer provedor XMPP da súa elección.\nMais para a súa conveniencia fixemos que fose doado crear unha conta en conversations.im¹; un provedor especialmente axeitado para utilizar con Conversations. + + \ No newline at end of file From 43254663fbdef2ac041d1d48fcb8a48d90e9e868 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 3 May 2019 10:49:46 +0200 Subject: [PATCH 8/9] version bump to 2.5.1 + changelog --- CHANGELOG.md | 4 ++++ build.gradle | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc89dc90..f4b42603c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### Version 2.5.1 +* minor bug fixes +* Set own OMEMO devices to inactive after not seing them for 14 days. (was 7 days) + ### Version 2.5.0 * Added channel search via search.jabbercat.org * Reworked onboarding screens diff --git a/build.gradle b/build.gradle index ef1dd74af..a191d6e8e 100644 --- a/build.gradle +++ b/build.gradle @@ -81,8 +81,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 28 - versionCode 326 - versionName "2.5.0" + versionCode 327 + versionName "2.5.1" archivesBaseName += "-$versionName" applicationId "eu.siacs.conversations" resValue "string", "applicationId", applicationId From 2869ed44a64b55211b87553a6d43efc37eff557e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 3 May 2019 11:58:53 +0200 Subject: [PATCH 9/9] fixed typo in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4b42603c..6ac520342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Version 2.5.1 * minor bug fixes -* Set own OMEMO devices to inactive after not seing them for 14 days. (was 7 days) +* Set own OMEMO devices to inactive after not seeing them for 14 days. (was 7 days) ### Version 2.5.0 * Added channel search via search.jabbercat.org