From 0f0ca2db363fcf60bee9b1b11e405e8ace74a544 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 20 Oct 2023 16:24:21 +0200 Subject: [PATCH 1/3] Rename .java to .kt Signed-off-by: alperozturk --- ...onfirmationDialog.java => AccountRemovalConfirmationDialog.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/com/owncloud/android/ui/dialog/{AccountRemovalConfirmationDialog.java => AccountRemovalConfirmationDialog.kt} (100%) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.java b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt similarity index 100% rename from app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.java rename to app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt From c6b6225e45cd9dcbdb7c0ddebdf6e4c1a0b401a4 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 20 Oct 2023 16:24:21 +0200 Subject: [PATCH 2/3] Convert to kt Signed-off-by: alperozturk --- .../AccountRemovalConfirmationDialog.kt | 140 +++++++++--------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt index a3a7e1391281..8ca103d2380d 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt @@ -19,87 +19,89 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -package com.owncloud.android.ui.dialog; - -import android.app.Dialog; -import android.os.Bundle; - -import com.google.android.material.button.MaterialButton; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.nextcloud.client.account.User; -import com.nextcloud.client.di.Injectable; -import com.nextcloud.client.jobs.BackgroundJobManager; -import com.owncloud.android.R; -import com.owncloud.android.utils.theme.ViewThemeUtils; - -import javax.inject.Inject; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.DialogFragment; - -public class AccountRemovalConfirmationDialog extends DialogFragment implements Injectable { - private static final String KEY_USER = "USER"; - - @Inject BackgroundJobManager backgroundJobManager; - @Inject ViewThemeUtils viewThemeUtils; - private User user; - - public static AccountRemovalConfirmationDialog newInstance(User user) { - Bundle bundle = new Bundle(); - bundle.putParcelable(KEY_USER, user); - - AccountRemovalConfirmationDialog dialog = new AccountRemovalConfirmationDialog(); - dialog.setArguments(bundle); - - return dialog; - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Bundle arguments = getArguments(); - if (arguments != null) { - user = arguments.getParcelable(KEY_USER); +package com.owncloud.android.ui.dialog + +import android.app.Dialog +import android.content.DialogInterface +import android.os.Build +import android.os.Bundle +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment +import com.google.android.material.button.MaterialButton +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.nextcloud.client.account.User +import com.nextcloud.client.di.Injectable +import com.nextcloud.client.jobs.BackgroundJobManager +import com.owncloud.android.R +import com.owncloud.android.utils.theme.ViewThemeUtils +import javax.inject.Inject + +class AccountRemovalConfirmationDialog : DialogFragment(), Injectable { + @JvmField + @Inject + var backgroundJobManager: BackgroundJobManager? = null + + @JvmField + @Inject + var viewThemeUtils: ViewThemeUtils? = null + + private var user: User? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + user = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + requireArguments().getParcelable(KEY_USER, User::class.java) + } else { + @Suppress("DEPRECATION") + requireArguments().getParcelable(KEY_USER) } } - @Override - public void onStart() { - super.onStart(); + override fun onStart() { + super.onStart() - AlertDialog alertDialog = (AlertDialog) getDialog(); - if (alertDialog != null) { + val alertDialog = dialog as AlertDialog? - MaterialButton positiveButton = (MaterialButton) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); - if (positiveButton != null) { - viewThemeUtils.material.colorMaterialButtonPrimaryTonal(positiveButton); - } + if (alertDialog != null) { + val positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE) as MaterialButton + viewThemeUtils?.material?.colorMaterialButtonPrimaryTonal(positiveButton) - MaterialButton negativeButton = (MaterialButton) alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); - if (negativeButton != null) { - viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(negativeButton); - } + val negativeButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE) as MaterialButton + viewThemeUtils?.material?.colorMaterialButtonPrimaryBorderless(negativeButton) } } - @NonNull - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity()) + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val builder = MaterialAlertDialogBuilder(requireActivity()) .setTitle(R.string.delete_account) - .setMessage(getResources().getString(R.string.delete_account_warning, user.getAccountName())) + .setMessage(resources.getString(R.string.delete_account_warning, user!!.accountName)) .setIcon(R.drawable.ic_warning) - .setPositiveButton(R.string.common_ok, - (dialogInterface, i) -> backgroundJobManager.startAccountRemovalJob(user.getAccountName(), - false)) - .setNegativeButton(R.string.common_cancel, null); + .setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int -> + backgroundJobManager?.startAccountRemovalJob( + user!!.accountName, + false + ) + } + .setNegativeButton(R.string.common_cancel, null) - viewThemeUtils.dialog.colorMaterialAlertDialogBackground(requireActivity(), builder); + viewThemeUtils?.dialog?.colorMaterialAlertDialogBackground(requireActivity(), builder) - return builder.create(); + return builder.create() } + + companion object { + + private const val KEY_USER = "USER" + + @JvmStatic + fun newInstance(user: User?): AccountRemovalConfirmationDialog { + val bundle = Bundle() + bundle.putParcelable(KEY_USER, user) + val dialog = AccountRemovalConfirmationDialog() + dialog.arguments = bundle + return dialog + } + } + } From 64f4c46903527fd76e829218169a44fc2caafab2 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 30 Oct 2023 19:31:14 +0100 Subject: [PATCH 3/3] remove unneeded empty lines Signed-off-by: Andy Scherzinger --- .../android/ui/dialog/AccountRemovalConfirmationDialog.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt index 8ca103d2380d..a32e818abe43 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/AccountRemovalConfirmationDialog.kt @@ -1,5 +1,4 @@ /* - * * Nextcloud Android client application * * @author Tobias Kaminsky @@ -103,5 +102,4 @@ class AccountRemovalConfirmationDialog : DialogFragment(), Injectable { return dialog } } - }