From ce192ad34d856e4d92f8e89c9716b7649de4dc74 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Mon, 28 Sep 2020 17:06:15 -0400 Subject: [PATCH 01/12] fix how we look up the canonical address or alias --- .../matrix/plugin/MatrixChatSessionManager.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixChatSessionManager.java b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixChatSessionManager.java index 0256e9e..adf1193 100644 --- a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixChatSessionManager.java +++ b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixChatSessionManager.java @@ -657,19 +657,20 @@ public void enableEncryption (ChatSession session, boolean enableEncryption) } - public String getPublicAddress (ChatSession session) - { + public String getPublicAddress (ChatSession session) { Room room = getRoom(session); - List listAlias = room.getAliases(); + String publicAddress = room.getState().getCanonicalAlias(); - if (listAlias != null && (!listAlias.isEmpty())) - { - return listAlias.get(0); + if (publicAddress == null) { + List listAlias = room.getState().getAliases(); + if (listAlias != null && (!listAlias.isEmpty())) { + publicAddress = listAlias.get(0); + } } - return null; + return publicAddress; } public void setPublic (ChatSession session, boolean isPublic) From 531149fc0cfbc2520478bd732ecfba15db340637 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Mon, 28 Sep 2020 17:06:25 -0400 Subject: [PATCH 02/12] update group invite link sharing --- .../ui/contacts/GroupDisplayActivity.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/guardianproject/keanuapp/ui/contacts/GroupDisplayActivity.java b/app/src/main/java/info/guardianproject/keanuapp/ui/contacts/GroupDisplayActivity.java index 43a44e1..a206cd9 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ui/contacts/GroupDisplayActivity.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ui/contacts/GroupDisplayActivity.java @@ -45,6 +45,7 @@ import info.guardianproject.keanu.core.service.IChatSessionManager; import info.guardianproject.keanu.core.service.IImConnection; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -237,8 +238,14 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) public void onClick(View v) { String inviteString; try { - inviteString = OnboardingManager.generateInviteLink(mAddress); - OnboardingManager.inviteScan(GroupDisplayActivity.this, inviteString); + if (mSession != null) { + mSession.setPublic(true); + String publicAddress = mSession.getPublicAddress(); + if (!TextUtils.isEmpty(publicAddress)) { + inviteString = OnboardingManager.generateInviteLink(URLEncoder.encode(publicAddress,"UTF-8")); + OnboardingManager.inviteScan(GroupDisplayActivity.this, inviteString); + } + } } catch (Exception e) { e.printStackTrace(); } @@ -256,11 +263,19 @@ public void onClick(View v) { try { if (mSession != null) { mSession.setPublic(true); + + String publicAddress = mSession.getPublicAddress(); + + if (!TextUtils.isEmpty(publicAddress)) { + String inviteLink = OnboardingManager.generateInviteLink(URLEncoder.encode(publicAddress,"UTF-8")); + new QrShareAsyncTask(GroupDisplayActivity.this).execute(inviteLink, mName); + } + } } catch (Exception ignored){} - String inviteLink = OnboardingManager.generateInviteLink(mAddress); - new QrShareAsyncTask(GroupDisplayActivity.this).execute(inviteLink, mName); + + } catch (Exception e) { Log.e(LOG_TAG, "couldn't generate QR code", e); } From 87496755eefbd5bfda66472e5b183d67ebe9fe9a Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Mon, 28 Sep 2020 17:07:02 -0400 Subject: [PATCH 03/12] update libs to 0.0.1.65 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 1a84116..97193cb 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,8 @@ allprojects { maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } } project.ext { - keanuLibsVersionCode=164 - keanuLibsVersion="0.0.1.64" + keanuLibsVersionCode=165 + keanuLibsVersion="0.0.1.65" } } From 0888c5a8f7a29a7d48e4c4fd4edc722fcd5a16c0 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Fri, 9 Oct 2020 13:40:10 -0400 Subject: [PATCH 04/12] update core to support media replies and contact names --- .../keanu/core/service/IChatSession.aidl | 2 +- .../keanu/core/provider/Imps.java | 1 + .../keanu/core/provider/ImpsProvider.java | 2 + .../service/adapters/ChatSessionAdapter.java | 114 ++++++++++-------- 4 files changed, 65 insertions(+), 54 deletions(-) diff --git a/keanuCore/src/main/aidl/info/guardianproject/keanu/core/service/IChatSession.aidl b/keanuCore/src/main/aidl/info/guardianproject/keanu/core/service/IChatSession.aidl index 4157159..f259498 100644 --- a/keanuCore/src/main/aidl/info/guardianproject/keanu/core/service/IChatSession.aidl +++ b/keanuCore/src/main/aidl/info/guardianproject/keanu/core/service/IChatSession.aidl @@ -93,7 +93,7 @@ interface IChatSession { /** * Sends data to all participants in this ChatSession. */ - boolean offerData(String offerId, String localUri, String type); + boolean offerData(String offerId, String replyId, String localUri, String type); /** * Mark this chat session as read. diff --git a/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/Imps.java b/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/Imps.java index 51347d6..0eb4e32 100644 --- a/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/Imps.java +++ b/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/Imps.java @@ -1029,6 +1029,7 @@ public static final Uri getOtrMessagesContentUriByAccount(long accountId) { * (joined with the contacts table) */ public static final String CONTACT = "contact"; + public static final String CONTACT_NAME = "contact_name"; } /** Columns for the GroupMember table. */ diff --git a/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/ImpsProvider.java b/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/ImpsProvider.java index 29e1084..009dde7 100644 --- a/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/ImpsProvider.java +++ b/keanuCore/src/main/java/info/guardianproject/keanu/core/provider/ImpsProvider.java @@ -1226,6 +1226,7 @@ public boolean columnExists(SQLiteDatabase db, String tableName, String column) "messages.mime_type AS mime_type"); // contacts columns sMessagesProjectionMap.put(Imps.Messages.CONTACT, "contacts.username AS contact"); + sMessagesProjectionMap.put(Imps.Messages.CONTACT_NAME, "contacts.nickname AS contact_name"); sMessagesProjectionMap.put(Imps.Contacts.PROVIDER, "contacts.provider AS provider"); sMessagesProjectionMap.put(Imps.Contacts.ACCOUNT, "contacts.account AS account"); sMessagesProjectionMap.put("contact_type", "contacts.type AS contact_type"); @@ -1256,6 +1257,7 @@ public boolean columnExists(SQLiteDatabase db, String tableName, String column) "inMemoryMessages.mime_type AS mime_type"); // contacts columns sInMemoryMessagesProjectionMap.put(Imps.Messages.CONTACT, "contacts.username AS contact"); + sInMemoryMessagesProjectionMap.put(Imps.Messages.CONTACT_NAME, "contacts.nickname AS contact_name"); sInMemoryMessagesProjectionMap.put(Imps.Contacts.PROVIDER, "contacts.provider AS provider"); sInMemoryMessagesProjectionMap.put(Imps.Contacts.ACCOUNT, "contacts.account AS account"); sInMemoryMessagesProjectionMap.put("contact_type", "contacts.type AS contact_type"); diff --git a/keanuCore/src/main/java/info/guardianproject/keanu/core/service/adapters/ChatSessionAdapter.java b/keanuCore/src/main/java/info/guardianproject/keanu/core/service/adapters/ChatSessionAdapter.java index ca80fb0..89845d8 100644 --- a/keanuCore/src/main/java/info/guardianproject/keanu/core/service/adapters/ChatSessionAdapter.java +++ b/keanuCore/src/main/java/info/guardianproject/keanu/core/service/adapters/ChatSessionAdapter.java @@ -549,7 +549,7 @@ private Message storeMediaMessage(String mediaPath, String mimeType, String file @Override - public boolean offerData(String offerId, final String mediaPath, final String mimeType) { + public boolean offerData(String offerId, String replyToId, final String mediaPath, final String mimeType) { if (TextUtils.isEmpty(mimeType)) return false; @@ -626,14 +626,14 @@ else if (mediaUri.getScheme() != null && } } - sendMediaMessageAsync(mediaPath, mimeType, fileName, fileLength); + sendMediaMessageAsync(replyToId, mediaPath, mimeType, fileName, fileLength); return true; } - private void sendMediaMessageAsync (final String mediaPath, final String mimeType, final String fileName, final long fileLength) + private void sendMediaMessageAsync (final String replyToId, final String mediaPath, final String mimeType, final String fileName, final long fileLength) { //TODO do HTTP Upload XEP 363 @@ -644,9 +644,10 @@ private void sendMediaMessageAsync (final String mediaPath, final String mimeTyp public void run () { - final Message msgMedia = storeMediaMessage(mediaPath, mimeType, fileName); + final Message msgMedia = storeMediaMessage(mediaPath, mimeType, replyToId); + + msgMedia.setReplyId(replyToId); - /** UploadProgressListener listener = new UploadProgressListener() { @Override public void onUploadProgress(long sent, long total) { @@ -657,7 +658,7 @@ public void onUploadProgress(long sent, long total) { if (mDataHandlerListener != null) mDataHandlerListener.onTransferProgress(true,"","",mediaPath,percentF); } - };**/ + }; int newType = mChatSession.sendMessageAsync(msgMedia, new ChatSessionListener() { @Override @@ -685,7 +686,8 @@ public void onMessageSendFail(Message msg, String newPacketId) { if (msg.getDateTime() != null) sendTime = msg.getDateTime().getTime(); - updateMessageInDb(msg.getID(),Imps.MessageType.QUEUED,sendTime, null, newPacketId); + updateMessageInDb(msg.getID(),msg.getType(),sendTime, null, newPacketId); + msg.setID(newPacketId); } @@ -705,64 +707,65 @@ public void onMessageSendQueued(Message msg, String newPacketId) { /** - String resultUrl = mConnection.sendMediaMessage(mChatSession.getParticipant().getAddress().getAddress(), Uri.parse(mediaPath), sendFileName, mimeType, fileLength, doEncryption, listener); + String resultUrl = mConnection.sendMediaMessage(mChatSession.getParticipant().getAddress().getAddress(), Uri.parse(mediaPath), sendFileName, mimeType, fileLength, doEncryption, listener); - int newType = Imps.MessageType.OUTGOING_ENCRYPTED; + int newType = Imps.MessageType.OUTGOING_ENCRYPTED; - if (TextUtils.isEmpty(resultUrl)) - newType = Imps.MessageType.QUEUED; + if (TextUtils.isEmpty(resultUrl)) + newType = Imps.MessageType.QUEUED; - long sendTime = System.currentTimeMillis(); - msgMedia.setBody(resultUrl); - if (msgMedia.getDateTime() != null) - sendTime = msgMedia.getDateTime().getTime(); + long sendTime = System.currentTimeMillis(); + msgMedia.setBody(resultUrl); + if (msgMedia.getDateTime() != null) + sendTime = msgMedia.getDateTime().getTime(); - updateMessageInDb(msgMedia.getID(),newType,sendTime,mediaPath + ' ' + resultUrl, null); - **/ + updateMessageInDb(msgMedia.getID(),newType,sendTime,mediaPath + ' ' + resultUrl, null); + **/ /** - String mediaPath = localUrl + ' ' + publishUrl; + String mediaPath = localUrl + ' ' + publishUrl; - long sendTime = System.currentTimeMillis(); + long sendTime = System.currentTimeMillis(); - msg.setBody(publishUrl); - // insertOrUpdateChat(mediaPath); + msg.setBody(publishUrl); + // insertOrUpdateChat(mediaPath); - int newType = mChatSession.sendMessageAsync(msg, mEnableOmemoGroups); + int newType = mChatSession.sendMessageAsync(msg, mEnableOmemoGroups); - if (msg.getDateTime() != null) - sendTime = msg.getDateTime().getTime(); + if (msg.getDateTime() != null) + sendTime = msg.getDateTime().getTime(); - updateMessageInDb(msg.getID(),newType,sendTime,mediaPath); - */ + updateMessageInDb(msg.getID(),newType,sendTime,mediaPath); + */ //make sure result is valid and starts with https, if so, send it! /** - if (!TextUtils.isEmpty(resultUrl)) { - - if (Preferences.useProofMode()) { - Uri proofUri = Uri.parse(mediaPath + PROOF_FILE_TAG); - File fileProof = new info.guardianproject.iocipher.File(proofUri.getPath()); - if (fileProof.exists()) { - String proofUrl = null; - try { - proofUrl = mConnection.publishFile(sendFileName + ProofMode.PROOF_FILE_TAG, ProofMode.PROOF_MIME_TYPE, fileProof.length(), new info.guardianproject.iocipher.FileInputStream(fileProof), doEncryption, null); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - resultUrl += ' ' + proofUrl; - } - } - - sendMediaMessage(mediaPath, resultUrl, msgMedia); - }**/ + if (!TextUtils.isEmpty(resultUrl)) { + + if (Preferences.useProofMode()) { + Uri proofUri = Uri.parse(mediaPath + PROOF_FILE_TAG); + File fileProof = new info.guardianproject.iocipher.File(proofUri.getPath()); + if (fileProof.exists()) { + String proofUrl = null; + try { + proofUrl = mConnection.publishFile(sendFileName + ProofMode.PROOF_FILE_TAG, ProofMode.PROOF_MIME_TYPE, fileProof.length(), new info.guardianproject.iocipher.FileInputStream(fileProof), doEncryption, null); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + resultUrl += ' ' + proofUrl; + } + } + + sendMediaMessage(mediaPath, resultUrl, msgMedia); + }**/ } }.start(); } + /** * Sends a message to other participant(s) in this session without adding it * to the history. @@ -811,7 +814,7 @@ void sendPostponedMessages() { String[] projection = new String[]{BaseColumns._ID, Imps.Messages.BODY, Imps.Messages.PACKET_ID, - Imps.Messages.DATE, Imps.Messages.TYPE, Imps.Messages.IS_DELIVERED}; + Imps.Messages.DATE, Imps.Messages.TYPE, Imps.Messages.IS_DELIVERED,Imps.Messages.REPLY_ID}; String selection = Imps.Messages.TYPE + "=?"; Cursor c = mContentResolver.query(mMessageURI, projection, selection, @@ -822,31 +825,36 @@ void sendPostponedMessages() { } if (c.getCount() > 0) { - ArrayList messages = new ArrayList(); + ArrayList messages = new ArrayList(); + + while (c.moveToNext()) { + Message msg = new Message(c.getString(1)); + msg.setReplyId(c.getString(6)); + messages.add(msg); + } - while (c.moveToNext()) - messages.add(c.getString(1)); removeMessageInDb(Imps.MessageType.QUEUED); - for (String body : messages) { + for (Message msg : messages) { - if (body.startsWith("vfs:/") && (body.split(" ").length == 1)) + if (msg.getBody().startsWith("vfs:/") && (msg.getBody().split(" ").length == 1)) { String offerId = UUID.randomUUID().toString(); - String mimeType = URLConnection.guessContentTypeFromName(body); + String mimeType = URLConnection.guessContentTypeFromName(msg.getBody()); if (mimeType != null) { if (mimeType.startsWith("text")) mimeType = "text/plain"; - offerData(offerId, body, mimeType); + offerData(offerId, msg.getReplyId(), msg.getBody(), mimeType); } } else { - sendMessage(body, false, false, false, null); + sendMessage(msg.getBody(), false, false, false, null); } } + } c.close(); From aae4a08a1db2eb7286c8b3e793914fbd4fc80f79 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Fri, 9 Oct 2020 13:41:00 -0400 Subject: [PATCH 05/12] update libs to 0.0.1.66 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 97193cb..b2563fd 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,8 @@ allprojects { maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } } project.ext { - keanuLibsVersionCode=165 - keanuLibsVersion="0.0.1.65" + keanuLibsVersionCode=166 + keanuLibsVersion="0.0.1.66" } } From 0160aa24e622c9d1db7ae2b49707d61c43c78cf9 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Fri, 9 Oct 2020 13:56:04 -0400 Subject: [PATCH 06/12] update code to use new core method improvements --- .../java/info/guardianproject/keanuapp/ImUrlActivity.java | 4 ++-- .../keanuapp/ui/conversation/ConversationDetailActivity.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/guardianproject/keanuapp/ImUrlActivity.java b/app/src/main/java/info/guardianproject/keanuapp/ImUrlActivity.java index ff9d95f..0289588 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ImUrlActivity.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ImUrlActivity.java @@ -751,7 +751,7 @@ else if (mSendUri != null) { if (SecureMediaStore.isVfsUri(mSendUri)) { - boolean sent = session.offerData(offerId, mSendUri.toString(), mSendType); + boolean sent = session.offerData(offerId, null, mSendUri.toString(), mSendType); if (sent) return; @@ -768,7 +768,7 @@ else if (mSendUri != null) { mSendUri = importedMediaUri; } - boolean sent = session.offerData(offerId, mSendUri.toString(), importInfo.type); + boolean sent = session.offerData(offerId, null, mSendUri.toString(), importInfo.type); if (sent) return; } diff --git a/app/src/main/java/info/guardianproject/keanuapp/ui/conversation/ConversationDetailActivity.java b/app/src/main/java/info/guardianproject/keanuapp/ui/conversation/ConversationDetailActivity.java index 656014d..b202f2d 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ui/conversation/ConversationDetailActivity.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ui/conversation/ConversationDetailActivity.java @@ -1058,7 +1058,7 @@ public boolean handleSendData(IChatSession session, Uri uri, String mimeType) { if (session != null) { String offerId = UUID.randomUUID().toString(); - return session.offerData(offerId, uri.toString(), mimeType ); + return session.offerData(offerId, null, uri.toString(), mimeType ); } } catch (RemoteException e) { From 70a9d24e9ff7defb98d11f218415104cc7845c2c Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Fri, 13 Nov 2020 12:17:45 -0500 Subject: [PATCH 07/12] update gradle settings --- app/build.gradle | 2 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c20d2fc..b4d6d11 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -182,7 +182,7 @@ dependencies { implementation 'com.github.tladesignz:AirShare-Android:master-SNAPSHOT' implementation 'com.google.code.gson:gson:2.8.6' // Emojis - implementation 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT' + implementation 'com.vanniktech:emoji-google:0.7.0' } // Map for the version code that gives each ABI a value. diff --git a/build.gradle b/build.gradle index b2563fd..fde27a5 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.realm:realm-gradle-plugin:6.0.2" classpath 'com.testdroid:gradle:2.63.1' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b42f869..e7180d9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -gradle-6.1.1-all.zip#Mon Jul 06 22:01:32 EDT 2020 +#Fri Nov 13 10:13:04 EST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip From 3cd75002ab4fda037cf22964b906e750126d789c Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Fri, 13 Nov 2020 12:17:50 -0500 Subject: [PATCH 08/12] handle null issues --- .../keanu/matrix/plugin/MatrixConnection.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java index 87edb94..782b390 100644 --- a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java +++ b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java @@ -404,7 +404,7 @@ private void loginAsync(final String password, final LoginListener listener) { } - private void loginSync(String password, boolean enableEncryption, LoginListener listener) { + private synchronized void loginSync(String password, boolean enableEncryption, LoginListener listener) { String username = mUser.getAddress().getUser(); setState(ImConnection.LOGGING_IN, null); @@ -861,8 +861,10 @@ public void syncMessages(ChatSession session) { private void redactMessage (String roomId, String redactId) { ChatSession session = mChatSessionManager.getSession(roomId); - session.getMessageListener().onMessageRedacted(redactId); + if (session != null + && session.getMessageListener() != null) + session.getMessageListener().onMessageRedacted(redactId); } @@ -1216,6 +1218,7 @@ public void run() { group.endMemberUpdates(); if (room.isEncrypted()) + if (mDataHandler != null && mDataHandler.getCrypto() != null && (!userList.isEmpty())) mDataHandler.getCrypto().ensureOlmSessionsForUsers(userList, new BasicApiCallback<>("ensureOlmSessions")); } } @@ -2530,6 +2533,7 @@ private Pair getReplyToFromEvent(Event event) { } @SuppressWarnings({"unused", "RedundantSuppression"}) - public void getMessages() { + public Collection getMessages(String roomId) { + return mStore.getRoomMessages(roomId); } } From 624f40e4ab576eca1353eb68d43d6ad691bc8048 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Tue, 1 Dec 2020 13:50:26 -0500 Subject: [PATCH 09/12] can't get thumbnail from an audio file --- .../keanuapp/ui/stories/GalleryAdapter.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/guardianproject/keanuapp/ui/stories/GalleryAdapter.java b/app/src/main/java/info/guardianproject/keanuapp/ui/stories/GalleryAdapter.java index d83d957..c15f55f 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ui/stories/GalleryAdapter.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ui/stories/GalleryAdapter.java @@ -292,15 +292,20 @@ protected Bitmap doInBackground(Void... voids) { case MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO: { Context context = _context.get(); if (context != null) { - MediaMetadataRetriever mmr = new MediaMetadataRetriever(); - byte[] rawArt; - BitmapFactory.Options bfo = new BitmapFactory.Options(); - - mmr.setDataSource(context, uri); - rawArt = mmr.getEmbeddedPicture(); - if (null != rawArt) { - return BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo); + + if (uri.getScheme().equals("content")) { + MediaMetadataRetriever mmr = new MediaMetadataRetriever(); + + byte[] rawArt; + BitmapFactory.Options bfo = new BitmapFactory.Options(); + + mmr.setDataSource(context, uri); + rawArt = mmr.getEmbeddedPicture(); + if (null != rawArt) { + return BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo); + } } + } } break; From a70c774ef80e67a73e52fef6029777c7569b78aa Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Tue, 1 Dec 2020 13:50:52 -0500 Subject: [PATCH 10/12] fixes for login --- .../keanu/matrix/plugin/MatrixConnection.java | 50 +++++++++++++++---- keanuMatrix/src/main/res/values/strings.xml | 1 + 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java index 782b390..59e33a1 100644 --- a/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java +++ b/keanuMatrix/src/main/java/info/guardianproject/keanu/matrix/plugin/MatrixConnection.java @@ -1,7 +1,9 @@ package info.guardianproject.keanu.matrix.plugin; +import android.app.Activity; import android.content.ContentResolver; import android.content.Context; +import android.content.Intent; import android.database.Cursor; import android.net.TrafficStats; import android.net.Uri; @@ -67,6 +69,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.ref.WeakReference; import java.net.InetAddress; import java.nio.charset.Charset; import java.util.ArrayList; @@ -240,7 +243,7 @@ public int getCapability() { } @Override - public void loginAsync(long accountId, final String password, long providerId, boolean retry) { + public void loginAsync(final long accountId, final String password, final long providerId, boolean retry) { if (mDataHandler == null || (!mDataHandler.isAlive())) return; @@ -260,6 +263,27 @@ public void onLoginSuccess() { @Override public void onLoginFailed(String message) { + PopupAlertManager.VectorAlert alert = new PopupAlertManager.VectorAlert("000",mContext.getString(R.string.login_error),message,R.drawable.alerts_and_states_error); + + alert.addButton(mContext.getString(R.string.ok),new Runnable(){ + @Override + public void run() { + + Activity act = alert.getWeakCurrentActivity().get(); + try { + Intent intent = new Intent(act,Class.forName("info.guardianproject.keanuapp.ui.onboarding.OnboardingActivity")); + intent.putExtra("account",accountId); + intent.putExtra("provider",providerId); + act.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + + + } + },false); + + PopupAlertManager.INSTANCE.postVectorAlert(alert); } })); @@ -404,7 +428,7 @@ private void loginAsync(final String password, final LoginListener listener) { } - private synchronized void loginSync(String password, boolean enableEncryption, LoginListener listener) { + private void loginSync(String password, boolean enableEncryption, LoginListener listener) { String username = mUser.getAddress().getUser(); setState(ImConnection.LOGGING_IN, null); @@ -494,11 +518,12 @@ public void onNetworkError(Exception e) { if (listener != null) listener.onLoginFailed(e.getMessage()); + /** mExecutor.execute(new Runnable() { public void run() { loginAsync(null, listener); } - }); + });**/ } @Override @@ -608,7 +633,8 @@ public synchronized void logout(boolean fullLogout) { if (fullLogout) { if (mSession.isOnline() && mDataHandler.isAlive()) { mSession.stopEventStream(); - mSession.logout(mContext, new BasicApiCallback<>("loggout full")); + if (mSession.isAlive()) + mSession.logout(mContext, new BasicApiCallback<>("loggout full")); } String username = mUser.getAddress().getUser(); @@ -1203,13 +1229,17 @@ public void run() { if (members.size() < 40) { - String avatarUrl = mDataHandler.getUser(member.getUserId()).getAvatarUrl(); - String downloadUrl = mSession.getContentManager().getDownloadableThumbnailUrl(avatarUrl, - DEFAULT_AVATAR_WIDTH, DEFAULT_AVATAR_HEIGHT, "scale"); + User aUser = mDataHandler.getUser(member.getUserId()); - if (!TextUtils.isEmpty(downloadUrl)) { - if (!hasAvatar(member.getUserId(), downloadUrl)) { - downloadAvatar(member.getUserId(), downloadUrl); + if (aUser != null) { + String avatarUrl = aUser.getAvatarUrl(); + String downloadUrl = mSession.getContentManager().getDownloadableThumbnailUrl(avatarUrl, + DEFAULT_AVATAR_WIDTH, DEFAULT_AVATAR_HEIGHT, "scale"); + + if (!TextUtils.isEmpty(downloadUrl)) { + if (!hasAvatar(member.getUserId(), downloadUrl)) { + downloadAvatar(member.getUserId(), downloadUrl); + } } } } diff --git a/keanuMatrix/src/main/res/values/strings.xml b/keanuMatrix/src/main/res/values/strings.xml index ff2afb0..2aecb39 100644 --- a/keanuMatrix/src/main/res/values/strings.xml +++ b/keanuMatrix/src/main/res/values/strings.xml @@ -42,6 +42,7 @@ This phone number is already in use. Additional info: %s Mobile + Login Error From 987f146bbdb2c922e420f196cd419fd737b7a736 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Wed, 2 Dec 2020 04:32:28 -0500 Subject: [PATCH 11/12] if signing in again, update existing account --- .../keanuapp/ui/onboarding/OnboardingActivity.java | 10 +++++++++- .../keanuapp/ui/onboarding/OnboardingManager.java | 14 ++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingActivity.java b/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingActivity.java index 4bee066..da62067 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingActivity.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingActivity.java @@ -86,12 +86,18 @@ public class OnboardingActivity extends BaseActivity implements OnboardingListen private OnboardingManager mManager; + private long mProviderId = -1; + private long mAccountId = -1; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mShowSplash = getIntent().getBooleanExtra("showSplash",true); + mProviderId = getIntent().getLongExtra("provider",-1L); + mAccountId = getIntent().getLongExtra("account",-1L); + setContentView(R.layout.awesome_onboarding); ActionBar ab = getSupportActionBar(); @@ -301,6 +307,8 @@ public void onClick(View v) { showOnboarding(); } + if (mAccountId != -1 && mProviderId != -1) + showLoginScreen(); } private void setAnimLeft () @@ -608,7 +616,7 @@ private synchronized void doExistingAccountRegister() { if (mManager == null) mManager = new OnboardingManager(this, this); - mManager.addExistingAccount(username, server, password); + mManager.addExistingAccount(username, server, password, mAccountId, mProviderId); } } diff --git a/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingManager.java b/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingManager.java index 0b2b1d5..90e2fcb 100644 --- a/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingManager.java +++ b/app/src/main/java/info/guardianproject/keanuapp/ui/onboarding/OnboardingManager.java @@ -53,6 +53,7 @@ public OnboardingManager(Activity activity, OnboardingListener listener) { mActivity = new WeakReference<>(activity); mListener = new WeakReference<>(listener); mConn = new MatrixConnection(activity); + } public static void inviteSMSContact(Activity context, String message) { @@ -331,7 +332,7 @@ public void continueRegister(String captchaResponse, boolean termsApproved) { mConn.continueRegister(captchaResponse, termsApproved); } - public void addExistingAccount(String username, String domain, String password) { + public void addExistingAccount(String username, String domain, String password, long accountId, long providerId) { Activity activity = mActivity.get(); if (activity == null) return; @@ -343,9 +344,10 @@ public void addExistingAccount(String username, String domain, String password) ContentResolver cr = activity.getContentResolver(); ImPluginHelper helper = ImPluginHelper.getInstance(activity); - long providerId = helper.createAdditionalProvider(helper.getProviderNames().get(0)); //xmpp FIXME + if (providerId == -1) + providerId = helper.createAdditionalProvider(helper.getProviderNames().get(0)); //xmpp FIXME - long accountId = ImApp.insertOrUpdateAccount(cr, providerId, -1, username, username, password); + accountId = ImApp.insertOrUpdateAccount(cr, providerId, accountId, username, username, password); if (accountId == -1) return; @@ -394,6 +396,10 @@ public void addExistingAccount(String username, String domain, String password) if (Looper.myLooper() == null) Looper.prepare(); + OnboardingListener listener = mListener.get(); + if (listener != null) listener.registrationSuccessful(result); + + /** mConn.initUser(providerId, accountId); mConn.checkAccount(accountId, password, providerId, new MatrixConnection.LoginListener() { @@ -409,7 +415,7 @@ public void onLoginFailed(String message) { if (listener != null) listener.registrationFailed(message); } }); - + **/ // settings closed in registerAccount } catch (Exception e) { From 11cb75e2f3808fb6b1591d1c6b32caa5cc55f207 Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Wed, 2 Dec 2020 04:33:09 -0500 Subject: [PATCH 12/12] update libraries to 0.0.1.67 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fde27a5..925f9e6 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,8 @@ allprojects { maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } } project.ext { - keanuLibsVersionCode=166 - keanuLibsVersion="0.0.1.66" + keanuLibsVersionCode=167 + keanuLibsVersion="0.0.1.67" } }