Android ADA Compliance - android

I'm currently developing an application, and my client would like it to be ADA compliant. I've looked into Android Accessibility on the documentation and I'm having partial success. I downloaded Talkback to my android phone and the device will read out each Activity title, but it wont read the onscreen text(within a textview). I've tried to set the content descirption within the textview XML like this:
android:contentDescription="#string/terms_conditions"
However, it wont read the text from the text view for me. Is there something else I should be declaring?

Related

Issue with float.Parse in Unity Android App

I develop an Android app. If I call
float.Parse("51.552058")
in Editor or App on my Mac Book (Language Setting English), it works fine. After publishing to Android (Language Setting German) the result of the Parse operation is not "51.552058" anymore but "5,155211E+09". I understand that this might be related to the device's language but I still don't really understand what is happening and why.
I also tried following with no success:
float.Parse("51.552058", System.Globalization.NumberStyles.Any)
float.Parse("51.552058", System.Globalization.NumberStyles.AllowDecimalPoint)
Did anyone stumble over this before?
float.Parse is culture dependent.
See e.g. from NumberFormatInfo
// '1,034,562.91' --> 1034562.91 (en-US)
// '1,034,562.91': FormatException (fr-FR)
// '1,034,562.91' --> 1034562.91 (Invariant)
Reason here is that in EU cultures the , is usually the decimal separator while the . is used as the group separator. So from the example above the correct format for fr-FR would be 1.034.562,91
You probably rather want to use CultureInfo.InvariantCulture like
float.Parse("51.552058", CultureInfo.InvariantCulture);
or directly NumberFormatInfo.InvariantInfo
float.Parse("51.552058", NumberFormatInfo.InvariantInfo);
which simply has defined
NumberDecimalSeparator .
NumberGroupSeparator ,

Add a settings page looking like in native app

I would like to create settings page which would look like the settings on native platform (eg. PreferenceActivity/Fragment with xml on Android).
I am used to design the settings page by creating simple preference xml on Android which handles the basic settings flawlessly, however I am unable to find the similar mechanism in Xamarin.Forms which would do the same thing for all platforms natively (with the gui part). I just only found the SettingsPlugin which handles "Create and access settings from shared code across all of your apps!".
https://github.com/jamesmontemagno/SettingsPlugin
I would really appreciate any recommendation on designing the settings pages.
You can use a TableView, which is an original Xamarin Forms User interface (without any plugin).
If you set his Intent="Settings" , you can display a nice list of configuration settings like SwitchCell, EntryCell, or a CustomCell.
Displaying these elements depend on the operating system and on the version of it. So it looks and feels different on f.e. Android 4.4 and different on Android 8.
For example:
<TableView Intent="Settings">
<TableRoot>
<TableSection Title="My settings">
<EntryCell Label="Name:" Placeholder="Enter Your First Name Here"/>
<SwitchCell Text="Show my name" On="true"/>
<SwitchCell Text="Update app automatically"/>
</TableSection>
</TableRoot>
</TableView>
Which will render something (not exactly that) like this: {source of img}

Google has changed Linkify implementation with custom links in Android 5

We've got some custom links in our application that look like that bar.foo://var?parameter=value
Prior Android 5.0.0 bar.foo was not recognised as a link. However in Android 5.0.0 it is recognized as a link and Android will try to open it in the default browser if you click anywhere on bar.foo:. If you however click on //var?parameter=value it will treat it as a customized link and do the stuff that is intended.
Is there any way to prevent this?
This is our Linkify related code:
Linkify.addLinks(this, Linkify.WEB_URLS); // This one is causing the issue. Unfortunately we can't disable it
for (final Pattern pattern : linkPatterns) {
Linkify.addLinks(this, pattern, linkPrefix);
}

Giving password protection to Android Settings

I am using android settings inside my app(Launcher), so i can able to set a password protection, but far from that some tabs/device can able to access settings in different methods, so i am trying to create a password protection to the whole"system(Device)settings", how i can do it, is it possible ,
From my search i found this Android, Detect when other apps are launched
Can any one tell me how it works..
And it says that will not work from JellyBean and above. READ_LOGS permission is now reserved for system apps only, Is there any way for JellyBean.
If the solution proposed in the comment is ok with you, here I found this:
AlertDialog.Builder alert = new AlertDialog.Builder(MyFeedActivity.this);
LayoutInflater inflater=MyFeedActivity.this.getLayoutInflater();
//this is what I did to added the layout to the alert dialog
View layout=inflater.inflate(R.layout.dialog,null);
alert.setView(layout);
final EditText usernameInput=(EditText)layout.findViewById(R.id.dialogusername);
final EditText passwordInput=(EditText)layout.findViewById(R.id.dialogpassword);
I hope it will fit your needs.

Accessibility and Android WebView

Is Accessibility enabled for Android WebView? Can anyone tell how to make a WebView accessible?
The Android webview accessibility is enabled via javascript injection in Honeycomb and above (as pointed out by alanv). The user must enable it by:
Turning on Accessibility mode, including 'Explore by Touch' in 4.0+.
Enabling 'Enhanced Web Accessibility', or, on older devices, 'Inject Web Scripts'.
This works by injecting javascript into each loaded pages via <script> tags. Note that you will have to be careful, as not all content will play nice with this javascript, and the injection will fail in some edge cases.
You can extend the WebView class to implement Accessibility API methods.
http://developer.android.com/guide/topics/ui/accessibility/apps.html#custom-views
I also ran into this issue on 4.0 devices. I ended up placing a TextView on top of the WebView, making the TextView background and text transparent. The text content of the TextView being set to the content of WebView with all HTML tags stripped out.
A most inelegant solution, I know, but hey it works....
No, the WebView is not accessible from the built-in TalkBack service, at least as of Android version 4.0. Instead, blind users are instructed to use something like Mobile Accessibility for Android, which provides a spoken browsing interface. I would suggest making your content available to other processes, allowing blind users to view the content in their browser of choice. I did this by starting an intent to view the content:
public static void loadUrlInBrowser(Context c, Uri uri) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "text/html");
c.startActivity(i);
}
Alternatively, you can set the content description of the WebView. Note that this only seems to work in pre 4.0 versions of android. I've found that 4.0 devices keep either say WebView or nothing at all.
I know how to access web view content by Accessibility API, when AccessibilityNodeInfo.getText() is null or "null", call AccessibilityNodeInfo.getContentDescription().
simple code:
private String getTextOrDescription(AccessibilityNodeInfo info) {
String text = String.valueOf(info.getText());
if (isEmptyOrNullString(text)) {
text = String.valueOf(info.getContentDescription());
}
return text;
}
private boolean isEmptyOrNullString(String text) {
if (TextUtils.isEmpty(text) || text.equalsIgnoreCase("null")) {
return true;
}
return false;
}
getContentDescription() can get the web view content.
sorry for my poor english.

Categories

Resources