mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Remove Deaddrop chat (Android UI) (#1975)
See deltachat/deltachat-core-rust#2514 Fixes #1963 Fixes #1890 Before deleting a chat the user is asked for confirmation. Before blocking not, because blocking is not "destructive" (i.e. can be completely reverted by unblocking the contact). I'm wondering whether we should show a snackbar with an Undo button though, but we can probably wait for user feedback on this. * Start removing deaddrop chat * Generally works * Fix the buttons (it's not easy to not show one of the buttons in ConstraintLayout; if problems turn up, we should probably just not use ConstraintLayout) * fix more things * restartLoader() instead of notifyDataSetChanged() because the latter didn't do anything * Archived badge * Rename "Contact request" to "Request" * oops * Remove setStockTranslation(8, context.getString(R.string.chat_contact_request)); * Remove commented-out code, we probably won't need it * Don't show "Delete" button for 1:1 chats * Get rid of short flickering when declining a request * Set the app's night mode to match the preference This added 6ms to startup time, but I think that's OK, as we will also be able to use more `-night` views in the future * Make "Accept" text a bit brighter and easier to read in dark mode * Check if the chattype is Group instead of members.length == 1
This commit is contained in:
+17
-11
@@ -438,15 +438,21 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_deleteChat(JNIEnv *env, jobject
|
||||
}
|
||||
|
||||
|
||||
/* DcContext - handle messages */
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_decideOnContactRequest(JNIEnv *env, jobject obj, jint msg_id, jint decision)
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_blockChat(JNIEnv *env, jobject obj, jint chat_id)
|
||||
{
|
||||
return (jint)dc_decide_on_contact_request(get_dc_context(env, obj), msg_id, decision);
|
||||
dc_block_chat(get_dc_context(env, obj), chat_id);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_acceptChat(JNIEnv *env, jobject obj, jint chat_id)
|
||||
{
|
||||
dc_accept_chat(get_dc_context(env, obj), chat_id);
|
||||
}
|
||||
|
||||
|
||||
/* DcContext - handle messages */
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_getFreshMsgCount(JNIEnv *env, jobject obj, jint chat_id)
|
||||
{
|
||||
return dc_get_fresh_msg_cnt(get_dc_context(env, obj), chat_id);
|
||||
@@ -1078,6 +1084,12 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isSendingLocations(JNIEnv *env
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isContactRequest(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_chat_is_contact_request(get_dc_chat(env, obj))!=0;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jintArray Java_com_b44t_messenger_DcContext_getChatMedia(JNIEnv *env, jobject obj, jint chat_id, jint type1, jint type2, jint type3)
|
||||
{
|
||||
dc_array_t* ca = dc_get_chat_media(get_dc_context(env, obj), chat_id, type1, type2, type3);
|
||||
@@ -1234,12 +1246,6 @@ JNIEXPORT jint Java_com_b44t_messenger_DcMsg_getChatId(JNIEnv *env, jobject obj)
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcMsg_getRealChatId(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_msg_get_real_chat_id(get_dc_msg(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcMsg_getFromId(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_msg_get_from_id(get_dc_msg(env, obj));
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- TODO - Consolidate using attr if we move away from API 19 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="#3b3b3b"/>
|
||||
<corners android:radius="8dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- TODO - Consolidate using attr if we move away from API 19 -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="#e9e9e9"/>
|
||||
<corners android:radius="8dp"/>
|
||||
</shape>
|
||||
@@ -42,6 +42,19 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<org.thoughtcrime.securesms.messagerequests.MessageRequestsBottomView
|
||||
android:id="@+id/conversation_activity_message_request_bottom_bar"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:visibility="gone"
|
||||
android:clickable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:focusable="true" />
|
||||
|
||||
<include layout="@layout/conversation_input_panel"/>
|
||||
|
||||
<ViewStub
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/archived"
|
||||
<TextView android:id="@+id/badge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/message_request_question"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="11dp"
|
||||
android:paddingTop="11dp"
|
||||
android:textSize="14sp"
|
||||
tools:text="Chat with Alice In Wondeful Wonderland (alice@wonderland.org)?"
|
||||
app:layout_constraintBottom_toTopOf="@id/message_request_block"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/message_request_block"
|
||||
style="@style/Signal.MessageRequest.Button.Deny"
|
||||
android:text="@string/block"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/message_request_accept"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/message_request_accept"
|
||||
style="@style/Signal.MessageRequest.Button.Accept"
|
||||
android:text="@string/accept"
|
||||
app:layout_constraintBottom_toBottomOf="@id/message_request_block"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/message_request_block"
|
||||
app:layout_constraintTop_toTopOf="@id/message_request_block" />
|
||||
</merge>
|
||||
@@ -10,9 +10,6 @@
|
||||
<item android:title="@string/menu_new_chat"
|
||||
android:id="@+id/menu_new_chat" />
|
||||
|
||||
<item android:title="@string/menu_deaddrop"
|
||||
android:id="@+id/menu_deaddrop" />
|
||||
|
||||
<item android:title="@string/menu_show_global_map"
|
||||
android:id="@+id/menu_global_map"
|
||||
android:visible="false"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="accept_button">@color/document_icon_text</color>
|
||||
</resources>
|
||||
@@ -71,4 +71,5 @@
|
||||
unknown_sender is used for the sender-name/quote-bar if the sender is unknown -->
|
||||
<color name="unknown_sender">#ff999999</color>
|
||||
|
||||
<color name="accept_button">@color/core_ultramarine</color>
|
||||
</resources>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<color name="core_blue">#2090ea</color>
|
||||
<color name="core_red">#f44336</color>
|
||||
<color name="core_red_highlight">#ef5350</color>
|
||||
<color name="core_ultramarine">#2c6bed</color>
|
||||
|
||||
<color name="audio_icon">#f68751</color>
|
||||
<color name="audio_icon_text">#ed824e</color>
|
||||
|
||||
@@ -203,6 +203,7 @@
|
||||
<string name="block">Block</string>
|
||||
<string name="menu_block_contact">Block Contact</string>
|
||||
<string name="menu_unblock_contact">Unblock Contact</string>
|
||||
<string name="accept">Accept</string>
|
||||
<string name="menu_play">Play</string>
|
||||
<string name="menu_pause">Pause</string>
|
||||
<string name="menu_scroll_to_bottom">Scroll to the Bottom</string>
|
||||
@@ -338,6 +339,7 @@
|
||||
<string name="chat_share_with_title">Share with</string>
|
||||
<string name="chat_input_placeholder">Message</string>
|
||||
<string name="chat_archived_label">Archived</string>
|
||||
<string name="chat_request_label">Request</string>
|
||||
<string name="chat_no_messages">No messages.</string>
|
||||
<string name="chat_self_talk_subtitle">Messages I sent to myself</string>
|
||||
<string name="saved_messages">Saved Messages</string>
|
||||
|
||||
@@ -105,4 +105,21 @@
|
||||
<item name="colorControlActivated">#ff2090ea</item>
|
||||
</style>
|
||||
|
||||
<style name="Button.Borderless" parent="Base.Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:textColor">?attr/colorAccent</item>
|
||||
</style>
|
||||
<style name="Signal.MessageRequest.Button" parent="Button.Borderless">
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:layout_width">0dp</item>
|
||||
<item name="android:layout_height">48dp</item>
|
||||
<item name="android:background">@drawable/message_request_button_background</item>
|
||||
</style>
|
||||
<style name="Signal.MessageRequest.Button.Deny">
|
||||
<item name="android:textColor">@color/core_red</item>
|
||||
</style>
|
||||
|
||||
<style name="Signal.MessageRequest.Button.Accept">
|
||||
<item name="android:textColor">@color/accept_button</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -30,5 +30,4 @@
|
||||
<item name="android:textColor">?conversation_item_outgoing_text_secondary_color</item>
|
||||
<item name="android:shadowRadius">0</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -8,7 +8,6 @@ public class DcChat {
|
||||
public static final int DC_CHAT_TYPE_MAILINGLIST = 140;
|
||||
|
||||
public static final int DC_CHAT_NO_CHAT = 0;
|
||||
public final static int DC_CHAT_ID_DEADDROP = 1;
|
||||
public final static int DC_CHAT_ID_ARCHIVED_LINK = 6;
|
||||
public final static int DC_CHAT_ID_ALLDONE_HINT = 7;
|
||||
public final static int DC_CHAT_ID_LAST_SPECIAL = 9;
|
||||
@@ -40,6 +39,7 @@ public class DcChat {
|
||||
public native boolean isProtected ();
|
||||
public native boolean isSendingLocations();
|
||||
public native boolean isMuted ();
|
||||
public native boolean isContactRequest ();
|
||||
|
||||
|
||||
// aliases and higher-level tools
|
||||
|
||||
@@ -164,7 +164,8 @@ public class DcContext {
|
||||
public native boolean setChatEphemeralTimer (int chat_id, int timer);
|
||||
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 native void blockChat (int chat_id);
|
||||
public native void acceptChat (int chat_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);
|
||||
|
||||
@@ -91,7 +91,6 @@ public class DcMsg {
|
||||
public native int getType ();
|
||||
public native int getState ();
|
||||
public native int getChatId ();
|
||||
public native int getRealChatId ();
|
||||
public native int getFromId ();
|
||||
public native int getWidth (int def);
|
||||
public native int getHeight (int def);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.notifications.InChatSounds;
|
||||
import org.thoughtcrime.securesms.util.AndroidSignalProtocolLogger;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.SignalProtocolLoggerProvider;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -82,6 +83,8 @@ public class ApplicationContext extends MultiDexApplication {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
DynamicTheme.setDefaultDayNightMode(this);
|
||||
|
||||
dcContext.setStockTranslations();
|
||||
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
|
||||
|
||||
@@ -126,6 +126,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(Prefs.THEME_PREF)) {
|
||||
DynamicTheme.setDefaultDayNightMode(this);
|
||||
recreate();
|
||||
} else if (key.equals(Prefs.LANGUAGE_PREF)) {
|
||||
recreate();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -12,7 +11,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
@@ -76,23 +74,6 @@ public abstract class BaseConversationItem extends LinearLayout
|
||||
return batchSelected.isEmpty() && (messageRecord.isFailed());
|
||||
}
|
||||
|
||||
protected void handleDeadDropClick() {
|
||||
ConversationListFragment.DeaddropQuestionHelper helper = new ConversationListFragment.DeaddropQuestionHelper(context, messageRecord);
|
||||
new AlertDialog.Builder(context)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
int chatId = dcContext.decideOnContactRequest(messageRecord.getId(), DcContext.DC_DECISION_START_CHAT);
|
||||
if( chatId != 0 ) {
|
||||
Intent intent = new Intent(context, ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setNeutralButton(helper.answerBlock, (dialog, which) -> dcContext.decideOnContactRequest(messageRecord.getId(), DcContext.DC_DECISION_BLOCK))
|
||||
.setMessage(helper.question)
|
||||
.show();
|
||||
}
|
||||
|
||||
protected class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
|
||||
|
||||
@Override
|
||||
@@ -118,9 +99,7 @@ public abstract class BaseConversationItem extends LinearLayout
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
if (dcChat.getId() == DcChat.DC_CHAT_ID_DEADDROP && batchSelected.isEmpty()) {
|
||||
handleDeadDropClick();
|
||||
} else if (!shouldInterceptClicks(messageRecord) && parent != null) {
|
||||
if (!shouldInterceptClicks(messageRecord) && parent != null) {
|
||||
parent.onClick(v);
|
||||
} else if (messageRecord.isFailed()) {
|
||||
View view = View.inflate(context, R.layout.message_details_view, null);
|
||||
|
||||
@@ -33,7 +33,6 @@ import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Browser;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
@@ -90,6 +89,7 @@ import org.thoughtcrime.securesms.connect.DcEventCenter;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.map.MapActivity;
|
||||
import org.thoughtcrime.securesms.messagerequests.MessageRequestsBottomView;
|
||||
import org.thoughtcrime.securesms.mms.AttachmentManager;
|
||||
import org.thoughtcrime.securesms.mms.AttachmentManager.MediaType;
|
||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||
@@ -191,6 +191,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private InputAwareLayout container;
|
||||
private View composePanel;
|
||||
private ScaleStableImageView backgroundView;
|
||||
private MessageRequestsBottomView messageRequestBottomView;
|
||||
|
||||
private AttachmentTypeSelector attachmentTypeSelector;
|
||||
private AttachmentManager attachmentManager;
|
||||
@@ -271,6 +272,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
} else if (isSharing(this)) {
|
||||
handleSharing();
|
||||
}
|
||||
|
||||
initializeContactRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -297,6 +300,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
initializeDraft();
|
||||
}
|
||||
});
|
||||
initializeContactRequest();
|
||||
|
||||
if (fragment != null) {
|
||||
fragment.onNewIntent();
|
||||
@@ -453,10 +457,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
MenuInflater inflater = this.getMenuInflater();
|
||||
menu.clear();
|
||||
|
||||
if(chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
|
||||
if (dcChat.isSelfTalk()) {
|
||||
@@ -601,7 +601,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void handleReturnToConversationList() {
|
||||
handleReturnToConversationList(null);
|
||||
}
|
||||
|
||||
private void handleReturnToConversationList(@Nullable Bundle extras) {
|
||||
if (isRelayingMessageContent(this) || successfulForwardingAttempt) {
|
||||
if (isSharing(this)) {
|
||||
// we're allowing only 1 try to share, going back to the conversation list will
|
||||
@@ -615,6 +618,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
Intent intent = new Intent(this, (isArchived() ? ConversationListArchiveActivity.class : ConversationListActivity.class));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
if (extras != null) intent.putExtras(extras);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
@@ -633,13 +637,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void handleProfile() {
|
||||
if(chatId != DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
Intent intent = new Intent(this, ProfileActivity.class);
|
||||
intent.putExtra(ProfileActivity.CHAT_ID_EXTRA, chatId);
|
||||
intent.putExtra(ProfileActivity.FROM_CHAT, true);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
Intent intent = new Intent(this, ProfileActivity.class);
|
||||
intent.putExtra(ProfileActivity.CHAT_ID_EXTRA, chatId);
|
||||
intent.putExtra(ProfileActivity.FROM_CHAT, true);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
|
||||
private void handleLeaveGroup() {
|
||||
@@ -875,6 +877,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
|
||||
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
|
||||
backgroundView = ViewUtil.findById(this, R.id.conversation_background);
|
||||
messageRequestBottomView = ViewUtil.findById(this, R.id.conversation_activity_message_request_bottom_bar);
|
||||
|
||||
ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
|
||||
|
||||
@@ -966,10 +969,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
setComposePanelVisibility();
|
||||
|
||||
if (chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
titleView.hideAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
private void setComposePanelVisibility() {
|
||||
@@ -1555,6 +1554,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
initializeSecurity(isSecureText, isDefaultSms);
|
||||
setComposePanelVisibility();
|
||||
}
|
||||
|
||||
if (eventId == DcContext.DC_EVENT_CHAT_MODIFIED && event.getData1Int() == chatId) {
|
||||
initializeContactRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1653,4 +1656,44 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
return true; // action handled by listener
|
||||
}
|
||||
|
||||
public void initializeContactRequest() {
|
||||
if (!dcChat.isContactRequest()) {
|
||||
messageRequestBottomView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
messageRequestBottomView.setVisibility(View.VISIBLE);
|
||||
messageRequestBottomView.setAcceptOnClickListener(v -> {
|
||||
dcContext.acceptChat(chatId);
|
||||
messageRequestBottomView.setVisibility(View.GONE);
|
||||
composePanel.setVisibility(View.VISIBLE);
|
||||
});
|
||||
messageRequestBottomView.setBlockOnClickListener(v -> {
|
||||
dcContext.blockChat(chatId);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt(ConversationListFragment.RELOAD_LIST, 1);
|
||||
handleReturnToConversationList(extras);
|
||||
});
|
||||
|
||||
String question = null;
|
||||
if (dcChat.isMailingList()) {
|
||||
question = getString(R.string.ask_show_mailing_list, dcChat.getName());
|
||||
} else {
|
||||
if (dcChat.getType() == DcChat.DC_CHAT_TYPE_GROUP) {
|
||||
// We don't support blocking groups yet, so offer to delete it instead
|
||||
messageRequestBottomView.setBlockText(R.string.delete);
|
||||
messageRequestBottomView.setBlockOnClickListener(v -> handleDeleteChat());
|
||||
} else {
|
||||
int[] members = dcContext.getChatContacts(chatId);
|
||||
if (members.length == 1) {
|
||||
DcContact dcContact = dcContext.getContact(members[0]);
|
||||
question = getString(R.string.ask_start_chat_with, dcContact.getNameNAddr());
|
||||
} else {
|
||||
Log.w(TAG, "Non-group non-mailinglist has " + members.length + " (!= 1) members");
|
||||
}
|
||||
}
|
||||
}
|
||||
messageRequestBottomView.setQuestion(question);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,15 +172,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
|
||||
private void setNoMessageText() {
|
||||
DcChat dcChat = getListAdapter().getChat();
|
||||
if(chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
if(DcHelper.getInt(getActivity(), "show_emails")!= DcContext.DC_SHOW_EMAILS_ALL) {
|
||||
noMessageTextView.setText(R.string.chat_no_contact_requests);
|
||||
}
|
||||
else {
|
||||
noMessageTextView.setText(R.string.chat_no_messages);
|
||||
}
|
||||
}
|
||||
else if(dcChat.isGroup()){
|
||||
if(dcChat.isGroup()){
|
||||
if(dcContext.getChat((int) chatId).isUnpromoted()) {
|
||||
noMessageTextView.setText(R.string.chat_new_group_hint);
|
||||
}
|
||||
@@ -334,7 +326,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
menu.findItem(R.id.menu_context_save_attachment).setVisible(messageRecord.hasFile());
|
||||
boolean canReply = canReplyToMsg(messageRecord);
|
||||
menu.findItem(R.id.menu_context_reply).setVisible(chat.canSend() && canReply);
|
||||
boolean showReplyPrivately = chat.isGroup() && !messageRecord.isOutgoing() && canReply && chat.getId() != DcChat.DC_CHAT_ID_DEADDROP;
|
||||
boolean showReplyPrivately = chat.isGroup() && !messageRecord.isOutgoing() && canReply;
|
||||
menu.findItem(R.id.menu_context_reply_privately).setVisible(showReplyPrivately);
|
||||
}
|
||||
|
||||
|
||||
@@ -382,22 +382,14 @@ public class ConversationItem extends BaseConversationItem
|
||||
if (stickerStub.resolved()) stickerStub.get().setVisibility(View.GONE);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
if(dcChat.getId() == DcChat.DC_CHAT_ID_DEADDROP) { // no audio on dead drops
|
||||
// TODO: replace the currently defunct display of a play button with some notification text
|
||||
// to inform the user that here would be audio, if this were a proper chat, then ask the user
|
||||
// if he wants to start the chat on click.
|
||||
audioViewStub.get().setEnabled(false);
|
||||
audioViewStub.get().setOnClickListener(passthroughClickListener);
|
||||
} else {
|
||||
int duration = messageRecord.getDuration();
|
||||
if (duration == 0) {
|
||||
AudioSlide audio = new AudioSlide(context, messageRecord);
|
||||
AudioSlidePlayer audioSlidePlayer = AudioSlidePlayer.createFor(getContext(), audio, new SetDurationListener());
|
||||
audioSlidePlayer.requestDuration();
|
||||
}
|
||||
|
||||
audioViewStub.get().setAudio(new AudioSlide(context, messageRecord), duration);
|
||||
int duration = messageRecord.getDuration();
|
||||
if (duration == 0) {
|
||||
AudioSlide audio = new AudioSlide(context, messageRecord);
|
||||
AudioSlidePlayer audioSlidePlayer = AudioSlidePlayer.createFor(getContext(), audio, new SetDurationListener());
|
||||
audioSlidePlayer.requestDuration();
|
||||
}
|
||||
|
||||
audioViewStub.get().setAudio(new AudioSlide(context, messageRecord), duration);
|
||||
audioViewStub.get().setOnLongClickListener(passthroughClickListener);
|
||||
|
||||
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
@@ -709,9 +701,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
|
||||
private class ThumbnailClickListener implements SlideClickListener {
|
||||
public void onClick(final View v, final Slide slide) {
|
||||
if (dcChat.getId() == DcChat.DC_CHAT_ID_DEADDROP && batchSelected.isEmpty()) {
|
||||
handleDeadDropClick();
|
||||
} else if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
performClick();
|
||||
} else if (MediaPreviewActivity.isTypeSupported(slide) && slide.getUri() != null) {
|
||||
Intent intent = new Intent(context, MediaPreviewActivity.class);
|
||||
@@ -730,9 +720,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
|
||||
private class StickerClickListener implements SlideClickListener {
|
||||
public void onClick(final View v, final Slide slide) {
|
||||
if (dcChat.getId() == DcChat.DC_CHAT_ID_DEADDROP && batchSelected.isEmpty()) {
|
||||
handleDeadDropClick();
|
||||
} else if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
performClick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
@@ -235,9 +234,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
case R.id.menu_qr:
|
||||
new IntentIntegrator(this).setCaptureActivity(QrActivity.class).initiateScan();
|
||||
return true;
|
||||
case R.id.menu_deaddrop:
|
||||
handleDeaddrop();
|
||||
return true;
|
||||
case R.id.menu_global_map:
|
||||
handleShowMap();
|
||||
return true;
|
||||
@@ -338,12 +334,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeaddrop() {
|
||||
Intent intent = new Intent(this, ConversationActivity.class);
|
||||
intent.putExtra(CHAT_ID_EXTRA, DcChat.DC_CHAT_ID_DEADDROP);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
@@ -48,7 +48,6 @@ class ConversationListAdapter extends RecyclerView.Adapter {
|
||||
private static final int MESSAGE_TYPE_SWITCH_ARCHIVE = 1;
|
||||
private static final int MESSAGE_TYPE_THREAD = 2;
|
||||
private static final int MESSAGE_TYPE_INBOX_ZERO = 3;
|
||||
private static final int MESSAGE_TYPE_DEADDROP = 4; // DEADDROP and THREAD share the same class, however, for DEADDROP it is modified on construction so it cannot be reused
|
||||
|
||||
private final @NonNull ApplicationDcContext dcContext;
|
||||
private @NonNull DcChatlist dcChatlist;
|
||||
@@ -138,10 +137,7 @@ class ConversationListAdapter extends RecyclerView.Adapter {
|
||||
public int getItemViewType(int i) {
|
||||
int chatId = dcChatlist.getChatId(i);
|
||||
|
||||
if (chatId==DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
return MESSAGE_TYPE_DEADDROP;
|
||||
}
|
||||
else if (chatId == DcChat.DC_CHAT_ID_ARCHIVED_LINK) {
|
||||
if (chatId == DcChat.DC_CHAT_ID_ARCHIVED_LINK) {
|
||||
return MESSAGE_TYPE_SWITCH_ARCHIVE;
|
||||
} else if(chatId == DcChat.DC_CHAT_ID_ALLDONE_HINT) {
|
||||
return MESSAGE_TYPE_INBOX_ZERO;
|
||||
@@ -189,7 +185,7 @@ class ConversationListAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
void changeData(@Nullable DcChatlist chatlist) {
|
||||
dcChatlist = chatlist==null? new DcChatlist(0) : chatlist;
|
||||
dcChatlist = chatlist == null ? new DcChatlist(0) : chatlist;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -41,26 +41,20 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.view.ActionMode;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.Loader;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcChatlist;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcEvent;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import static org.thoughtcrime.securesms.ConversationActivity.CHAT_ID_EXTRA;
|
||||
import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
|
||||
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
|
||||
import org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton;
|
||||
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;
|
||||
@@ -87,8 +81,9 @@ import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent
|
||||
|
||||
|
||||
public class ConversationListFragment extends Fragment
|
||||
implements LoaderManager.LoaderCallbacks<DcChatlist>, ActionMode.Callback, ItemClickListener, DcEventCenter.DcEventDelegate {
|
||||
implements ActionMode.Callback, ItemClickListener, DcEventCenter.DcEventDelegate {
|
||||
public static final String ARCHIVE = "archive";
|
||||
public static final String RELOAD_LIST = "reload_list";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = ConversationListFragment.class.getSimpleName();
|
||||
@@ -102,6 +97,7 @@ public class ConversationListFragment extends Fragment
|
||||
private String queryFilter = "";
|
||||
private boolean archive;
|
||||
private Timer reloadTimer;
|
||||
private boolean chatlistJustLoaded;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -153,7 +149,9 @@ public class ConversationListFragment extends Fragment
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
initializeFabClickListener(false);
|
||||
initializeListAdapter();
|
||||
list.setAdapter(new ConversationListAdapter(getActivity(), GlideApp.with(this), locale, this));
|
||||
loadChatlist();
|
||||
chatlistJustLoaded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,13 +159,18 @@ public class ConversationListFragment extends Fragment
|
||||
super.onResume();
|
||||
|
||||
updateReminders();
|
||||
list.getAdapter().notifyDataSetChanged();
|
||||
|
||||
if (getActivity().getIntent().getIntExtra(RELOAD_LIST, 0) == 1
|
||||
&& !chatlistJustLoaded) {
|
||||
loadChatlist();
|
||||
}
|
||||
chatlistJustLoaded = false;
|
||||
|
||||
reloadTimer = new Timer();
|
||||
reloadTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Util.runOnMain(() -> { list.getAdapter().notifyDataSetChanged(); });
|
||||
Util.runOnMain(() -> loadChatlist());
|
||||
}
|
||||
}, 60 * 1000, 60 * 1000);
|
||||
}
|
||||
@@ -249,11 +252,6 @@ public class ConversationListFragment extends Fragment
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
|
||||
}
|
||||
|
||||
private void initializeListAdapter() {
|
||||
list.setAdapter(new ConversationListAdapter(getActivity(), GlideApp.with(this), locale, this));
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
|
||||
private void handlePinAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final Set<Long> selectedConversations = new HashSet<>(getListAdapter().getBatchSelections());
|
||||
@@ -300,13 +298,8 @@ public class ConversationListFragment extends Fragment
|
||||
@Override
|
||||
protected void executeAction(@Nullable Void parameter) {
|
||||
for (long chatId : selectedConversations) {
|
||||
if (chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
dcContext.marknoticedChat(DcChat.DC_CHAT_ID_DEADDROP);
|
||||
}
|
||||
else {
|
||||
dcContext.setChatVisibility((int)chatId,
|
||||
!archive? DcChat.DC_CHAT_VISIBILITY_ARCHIVED : DcChat.DC_CHAT_VISIBILITY_NORMAL);
|
||||
}
|
||||
dcContext.setChatVisibility((int)chatId,
|
||||
!archive? DcChat.DC_CHAT_VISIBILITY_ARCHIVED : DcChat.DC_CHAT_VISIBILITY_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,13 +341,8 @@ public class ConversationListFragment extends Fragment
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
for (long chatId : selectedConversations) {
|
||||
if (chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
dcContext.marknoticedChat(DcChat.DC_CHAT_ID_DEADDROP);
|
||||
}
|
||||
else {
|
||||
dcContext.notificationCenter.removeNotifications((int) chatId);
|
||||
dcContext.deleteChat((int) chatId);
|
||||
}
|
||||
dcContext.notificationCenter.removeNotifications((int) chatId);
|
||||
dcContext.deleteChat((int) chatId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -384,8 +372,7 @@ public class ConversationListFragment extends Fragment
|
||||
((ConversationSelectedListener)getActivity()).onCreateConversation(chatId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<DcChatlist> onCreateLoader(int arg0, Bundle arg1) {
|
||||
public void loadChatlist() {
|
||||
int listflags = 0;
|
||||
if (archive) {
|
||||
listflags |= DcContext.DC_GCL_ARCHIVED_ONLY;
|
||||
@@ -394,12 +381,8 @@ public class ConversationListFragment extends Fragment
|
||||
} else {
|
||||
listflags |= DcContext.DC_GCL_ADD_ALLDONE_HINT;
|
||||
}
|
||||
return new DcChatlistLoader(getActivity(), listflags, queryFilter.isEmpty()? null : queryFilter, 0);
|
||||
}
|
||||
DcChatlist chatlist = DcHelper.getContext(getContext()).getChatlist(listflags, queryFilter.isEmpty() ? null : queryFilter, 0);
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<DcChatlist> arg0, DcChatlist chatlist) {
|
||||
if (chatlist.getCnt() <= 0 && TextUtils.isEmpty(queryFilter) && !archive) {
|
||||
list.setVisibility(View.INVISIBLE);
|
||||
emptyState.setVisibility(View.VISIBLE);
|
||||
@@ -418,43 +401,12 @@ public class ConversationListFragment extends Fragment
|
||||
}
|
||||
|
||||
getListAdapter().changeData(chatlist);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<DcChatlist> arg0) {
|
||||
getListAdapter().changeData(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(ConversationListItem item) {
|
||||
if (actionMode == null) {
|
||||
int chatId = (int)item.getChatId();
|
||||
|
||||
if (chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final int msgId = item.getMsgId();
|
||||
if (DcHelper.getInt(getActivity(), "show_emails") == DcContext.DC_SHOW_EMAILS_ALL) {
|
||||
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
||||
intent.putExtra(CHAT_ID_EXTRA, DcChat.DC_CHAT_ID_DEADDROP);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
DeaddropQuestionHelper helper = new DeaddropQuestionHelper(getContext(), dcContext.getMsg(msgId));
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
int belongingChatId = dcContext.decideOnContactRequest(msgId, DcContext.DC_DECISION_START_CHAT);
|
||||
if (belongingChatId != 0) {
|
||||
handleCreateConversation(belongingChatId);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.not_now, (dialog, which) -> dcContext.decideOnContactRequest(msgId, DcContext.DC_DECISION_NOT_NOW))
|
||||
.setNeutralButton(helper.answerBlock, (dialog, which) -> dcContext.decideOnContactRequest(msgId, DcContext.DC_DECISION_BLOCK))
|
||||
.setMessage(helper.question)
|
||||
.show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
handleCreateConversation(chatId);
|
||||
} else {
|
||||
ConversationListAdapter adapter = (ConversationListAdapter) list.getAdapter();
|
||||
@@ -486,25 +438,6 @@ public class ConversationListFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
static class DeaddropQuestionHelper {
|
||||
public String question;
|
||||
public String answerBlock;
|
||||
|
||||
DeaddropQuestionHelper(Context context, DcMsg dcMsg) {
|
||||
DcContext dcContext = DcHelper.getContext(context);
|
||||
DcChat dcChat = dcContext.getChat(dcMsg.getRealChatId());
|
||||
|
||||
if (dcChat.isMailingList()) {
|
||||
question = context.getString(R.string.ask_show_mailing_list, dcChat.getName());
|
||||
answerBlock = context.getString(R.string.block);
|
||||
} else {
|
||||
DcContact dcContact = dcContext.getContact(dcMsg.getFromId());
|
||||
question = context.getString(R.string.ask_start_chat_with, dcMsg.getSenderName(dcContact, false));
|
||||
answerBlock = context.getString(R.string.menu_block_contact);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onSwitchToArchive() {
|
||||
((ConversationSelectedListener)getActivity()).onSwitchToArchive();
|
||||
@@ -614,7 +547,7 @@ public class ConversationListFragment extends Fragment
|
||||
if (event.getId() == DcContext.DC_EVENT_CONNECTIVITY_CHANGED) {
|
||||
((ConversationListActivity) getActivity()).refreshTitle();
|
||||
} else {
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
loadChatlist();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
private TextView subjectView;
|
||||
private FromTextView fromView;
|
||||
private TextView dateView;
|
||||
private TextView archivedView;
|
||||
private TextView badgeView;
|
||||
private DeliveryStatusView deliveryStatusIndicator;
|
||||
private ImageView unreadIndicator;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.dateView = findViewById(R.id.date);
|
||||
this.deliveryStatusIndicator = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
|
||||
this.archivedView = findViewById(R.id.archived);
|
||||
this.badgeView = findViewById(R.id.badge);
|
||||
this.unreadIndicator = findViewById(R.id.unread_indicator);
|
||||
|
||||
ViewUtil.setTextViewGravityStart(this.fromView, getContext());
|
||||
@@ -125,8 +125,6 @@ public class ConversationListItem extends RelativeLayout
|
||||
boolean batchMode,
|
||||
@Nullable String highlightSubstring)
|
||||
{
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(getContext());
|
||||
|
||||
this.dcSummary = dcSummary;
|
||||
this.selectedThreads = selectedThreads;
|
||||
Recipient recipient = thread.getRecipient();
|
||||
@@ -161,17 +159,11 @@ public class ConversationListItem extends RelativeLayout
|
||||
thread.isSendingLocations()? R.drawable.ic_location_chatlist : 0, 0
|
||||
);
|
||||
|
||||
setStatusIcons(thread.getVisibility(), state, unreadCount);
|
||||
setStatusIcons(thread.getVisibility(), state, unreadCount, thread.isContactRequest());
|
||||
setBatchState(batchMode);
|
||||
setBgColor(thread);
|
||||
|
||||
if(chatId == DcChat.DC_CHAT_ID_DEADDROP) {
|
||||
DcContact dcContact = dcContext.getContact(dcContext.getMsg(msgId).getFromId());
|
||||
this.contactPhotoImage.setAvatar(glideRequests, dcContext.getRecipient(dcContact), false);
|
||||
}
|
||||
else {
|
||||
this.contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||
}
|
||||
this.contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||
|
||||
fromView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
thread.isMuted()? R.drawable.ic_volume_off_grey600_18dp : 0,
|
||||
@@ -194,7 +186,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
subjectView.setText(getHighlightedSpan(locale, contact.getAddr(), highlightSubstring));
|
||||
dateView.setText("");
|
||||
dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
archivedView.setVisibility(GONE);
|
||||
badgeView.setVisibility(GONE);
|
||||
unreadIndicator.setVisibility(GONE);
|
||||
deliveryStatusIndicator.setNone();
|
||||
|
||||
@@ -225,7 +217,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
dateView.setText("");
|
||||
}
|
||||
dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
archivedView.setVisibility(GONE);
|
||||
badgeView.setVisibility(GONE);
|
||||
unreadIndicator.setVisibility(GONE);
|
||||
deliveryStatusIndicator.setNone();
|
||||
|
||||
@@ -249,16 +241,23 @@ public class ConversationListItem extends RelativeLayout
|
||||
return msgId;
|
||||
}
|
||||
|
||||
private void setStatusIcons(int visibility, int state, int unreadCount) {
|
||||
private void setStatusIcons(int visibility, int state, int unreadCount, boolean isContactRequest) {
|
||||
if (visibility==DcChat.DC_CHAT_VISIBILITY_ARCHIVED)
|
||||
{
|
||||
this.archivedView.setVisibility(View.VISIBLE);
|
||||
badgeView.setVisibility(View.VISIBLE);
|
||||
badgeView.setText(R.string.chat_archived_label);
|
||||
deliveryStatusIndicator.setNone();
|
||||
unreadIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
else if (isContactRequest) {
|
||||
badgeView.setVisibility(View.VISIBLE);
|
||||
badgeView.setText(R.string.chat_request_label);
|
||||
deliveryStatusIndicator.setNone();
|
||||
unreadIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.archivedView.setVisibility(View.GONE);
|
||||
this.badgeView.setVisibility(View.GONE);
|
||||
if (state==DcMsg.DC_STATE_IN_FRESH || state==DcMsg.DC_STATE_IN_NOTICED)
|
||||
{
|
||||
deliveryStatusIndicator.setNone();
|
||||
@@ -305,8 +304,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
|
||||
private void setBgColor(ThreadRecord thread) {
|
||||
int bg = R.attr.conversation_list_item_background;
|
||||
if (chatId == DcChat.DC_CHAT_ID_DEADDROP
|
||||
|| (thread!=null && thread.getVisibility()==DcChat.DC_CHAT_VISIBILITY_PINNED)) {
|
||||
if (thread!=null && thread.getVisibility()==DcChat.DC_CHAT_VISIBILITY_PINNED) {
|
||||
bg = R.attr.pinned_list_item_background;
|
||||
}
|
||||
TypedArray ta = getContext().obtainStyledAttributes(new int[] { bg });
|
||||
|
||||
@@ -65,33 +65,28 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
final DcContext dcContext = DcHelper.getContext(context);
|
||||
|
||||
// set title and subtitle texts
|
||||
if( chatId == DcChat.DC_CHAT_ID_DEADDROP ) {
|
||||
title.setText(R.string.menu_deaddrop);
|
||||
subtitle.setText(R.string.menu_deaddrop_subtitle);
|
||||
} else {
|
||||
title.setText(dcChat.getName());
|
||||
String subtitleStr = "ErrSubtitle";
|
||||
title.setText(dcChat.getName());
|
||||
String subtitleStr = "ErrSubtitle";
|
||||
|
||||
int[] chatContacts = dcContext.getChatContacts(chatId);
|
||||
if (dcChat.isMailingList()) {
|
||||
subtitleStr = context.getString(R.string.mailing_list);
|
||||
} else if( dcChat.isGroup() ) {
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
} else if( chatContacts.length>=1 ) {
|
||||
if( dcChat.isSelfTalk() ) {
|
||||
subtitleStr = context.getString(R.string.chat_self_talk_subtitle);
|
||||
}
|
||||
else if( dcChat.isDeviceTalk() ) {
|
||||
subtitleStr = context.getString(R.string.device_talk_subtitle);
|
||||
}
|
||||
else {
|
||||
subtitleStr = dcContext.getContact(chatContacts[0]).getAddr();
|
||||
}
|
||||
int[] chatContacts = dcContext.getChatContacts(chatId);
|
||||
if (dcChat.isMailingList()) {
|
||||
subtitleStr = context.getString(R.string.mailing_list);
|
||||
} else if( dcChat.isGroup() ) {
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
} else if( chatContacts.length>=1 ) {
|
||||
if( dcChat.isSelfTalk() ) {
|
||||
subtitleStr = context.getString(R.string.chat_self_talk_subtitle);
|
||||
}
|
||||
else if( dcChat.isDeviceTalk() ) {
|
||||
subtitleStr = context.getString(R.string.device_talk_subtitle);
|
||||
}
|
||||
else {
|
||||
subtitleStr = dcContext.getContact(chatContacts[0]).getAddr();
|
||||
}
|
||||
|
||||
subtitle.setText(subtitleStr);
|
||||
}
|
||||
|
||||
subtitle.setText(subtitleStr);
|
||||
|
||||
// set icons etc.
|
||||
int imgLeft = 0;
|
||||
int imgRight = 0;
|
||||
|
||||
@@ -116,7 +116,6 @@ public class ApplicationDcContext extends DcContext {
|
||||
setStockTranslation(2, context.getString(R.string.self));
|
||||
setStockTranslation(3, context.getString(R.string.draft));
|
||||
setStockTranslation(7, context.getString(R.string.voice_message));
|
||||
setStockTranslation(8, context.getString(R.string.chat_contact_request));
|
||||
setStockTranslation(9, context.getString(R.string.image));
|
||||
setStockTranslation(10, context.getString(R.string.video));
|
||||
setStockTranslation(11, context.getString(R.string.audio));
|
||||
@@ -330,7 +329,7 @@ public class ApplicationDcContext extends DcContext {
|
||||
|
||||
return new ThreadRecord(body, recipient, date,
|
||||
unreadCount, chatId,
|
||||
chat.getVisibility(), chat.isProtected(), chat.isSendingLocations(), chat.isMuted(), summary);
|
||||
chat.getVisibility(), chat.isProtected(), chat.isSendingLocations(), chat.isMuted(), chat.isContactRequest(), summary);
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.b44t.messenger.DcChatlist;
|
||||
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||
|
||||
public class DcChatlistLoader extends AsyncLoader<DcChatlist> {
|
||||
|
||||
private static final String TAG = DcChatlistLoader.class.getName();
|
||||
|
||||
private final int listflags;
|
||||
private final String query;
|
||||
private final int queryId;
|
||||
|
||||
public DcChatlistLoader(Context context, int listflags, String query, int queryId) {
|
||||
super(context);
|
||||
this.listflags = listflags;
|
||||
this.query = query;
|
||||
this.queryId = queryId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull
|
||||
DcChatlist loadInBackground() {
|
||||
try {
|
||||
return DcHelper.getContext(getContext()).getChatlist(listflags, query, queryId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
||||
return new DcChatlist(0);
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,13 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.b44t.messenger.DcLot;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -47,6 +46,7 @@ public class ThreadRecord {
|
||||
private final boolean isProtected;
|
||||
private final boolean isSendingLocations;
|
||||
private final boolean isMuted;
|
||||
private final boolean isContactRequest;
|
||||
private @Nullable final DcLot dcSummary;
|
||||
|
||||
public ThreadRecord(@NonNull String body,
|
||||
@@ -56,6 +56,7 @@ public class ThreadRecord {
|
||||
boolean isProtected,
|
||||
boolean isSendingLocations,
|
||||
boolean isMuted,
|
||||
boolean isContactRequest,
|
||||
@Nullable DcLot dcSummary)
|
||||
{
|
||||
this.threadId = threadId;
|
||||
@@ -67,6 +68,7 @@ public class ThreadRecord {
|
||||
this.isProtected = isProtected;
|
||||
this.isSendingLocations = isSendingLocations;
|
||||
this.isMuted = isMuted;
|
||||
this.isContactRequest = isContactRequest;
|
||||
this.dcSummary = dcSummary;
|
||||
}
|
||||
|
||||
@@ -125,4 +127,8 @@ public class ThreadRecord {
|
||||
public boolean isMuted() {
|
||||
return isMuted;
|
||||
}
|
||||
|
||||
public boolean isContactRequest() {
|
||||
return isContactRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.thoughtcrime.securesms.messagerequests;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class MessageRequestsBottomView extends ConstraintLayout {
|
||||
|
||||
private AppCompatTextView question;
|
||||
private Button accept;
|
||||
private Button block;
|
||||
|
||||
public MessageRequestsBottomView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MessageRequestsBottomView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public MessageRequestsBottomView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
inflate(getContext(), R.layout.message_request_bottom_bar, this);
|
||||
|
||||
question = findViewById(R.id.message_request_question);
|
||||
accept = findViewById(R.id.message_request_accept);
|
||||
block = findViewById(R.id.message_request_block);
|
||||
}
|
||||
|
||||
public void setAcceptOnClickListener(OnClickListener acceptOnClickListener) {
|
||||
accept.setOnClickListener(acceptOnClickListener);
|
||||
}
|
||||
|
||||
public void setBlockOnClickListener(OnClickListener deleteOnClickListener) {
|
||||
block.setOnClickListener(deleteOnClickListener);
|
||||
}
|
||||
|
||||
public void setBlockText(int text) {
|
||||
block.setText(text);
|
||||
}
|
||||
|
||||
public void setQuestion(String text) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
question.setMaxHeight(ViewUtil.dpToPx(5));
|
||||
} else {
|
||||
question.setMaxHeight(Integer.MAX_VALUE);
|
||||
question.setText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
@@ -47,6 +48,21 @@ public class DynamicTheme {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDefaultDayNightMode(@NonNull Context context) {
|
||||
String theme = Prefs.getTheme(context);
|
||||
|
||||
if (theme.equals(SYSTEM)) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
} else if (DynamicTheme.isDarkTheme(context)) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
|
||||
//CachedInflater.from(context).clear();
|
||||
}
|
||||
|
||||
|
||||
private @StyleRes int getSelectedTheme(Activity activity) {
|
||||
if (isDarkTheme(activity)) {
|
||||
return getDarkThemeStyle();
|
||||
|
||||
Reference in New Issue
Block a user