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 DrawerLayout drawer = null;
private NavigationView drawerItems = null; private NavigationView drawerItems = null;
private TextView headerServiceView = null; private TextView headerServiceView = null;
private Button toggleServiceButton = null;
private boolean servicesShown = false; private boolean servicesShown = false;
private ImageView serviceArrow; private ImageView serviceArrow;
@ -266,8 +267,8 @@ public class MainActivity extends AppCompatActivity {
serviceArrow = hView.findViewById(R.id.drawer_arrow); serviceArrow = hView.findViewById(R.id.drawer_arrow);
headerServiceView = hView.findViewById(R.id.drawer_header_service_view); headerServiceView = hView.findViewById(R.id.drawer_header_service_view);
Button action = hView.findViewById(R.id.drawer_header_action_button); toggleServiceButton = hView.findViewById(R.id.drawer_header_action_button);
action.setOnClickListener(view -> { toggleServiceButton.setOnClickListener(view -> {
toggleServices(); toggleServices();
}); });
} }
@ -279,6 +280,7 @@ public class MainActivity extends AppCompatActivity {
drawerItems.getMenu().removeGroup(R.id.menu_tabs_group); drawerItems.getMenu().removeGroup(R.id.menu_tabs_group);
drawerItems.getMenu().removeGroup(R.id.menu_options_about_group); drawerItems.getMenu().removeGroup(R.id.menu_options_about_group);
if(servicesShown) { if(servicesShown) {
showServices(); showServices();
} else { } else {
@ -364,6 +366,8 @@ public class MainActivity extends AppCompatActivity {
String selectedServiceName = NewPipe.getService( String selectedServiceName = NewPipe.getService(
ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName(); ServiceHelper.getSelectedServiceId(this)).getServiceInfo().getName();
headerServiceView.setText(selectedServiceName); headerServiceView.setText(selectedServiceName);
toggleServiceButton.setContentDescription(
getString(R.string.drawer_header_description) + selectedServiceName);
} catch (Exception e) { } catch (Exception e) {
ErrorActivity.reportUiError(this, 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) { private void handleIntent(Intent intent) {
try { try {
if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]"); if (DEBUG) Log.d(TAG, "handleIntent() called with: intent = [" + intent + "]");

View file

@ -9,6 +9,7 @@
android:id="@+id/drawer_header_action_button" android:id="@+id/drawer_header_action_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:contentDescription="@string/drawer_header_description"
android:background="?android:attr/selectableItemBackground" /> android:background="?android:attr/selectableItemBackground" />
<ImageView <ImageView

View file

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