Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove android dependencies from bindings #1825

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/com/b44t/messenger/DcChatlist.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.b44t.messenger;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class DcChatlist {

public DcChatlist(long chatlistCPtr) {
Expand All @@ -17,10 +14,10 @@ public DcChatlist(long chatlistCPtr) {

public native int getCnt ();
public native int getChatId (int index);
public @NonNull DcChat getChat (int index) { return new DcChat(getChatCPtr(index)); }
public DcChat getChat (int index) { return new DcChat(getChatCPtr(index)); }
public native int getMsgId (int index);
public @NonNull DcMsg getMsg (int index) { return new DcMsg(getMsgCPtr(index)); }
public @NonNull DcLot getSummary(int index, @Nullable DcChat chat) { return new DcLot(getSummaryCPtr(index, chat==null? 0 : chat.getChatCPtr())); }
public DcMsg getMsg (int index) { return new DcMsg(getMsgCPtr(index)); }
public DcLot getSummary(int index, DcChat chat) { return new DcLot(getSummaryCPtr(index, chat==null? 0 : chat.getChatCPtr())); }

public class Item {
public DcLot summary;
Expand Down
8 changes: 0 additions & 8 deletions src/com/b44t/messenger/DcContact.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.b44t.messenger;

import android.graphics.Color;
import android.util.Log;

public class DcContact {

public final static int DC_CONTACT_ID_SELF = 1;
Expand Down Expand Up @@ -60,9 +57,4 @@ public String toString() {
// working with raw c-data
private long contactCPtr; // CAVE: the name is referenced in the JNI
private native void unrefContactCPtr();

public int getArgbColor() {
int rgb = getColor();
return Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
}
}
19 changes: 8 additions & 11 deletions src/com/b44t/messenger/DcContext.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.b44t.messenger;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class DcContext {

public final static int DC_PREF_DEFAULT_MDNS_ENABLED = 1;
Expand Down Expand Up @@ -124,14 +121,14 @@ public void unref() {
public native int lookupContactIdByAddr(String addr);
public native int[] getContacts (int flags, String query);
public native int[] getBlockedContacts ();
public @NonNull DcContact getContact (int contact_id) { return new DcContact(getContactCPtr(contact_id)); }
public DcContact getContact (int contact_id) { return new DcContact(getContactCPtr(contact_id)); }
public native int createContact (String name, String addr);
public native void blockContact (int id, int block);
public native String getContactEncrInfo (int contact_id);
public native boolean deleteContact (int id);
public native int addAddressBook (String adrbook);
public @NonNull DcChatlist getChatlist (int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
public @NonNull DcChat getChat (int chat_id) { return new DcChat(getChatCPtr(chat_id)); }
public DcChatlist getChatlist (int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
public DcChat getChat (int chat_id) { return new DcChat(getChatCPtr(chat_id)); }
public native String getChatEncrInfo (int chat_id);
public native void markseenMsgs (int msg_ids[]);
public native void marknoticedChat (int chat_id);
Expand All @@ -143,7 +140,7 @@ public void unref() {
public native int addContactToChat (int chat_id, int contact_id);
public native int removeContactFromChat(int chat_id, int contact_id);
public native void setDraft (int chat_id, DcMsg msg/*null=delete*/);
public @Nullable DcMsg getDraft (int chat_id) { return new DcMsg(getDraftCPtr(chat_id)); }
public DcMsg getDraft (int chat_id) { return new DcMsg(getDraftCPtr(chat_id)); }
public native int setChatName (int chat_id, String name);
public native int setChatProfileImage (int chat_id, String name);
public native int[] getChatMsgs (int chat_id, int flags, int marker1before);
Expand All @@ -157,7 +154,7 @@ public void unref() {
public native boolean setChatMuteDuration (int chat_id, long duration);
public native void deleteChat (int chat_id);
public native int decideOnContactRequest(int msg_id, int decision);
public @NonNull DcMsg getMsg (int msg_id) { return new DcMsg(getMsgCPtr(msg_id)); }
public DcMsg getMsg (int msg_id) { return new DcMsg(getMsgCPtr(msg_id)); }
public native String getMsgInfo (int id);
public native String getMsgHtml (int msg_id);
public native int getFreshMsgCount (int chat_id);
Expand All @@ -170,14 +167,14 @@ public void unref() {
public native int sendVideochatInvitation(int chat_id);
public native int addDeviceMsg (String label, DcMsg msg);
public native boolean wasDeviceMsgEverAdded(String label);
public @NonNull DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); }
public DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); }
public native String getSecurejoinQr (int chat_id);
public native int joinSecurejoin (String qr);
public native void sendLocationsToChat (int chat_id, int seconds);
public native boolean isSendingLocationsToChat(int chat_id);
public @NonNull DcArray getLocations (int chat_id, int contact_id, long timestamp_start, long timestamp_end) { return new DcArray(getLocationsCPtr(chat_id, contact_id, timestamp_start, timestamp_end)); }
public DcArray getLocations (int chat_id, int contact_id, long timestamp_start, long timestamp_end) { return new DcArray(getLocationsCPtr(chat_id, contact_id, timestamp_start, timestamp_end)); }
public native void deleteAllLocations ();
public @Nullable DcProvider getProviderFromEmail (String email) { long cptr = getProviderFromEmailCPtr(email); return cptr!=0 ? new DcProvider(cptr) : null; }
public DcProvider getProviderFromEmail (String email) { long cptr = getProviderFromEmailCPtr(email); return cptr!=0 ? new DcProvider(cptr) : null; }

/**
* @return true if at least one chat has location streaming enabled
Expand Down
18 changes: 4 additions & 14 deletions src/com/b44t/messenger/DcMsg.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package com.b44t.messenger;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;

import java.io.File;
import java.util.Set;

Expand Down Expand Up @@ -58,9 +51,6 @@ protected void finalize() throws Throwable {

@Override
public int hashCode() {
if (this.getId() == 0) {
Log.e(TAG, "encountered a DcMsg with id 0.");
}
return this.getId();
}

Expand All @@ -77,7 +67,7 @@ public boolean equals(Object other) {
/**
* If given a message, calculates the position of the message in the chat
*/
public static int getMessagePosition(DcMsg msg, ApplicationDcContext dcContext) {
public static int getMessagePosition(DcMsg msg, DcContext dcContext) {
int msgs[] = dcContext.getChatMsgs(msg.getChatId(), 0, 0);
int startingPosition = -1;
int msgId = msg.getId();
Expand Down Expand Up @@ -105,7 +95,7 @@ public static int getMessagePosition(DcMsg msg, ApplicationDcContext dcContext)
public native int getHeight (int def);
public native int getDuration ();
public native void lateFilingMediaSize(int width, int height, int duration);
public @NonNull DcLot getSummary (DcChat chat) { return new DcLot(getSummaryCPtr(chat.getChatCPtr())); }
public DcLot getSummary (DcChat chat) { return new DcLot(getSummaryCPtr(chat.getChatCPtr())); }
public native String getSummarytext (int approx_characters);
public native int showPadlock ();
public boolean hasFile () { String file = getFile(); return file!=null && !file.isEmpty(); }
Expand All @@ -129,9 +119,9 @@ public static int getMessagePosition(DcMsg msg, ApplicationDcContext dcContext)
public void setQuote (DcMsg quote) { setQuoteCPtr(quote.msgCPtr); }
public native String getQuotedText ();
public native String getError ();
private native @Nullable String getOverrideSenderName();
private native String getOverrideSenderName();

public @NonNull String getSenderName(@NonNull DcContact dcContact, boolean markOverride) {
public String getSenderName(DcContact dcContact, boolean markOverride) {
String overrideName = getOverrideSenderName();
if (overrideName != null) {
return (markOverride ? "~" : "") + overrideName;
Expand Down
1 change: 0 additions & 1 deletion src/org/thoughtcrime/securesms/ApplicationContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import androidx.multidex.MultiDexApplication;

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.FetchWorker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcContactsLoader;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter;
import org.thoughtcrime.securesms.contacts.ContactSelectionListItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.components.RecyclerViewFastScroller;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcContactsLoader;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/ConversationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcMsg;

import org.thoughtcrime.securesms.attachments.Attachment;
Expand All @@ -85,6 +84,7 @@
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.map.MapActivity;
import org.thoughtcrime.securesms.mms.AttachmentManager;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/ConversationFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcMsg;

import org.thoughtcrime.securesms.ConversationAdapter.ItemClickListener;
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.mms.GlideApp;
Expand Down
3 changes: 2 additions & 1 deletion src/org/thoughtcrime/securesms/ConversationItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.Stub;

Expand Down Expand Up @@ -663,7 +664,7 @@ private void setGroupMessageStatus() {
}
else if (groupThread && !messageRecord.isOutgoing() && dcContact !=null) {
this.groupSender.setText(messageRecord.getSenderName(dcContact, true));
this.groupSender.setTextColor(dcContact.getArgbColor());
this.groupSender.setTextColor(Util.rgbToArgbColor(dcContact.getColor()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcMsg;
import com.google.android.material.snackbar.Snackbar;

Expand All @@ -61,6 +60,7 @@
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcChatlistLoader;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.util.RelayUtil;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/GroupCreateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.soundcloud.android.crop.Crop;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
import org.thoughtcrime.securesms.database.Address;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/ProfileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import com.b44t.messenger.DcChat;
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.util.DynamicLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcMsg;
import com.codewaves.stickyheadergrid.StickyHeaderGridLayoutManager;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.database.loaders.BucketedThreadMediaLoader;
import org.thoughtcrime.securesms.util.ViewUtil;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/ProfileGalleryFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcMsg;
import com.codewaves.stickyheadergrid.StickyHeaderGridLayoutManager;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.loaders.BucketedThreadMediaLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.qr.QrShowActivity;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/RegistrationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import android.widget.Toast;

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEventCenter;

import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.util.DynamicTheme;
Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcLot;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

import org.thoughtcrime.securesms.connect.AccountManager;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.qr.RegistrationQrActivity;
Expand Down
5 changes: 3 additions & 2 deletions src/org/thoughtcrime/securesms/components/QuoteView.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.Util;

import java.util.List;

Expand Down Expand Up @@ -160,8 +161,8 @@ private void setQuoteAuthor(@Nullable Recipient author) {
} else {
authorView.setVisibility(VISIBLE);
authorView.setText(quotedMsg.getSenderName(contact, false));
authorView.setTextColor(contact.getArgbColor());
quoteBarView.setBackgroundColor(contact.getArgbColor());
authorView.setTextColor(Util.rgbToArgbColor(contact.getColor()));
quoteBarView.setBackgroundColor(Util.rgbToArgbColor(contact.getColor()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.b44t.messenger.DcEventEmitter;
import com.b44t.messenger.DcLot;
import com.b44t.messenger.DcMsg;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.b44t.messenger;
package org.thoughtcrime.securesms.connect;

import com.b44t.messenger.DcEvent;

import org.thoughtcrime.securesms.util.Util;

Expand Down
2 changes: 1 addition & 1 deletion src/org/thoughtcrime/securesms/map/MapDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import androidx.annotation.NonNull;

import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcEventCenter;
import com.mapbox.android.core.permissions.PermissionsManager;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
Expand All @@ -28,6 +27,7 @@
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.emoji.EmojiProvider;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.map.DataCollectionTask.DataCollectionCallback;
import org.thoughtcrime.securesms.map.GenerateInfoWindowTask.GenerateInfoWindowCallback;
Expand Down
Loading