diff --git a/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.java b/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.java index 1eea06bb36b7194ea2d77678b642f71a43218a62..aac82847115bc6054c222b2a6596dbd77cbc2da1 100644 --- a/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.java +++ b/ring-android/app/src/main/java/cx/ring/fragments/AccountMigrationFragment.java @@ -90,6 +90,7 @@ public class AccountMigrationFragment extends Fragment { }); binding.ringMigrateBtn.setOnClickListener(v -> initAccountMigration(binding.ringPassword.getText().toString())); + binding.deleteBtn.setOnClickListener(v -> initAccountDelete()); } @Override @@ -100,11 +101,26 @@ public class AccountMigrationFragment extends Fragment { } } - private void initAccountMigration(String password) { - if (migratingAccount) { + private void initAccountDelete() { + if (migratingAccount) 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; //orientation is locked during the migration of account to avoid the destruction of the thread diff --git a/ring-android/app/src/main/res/layout/frag_account_migration.xml b/ring-android/app/src/main/res/layout/frag_account_migration.xml index fd72890e1c69c3d47fb3f7e4571736dc927b9890..e9126516c1d88f6e71b8e9b420127334e35cd3ed 100644 --- a/ring-android/app/src/main/res/layout/frag_account_migration.xml +++ b/ring-android/app/src/main/res/layout/frag_account_migration.xml @@ -33,7 +33,7 @@ along with this program; if not, write to the Free Software android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true" android:orientation="vertical" - app:bounded_width="320dp"> + app:bounded_width="380dp"> <androidx.cardview.widget.CardView android:layout_width="match_parent" @@ -57,36 +57,48 @@ along with this program; if not, write to the Free Software android:contentDescription="@string/app_name" app:srcCompat="@drawable/ic_jami_48" /> - <LinearLayout + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/password_layout" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_below="@id/textView" - android:orientation="vertical"> + android:layout_margin="16dp" + app:passwordToggleEnabled="true"> - <com.google.android.material.textfield.TextInputLayout + <com.google.android.material.textfield.TextInputEditText + android:id="@+id/ring_password" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingLeft="16dp" - android:paddingRight="16dp" - app:passwordToggleEnabled="true"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/ring_password" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/account_enter_password" - android:imeOptions="actionDone" - android:inputType="textPassword" /> - </com.google.android.material.textfield.TextInputLayout> + android:hint="@string/account_enter_password" + android:imeOptions="actionDone" + android:inputType="textPassword" /> + </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 - android:id="@+id/ring_migrate_btn" + android:id="@+id/delete_btn" style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush" android:layout_width="wrap_content" - android:layout_height="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" 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:text="@string/update_account"/> + android:layout_weight="1" + android:text="@string/update_account" /> </LinearLayout> <TextView @@ -98,7 +110,7 @@ along with this program; if not, write to the Free Software android:paddingLeft="16dp" android:paddingTop="16dp" android:paddingRight="16dp" - android:paddingBottom="24dp" + android:paddingBottom="16dp" android:text="@string/account_migration" android:textSize="14sp" /> @@ -113,7 +125,7 @@ along with this program; if not, write to the Free Software android:paddingTop="24dp" android:paddingRight="16dp" android:text="@string/ring_account" - android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"/> + android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5" /> </RelativeLayout>