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

Commit 8b1107d2 authored by Robin Lee's avatar Robin Lee
Browse files

Keyboard navigation for CompanionDeviceTestActivity

Problem:
  1) Open CTS Verifier > Companion Device Test > Go
  2) Click some items
  3) Find that they can't open and so the test is failed.

Root cause:
  - Pressing the view triggers the OnItemClickListener instead of the
    OnClickListener because the container is an AdapterView and that is
    how AdapterView handles keyboard input.

Solution:
  - Add a ListView setOnItemClickListener function to handle the keyboard
    actions. Remove the original touch listener because this is not
    needed any more.

Test: make dist
Test: manual (go through CTS Verifier)
Bug: 161863859
Test: manualTests#com.android.cts.verifier.companion.CompanionDeviceTestActivity
Change-Id: Idf8867afae35f243c44ee726e444febb3209d357
parent e3ad82a2
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.text.Html;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -75,6 +76,14 @@ public class DeviceChooserActivity extends Activity {
            mDeviceListView = findViewById(R.id.device_list);
            final DeviceDiscoveryService.DevicesAdapter adapter = getService().mDevicesAdapter;
            mDeviceListView.setAdapter(adapter);
            mDeviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
                    getService().mSelectedDevice =
                            (DeviceFilterPair) adapterView.getItemAtPosition(pos);
                    adapter.notifyDataSetChanged();
                }
            });
            adapter.registerDataSetObserver(new DataSetObserver() {
                @Override
                public void onChanged() {
+0 −4
Original line number Diff line number Diff line
@@ -349,10 +349,6 @@ public class DeviceDiscoveryService extends Service {
                        ? WIFI_ICON
                        : BLUETOOTH_ICON,
                    null, null, null);
            textView.setOnClickListener((view) -> {
                mSelectedDevice = device;
                notifyDataSetChanged();
            });
        }

        //TODO move to a layout file