diff --git a/jni/Android.mk b/jni/Android.mk index bb0712b83..6041a9d1c 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -871,7 +871,7 @@ LOCAL_STATIC_LIBRARIES := etpan sasl2 sqlite crypto libiconv # "breakpad" was placed after "crypto", NativeLoader.cpp after dc_wrapper.c LOCAL_CFLAGS := -w -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno +LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno -std=c99 LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS LOCAL_SRC_FILES := \ diff --git a/jni/Application.mk b/jni/Application.mk index 1381bda63..605abf3db 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,5 +1,5 @@ +APP_PLATFORM := android-14 APP_ABI := armeabi armeabi-v7a x86 -APP_PLATFORM := android-9 -APP_STL := stlport_static -APP_CPPFLAGS += -fexceptions -APP_OPTIM := debug \ No newline at end of file +NDK_TOOLCHAIN_VERSION := 4.9 +APP_STL := gnustl_static + diff --git a/jni/dc_wrapper.c b/jni/dc_wrapper.c index 73abeb0f9..e7333bd87 100644 --- a/jni/dc_wrapper.c +++ b/jni/dc_wrapper.c @@ -590,15 +590,13 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_setConfig(JNIEnv *env, jobject JNIEXPORT jstring Java_com_b44t_messenger_DcContext_getConfig(JNIEnv *env, jobject obj, jstring key, jstring def/*may be NULL*/) { CHAR_REF(key); - CHAR_REF(def); - char* temp = dc_get_config(get_dc_context(env, obj), keyPtr, defPtr /*is NULL if value is NULL, CHAR_REF() handles this*/); + char* temp = dc_get_config(get_dc_context(env, obj), keyPtr); jstring ret = NULL; if (temp) { ret = JSTRING_NEW(temp); } free(temp); CHAR_UNREF(key); - CHAR_UNREF(def); return ret; /* returns NULL only if key is unset and "def" is NULL */ } diff --git a/jni/messenger-backend b/jni/messenger-backend index 987dc8003..d7055d088 160000 --- a/jni/messenger-backend +++ b/jni/messenger-backend @@ -1 +1 @@ -Subproject commit 987dc8003327593a3f77a7ae39889a83cdda8652 +Subproject commit d7055d088a99b9ef76c295221b33fe52f18e03ae diff --git a/res/values/strings.xml b/res/values/strings.xml index f795b0559..51a071ea8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -752,6 +752,8 @@ Delta Chat requires the Contacts permission in order to display your contacts, but it has been permanently denied. Please continue to the app settings menu, select \"Permissions\", and enable \"Contacts\". Error retrieving contacts, check your network connection Error deleting contacts, some contacts couldn\'t get deleted. Please delete existing conversations before. + Delete contacts? + This will permanently delete the selected contacts.\n\nContacts with ongoing chats and contacts from the system\'s address book cannot be deleted permanently. No blocked contacts diff --git a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java index baf87813d..33cfe57fa 100644 --- a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java +++ b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java @@ -19,6 +19,8 @@ package org.thoughtcrime.securesms; import android.Manifest; import android.annotation.SuppressLint; +import android.content.res.TypedArray; +import android.graphics.Color; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -27,10 +29,11 @@ import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.view.ActionMode; import android.util.SparseIntArray; -import android.view.ActionMode; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -53,6 +56,7 @@ import org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter; import org.thoughtcrime.securesms.contacts.ContactSelectionListItem; import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.permissions.Permissions; +import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.StickyHeaderDecoration; import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.ViewUtil; @@ -161,6 +165,12 @@ public class ContactSelectionListFragment extends Fragment public void onDestroyActionMode(ActionMode actionMode) { ContactSelectionListFragment.this.actionMode = null; getContactSelectionListAdapter().resetActionModeSelection(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + TypedArray color = getActivity().getTheme().obtainStyledAttributes(new int[] {android.R.attr.statusBarColor}); + getActivity().getWindow().setStatusBarColor(color.getColor(0, Color.BLACK)); + color.recycle(); + } } }; @@ -176,23 +186,25 @@ public class ContactSelectionListFragment extends Fragment } private void handleDeleteSelected() { - ContactSelectionListAdapter adapter = getContactSelectionListAdapter(); - final SparseIntArray actionModeSelection = adapter.getActionModeSelection().clone(); - new Thread(() -> { - boolean failed = false; - for (int index = 0; index < actionModeSelection.size(); index++) { - int contactId = actionModeSelection.valueAt(index); - boolean currentFailed = !dcContext.deleteContact(contactId); - failed = currentFailed || failed; - } - if (failed) { - Util.runOnMain(()-> { - Toast.makeText(getActivity(), R.string.ContactSelectionListFragment_error_deleting_contacts_check_existing_conversations, Toast.LENGTH_LONG).show(); - }); - } - }).start(); - adapter.resetActionModeSelection(); - actionMode.finish(); + Dialogs.showResponseDialog(getActivity(), getString(R.string.ContactSelectionListFragment_contact_delete_confirmation_title), getString(R.string.ContactSelectionListFragment_contact_delete_confirmation_message), (dialogInterface, i) -> { + ContactSelectionListAdapter adapter = getContactSelectionListAdapter(); + final SparseIntArray actionModeSelection = adapter.getActionModeSelection().clone(); + new Thread(() -> { + boolean failed = false; + for (int index = 0; index < actionModeSelection.size(); index++) { + int contactId = actionModeSelection.valueAt(index); + boolean currentFailed = !dcContext.deleteContact(contactId); + failed = currentFailed || failed; + } + if (failed) { + Util.runOnMain(()-> { + Toast.makeText(getActivity(), R.string.ContactSelectionListFragment_error_deleting_contacts_check_existing_conversations, Toast.LENGTH_LONG).show(); + }); + } + }).start(); + adapter.resetActionModeSelection(); + actionMode.finish(); + }); } private ContactSelectionListAdapter getContactSelectionListAdapter() { @@ -355,7 +367,7 @@ public class ContactSelectionListFragment extends Fragment @Override public void onItemLongClick(ContactSelectionListItem view) { if (actionMode == null) { - actionMode = Objects.requireNonNull(getActivity()).startActionMode(actionModeCallback); + actionMode = ((AppCompatActivity)getActivity()).startSupportActionMode(actionModeCallback); } else { finishActionModeIfSelectionIsEmpty(); } diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 12a34bb5c..80f36c623 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -376,14 +376,20 @@ public class ConversationItem extends LinearLayout bodyText.setFocusable(false); bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(context)); + String text = messageRecord.getText(); + if (messageRecord.isSetupMessage()) { - bodyText.setText(context.getString(R.string.autocrypt__asm_tap_body)); + bodyText.setText(context.getString(R.string.autocrypt__asm_tap_body)); + bodyText.setVisibility(View.VISIBLE); + } + else if (text.isEmpty()) { + bodyText.setVisibility(View.GONE); } else { - bodyText.setText(linkifyMessageBody(new SpannableString(messageRecord.getText()), batchSelected.isEmpty())); + bodyText.setText(linkifyMessageBody(new SpannableString(text), batchSelected.isEmpty())); + bodyText.setVisibility(View.VISIBLE); } - bodyText.setVisibility(View.VISIBLE); } private void setMediaAttributes(@NonNull DcMsg messageRecord, diff --git a/src/org/thoughtcrime/securesms/util/Dialogs.java b/src/org/thoughtcrime/securesms/util/Dialogs.java index 0f2937457..16d4ea766 100644 --- a/src/org/thoughtcrime/securesms/util/Dialogs.java +++ b/src/org/thoughtcrime/securesms/util/Dialogs.java @@ -17,11 +17,22 @@ package org.thoughtcrime.securesms.util; import android.content.Context; +import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import org.thoughtcrime.securesms.R; public class Dialogs { + public static void showResponseDialog(Context context, String title, String message, DialogInterface.OnClickListener listener) { + AlertDialog.Builder dialog = new AlertDialog.Builder(context); + dialog.setTitle(title); + dialog.setMessage(message); + dialog.setIconAttribute(R.attr.dialog_alert_icon); + dialog.setPositiveButton(android.R.string.ok, listener); + dialog.setNegativeButton(android.R.string.cancel, null); + dialog.show(); + } + public static void showAlertDialog(Context context, String title, String message) { AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(title);