Merge pull request #1121 from deltachat/add-device-msgs

add device msgs
This commit is contained in:
björn petersen
2019-12-03 11:39:44 +01:00
committed by GitHub
5 changed files with 17 additions and 2 deletions
+6
View File
@@ -674,6 +674,12 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_wasDeviceMsgEverAdded(JNIEn
}
JNIEXPORT void Java_com_b44t_messenger_DcContext_updateDeviceChats(JNIEnv *env, jobject obj)
{
dc_update_device_chats(get_dc_context(env, obj));
}
/* DcContext - handle config */
JNIEXPORT void Java_com_b44t_messenger_DcContext_setConfig(JNIEnv *env, jobject obj, jstring key, jstring value /*may be NULL*/)
+1
View File
@@ -158,6 +158,7 @@ public class DcContext {
public native int sendTextMsg (int chat_id, String text);
public native int addDeviceMsg (String label, DcMsg msg);
public native boolean wasDeviceMsgEverAdded(String label);
public native void updateDeviceChats ();
public @NonNull DcLot checkQr (String qr) { return new DcLot(checkQrCPtr(qr)); }
public native String getSecurejoinQr (int chat_id);
public native int joinSecurejoin (String qr);
@@ -34,6 +34,7 @@ import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import org.thoughtcrime.securesms.components.SearchToolbar;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.map.MapActivity;
import org.thoughtcrime.securesms.qr.QrCodeHandler;
import org.thoughtcrime.securesms.search.SearchFragment;
@@ -78,6 +79,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
@Override
protected void onCreate(Bundle icicle, boolean ready) {
DcHelper.getContext(this).updateDeviceChats();
setContentView(R.layout.conversation_list_activity);
Toolbar toolbar = findViewById(R.id.toolbar);
@@ -61,11 +61,11 @@ public class DozeReminder extends Reminder {
return false;
}
// if the chatlist is empty, just after installation,
// if the chatlist only contains device-talk and self-talk, just after installation,
// do not bother with battery, let the user check out other things first.
try {
int numberOfChats = DcHelper.getContext(context).getChatlist(0, null, 0).getCnt();
if (numberOfChats == 0) {
if (numberOfChats <= 2) {
return false;
}
}
@@ -178,6 +178,12 @@ abstract class MessageNotifier {
lastAudibleNotification = System.currentTimeMillis();
}
if (dcContext.getChat(chatId).isDeviceTalk()) {
// currently, we just never notify on device chat.
// esp. on first start, this is annoying.
return;
}
synchronized (lock) {
addMessageToNotificationState(dcContext, chatId, messageId);
if (notificationState.hasMultipleChats()) {