Skip to content

Commit

Permalink
TalkBack 5.0 release
Browse files Browse the repository at this point in the history
- enhanced support for Chrome and web views.
- extended keyboard support for web views and native apps via "default" keymap.
- Support for split-screen mode in Nougat.
- updated TalkBack tutorial.
- test app with code samples, widgets and patterns.
- updates to Switch Access.
- and more.
  • Loading branch information
Victor Tsaran committed Dec 19, 2016
1 parent 1b30727 commit 12bdf20
Show file tree
Hide file tree
Showing 1,063 changed files with 147,571 additions and 19,886 deletions.
16 changes: 0 additions & 16 deletions README

This file was deleted.

44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Introduction
This repository contains sources for two Android accessibility services:

* TalkBack -- a screen reader for blind and visually impaired users. For usage instructions, see [TalkBack User Guide](https://support.google.com/accessibility/android/answer/6283677?hl=en).
* Switch Access -- screen navigation tool for users with mobility limitations. For usage instructions, see [Switch Access User Guide](https://support.google.com/accessibility/android/answer/6122836?hl=en).

When you build and install TalkBack package, both services will be installed under Settings -> Accessibility and will be turned off by default. It is *not recommended* running both services at the same time as they may conflict with each other.


## Dependencies
To build TalkBack sources you will need:

1. Download android sdk from <https://developer.android.com/sdk/installing/index.html?pkg=tools>
2. Set ANDROID_HOME to the path of Android sdk folder
3. Open Android SDK manager and install
- Tools/Android SDK Build-tools 22.0.1
- Android 7.0 (API 24)
- Extras/Android Support Repository
- Extras/Google Repository


## Building, Installing and Testing
TalkBack uses gradle as build system.
Here are commands to build, install and test the project from command line:

1. Assemble debug and release apks: ./gradlew assemble
2. Assemble only debug apk: ./gradlew assembleDebug
3. Install debug apk on connected device: ./gradlew installDebug
4. Run robolectric tests: ./gradlew test


## Test App
This repository also includes a test app that you can use to:

1. Test TalkBack's behavior against various standard widgets and interaction patterns.
2. Explore source code for test cases to see the implementation of various TalkBack features.

To build and install the app, do the following:

1. Switch to the root directory of this repository.
2. Change to the "tests" directory.
3. To assemble debug and release apk: ./gradlew assemble
4. To build debug apk: ./gradlew assembleDebug
5. The apks will be located in the app/build/outputs/apk directory.
29 changes: 29 additions & 0 deletions assemble.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

function exitOnFailure() {
rc=$?
if [[ $rc != 0 ]] ; then
exit 1
fi
}

if [ $1 == "assembleDebugTest" ]
then
./vendor/unbundled_google/packages/TalkBack/gradlew clean :robolectricTargetZip:assembleTargetZip :robolectricTest:assembleTestJar :robolectricTestSuite:assembleSuiteJar -PoutDir=$OUT_DIR/build
exitOnFailure
cp -r $OUT_DIR/build/robolectric/* $DIST_DIR
exitOnFailure
./vendor/unbundled_google/packages/TalkBack/gradlew clean assembleGoogleDebug assembleGoogleDebugAndroidTest -PoutDir=$OUT_DIR/build
elif [ $1 == "assembleDebug" ]
then
./vendor/unbundled_google/packages/TalkBack/gradlew clean assembleGoogleDebug assembleGoogleRelease -PoutDir=$OUT_DIR/build
elif [ $1 == "assembleRelease" ]
then
./vendor/unbundled_google/packages/TalkBack/gradlew clean assembleGoogleRelease -PoutDir=$OUT_DIR/build
else
./vendor/unbundled_google/packages/TalkBack/gradlew clean $1 -PoutDir=$OUT_DIR/build
fi

exitOnFailure
cp -r $OUT_DIR/build/outputs/apk/* $DIST_DIR
exitOnFailure
94 changes: 36 additions & 58 deletions base.gradle
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
apply plugin: 'com.android.application'
apply plugin: 'robolectric'

def projectDir = System.getProperty('projectPath')
def rootDir = "$projectDir/../../.."

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'org.aspectj:aspectjtools:1.8.1'
classpath 'org.robolectric:robolectric-gradle-plugin:0.13.2'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

repositories {
mavenCentral()
maven {
// TODO: Remove this after support library v24 public release.
url "$rootDir/prebuilts/fullsdk/extras/android/m2repository"
}
}

android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'LICENSE'
exclude 'README'
}
compileSdkVersion "android-23"
compileSdkVersion "android-24"
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
targetSdkVersion 24
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
}
compileOptions {
Expand All @@ -52,12 +53,17 @@ android {
}
}
sourceSets {
androidTest {
setRoot("$projectDir/src/test")
}
main {
setRoot("$projectDir/src/main")
}
test {
setRoot("$projectDir/src/test")
}
androidTest {
setRoot("$projectDir/src/instrumentation_tests")
android.sourceSets.main.res.srcDirs = ["$projectDir/src/main/res",
"$projectDir/src/instrumentation_tests/res"]
}
}
lintOptions {
checkReleaseBuilds false
Expand All @@ -70,12 +76,9 @@ android {
}

dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile('com.squareup.dagger:dagger:1.1.0') {
exclude module: 'junit'
}
testCompile 'junit:junit:4.12'

androidTestCompile('org.robolectric:robolectric:3.0-rc2') {
testCompile('org.robolectric:robolectric:3.0') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'maven-artifact'
Expand All @@ -92,59 +95,34 @@ dependencies {
exclude module: 'wagon-provider-api'
exclude module: 'support-v4'
}
androidTestCompile('com.squareup:fest-android:1.0.8') {
exclude module: 'support-v4'
}
androidTestCompile('org.mockito:mockito-core:1.10.8') {
testCompile('org.mockito:mockito-core:1.10.8') {
exclude module: 'hamcrest-core'
}
}

/*
Both instrumentation tests task that is defined in android plugin and robolectric tests task
that is defined in robolectric plugin use the same configuration androidTest.
To split running robolectric and instrumetation tests we define different paths to test sources.
When gradle run task on project script it does configuration phase where it parse whole script
and defines tasks, theirs dependecies and counfigurations. Then it does execution phase when
it executes the task. We have to set all source paths (android.sourceSets.androidTest...)
on configuration phase.
So here we check what task was started and if it was instrumentation test task we set paths
to instrumentation tests as source for androidTest configuration.
*/
task addInstrumenationPaths {
if(startedWithTask('instrumentationTest')) {
android.sourceSets.androidTest.manifest.srcFile "$projectDir/src/instrumentation_tests/AndroidManifest.xml"
android.sourceSets.androidTest.java.srcDirs = ["$projectDir/src/instrumentation_tests/src"]
android.sourceSets.main.res.srcDirs = ["$projectDir/src/main/res", "$projectDir/src/instrumentation_tests/res"]
androidTestCompile 'junit:junit:4.12'
androidTestCompile('com.squareup.dagger:dagger:1.1.0') {
exclude module: 'junit'
}

if(startedWithTask('test')) {
android {
defaultConfig {
targetSdkVersion 22
}
}
androidTestCompile('com.squareup:fest-android:1.0.8') {
exclude module: 'support-v4'
}
}

def startedWithTask(String taskName) {
if(project.getGradle().startParameter.taskRequests.size() > 0) {
def startingArgs = project.getGradle().startParameter.taskRequests.get(0).args
if (startingArgs.toString().contains(taskName)) {
return true
}
androidTestCompile('org.mockito:mockito-core:1.10.8') {
exclude module: 'hamcrest-core'
}
return false
}

ext.startedWith = this.&startedWithTask

task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}

// Copy preferences.xml to xml-v21 replacing CheckBoxPreference with SwitchPreference.
task copyPreferencesXmlForV21(type: Copy) {
from "$projectDir/src/main/res/xml/preferences.xml"
into "$projectDir/src/main/res/xml-v21/"
filter { String l -> l.replaceAll("CheckBoxPreference", "SwitchPreference") }
}

afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
Expand All @@ -154,4 +132,4 @@ afterEvaluate {
}
dx.additionalParameters += '--multi-dex'
}
}
}
28 changes: 16 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'org.aspectj:aspectjtools:1.8.1'
classpath 'org.robolectric:robolectric-gradle-plugin:0.13.2'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand All @@ -17,30 +16,35 @@ android {
java.srcDirs = ["$projectDir/src/aosp/java"]
res.srcDirs = ["$projectDir/src/aosp/res"]
}
robolectric {
java.srcDirs = ["$projectDir/src/aosp/java"]
res.srcDirs = ["$projectDir/src/aosp/res"]
}
}
productFlavors {
aosp {
applicationId "com.android.talkback"
testApplicationId "com.android.talkback.test"
versionName "4.3.1_aosp"
versionName "5.0.7_aosp"
}
}
}

dependencies {
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:24.0.0'
}

task grantPermission(type: Exec, dependsOn: ['installAospDebug', 'installAospDebugTest']) {
task grantPermission(type: Exec) {
commandLine 'adb', 'shell', 'pm', 'grant', 'com.android.talkback.test',
'android.permission.WRITE_SECURE_SETTINGS'
}

task instrumentationTest(type: Exec, dependsOn: ['installAospDebug', 'installAospDebugTest', 'grantPermission']) {
commandLine 'adb', 'shell', 'am', 'instrument', '-w', 'com.android.talkback.test/android.test.InstrumentationTestRunner'
task instrumentationTest(type: Exec, dependsOn: ['installAospDebug',
'installAospDebugAndroidTest',
'grantPermission']) {
commandLine 'adb', 'shell', 'am', 'instrument', '-w',
'com.android.talkback.test/android.test.InstrumentationTestRunner'
}

afterEvaluate {
tasks.withType (org.gradle.api.tasks.compile.AbstractCompile) {
compileTask -> compileTask.dependsOn(copyPreferencesXmlForV21)
}
}
Empty file added libs/espresso-1.1.jar
Empty file.
Empty file added libs/testrunner-1.1.jar
Empty file.
Empty file added libs/testrunner-runtime-1.1.jar
Empty file.
29 changes: 29 additions & 0 deletions src/aosp/java/com/android/switchaccess/HelpUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.android.switchaccess;

import android.content.Context;

public class HelpUtils {

@SuppressWarnings("unused")
private HelpUtils() {
}

public static void launchHelp(Context context) {
}
}
29 changes: 29 additions & 0 deletions src/aosp/java/com/android/talkback/HelpAndFeedbackUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.android.talkback;

import android.app.Activity;
import android.content.Context;

public final class HelpAndFeedbackUtils {
public static void launchHelpAndFeedback(Activity activity) {
}

public static boolean supportsHelpAndFeedback(Context context) {
return true;
}
}
Loading

0 comments on commit 12bdf20

Please sign in to comment.