Added delete all data button

This commit is contained in:
M66B 2022-03-03 21:53:54 +01:00
parent c2d2f5ea68
commit 2a0f3fe5c3
4 changed files with 52 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2022 by Marcel Bokhorst (M66B)
*/
import android.app.ActivityManager;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@ -93,6 +94,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swDisconnectAutoUpdate;
private SwitchCompat swDisconnectLinks;
private SwitchCompat swDisconnectImages;
private Button btnClearAll;
private Group grpSafeBrowsing;
@ -150,6 +152,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisconnectAutoUpdate = view.findViewById(R.id.swDisconnectAutoUpdate);
swDisconnectLinks = view.findViewById(R.id.swDisconnectLinks);
swDisconnectImages = view.findViewById(R.id.swDisconnectImages);
btnClearAll = view.findViewById(R.id.btnClearAll);
grpSafeBrowsing = view.findViewById(R.id.grpSafeBrowsing);
@ -437,6 +440,26 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
btnClearAll.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
btnClearAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(getContext())
.setIcon(R.drawable.twotone_dangerous_24)
.setTitle(R.string.title_advanced_clear_all)
.setMessage(R.string.title_advanced_clear_all_remark)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
am.clearApplicationUserData();
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
});
// Initialize
FragmentDialogTheme.setBackground(getContext(), view, false);

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9.1,5L5,9.1v5.8L9.1,19h5.8l4.1,-4.1V9.1L14.9,5H9.1zM16.24,14.83l-1.41,1.41L12,13.41l-2.83,2.83l-1.41,-1.41L10.59,12L7.76,9.17l1.41,-1.41L12,10.59l2.83,-2.83l1.41,1.41L13.41,12L16.24,14.83z"
android:strokeAlpha="0.3"
android:fillAlpha="0.3"/>
<path
android:fillColor="@android:color/white"
android:pathData="M15.73,3H8.27L3,8.27v7.46L8.27,21h7.46L21,15.73V8.27L15.73,3zM19,14.9L14.9,19H9.1L5,14.9V9.1L9.1,5h5.8L19,9.1V14.9zM14.83,7.76L12,10.59L9.17,7.76L7.76,9.17L10.59,12l-2.83,2.83l1.41,1.41L12,13.41l2.83,2.83l1.41,-1.41L13.41,12l2.83,-2.83L14.83,7.76z"/>
</vector>

View File

@ -634,6 +634,18 @@
app:layout_constraintTop_toBottomOf="@+id/swDisconnectLinks"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnClearAll"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_dangerous_24"
android:drawablePadding="6dp"
android:text="@string/title_advanced_clear_all"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDisconnectImages" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpSafeBrowsing"
android:layout_width="0dp"

View File

@ -636,6 +636,8 @@
<string name="title_advanced_disconnect_auto_update">Automatically update lists weekly</string>
<string name="title_advanced_disconnect_links">Use lists to warn about tracking links</string>
<string name="title_advanced_disconnect_images">Use lists to recognize tracking images</string>
<string name="title_advanced_clear_all">Delete all data</string>
<string name="title_advanced_clear_all_remark">All app data will be irreversibly deleted!</string>
<string name="title_advanced_sign_default">Sign by default</string>
<string name="title_advanced_encrypt_default">Encrypt by default</string>