diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index a9f2e9622..b9b2e158a 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -73,6 +73,7 @@ public class MainActivity extends AppCompatActivity { private DrawerLayout drawer = null; private NavigationView drawerItems = null; private TextView headerServiceView = null; + private Button toggleServiceButton = null; private boolean servicesShown = false; private ImageView serviceArrow; @@ -266,8 +267,8 @@ public class MainActivity extends AppCompatActivity { serviceArrow = hView.findViewById(R.id.drawer_arrow); headerServiceView = hView.findViewById(R.id.drawer_header_service_view); - Button action = hView.findViewById(R.id.drawer_header_action_button); - action.setOnClickListener(view -> { + toggleServiceButton = hView.findViewById(R.id.drawer_header_action_button); + toggleServiceButton.setOnClickListener(view -> { toggleServices(); }); } @@ -279,6 +280,7 @@ public class MainActivity extends AppCompatActivity { drawerItems.getMenu().removeGroup(R.id.menu_tabs_group); drawerItems.getMenu().removeGroup(R.id.menu_options_about_group); + if(servicesShown) { showServices(); } else { @@ -364,6 +366,8 @@ public class MainActivity extends AppCompatActivity { String selectedServiceName = NewPipe.getService( ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName(); headerServiceView.setText(selectedServiceName); + toggleServiceButton.setContentDescription( + getString(R.string.drawer_header_description) + selectedServiceName); } catch (Exception e) { ErrorActivity.reportUiError(this, e); } @@ -557,6 +561,14 @@ public class MainActivity extends AppCompatActivity { } } + private void updateDrawerHeaderString(String content) { + NavigationView navigationView = findViewById(R.id.navigation); + View hView = navigationView.getHeaderView(0); + Button action = hView.findViewById(R.id.drawer_header_action_button); + + action.setContentDescription(content); + } + private void handleIntent(Intent intent) { try { if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]"); diff --git a/app/src/main/res/layout-v21/drawer_header.xml b/app/src/main/res/layout-v21/drawer_header.xml index 4474ee4ed..22e81883d 100644 --- a/app/src/main/res/layout-v21/drawer_header.xml +++ b/app/src/main/res/layout-v21/drawer_header.xml @@ -9,6 +9,7 @@ android:id="@+id/drawer_header_action_button" android:layout_width="match_parent" android:layout_height="match_parent" + android:contentDescription="@string/drawer_header_description" android:background="?android:attr/selectableItemBackground" /> K M B + Toggle service, currently selected: No subscribers