Skip to content
Snippets Groups Projects
Commit 41f7c193 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

migration: allow to delete account

Change-Id: I456416a5ac76825dfd2774d0f7b1b8897d57f396
parent 496e49a8
No related branches found
No related tags found
No related merge requests found
...@@ -90,6 +90,7 @@ public class AccountMigrationFragment extends Fragment { ...@@ -90,6 +90,7 @@ public class AccountMigrationFragment extends Fragment {
}); });
binding.ringMigrateBtn.setOnClickListener(v -> initAccountMigration(binding.ringPassword.getText().toString())); binding.ringMigrateBtn.setOnClickListener(v -> initAccountMigration(binding.ringPassword.getText().toString()));
binding.deleteBtn.setOnClickListener(v -> initAccountDelete());
} }
@Override @Override
...@@ -100,11 +101,26 @@ public class AccountMigrationFragment extends Fragment { ...@@ -100,11 +101,26 @@ public class AccountMigrationFragment extends Fragment {
} }
} }
private void initAccountMigration(String password) { private void initAccountDelete() {
if (migratingAccount) { if (migratingAccount)
return; return;
new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.account_delete_dialog_title)
.setMessage(R.string.account_delete_dialog_message)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(R.string.menu_delete, (d, w) -> deleteAccount())
.create()
.show();
}
private void deleteAccount() {
mAccountService.removeAccount(mAccountId);
} }
private void initAccountMigration(String password) {
if (migratingAccount)
return;
migratingAccount = true; migratingAccount = true;
//orientation is locked during the migration of account to avoid the destruction of the thread //orientation is locked during the migration of account to avoid the destruction of the thread
......
...@@ -33,7 +33,7 @@ along with this program; if not, write to the Free Software ...@@ -33,7 +33,7 @@ along with this program; if not, write to the Free Software
android:descendantFocusability="beforeDescendants" android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:orientation="vertical" android:orientation="vertical"
app:bounded_width="320dp"> app:bounded_width="380dp">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -57,17 +57,12 @@ along with this program; if not, write to the Free Software ...@@ -57,17 +57,12 @@ along with this program; if not, write to the Free Software
android:contentDescription="@string/app_name" android:contentDescription="@string/app_name"
app:srcCompat="@drawable/ic_jami_48" /> app:srcCompat="@drawable/ic_jami_48" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/textView"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="16dp" android:layout_below="@id/textView"
android:paddingRight="16dp" android:layout_margin="16dp"
app:passwordToggleEnabled="true"> app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
...@@ -79,13 +74,30 @@ along with this program; if not, write to the Free Software ...@@ -79,13 +74,30 @@ along with this program; if not, write to the Free Software
android:inputType="textPassword" /> android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_layout"
android:orientation="horizontal"
android:layout_margin="8dp">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/ring_migrate_btn" android:id="@+id/delete_btn"
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush" style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/menu_delete"
android:textColor="@color/red_800"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/ring_migrate_btn"
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="@string/update_account" /> android:text="@string/update_account" />
</LinearLayout> </LinearLayout>
...@@ -98,7 +110,7 @@ along with this program; if not, write to the Free Software ...@@ -98,7 +110,7 @@ along with this program; if not, write to the Free Software
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingRight="16dp" android:paddingRight="16dp"
android:paddingBottom="24dp" android:paddingBottom="16dp"
android:text="@string/account_migration" android:text="@string/account_migration"
android:textSize="14sp" /> android:textSize="14sp" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment