further cleaning on signal sticker

This commit is contained in:
Ryan ZHAO 2021-02-22 15:07:16 +11:00
parent b2225697b4
commit 5b15decdd6
9 changed files with 0 additions and 418 deletions

View File

@ -22,12 +22,9 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
import org.thoughtcrime.securesms.database.model.StickerRecord;
import org.session.libsignal.utilities.logging.Log;
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
import org.thoughtcrime.securesms.mms.GlideRequests;
@ -322,7 +319,6 @@ public class InputPanel extends LinearLayout
void onRecorderPermissionRequired();
void onEmojiToggle();
void onLinkPreviewCanceled();
void onStickerSuggestionSelected(@NonNull StickerRecord sticker);
}
private static class SlideToCancel {

View File

@ -127,7 +127,6 @@ import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
import org.thoughtcrime.securesms.database.model.StickerRecord;
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
@ -2144,11 +2143,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
linkPreviewViewModel.onUserCancel();
}
@Override
public void onStickerSuggestionSelected(@NonNull StickerRecord sticker) {
sendSticker(sticker, true);
}
@Override
public void onMediaSelected(@NonNull Uri uri, String contentType) {
if (!TextUtils.isEmpty(contentType) && contentType.trim().equals("image/gif")) {
@ -2167,10 +2161,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), start, end);
}
private void sendSticker(@NonNull StickerRecord stickerRecord, boolean clearCompose) {
sendSticker(new StickerLocator(stickerRecord.getPackId(), stickerRecord.getPackKey(), stickerRecord.getStickerId()), stickerRecord.getUri(), stickerRecord.getSize(), clearCompose);
}
private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull Uri uri, long size, boolean clearCompose) {
long expiresIn = recipient.getExpireMessages() * 1000L;
int subscriptionId = -1;

View File

@ -1,21 +0,0 @@
package org.thoughtcrime.securesms.database.loaders;
import android.content.Context;
import android.database.Cursor;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.util.AbstractCursorLoader;
public class BlockedContactsLoader extends AbstractCursorLoader {
public BlockedContactsLoader(Context context) {
super(context);
}
@Override
public Cursor getCursor() {
return DatabaseFactory.getRecipientDatabase(getContext())
.getBlocked();
}
}

View File

@ -1,81 +0,0 @@
package org.thoughtcrime.securesms.database.loaders;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MergeCursor;
import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.session.libsession.messaging.threads.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.util.AbstractCursorLoader;
import java.util.LinkedList;
import java.util.List;
public class ConversationListLoader extends AbstractCursorLoader {
private final String filter;
private final boolean archived;
public ConversationListLoader(Context context, String filter, boolean archived) {
super(context);
this.filter = filter;
this.archived = archived;
}
@Override
public Cursor getCursor() {
if (filter != null && filter.trim().length() != 0) return getFilteredConversationList(filter);
else if (!archived) return getUnarchivedConversationList();
else return getArchivedConversationList();
}
private Cursor getUnarchivedConversationList() {
List<Cursor> cursorList = new LinkedList<>();
cursorList.add(DatabaseFactory.getThreadDatabase(context).getConversationList());
int archivedCount = DatabaseFactory.getThreadDatabase(context)
.getArchivedConversationListCount();
if (archivedCount > 0) {
MatrixCursor switchToArchiveCursor = new MatrixCursor(new String[] {
ThreadDatabase.ID, ThreadDatabase.DATE, ThreadDatabase.MESSAGE_COUNT,
ThreadDatabase.ADDRESS, ThreadDatabase.SNIPPET, ThreadDatabase.READ, ThreadDatabase.UNREAD_COUNT,
ThreadDatabase.TYPE, ThreadDatabase.SNIPPET_TYPE, ThreadDatabase.SNIPPET_URI,
ThreadDatabase.ARCHIVED, ThreadDatabase.STATUS, ThreadDatabase.DELIVERY_RECEIPT_COUNT,
ThreadDatabase.EXPIRES_IN, ThreadDatabase.LAST_SEEN, ThreadDatabase.READ_RECEIPT_COUNT}, 1);
if (cursorList.get(0).getCount() <= 0) {
switchToArchiveCursor.addRow(new Object[] {-1L, System.currentTimeMillis(), archivedCount,
"-1", null, 1, 0, ThreadDatabase.DistributionTypes.INBOX_ZERO,
0, null, 0, -1, 0, 0, 0, -1});
}
switchToArchiveCursor.addRow(new Object[] {-1L, System.currentTimeMillis(), archivedCount,
"-1", null, 1, 0, ThreadDatabase.DistributionTypes.ARCHIVE,
0, null, 0, -1, 0, 0, 0, -1});
cursorList.add(switchToArchiveCursor);
}
return new MergeCursor(cursorList.toArray(new Cursor[0]));
}
private Cursor getArchivedConversationList() {
return DatabaseFactory.getThreadDatabase(context).getArchivedConversationList();
}
private Cursor getFilteredConversationList(String filter) {
List<String> numbers = ContactAccessor.getInstance().getNumbersForThreadSearchFilter(context, filter);
List<Address> addresses = new LinkedList<>();
for (String number : numbers) {
addresses.add(Address.fromExternal(context, number));
}
return DatabaseFactory.getThreadDatabase(context).getFilteredConversationList(addresses);
}
}

View File

@ -1,28 +0,0 @@
package org.thoughtcrime.securesms.database.loaders;
import android.content.Context;
import androidx.loader.content.AsyncTaskLoader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
public class CountryListLoader extends AsyncTaskLoader<ArrayList<Map<String, String>>> {
public CountryListLoader(Context context) {
super(context);
}
@Override
public ArrayList<Map<String, String>> loadInBackground() {
return new ArrayList<>();
}
private static class RegionComparator implements Comparator<Map<String, String>> {
@Override
public int compare(Map<String, String> lhs, Map<String, String> rhs) {
return lhs.get("country_name").compareTo(rhs.get("country_name"));
}
}
}

View File

@ -1,66 +0,0 @@
package org.thoughtcrime.securesms.database.model;
import androidx.annotation.NonNull;
public class IncomingSticker {
private final String packKey;
private final String packId;
private final String packTitle;
private final String packAuthor;
private final int stickerId;
private final String emoji;
private final boolean isCover;
private final boolean isInstalled;
public IncomingSticker(@NonNull String packId,
@NonNull String packKey,
@NonNull String packTitle,
@NonNull String packAuthor,
int stickerId,
@NonNull String emoji,
boolean isCover,
boolean isInstalled)
{
this.packId = packId;
this.packKey = packKey;
this.packTitle = packTitle;
this.packAuthor = packAuthor;
this.stickerId = stickerId;
this.emoji = emoji;
this.isCover = isCover;
this.isInstalled = isInstalled;
}
public @NonNull String getPackKey() {
return packKey;
}
public @NonNull String getPackId() {
return packId;
}
public @NonNull String getPackTitle() {
return packTitle;
}
public @NonNull String getPackAuthor() {
return packAuthor;
}
public int getStickerId() {
return stickerId;
}
public @NonNull String getEmoji() {
return emoji;
}
public boolean isCover() {
return isCover;
}
public boolean isInstalled() {
return isInstalled;
}
}

View File

@ -1,40 +0,0 @@
package org.thoughtcrime.securesms.database.model;
import androidx.annotation.NonNull;
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
public class Sticker {
private final String packId;
private final String packKey;
private final int stickerId;
private final Attachment attachment;
public Sticker(@NonNull String packId,
@NonNull String packKey,
int stickerId,
@NonNull Attachment attachment)
{
this.packId = packId;
this.packKey = packKey;
this.stickerId = stickerId;
this.attachment = attachment;
}
public @NonNull String getPackId() {
return packId;
}
public @NonNull String getPackKey() {
return packKey;
}
public int getStickerId() {
return stickerId;
}
public @NonNull Attachment getAttachment() {
return attachment;
}
}

View File

@ -1,78 +0,0 @@
package org.thoughtcrime.securesms.database.model;
import androidx.annotation.NonNull;
import android.text.TextUtils;
import org.session.libsignal.libsignal.util.guava.Optional;
import java.util.Objects;
/**
* Represents a record for a sticker pack in the {@link org.thoughtcrime.securesms.database.StickerDatabase}.
*/
public final class StickerPackRecord {
private final String packId;
private final String packKey;
private final Optional<String> title;
private final Optional<String> author;
private final StickerRecord cover;
private final boolean installed;
public StickerPackRecord(@NonNull String packId,
@NonNull String packKey,
@NonNull String title,
@NonNull String author,
@NonNull StickerRecord cover,
boolean installed)
{
this.packId = packId;
this.packKey = packKey;
this.title = TextUtils.isEmpty(title) ? Optional.absent() : Optional.of(title);
this.author = TextUtils.isEmpty(author) ? Optional.absent() : Optional.of(author);
this.cover = cover;
this.installed = installed;
}
public @NonNull String getPackId() {
return packId;
}
public @NonNull String getPackKey() {
return packKey;
}
public @NonNull Optional<String> getTitle() {
return title;
}
public @NonNull Optional<String> getAuthor() {
return author;
}
public @NonNull StickerRecord getCover() {
return cover;
}
public boolean isInstalled() {
return installed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StickerPackRecord record = (StickerPackRecord) o;
return installed == record.installed &&
packId.equals(record.packId) &&
packKey.equals(record.packKey) &&
title.equals(record.title) &&
author.equals(record.author) &&
cover.equals(record.cover);
}
@Override
public int hashCode() {
return Objects.hash(packId, packKey, title, author, cover, installed);
}
}

View File

@ -1,90 +0,0 @@
package org.thoughtcrime.securesms.database.model;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.mms.PartAuthority;
import java.util.Objects;
/**
* Represents a record for a sticker pack in the {@link org.thoughtcrime.securesms.database.StickerDatabase}.
*/
public final class StickerRecord {
private final long rowId;
private final String packId;
private final String packKey;
private final int stickerId;
private final String emoji;
private final long size;
private final boolean isCover;
public StickerRecord(long rowId,
@NonNull String packId,
@NonNull String packKey,
int stickerId,
@NonNull String emoji,
long size,
boolean isCover)
{
this.rowId = rowId;
this.packId = packId;
this.packKey = packKey;
this.stickerId = stickerId;
this.emoji = emoji;
this.size = size;
this.isCover = isCover;
}
public long getRowId() {
return rowId;
}
public @NonNull String getPackId() {
return packId;
}
public @NonNull String getPackKey() {
return packKey;
}
public int getStickerId() {
return stickerId;
}
public @NonNull Uri getUri() {
return PartAuthority.getStickerUri(rowId);
}
public @NonNull String getEmoji() {
return emoji;
}
public long getSize() {
return size;
}
public boolean isCover() {
return isCover;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StickerRecord that = (StickerRecord) o;
return rowId == that.rowId &&
stickerId == that.stickerId &&
size == that.size &&
isCover == that.isCover &&
packId.equals(that.packId) &&
packKey.equals(that.packKey) &&
emoji.equals(that.emoji);
}
@Override
public int hashCode() {
return Objects.hash(rowId, packId, packKey, stickerId, emoji, size, isCover);
}
}