Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9aaa9246 authored by Sumedh Sen's avatar Sumedh Sen
Browse files

Dynamically set positive button text in Pia V2

While an update owner is changed, the positive button of confirmation
dialog should show "Update Anyway"

Bug: 318554368
Bug: 182205982
Test: atest CtsPackageInstallTestCases:PreapprovalInstallTest
Change-Id: I9f9aae9c557ad3f57995313e03acaa6b2ad8b5b9
parent 68779b7f
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -60,20 +60,29 @@ public class InstallConfirmationFragment extends DialogFragment {
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        View dialogView = getLayoutInflater().inflate(R.layout.install_content_view, null);

        int positiveBtnTextRes;
        if (mDialogData.isAppUpdating()) {
            if (mDialogData.getDialogMessage() != null) {
                positiveBtnTextRes = R.string.update_anyway;
            } else {
                positiveBtnTextRes = R.string.update;
            }
        } else {
            positiveBtnTextRes = R.string.install;
        }

        mDialog = new AlertDialog.Builder(requireContext())
            .setIcon(mDialogData.getAppIcon())
            .setTitle(mDialogData.getAppLabel())
            .setView(dialogView)
            .setPositiveButton(mDialogData.isAppUpdating() ? R.string.update : R.string.install,
            .setPositiveButton(positiveBtnTextRes,
                (dialogInt, which) -> mInstallActionListener.onPositiveResponse(
                    InstallUserActionRequired.USER_ACTION_REASON_INSTALL_CONFIRMATION))
            .setNegativeButton(R.string.cancel,
                (dialogInt, which) -> mInstallActionListener.onNegativeResponse(
                    mDialogData.getStageCode()))

            .create();

        // TODO: Dynamically change positive button text to update anyway
        TextView viewToEnable;
        if (mDialogData.isAppUpdating()) {
            viewToEnable = dialogView.requireViewById(R.id.install_confirm_question_update);