mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
adapt to new api
This commit is contained in:
@@ -9,6 +9,10 @@ public class DcChat {
|
||||
public final static int DC_CHAT_ID_ALLDONE_HINT = 7;
|
||||
public final static int DC_CHAT_ID_LAST_SPECIAL = 9;
|
||||
|
||||
public final static int DC_CHAT_VISIBILITY_NORMAL = 0;
|
||||
public final static int DC_CHAT_VISIBILITY_ARCHIVED = 1;
|
||||
public final static int DC_CHAT_VISIBILITY_PINNED = 2;
|
||||
|
||||
public DcChat(long chatCPtr) {
|
||||
this.chatCPtr = chatCPtr;
|
||||
}
|
||||
@@ -21,7 +25,7 @@ public class DcChat {
|
||||
|
||||
public native int getId ();
|
||||
public native boolean isGroup ();
|
||||
public native int getArchived ();
|
||||
public native int getVisibility ();
|
||||
public native String getName ();
|
||||
public native String getProfileImage ();
|
||||
public native int getColor ();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class DcContext {
|
||||
public native void marknoticedChat (int chat_id);
|
||||
public native void marknoticedAllChats ();
|
||||
public native void marknoticedContact (int contact_id);
|
||||
public native void archiveChat (int chat_id, int archive);
|
||||
public native void setChatVisibility (int chat_id, int visibility);
|
||||
public native int getChatIdByContactId (int contact_id);
|
||||
public native int createChatByContactId(int contact_id);
|
||||
public native int createChatByMsgId (int msg_id);
|
||||
|
||||
@@ -447,11 +447,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
if( dcChat.getArchived()==1 ) {
|
||||
inflater.inflate(R.menu.conversation_unarchive, menu);
|
||||
if (dcChat.getVisibility()!=DcChat.DC_CHAT_VISIBILITY_ARCHIVED) {
|
||||
inflater.inflate(R.menu.conversation_archive, menu);
|
||||
}
|
||||
else {
|
||||
inflater.inflate(R.menu.conversation_archive, menu);
|
||||
inflater.inflate(R.menu.conversation_unarchive, menu);
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation_delete, menu);
|
||||
@@ -558,10 +558,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void handleArchiveChat() {
|
||||
int doArchive = dcContext.getChat(chatId).getArchived() == 1 ? 0: 1;
|
||||
dcContext.archiveChat(chatId, doArchive);
|
||||
int newVisibility = dcContext.getChat(chatId).getVisibility()==DcChat.DC_CHAT_VISIBILITY_ARCHIVED?
|
||||
DcChat.DC_CHAT_VISIBILITY_NORMAL : DcChat.DC_CHAT_VISIBILITY_ARCHIVED;
|
||||
dcContext.setChatVisibility(chatId, newVisibility);
|
||||
Toast.makeText(this, getString(R.string.done), Toast.LENGTH_SHORT).show();
|
||||
if( doArchive == 1 ) {
|
||||
if (newVisibility==DcChat.DC_CHAT_VISIBILITY_ARCHIVED) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,8 @@ public class ConversationListFragment extends Fragment
|
||||
final Set<Long> selectedConversations = new HashSet<>(getListAdapter().getBatchSelections());
|
||||
boolean doPin = areSomeSelectedChatsUnpinned();
|
||||
for (long chatId : selectedConversations) {
|
||||
dcContext.archiveChat((int)chatId, doPin? 2 : 0);
|
||||
dcContext.setChatVisibility((int)chatId,
|
||||
doPin? DcChat.DC_CHAT_VISIBILITY_PINNED : DcChat.DC_CHAT_VISIBILITY_NORMAL);
|
||||
}
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
@@ -263,7 +264,8 @@ public class ConversationListFragment extends Fragment
|
||||
dcContext.marknoticedContact(getListAdapter().getDeaddropContactId());
|
||||
}
|
||||
else {
|
||||
dcContext.archiveChat((int)chatId, !archive? 1 : 0);
|
||||
dcContext.setChatVisibility((int)chatId,
|
||||
!archive? DcChat.DC_CHAT_VISIBILITY_ARCHIVED : DcChat.DC_CHAT_VISIBILITY_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +273,8 @@ public class ConversationListFragment extends Fragment
|
||||
@Override
|
||||
protected void reverseAction(@Nullable Void parameter) {
|
||||
for (long threadId : selectedConversations) {
|
||||
dcContext.archiveChat((int)threadId, !archive? 0 : 1);
|
||||
dcContext.setChatVisibility((int)threadId,
|
||||
!archive? DcChat.DC_CHAT_VISIBILITY_NORMAL : DcChat.DC_CHAT_VISIBILITY_ARCHIVED);
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
@@ -451,7 +454,7 @@ public class ConversationListFragment extends Fragment
|
||||
final Set<Long> selectedChats = getListAdapter().getBatchSelections();
|
||||
for (long chatId : selectedChats) {
|
||||
DcChat dcChat = dcContext.getChat((int)chatId);
|
||||
if (dcChat.getArchived()!=2) {
|
||||
if (dcChat.getVisibility()!=DcChat.DC_CHAT_VISIBILITY_PINNED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
}
|
||||
|
||||
private void setStatusIcons(ThreadRecord thread) {
|
||||
if (thread.getArchived()==1)
|
||||
if (thread.getVisibility()==DcChat.DC_CHAT_VISIBILITY_ARCHIVED)
|
||||
{
|
||||
// archived
|
||||
this.pinnedView.setVisibility(View.GONE);
|
||||
@@ -268,7 +268,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pinnedView.setVisibility(thread.getArchived()==2? View.VISIBLE : View.GONE);
|
||||
this.pinnedView.setVisibility(thread.getVisibility()==DcChat.DC_CHAT_VISIBILITY_PINNED? View.VISIBLE : View.GONE);
|
||||
this.archivedView.setVisibility(View.GONE);
|
||||
int state = dcSummary.getState();
|
||||
if (state==DcMsg.DC_STATE_IN_FRESH || state==DcMsg.DC_STATE_IN_NOTICED)
|
||||
|
||||
@@ -283,7 +283,7 @@ public class ApplicationDcContext extends DcContext {
|
||||
|
||||
return new ThreadRecord(context, body, recipient, date,
|
||||
unreadCount, chatId,
|
||||
chat.getArchived(), verified, chat.isSendingLocations(), summary);
|
||||
chat.getVisibility(), verified, chat.isSendingLocations(), summary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ThreadRecord {
|
||||
private final String body;
|
||||
|
||||
private final int unreadCount;
|
||||
private final int archived;
|
||||
private final int visibility;
|
||||
private final boolean verified;
|
||||
private final boolean isSendingLocations;
|
||||
private @Nullable final DcLot dcSummary;
|
||||
@@ -53,7 +53,7 @@ public class ThreadRecord {
|
||||
public ThreadRecord(@NonNull Context context, @NonNull String body,
|
||||
@NonNull Recipient recipient, long dateReceived, int unreadCount,
|
||||
long threadId,
|
||||
int archived,
|
||||
int visibility,
|
||||
boolean verified,
|
||||
boolean isSendingLocations,
|
||||
@Nullable DcLot dcSummary)
|
||||
@@ -64,7 +64,7 @@ public class ThreadRecord {
|
||||
this.dateReceived = dateReceived;
|
||||
this.body = body;
|
||||
this.unreadCount = unreadCount;
|
||||
this.archived = archived;
|
||||
this.visibility = visibility;
|
||||
this.verified = verified;
|
||||
this.isSendingLocations = isSendingLocations;
|
||||
this.dcSummary = dcSummary;
|
||||
@@ -110,8 +110,8 @@ public class ThreadRecord {
|
||||
return getDateReceived();
|
||||
}
|
||||
|
||||
public int getArchived() {
|
||||
return archived;
|
||||
public int getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public boolean isVerified() {
|
||||
|
||||
Reference in New Issue
Block a user