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

Commit f6442d65 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Request focus in uninstaller activity for Wear

A dialog in Wear needs to be focused to allow for rotational input, but a dialog loses focus when it's hidden. To mitigate this, we are re-requetsing focus any time the dialog is shown again.

Bug: 417602569
Test: see https://buganizer.corp.google.com/issues/375325428#comment15
Flag: EXEMPT minor, Wear only change
Change-Id: I5dde00e6487dfa45d586afff373ed3e34b9c0b61
parent e67f08bd
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.TextView;

@@ -302,6 +303,29 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
            // Focus is important on watches, since it is needed to navigate the screen with
            // rotary input. Because a dialog loses focuses anytime it's hidden, we request
            // it here to make sure that the focus is gained everytime it shows.
            requestFocusOnDialog();
        }
    }

    private void requestFocusOnDialog() {
        Dialog dialog = getDialog();
        if (dialog == null) {
            return;
        }
        Window window = dialog.getWindow();
        if (window == null) {
            return;
        }
        window.getDecorView().requestFocus();
    }

    /**
     * Returns whether there is only one "full" user on this device.
     *