mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 09:22:23 +00:00
Save replies in drafts.
Previously, quotes were not saved to drafts, meaning they would be lost when leaving the conversation or app. Now, a QuoteId (which represents the necessary data to restore the QuoteModel) is serialized and stored in the DraftDatabase. Fixes #7716 Closes #7729
This commit is contained in:
committed by
Moxie Marlinspike
parent
7100030c22
commit
43622e603d
@@ -101,6 +101,7 @@ public class DraftDatabase extends Database {
|
||||
public static final String VIDEO = "video";
|
||||
public static final String AUDIO = "audio";
|
||||
public static final String LOCATION = "location";
|
||||
public static final String QUOTE = "quote";
|
||||
|
||||
private final String type;
|
||||
private final String value;
|
||||
@@ -125,6 +126,7 @@ public class DraftDatabase extends Database {
|
||||
case VIDEO: return context.getString(R.string.DraftDatabase_Draft_video_snippet);
|
||||
case AUDIO: return context.getString(R.string.DraftDatabase_Draft_audio_snippet);
|
||||
case LOCATION: return context.getString(R.string.DraftDatabase_Draft_location_snippet);
|
||||
case QUOTE: return context.getString(R.string.DraftDatabase_Draft_quote_snippet);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.database;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import net.sqlcipher.database.SQLiteDatabase;
|
||||
@@ -71,8 +72,24 @@ public class MmsSmsDatabase extends Database {
|
||||
super(context, databaseHelper);
|
||||
}
|
||||
|
||||
public Cursor getMessagesFor(long timestamp) {
|
||||
return queryTables(PROJECTION, MmsSmsColumns.NORMALIZED_DATE_SENT + " = " + timestamp, null, null);
|
||||
public @Nullable MessageRecord getMessageFor(long timestamp, Address author) {
|
||||
MmsSmsDatabase db = DatabaseFactory.getMmsSmsDatabase(context);
|
||||
|
||||
try (Cursor cursor = queryTables(PROJECTION, MmsSmsColumns.NORMALIZED_DATE_SENT + " = " + timestamp, null, null)) {
|
||||
MmsSmsDatabase.Reader reader = db.readerFor(cursor);
|
||||
|
||||
MessageRecord messageRecord;
|
||||
|
||||
while ((messageRecord = reader.getNext()) != null) {
|
||||
if ((Util.isOwnNumber(context, author) && messageRecord.isOutgoing()) ||
|
||||
(!Util.isOwnNumber(context, author) && messageRecord.getIndividualRecipient().getAddress().equals(author)))
|
||||
{
|
||||
return messageRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Cursor getConversation(long threadId, long limit) {
|
||||
|
||||
Reference in New Issue
Block a user