Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorucinski committed Jul 30, 2016
2 parents 4999d79 + bd3c259 commit dafeba8
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Accessibility
Accessible apps allow more users to use your app; however, it is usually an afterthought for developers, and it makes your XML layout files messy whether Accessibility was a forethought or afterthought. This library allows for hassle-free accessibility additions in your application — possibly in 1 line of code!

##Motivation

I was finishing up a project of mine, and as an afterthought, of course, I decided to add Accessibility of navigation in custom views and Accessibility of spoken text. Since I always disliked accessibility additions "uglifying" my XML Layout Resource files, I decided to do it programmatically; however, that typically would only "uglifying" my Java code, and if there is anything I dislike the more, it is ugly Java code.

So for kicks and giggles, I went the Java code path and object-orientified it and was able to produce this libary.

##Usage

###Custom View

public class ContributionView extends RelativeLayout implements Mappable<Resume.Contribution> {

// Called from Constructors
private void init(AttributeSet attrs, int defStyle) {

root = (ViewGroup) LayoutInflater.from(getContext()).inflate(
R.layout.internal_contribution_view, this, true);

...

// Declare Navigation Accessibility
Accessibility.with(root)
// Disable certain views in the ViewGroup from ever gaining focus
.disableFocusableNavigationOn(
R.id.contribution_textview_creator,
R.id.contribution_textview_year)

// For all focusable views in the ViewGroup, set the D-pad Navigation
.setFocusableNavigationOn(txtProjectName)
.down(R.id.contribution_textview_description).complete()
.setFocusableNavigationOn(txtContributionDescription)
.up(R.id.contribution_textview_name)
.down(R.id.contribution_textview_link).complete()
.setFocusableNavigationOn(txtProjectLink)
.up(R.id.project_textview_description).complete()

// Set which view in the ViewGroup will have be first to be focused
.requestFocusOn(R.id.contribution_textview_name);

invalidateView();

}
private void invalidateView() {

...

// Declare Content Description Accessibility
Accessibility.with(root)

// Set the content descriptions for each focusable view in the ViewGroup

// Set the content description for the Contribution Name
.setAccessibilityTextOn(txtProjectName)
.setModifiableContentDescription(getProjectName())
.prepend("Contribution occurred on the Project called ")
.append(String.format(" by %s in %s",
getProjectCreator(),
getContributionYear())).complete()

// Set the content description for the Contribution Description
.setAccessibilityTextOn(txtContributionDescription)
.setModifiableContentDescription(getContributionDescription())
.prepend("Description: ").complete()

// Set the content description for the Contribution URL
.setAccessibilityTextOn(txtProjectLink)
.setModifiableContentDescription(getProjectLink())
.prepend("URL is ").complete();

}

...

}

0 comments on commit dafeba8

Please sign in to comment.