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

Commit 5054d106 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Request focus in uninstaller activity for Wear" into main

parents bfbdf101 f6442d65
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.
     *