add content description for toggle service button

This commit is contained in:
Christian Schabesberger 2019-09-22 11:59:50 +02:00
parent e1d2c576a9
commit 28accff9ba
3 changed files with 16 additions and 2 deletions

View File

@ -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 + "]");

View File

@ -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" />
<ImageView

View File

@ -250,6 +250,7 @@
<string name="short_thousand">K</string>
<string name="short_million">M</string>
<string name="short_billion">B</string>
<string name="drawer_header_description">Toggle service, currently selected:</string>
<!--Zero don't get selected (in some languages) as it is not a "special case" for android-->
<string name="no_subscribers">No subscribers</string>
<plurals name="subscribers">