[AndroidTV] Fix selecting PeerTube instance in navigation drawer

Fixes #10020
This commit is contained in:
TobiGr 2023-07-15 04:37:59 +02:00
parent 5c7a9a52f5
commit 27b2d5de70
1 changed files with 12 additions and 4 deletions

View File

@ -63,6 +63,7 @@ import org.schabi.newpipe.databinding.InstanceSpinnerLayoutBinding;
import org.schabi.newpipe.databinding.ToolbarLayoutBinding; import org.schabi.newpipe.databinding.ToolbarLayoutBinding;
import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.error.ErrorUtil;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance; import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
@ -258,8 +259,15 @@ public class MainActivity extends AppCompatActivity {
private boolean drawerItemSelected(final MenuItem item) { private boolean drawerItemSelected(final MenuItem item) {
switch (item.getGroupId()) { switch (item.getGroupId()) {
case R.id.menu_services_group: case R.id.menu_services_group:
changeService(item); if (item.getItemId() == ServiceList.PeerTube.getServiceId()
break; && DeviceUtils.isTv(getApplicationContext())
&& !item.isActionViewExpanded()) {
((Spinner) item.getActionView()).performClick();
return true;
} else {
changeService(item);
break;
}
case R.id.menu_tabs_group: case R.id.menu_tabs_group:
try { try {
tabSelected(item); tabSelected(item);
@ -383,8 +391,8 @@ public class MainActivity extends AppCompatActivity {
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title) .add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId())); .setIcon(ServiceHelper.getIcon(s.getServiceId()));
// peertube specifics // PeerTube specifics
if (s.getServiceId() == 3) { if (s == ServiceList.PeerTube) {
enhancePeertubeMenu(menuItem); enhancePeertubeMenu(menuItem);
} }
} }