mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
make delete-from-server working
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user