Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: accesibility labels for buttons #945

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/src/main/java/com/m2049r/xmrwallet/LoginFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,33 +325,46 @@ private void setFabOpen(boolean value) {
}

public void animateFAB() {
// NOTE: Without `fabX.setVisibility(View.VISIBLE)`, the code `fabX.setClickable(true)` does not work.
// Please update the future buttons with the above code for better accessibility.
if (isFabOpen()) { // close the fab
fabScreen.setClickable(false);
fabScreen.setVisibility(View.INVISIBLE);
fabScreen.startAnimation(fab_close_screen);
fab.startAnimation(rotate_backward);
fab.setContentDescription(getString(R.string.fab_create_or_restore));
if (fabLedgerL.getVisibility() == View.VISIBLE) {
fabLedgerL.startAnimation(fab_close);
fabLedger.setClickable(false);
fabLedger.setVisibility(View.INVISIBLE);
} else if (fabSidekickL.getVisibility() == View.VISIBLE) {
fabSidekickL.startAnimation(fab_close);
fabSidekick.setClickable(false);
fabSidekick.setVisibility(View.INVISIBLE);
} else {
fabNewL.startAnimation(fab_close);
fabNew.setClickable(false);
fabNew.setVisibility(View.INVISIBLE);
fabViewL.startAnimation(fab_close);
fabView.setClickable(false);
fabView.setVisibility(View.INVISIBLE);
fabKeyL.startAnimation(fab_close);
fabKey.setClickable(false);
fabKey.setVisibility(View.INVISIBLE);
fabSeedL.startAnimation(fab_close);
fabSeed.setClickable(false);
fabSeed.setVisibility(View.INVISIBLE);
fabImportL.startAnimation(fab_close);
fabImport.setClickable(false);
fabImport.setVisibility(View.INVISIBLE);
}
setFabOpen(false);
} else { // open the fab
fabScreen.setClickable(true);
fabScreen.setVisibility(View.VISIBLE);;
fabScreen.startAnimation(fab_open_screen);
fab.startAnimation(rotate_forward);
fab.setContentDescription(getString(R.string.fab_close));
if ((activityCallback.hasDevice(Wallet.Device.Ledger)
|| activityCallback.hasDevice(Wallet.Device.Sidekick))) {
fabNewL.setVisibility(View.GONE);
Expand All @@ -364,10 +377,12 @@ public void animateFAB() {
fabLedgerL.setVisibility(View.VISIBLE);
fabLedgerL.startAnimation(fab_open);
fabLedger.setClickable(true);
fabLedger.setVisibility(View.VISIBLE);
} else { // Sidekick
fabSidekickL.setVisibility(View.VISIBLE);
fabSidekickL.startAnimation(fab_open);
fabSidekick.setClickable(true);
fabSidekick.setVisibility(View.VISIBLE);
}
} else {
fabSidekickL.setVisibility(View.GONE);
Expand All @@ -380,14 +395,19 @@ public void animateFAB() {

fabNewL.startAnimation(fab_open);
fabNew.setClickable(true);
fabNew.setVisibility(View.VISIBLE);
fabViewL.startAnimation(fab_open);
fabView.setClickable(true);
fabView.setVisibility(View.VISIBLE);
fabKeyL.startAnimation(fab_open);
fabKey.setClickable(true);
fabKey.setVisibility(View.VISIBLE);
fabSeedL.startAnimation(fab_open);
fabSeed.setClickable(true);
fabSeed.setVisibility(View.VISIBLE);
fabImportL.startAnimation(fab_open);
fabImport.setClickable(true);
fabImport.setVisibility(View.VISIBLE);
}
setFabOpen(true);
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/m2049r/xmrwallet/NodeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Helper.hideKeyboard(getActivity());

nodeList = new HashSet<>(activityCallback.getFavouriteNodes());
nodesAdapter.setNodes(nodeList);
nodesAdapter.setNodes(nodeList, getContext());

ViewGroup llNotice = view.findViewById(R.id.llNotice);
Notice.showAll(llNotice, ".*_nodes");
Expand Down Expand Up @@ -266,7 +266,7 @@ private class AsyncFindNodes extends AsyncTask<Integer, NodeInfo, Boolean>
protected void onPreExecute() {
super.onPreExecute();
filterFavourites();
nodesAdapter.setNodes(null);
nodesAdapter.setNodes(null, getContext());
nodesAdapter.allowClick(false);
tvPull.setText(getString(R.string.node_scanning));
}
Expand Down Expand Up @@ -335,7 +335,7 @@ protected void onProgressUpdate(NodeInfo... values) {
if (values != null)
nodesAdapter.addNode(values[0]);
else
nodesAdapter.setNodes(null);
nodesAdapter.setNodes(null, getContext());
}

@Override
Expand All @@ -357,7 +357,7 @@ private void complete() {
//if (isCancelled()) return;
tvPull.setText(getString(R.string.node_pull_hint));
pullToRefresh.setRefreshing(false);
nodesAdapter.setNodes(nodeList);
nodesAdapter.setNodes(nodeList, getContext());
nodesAdapter.allowClick(true);
updateRefreshElements();
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ protected void onCreate(Bundle savedInstanceState) {
});

drawer = findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, 0, 0);
drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.open_drawer, R.string.close_drawer);
drawer.addDrawerListener(drawerToggle);
drawerToggle.syncState();
setDrawerEnabled(false); // disable until synced


detherminal marked this conversation as resolved.
Show resolved Hide resolved

accountsView = findViewById(R.id.accounts_nav);
accountsView.setNavigationItemSelectedListener(this);

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/m2049r/xmrwallet/data/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ public String toString() {
return sb.toString();
}

public String toNameString() {
return name;
}

public Node() {
this.networkType = WalletManager.getInstance().getNetworkType();
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/m2049r/xmrwallet/data/NodeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ public String toString() {
return sb.toString();
}

public String toNameString() {
return super.toNameString();
}

private static final int HTTP_TIMEOUT = 1000; //ms
public static final double PING_GOOD = HTTP_TIMEOUT / 3.0; //ms
public static final double PING_MEDIUM = 2 * PING_GOOD; //ms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public interface OnInteractionListener {

private final FragmentActivity activity;

private Context context;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there must be a better way of setting the context than from all the setNodes methods

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How?


public NodeInfoAdapter(FragmentActivity activity, OnInteractionListener listener) {
this.activity = activity;
this.listener = listener;
Expand Down Expand Up @@ -107,10 +109,11 @@ public void addNode(NodeInfo node) {
List<NodeInfo> newItems = new ArrayList<>(nodeItems);
if (!nodeItems.contains(node))
newItems.add(node);
setNodes(newItems); // in case the nodeinfo has changed
setNodes(newItems, context); // in case the nodeinfo has changed
}

public void setNodes(Collection<NodeInfo> newItemsCollection) {
public void setNodes(Collection<NodeInfo> newItemsCollection, Context iContext) {
context = iContext;
List<NodeInfo> newItems;
if (newItemsCollection != null) {
newItems = new ArrayList<>(newItemsCollection);
Expand All @@ -126,7 +129,7 @@ public void setNodes(Collection<NodeInfo> newItemsCollection) {
}

public void setNodes() {
setNodes(nodeItems);
setNodes(nodeItems, context);
}

private boolean itemsClickable = true;
Expand Down Expand Up @@ -156,7 +159,7 @@ class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
showStar();
if (!nodeItem.isFavourite()) {
nodeItem.setSelected(false);
setNodes(nodeItems);
setNodes(nodeItems, context);
}
});
itemView.setOnClickListener(this);
Expand All @@ -166,8 +169,10 @@ class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
private void showStar() {
if (nodeItem.isFavourite()) {
ibBookmark.setImageResource(R.drawable.ic_favorite_24dp);
ibBookmark.setContentDescription(context.getString(R.string.node_remove_favourite).replace("%1$", nodeItem.toNameString()));
} else {
ibBookmark.setImageResource(R.drawable.ic_favorite_border_24dp);
ibBookmark.setContentDescription(context.getString(R.string.node_add_favourite).replace("%1$", nodeItem.toNameString()));
}
}

Expand Down
38 changes: 29 additions & 9 deletions app/src/main/res/layout/layout_fabmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
android:alpha="0.93"
android:background="?android:attr/colorBackground"
android:focusable="true"
android:visibility="invisible">
android:visibility="invisible"
android:contentDescription="@string/fab_addition_options_menu"
>

<RelativeLayout
android:id="@+id/fabNewL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/fabViewL"
android:layout_alignEnd="@id/fabImportL">
android:layout_alignEnd="@id/fabImportL"
android:contentDescription="@string/fab_create_new"
>

<TextView
android:id="@+id/fabNewT"
Expand All @@ -43,9 +47,11 @@
android:layout_toEndOf="@+id/fabNewT"
android:elevation="6dp"
android:src="@drawable/ic_new"
android:contentDescription="@string/fab_create_new"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
app:pressedTranslationZ="12dp"
/>

</RelativeLayout>

Expand All @@ -54,7 +60,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/fabKeyL"
android:layout_alignEnd="@id/fabImportL">
android:layout_alignEnd="@id/fabImportL"
android:contentDescription="@string/fab_restore_viewonly"
>

<TextView
android:id="@+id/fabViewT"
Expand All @@ -74,9 +82,11 @@
android:layout_toEndOf="@+id/fabViewT"
android:elevation="6dp"
android:src="@drawable/ic_eye"
android:contentDescription="@string/fab_restore_viewonly"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
app:pressedTranslationZ="12dp"
/>

</RelativeLayout>

Expand All @@ -85,7 +95,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/fabSeedL"
android:layout_alignEnd="@id/fabImportL">
android:layout_alignEnd="@id/fabImportL"
android:contentDescription="@string/fab_restore_key"
>

<TextView
android:id="@+id/fabKeyT"
Expand All @@ -105,6 +117,7 @@
android:layout_toEndOf="@+id/fabKeyT"
android:elevation="6dp"
android:src="@drawable/ic_key"
android:contentDescription="@string/fab_restore_key"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
Expand All @@ -116,7 +129,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/fabImportL"
android:layout_alignEnd="@id/fabImportL">
android:layout_alignEnd="@id/fabImportL"
android:contentDescription="@string/fab_restore_seed"
>

<TextView
android:id="@+id/fabSeedT"
Expand All @@ -136,6 +151,7 @@
android:layout_toEndOf="@+id/fabSeedT"
android:elevation="6dp"
android:src="@drawable/ic_seed"
android:contentDescription="@string/fab_restore_seed"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
Expand All @@ -147,7 +163,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true">
android:layout_alignParentBottom="true"
android:contentDescription="@string/menu_restore"
>

<TextView
android:id="@+id/fabImportT"
Expand All @@ -170,6 +188,7 @@
android:layout_toEndOf="@+id/fabImportT"
android:elevation="6dp"
android:src="@drawable/ic_import"
android:contentDescription="@string/menu_restore"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
Expand Down Expand Up @@ -201,6 +220,7 @@
android:layout_toEndOf="@+id/fabLedgerT"
android:elevation="6dp"
android:src="@drawable/ic_ledger_restore"
android:contentDescription="@string/fab_restore_ledger"
app:borderWidth="0dp"
app:fabSize="mini"
app:pressedTranslationZ="12dp" />
Expand Down Expand Up @@ -258,7 +278,7 @@
android:layout_gravity="bottom|end"
android:backgroundTint="@android:color/transparent"
android:backgroundTintMode="src_in"
android:contentDescription="@string/fab_create_new"
android:contentDescription="@string/fab_create_or_restore"
android:src="@drawable/ic_add"
app:borderWidth="0dp"
app:elevation="0dp"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,19 @@
<string name="delete_alert_yes">Yes, do that!</string>
<string name="delete_alert_no">No thanks!</string>

<string name="fab_create_or_restore">Create or restore wallet</string>
<string name="fab_close">Close wallet addition options menu</string>
<string name="fab_create_new">Create new wallet</string>
<string name="fab_restore_viewonly">Restore view-only wallet</string>
<string name="fab_restore_key">Restore wallet from private keys</string>
<string name="fab_restore_seed">Restore wallet 25 word seed</string>
<string name="fab_addition_options_menu">Wallet addition options menu</string>

<string name="accounts_balance" translatable="false">%1$s XMR</string>
<string name="tx_account_formatted" translatable="false">(%1$d, %2$d) &nbsp;&lt;span style=\"background-color: #%3$s; color: #%4$s;\"&gt;&nbsp;%5$s&nbsp;&lt;/span&gt;</string>

<string name="open_drawer">Open accounts drawer</string>
<string name="close_drawer">Close accounts drawer</string>
<string name="accounts_drawer_new">Create Account</string>
<string name="accounts_new">Added new account #%1$d</string>
<string name="tx_account">Account #</string>
Expand Down Expand Up @@ -353,6 +358,8 @@
<string name="node_scanning">Scanning network&#8230;</string>
<string name="node_nobookmark">Automatically bookmarked best %1$d nodes</string>
<string name="label_test">Test</string><!--note: as in "Test a network connection"-->
<string name="node_add_favourite">Save %1$ node</string>
<string name="node_remove_favourite">Remove saved %1$ node</string>

<string name="send_address_hint">Receiver</string>

Expand Down