make delete-from-server working

This commit is contained in:
B. Petersen
2019-06-22 01:07:54 +02:00
parent 1996422d02
commit 83abb060ba
5 changed files with 56 additions and 11 deletions
+6
View File
@@ -738,6 +738,12 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcContext_imexHasBackup(JNIEnv *env, j
}
JNIEXPORT void Java_com_b44t_messenger_DcContext_emptyServer(JNIEnv *env, jobject obj, jint flags)
{
dc_empty_server(get_dc_context(env, obj), flags);
}
JNIEXPORT jint Java_com_b44t_messenger_DcContext_addAddressBook(JNIEnv *env, jobject obj, jstring adrbook)
{
CHAR_REF(adrbook);
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/empty_inbox_folder"
android:text="Delete ALL messages in Inbox folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
/>
<CheckBox
android:id="@+id/empty_deltachat_folder"
android:text="Delete ALL messages in DeltaChat folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</FrameLayout>
+4 -4
View File
@@ -42,16 +42,16 @@
<PreferenceCategory android:layout="@layout/preference_divider" />
<PreferenceCategory android:title="Experimental features">
<PreferenceCategory android:title="Experimenta l features">
<Preference android:key="pref_empty_server_folders"
android:title="Empty server folders" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_location_streaming_enabled"
android:title="On-demand location streaming"/>
<Preference android:key="pref_empty_server_folders"
android:title="Empty server folders" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider" />
+4
View File
@@ -69,6 +69,9 @@ public class DcContext {
public final static int DC_SHOW_EMAILS_ACCEPTED_CONTACTS = 1;
public final static int DC_SHOW_EMAILS_ALL = 2;
public final static int DC_EMPTY_MVBOX = 0x01;
public final static int DC_EMPTY_INBOX = 0x02;
public DcContext(String osName) {
handleEvent(0,0,0); // call handleEvent() to make sure it is not optimized away and JNI won't find it
contextCPtr = createContextCPtr(osName);
@@ -105,6 +108,7 @@ public class DcContext {
public native boolean continueKeyTransfer (int msg_id, String setup_code);
public native void imex (int what, String dir);
public native String imexHasBackup (String dir);
public native void emptyServer (int flags);
public native int checkPassword (String pw);
public native boolean mayBeValidAddr (String addr);
public native int lookupContactIdByAddr(String addr);
@@ -288,20 +288,23 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
public boolean onPreferenceClick(Preference preference) {
View gl = View.inflate(getActivity(), R.layout.empty_folder_options, null);
new AlertDialog.Builder(getActivity())
.setTitle("Empty folders on server")
.setMessage("This will delete all messages in the given folders on the server.")
.setTitle("Empty server folders")
.setMessage("This function helps to free space on your server by deleting messages in the given folders. Messages on this device will not be deleted.")
.setView(gl)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok, (dialog, which) -> {
.setPositiveButton("Delete messages", (dialog, which) -> {
int flags = 0;
CheckBox cb = gl.findViewById(R.id.empty_inbox_chat_folder);
CheckBox cb = gl.findViewById(R.id.empty_inbox_folder);
if (cb!=null && cb.isChecked()) {
flags |= DC_EMPTY_INBOX;
flags |= DcContext.DC_EMPTY_INBOX;
}
cb = gl.findViewById(R.id.empty_deltachat_folder);
if (cb!=null && cb.isChecked()) {
flags |= DC_EMPTY_MVBOX;
flags |= DcContext.DC_EMPTY_MVBOX;
}
if (flags!=0) {
dcContext.emptyServer(flags);
}
})
.show();
return true;