Repository: cketti/EmailIntentBuilder
Branch: master
Commit: 137148deee5e
Files: 27
Total size: 55.3 KB
Directory structure:
gitextract_qxd252kg/
├── .github/
│ ├── FUNDING.yml
│ └── workflows/
│ └── android.yml
├── .gitignore
├── LICENSE
├── README.md
├── android-mvn-push.gradle
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── .gitignore
│ ├── build.gradle
│ └── src/
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ └── java/
│ │ └── de/
│ │ └── cketti/
│ │ └── mailto/
│ │ └── EmailIntentBuilder.java
│ └── test/
│ └── java/
│ └── de/
│ └── cketti/
│ └── mailto/
│ └── EmailIntentBuilderTest.java
├── sample/
│ ├── .gitignore
│ ├── build.gradle
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── de/
│ │ └── cketti/
│ │ └── mailto/
│ │ └── sample/
│ │ └── MainActivity.java
│ └── res/
│ ├── layout/
│ │ └── activity_main.xml
│ ├── menu/
│ │ └── activity_main.xml
│ └── values/
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
github: cketti
================================================
FILE: .github/workflows/android.yml
================================================
name: Android CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build
================================================
FILE: .gitignore
================================================
.gradle
/local.properties
/.idea/
.DS_Store
/build
*.iml
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
================================================
FILE: README.md
================================================
# Email Intent Builder
[](https://maven-badges.herokuapp.com/maven-central/de.cketti.mailto/email-intent-builder)
An Android Library for the creation of [SendTo](https://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO) Intents with [mailto:](https://tools.ietf.org/html/rfc6068) URI
Read the article [Android: Sending Email using Intents](https://medium.com/@cketti/android-sending-email-using-intents-3da63662c58f) if you want to learn what motivated the creation of this library.
## Include the library
Add this to your `dependencies` block in `build.gradle`:
```groovy
implementation 'de.cketti.mailto:email-intent-builder:2.0.0'
```
## Usage
Creating a simple email intent is as easy as this:
```java
Intent emailIntent = EmailIntentBuilder.from(activity)
.to("alice@example.org")
.subject("Feedback")
.build();
```
This will build an intent with the action `android.intent.action.SENDTO` and the data
`mailto:alice@example.org?subject=Feedback`.
You can also use `EmailIntentBuilder` to add a couple of other fields and directly launch the intent:
```java
EmailIntentBuilder.from(activity)
.to("alice@example.org")
.cc("bob@example.org")
.bcc("charles@example.org")
.subject("Message from an app")
.body("Some text here")
.start();
```
## Changelog
**Version 2.0.0 (2019-11-26)**
- Use `org.jetbrains:annotations` for nullability annotations
- No functional changes
**Version 1.0.0 (2015-12-19)**
- Initial release
## License
Copyright 2015-2019 cketti
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.
================================================
FILE: android-mvn-push.gradle
================================================
if (!(hasProperty("nexusUsername") && hasProperty("nexusPassword"))) {
return
}
apply plugin: 'maven'
apply plugin: 'signing'
afterEvaluate { project ->
project.version = android.defaultConfig.versionName
project.group = project.pom.group
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.artifactId = project.pom.artifactId
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.project {
name project.pom.name
packaging 'aar'
description project.pom.description
url project.pom.url
scm {
url project.pom.scmUrl
connection project.pom.scmConnection
developerConnection project.pom.scmDevConnection
}
licenses {
license {
name project.pom.licenseName
url project.pom.licenseUrl
distribution project.pom.licenseDist
}
}
developers {
developer {
id project.pom.developerId
name project.pom.developerName
}
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options {
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
}
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
================================================
FILE: build.gradle
================================================
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: library/.gitignore
================================================
/build
================================================
FILE: library/build.gradle
================================================
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
versionName "2.0.0"
minSdkVersion 14
}
}
dependencies {
api 'org.jetbrains:annotations:18.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.21.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'com.squareup.assertj:assertj-android:1.2.0'
}
project.ext {
pom = [
group: "de.cketti.mailto",
artifactId: "email-intent-builder",
name: "Email Intent Builder",
description: "An Android Library for creation of SendTo Intents with mailto: URI",
url: "https://github.com/cketti/EmailIntentBuilder",
scmUrl: "https://github.com/cketti/EmailIntentBuilder",
scmConnection: "scm:git@github.com:cketti/EmailIntentBuilder.git",
scmDevConnection: "scm:git@github.com:cketti/EmailIntentBuilder.git",
licenseName: "The Apache Software License, Version 2.0",
licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.txt",
licenseDist: "repo",
developerId: "cketti",
developerName: "cketti"
]
}
apply from: '../android-mvn-push.gradle'
================================================
FILE: library/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.cketti.mailto">
</manifest>
================================================
FILE: library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java
================================================
/*
* Copyright 2015-2019 cketti
*
* 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 de.cketti.mailto;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Patterns;
import org.jetbrains.annotations.NotNull;
/**
* A helper to create email intents, i.e. {@link Intent#ACTION_SENDTO} with a {@code mailto:} URI.
*
* <p>Example usage:</p>
* <pre>
* <code>
* EmailIntentBuilder.from(activity)
* .to("alice@example.org")
* .subject("Bug report for 'My awesome app'")
* .body("Something went wrong :(")
* .start();
* </code>
* </pre>
* <p>This creates an intent containing the following {@code mailto:} URI:</p>
* <pre>
* <code>
* mailto:alice@example.org?subject=Bug%20report%20for%20'My%20awesome%20app'&body=Something%20went%20wrong%20%3A(
* </code>
* </pre>
*
* @see #from(Context)
*/
@SuppressWarnings("WeakerAccess")
public final class EmailIntentBuilder {
private final Context context;
private final Set<String> to = new LinkedHashSet<>();
private final Set<String> cc = new LinkedHashSet<>();
private final Set<String> bcc = new LinkedHashSet<>();
private String subject;
private String body;
private EmailIntentBuilder(@NotNull Context context) {
this.context = checkNotNull(context);
}
/**
* Create a builder to create an {@link Intent#ACTION_SENDTO} intent or to launch that intent.
*
* @param context
* The {@code Context} that will be used to launch the intent
*
* @return An email intent builder
*/
@NotNull
public static EmailIntentBuilder from(@NotNull Context context) {
return new EmailIntentBuilder(context);
}
/**
* Add an email address to be used in the "to" field.
*
* @param to
* the email address to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder to(@NotNull String to) {
checkEmail(to);
this.to.add(to);
return this;
}
/**
* Add a list of email addresses to be used in the "to" field.
*
* @param to
* the email addresses to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder to(@NotNull Collection<String> to) {
checkNotNull(to);
for (String email : to) {
checkEmail(email);
}
this.to.addAll(to);
return this;
}
/**
* Add an email address to be used in the "cc" field.
*
* @param cc
* the email address to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder cc(@NotNull String cc) {
checkEmail(cc);
this.cc.add(cc);
return this;
}
/**
* Add an email address to be used in the "cc" field.
*
* @param cc
* the email addresses to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder cc(@NotNull Collection<String> cc) {
checkNotNull(cc);
for (String email : cc) {
checkEmail(email);
}
this.cc.addAll(cc);
return this;
}
/**
* Add an email address to be used in the "bcc" field.
*
* @param bcc
* the email address to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder bcc(@NotNull String bcc) {
checkEmail(bcc);
this.bcc.add(bcc);
return this;
}
/**
* Add an email address to be used in the "bcc" field.
*
* @param bcc
* the email addresses to add
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder bcc(@NotNull Collection<String> bcc) {
checkNotNull(bcc);
for (String email : bcc) {
checkEmail(email);
}
this.bcc.addAll(bcc);
return this;
}
/**
* Set the subject line for this email intent.
*
* @param subject
* the email subject line
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder subject(@NotNull String subject) {
checkNotNull(subject);
checkNoLineBreaks(subject);
this.subject = subject;
return this;
}
/**
* Set the text body for this email intent.
*
* @param body
* the text body
*
* @return This {@code EmailIntentBuilder} for method chaining
*/
@NotNull
public EmailIntentBuilder body(@NotNull String body) {
checkNotNull(body);
this.body = fixLineBreaks(body);
return this;
}
/**
* Launch the email intent.
*
* @return {@code false} if no activity to handle the email intent could be found; {@code true} otherwise
*/
public boolean start() {
Intent emailIntent = build();
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
return false;
}
return true;
}
private void startActivity(Intent intent) {
if (!(context instanceof Activity)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
}
/**
* Build the {@link Intent#ACTION_SENDTO} intent.
*
* @return the intent containing the provided information
*/
@NotNull
public Intent build() {
Uri mailtoUri = constructMailtoUri();
return new Intent(Intent.ACTION_SENDTO, mailtoUri);
}
@NotNull
private Uri constructMailtoUri() {
StringBuilder mailto = new StringBuilder(1024);
mailto.append("mailto:");
addRecipients(mailto, to);
boolean hasQueryParameters;
hasQueryParameters = addRecipientQueryParameters(mailto, "cc", cc, false);
hasQueryParameters = addRecipientQueryParameters(mailto, "bcc", bcc, hasQueryParameters);
hasQueryParameters = addQueryParameter(mailto, "subject", subject, hasQueryParameters);
addQueryParameter(mailto, "body", body, hasQueryParameters);
return Uri.parse(mailto.toString());
}
private boolean addQueryParameter(StringBuilder mailto, String field, String value, boolean hasQueryParameters) {
if (value == null) {
return hasQueryParameters;
}
mailto.append(hasQueryParameters ? '&' : '?').append(field).append('=').append(Uri.encode(value));
return true;
}
private boolean addRecipientQueryParameters(StringBuilder mailto, String field, Set<String> recipients,
boolean hasQueryParameters) {
if (recipients.isEmpty()) {
return hasQueryParameters;
}
mailto.append(hasQueryParameters ? '&' : '?').append(field).append('=');
addRecipients(mailto, recipients);
return true;
}
private void addRecipients(StringBuilder mailto, Set<String> recipients) {
if (recipients.isEmpty()) {
return;
}
for (String recipient : recipients) {
mailto.append(encodeRecipient(recipient));
mailto.append(',');
}
mailto.setLength(mailto.length() - 1);
}
private void checkEmail(String email) {
checkNotNull(email);
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
throw new IllegalArgumentException("Argument is not a valid email address (according to " +
"Patterns.EMAIL_ADDRESS)");
}
}
private void checkNoLineBreaks(String text) {
boolean containsCarriageReturn = text.indexOf('\r') != -1;
boolean containsLineFeed = text.indexOf('\n') != -1;
if (containsCarriageReturn || containsLineFeed) {
throw new IllegalArgumentException("Argument must not contain line breaks");
}
}
@NotNull
private static <T> T checkNotNull(T object) {
if (object == null) {
throw new IllegalArgumentException("Argument must not be null");
}
return object;
}
@NotNull
static String encodeRecipient(String recipient) {
int index = recipient.lastIndexOf('@');
String localPart = recipient.substring(0, index);
String host = recipient.substring(index + 1);
return Uri.encode(localPart) + "@" + Uri.encode(host);
}
@NotNull
static String fixLineBreaks(String text) {
return text.replaceAll("\r\n", "\n").replace('\r', '\n').replaceAll("\n", "\r\n");
}
}
================================================
FILE: library/src/test/java/de/cketti/mailto/EmailIntentBuilderTest.java
================================================
package de.cketti.mailto;
import java.util.Arrays;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.assertj.android.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 28)
public class EmailIntentBuilderTest {
@Mock
private Context context;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@SuppressWarnings("ConstantConditions")
@Test(expected = IllegalArgumentException.class)
public void from_withNullArgument_shouldThrow() {
EmailIntentBuilder.from(null);
}
@Test
public void build_shouldReturnIntentWithSendToAction() {
Intent intent = EmailIntentBuilder.from(context).build();
assertThat(intent).hasAction(Intent.ACTION_SENDTO);
}
@Test
public void build_withSingleToValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.to("john@example.org")
.build();
assertThat(intent).hasData("mailto:john@example.org");
}
@Test
public void build_withListToValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.to(Arrays.asList("bob@example.org", "alice@example.org"))
.build();
assertThat(intent).hasData("mailto:bob@example.org,alice@example.org");
}
@Test
public void build_withSingleCcValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.cc("john@example.org")
.build();
assertThat(intent).hasData("mailto:?cc=john@example.org");
}
@Test
public void build_withListCcValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.cc(Arrays.asList("bob@example.org", "alice@example.org"))
.build();
assertThat(intent).hasData("mailto:?cc=bob@example.org,alice@example.org");
}
@Test
public void build_withSingleBccValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.bcc("john@example.org")
.build();
assertThat(intent).hasData("mailto:?bcc=john@example.org");
}
@Test
public void build_withListBccValue_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.bcc(Arrays.asList("alice@example.org", "bob@example.org"))
.build();
assertThat(intent).hasData("mailto:?bcc=alice@example.org,bob@example.org");
}
@Test
public void build_withSubject_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.subject("hi there")
.build();
assertThat(intent).hasData("mailto:?subject=hi%20there");
}
@Test
public void build_withBodyContainingImproperLineBreak_shouldReturnFixedResult() {
Intent intent = EmailIntentBuilder.from(context)
.body("this is\na test")
.build();
assertThat(intent).hasData("mailto:?body=this%20is%0D%0Aa%20test");
}
@Test
public void build_withAllExtras_shouldReturnExpectedResult() {
Intent intent = EmailIntentBuilder.from(context)
.to(Arrays.asList("leia@example.org", "luke@example.org"))
.cc("obi.wan@example.org")
.cc("han@example.org")
.bcc("chewbacca@example.org")
.subject("rebel stuff")
.body("start execution of secret plan & good luck")
.build();
assertThat(intent).hasData("mailto:" +
"leia@example.org,luke@example.org" +
"?cc=obi.wan@example.org,han@example.org" +
"&bcc=chewbacca@example.org" +
"&subject=rebel%20stuff" +
"&body=start%20execution%20of%20secret%20plan%20%26%20good%20luck");
}
@Test
public void start_fromActivity_shouldCreateIntentWithoutNewTaskFlag() {
Activity activity = mock(Activity.class);
EmailIntentBuilder.from(activity)
.to("john@example.org")
.start();
Intent intent = getIntentFromStartActivityInvocation(activity);
assertThat(intent).hasFlags(0);
}
@Test
public void start_fromContext_shouldCreateIntentWithNewTaskFlag() {
EmailIntentBuilder.from(context)
.to("john@example.org")
.start();
Intent intent = getIntentFromStartActivityInvocation(context);
assertThat(intent).hasFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
@Test
public void start_withoutError_shouldReturnTrue() {
boolean success = EmailIntentBuilder.from(context).start();
assertThat(success).isTrue();
}
@Test
public void start_withActivityNotFoundException_shouldReturnFalse() {
doThrow(new ActivityNotFoundException()).when(context).startActivity(any(Intent.class));
boolean success = EmailIntentBuilder.from(context).start();
assertThat(success).isFalse();
}
@Test
public void encodeRecipient_withComplicatedEmailOne_shouldReturnExpectedResult() {
String encoded = EmailIntentBuilder.encodeRecipient("\"not@me\"@example.org");
assertThat(encoded).isEqualTo("%22not%40me%22@example.org");
}
@Test
public void encodeRecipient_withComplicatedEmailTwo_shouldReturnExpectedResult() {
String encoded = EmailIntentBuilder.encodeRecipient("\"oh\\\\no\"@example.org");
assertThat(encoded).isEqualTo("%22oh%5C%5Cno%22@example.org");
}
@Test
public void encodeRecipient_withComplicatedEmailThree_shouldReturnExpectedResult() {
String encoded = EmailIntentBuilder.encodeRecipient("\"\\\\\\\"it's\\ ugly\\\\\\\"\"@example.org");
assertThat(encoded).isEqualTo("%22%5C%5C%5C%22it's%5C%20ugly%5C%5C%5C%22%22@example.org");
}
@SuppressWarnings("ConstantConditions")
@Test(expected = IllegalArgumentException.class)
public void to_withNullArgument_shouldThrow() {
EmailIntentBuilder.from(context)
.to((String) null);
}
@Test(expected = IllegalArgumentException.class)
public void to_withArgumentStartingWithAt_shouldThrow() {
EmailIntentBuilder.from(context)
.to("@example.org");
}
@Test(expected = IllegalArgumentException.class)
public void to_withArgumentEndingInAt_shouldThrow() {
EmailIntentBuilder.from(context)
.to("hi@");
}
@Test(expected = IllegalArgumentException.class)
public void to_withArgumentNotContainingAt_shouldThrow() {
EmailIntentBuilder.from(context)
.to("bob(at)example.org");
}
@SuppressWarnings("ConstantConditions")
@Test(expected = IllegalArgumentException.class)
public void subject_withNullArgument_shouldThrow() {
EmailIntentBuilder.from(context)
.subject(null);
}
@Test(expected = IllegalArgumentException.class)
public void subject_withArgumentContainingCarriageReturn_shouldThrow() {
EmailIntentBuilder.from(context)
.subject("This is an important\rsubject");
}
@Test(expected = IllegalArgumentException.class)
public void subject_withArgumentContainingLineFeed_shouldThrow() {
EmailIntentBuilder.from(context)
.subject("Keep\nreading");
}
@Test(expected = IllegalArgumentException.class)
public void subject_withArgumentContainingCrLf_shouldThrow() {
EmailIntentBuilder.from(context)
.subject("One\r\nTwo");
}
@Test
public void fixLineBreaks_withArgumentContainingCr_shouldReturnExpectedResult() {
String result = EmailIntentBuilder.fixLineBreaks("\r2nd");
assertThat(result).isEqualTo("\r\n2nd");
}
@Test
public void fixLineBreaks_withArgumentContainingLf_shouldReturnExpectedResult() {
String result = EmailIntentBuilder.fixLineBreaks("hi\nthere");
assertThat(result).isEqualTo("hi\r\nthere");
}
@Test
public void fixLineBreaks_withArgumentContainingCrLf_shouldReturnExpectedResult() {
String result = EmailIntentBuilder.fixLineBreaks("line one\r\nline two");
assertThat(result).isEqualTo("line one\r\nline two");
}
private Intent getIntentFromStartActivityInvocation(Context context) {
ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(context).startActivity(argumentCaptor.capture());
return argumentCaptor.getValue();
}
}
================================================
FILE: sample/.gitignore
================================================
/build
================================================
FILE: sample/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "de.cketti.mailto.sample"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
}
================================================
FILE: sample/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.cketti.mailto.sample" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="de.cketti.mailto.sample.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: sample/src/main/java/de/cketti/mailto/sample/MainActivity.java
================================================
package de.cketti.mailto.sample;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.snackbar.Snackbar;
import de.cketti.mailto.EmailIntentBuilder;
public class MainActivity extends AppCompatActivity {
private View mainContent;
private EditText emailTo;
private EditText emailCc;
private EditText emailBcc;
private EditText emailSubject;
private EditText emailBody;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainContent = findViewById(R.id.main_content);
emailTo = findViewById(R.id.email_to);
emailCc = findViewById(R.id.email_cc);
emailBcc = findViewById(R.id.email_bcc);
emailSubject = findViewById(R.id.email_subject);
emailBody = findViewById(R.id.email_body);
findViewById(R.id.button_send_email).setOnClickListener(v -> sendEmail());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_feedback) {
sendFeedback();
}
return true;
}
private void sendFeedback() {
boolean success = EmailIntentBuilder.from(this)
.to("cketti@gmail.com")
.subject(getString(R.string.feedback_subject))
.body(getString(R.string.feedback_body))
.start();
if (!success) {
Snackbar.make(mainContent, R.string.error_no_email_app, Snackbar.LENGTH_LONG).show();
}
}
void sendEmail() {
String to = emailTo.getText().toString();
String cc = emailCc.getText().toString();
String bcc = emailBcc.getText().toString();
String subject = emailSubject.getText().toString();
String body = emailBody.getText().toString();
EmailIntentBuilder builder = EmailIntentBuilder.from(this);
try {
if (!TextUtils.isEmpty(to)) {
builder.to(to);
}
if (!TextUtils.isEmpty(cc)) {
builder.cc(cc);
}
if (!TextUtils.isEmpty(bcc)) {
builder.bcc(bcc);
}
if (!TextUtils.isEmpty(subject)) {
builder.subject(subject);
}
if (!TextUtils.isEmpty(body)) {
builder.body(body);
}
boolean success = builder.start();
if (!success) {
Snackbar.make(mainContent, R.string.error_no_email_app, Snackbar.LENGTH_LONG).show();
}
} catch (IllegalArgumentException e) {
String errorMessage = getString(R.string.argument_error, e.getMessage());
Snackbar.make(mainContent, errorMessage, Snackbar.LENGTH_LONG).show();
}
}
}
================================================
FILE: sample/src/main/res/layout/activity_main.xml
================================================
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email_to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_to"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email_cc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_cc"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email_bcc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_bcc"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_subject"
android:inputType="textEmailSubject" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title_body"
android:inputType="textMultiLine"
tools:ignore="TextFields" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/button_send_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_label_send_email" />
</LinearLayout>
</ScrollView>
================================================
FILE: sample/src/main/res/menu/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_feedback"
android:title="@string/menu_feedback" />
</menu>
================================================
FILE: sample/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: sample/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">Email Intent Builder</string>
<string name="button_label_send_email">Send email</string>
<string name="title_to">To</string>
<string name="title_cc">Cc</string>
<string name="title_bcc">Bcc</string>
<string name="title_subject">Subject</string>
<string name="title_body">Body</string>
<string name="menu_feedback">Feedback</string>
<string name="feedback_subject">Feedback for EmailIntentBuilder</string>
<string name="error_no_email_app">No email app found</string>
<string name="feedback_body">[Your feedback here]</string>
<string name="argument_error">Error: %s</string>
</resources>
================================================
FILE: sample/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
================================================
FILE: settings.gradle
================================================
include ':sample', ':library'
gitextract_qxd252kg/ ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ └── android.yml ├── .gitignore ├── LICENSE ├── README.md ├── android-mvn-push.gradle ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ └── src/ │ ├── main/ │ │ ├── AndroidManifest.xml │ │ └── java/ │ │ └── de/ │ │ └── cketti/ │ │ └── mailto/ │ │ └── EmailIntentBuilder.java │ └── test/ │ └── java/ │ └── de/ │ └── cketti/ │ └── mailto/ │ └── EmailIntentBuilderTest.java ├── sample/ │ ├── .gitignore │ ├── build.gradle │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── de/ │ │ └── cketti/ │ │ └── mailto/ │ │ └── sample/ │ │ └── MainActivity.java │ └── res/ │ ├── layout/ │ │ └── activity_main.xml │ ├── menu/ │ │ └── activity_main.xml │ └── values/ │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle
SYMBOL INDEX (61 symbols across 3 files)
FILE: library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java
class EmailIntentBuilder (line 56) | @SuppressWarnings("WeakerAccess")
method EmailIntentBuilder (line 66) | private EmailIntentBuilder(@NotNull Context context) {
method from (line 78) | @NotNull
method to (line 91) | @NotNull
method to (line 106) | @NotNull
method cc (line 125) | @NotNull
method cc (line 140) | @NotNull
method bcc (line 159) | @NotNull
method bcc (line 174) | @NotNull
method subject (line 193) | @NotNull
method body (line 209) | @NotNull
method start (line 221) | public boolean start() {
method startActivity (line 232) | private void startActivity(Intent intent) {
method build (line 245) | @NotNull
method constructMailtoUri (line 251) | @NotNull
method addQueryParameter (line 266) | private boolean addQueryParameter(StringBuilder mailto, String field, ...
method addRecipientQueryParameters (line 276) | private boolean addRecipientQueryParameters(StringBuilder mailto, Stri...
method addRecipients (line 288) | private void addRecipients(StringBuilder mailto, Set<String> recipient...
method checkEmail (line 301) | private void checkEmail(String email) {
method checkNoLineBreaks (line 310) | private void checkNoLineBreaks(String text) {
method checkNotNull (line 319) | @NotNull
method encodeRecipient (line 328) | @NotNull
method fixLineBreaks (line 336) | @NotNull
FILE: library/src/test/java/de/cketti/mailto/EmailIntentBuilderTest.java
class EmailIntentBuilderTest (line 28) | @RunWith(RobolectricTestRunner.class)
method setUp (line 36) | @Before
method from_withNullArgument_shouldThrow (line 41) | @SuppressWarnings("ConstantConditions")
method build_shouldReturnIntentWithSendToAction (line 47) | @Test
method build_withSingleToValue_shouldReturnExpectedResult (line 54) | @Test
method build_withListToValue_shouldReturnExpectedResult (line 63) | @Test
method build_withSingleCcValue_shouldReturnExpectedResult (line 72) | @Test
method build_withListCcValue_shouldReturnExpectedResult (line 81) | @Test
method build_withSingleBccValue_shouldReturnExpectedResult (line 90) | @Test
method build_withListBccValue_shouldReturnExpectedResult (line 99) | @Test
method build_withSubject_shouldReturnExpectedResult (line 108) | @Test
method build_withBodyContainingImproperLineBreak_shouldReturnFixedResult (line 117) | @Test
method build_withAllExtras_shouldReturnExpectedResult (line 126) | @Test
method start_fromActivity_shouldCreateIntentWithoutNewTaskFlag (line 145) | @Test
method start_fromContext_shouldCreateIntentWithNewTaskFlag (line 157) | @Test
method start_withoutError_shouldReturnTrue (line 167) | @Test
method start_withActivityNotFoundException_shouldReturnFalse (line 174) | @Test
method encodeRecipient_withComplicatedEmailOne_shouldReturnExpectedResult (line 183) | @Test
method encodeRecipient_withComplicatedEmailTwo_shouldReturnExpectedResult (line 190) | @Test
method encodeRecipient_withComplicatedEmailThree_shouldReturnExpectedResult (line 197) | @Test
method to_withNullArgument_shouldThrow (line 204) | @SuppressWarnings("ConstantConditions")
method to_withArgumentStartingWithAt_shouldThrow (line 211) | @Test(expected = IllegalArgumentException.class)
method to_withArgumentEndingInAt_shouldThrow (line 217) | @Test(expected = IllegalArgumentException.class)
method to_withArgumentNotContainingAt_shouldThrow (line 223) | @Test(expected = IllegalArgumentException.class)
method subject_withNullArgument_shouldThrow (line 229) | @SuppressWarnings("ConstantConditions")
method subject_withArgumentContainingCarriageReturn_shouldThrow (line 236) | @Test(expected = IllegalArgumentException.class)
method subject_withArgumentContainingLineFeed_shouldThrow (line 242) | @Test(expected = IllegalArgumentException.class)
method subject_withArgumentContainingCrLf_shouldThrow (line 248) | @Test(expected = IllegalArgumentException.class)
method fixLineBreaks_withArgumentContainingCr_shouldReturnExpectedResult (line 254) | @Test
method fixLineBreaks_withArgumentContainingLf_shouldReturnExpectedResult (line 261) | @Test
method fixLineBreaks_withArgumentContainingCrLf_shouldReturnExpectedResult (line 268) | @Test
method getIntentFromStartActivityInvocation (line 275) | private Intent getIntentFromStartActivityInvocation(Context context) {
FILE: sample/src/main/java/de/cketti/mailto/sample/MainActivity.java
class MainActivity (line 16) | public class MainActivity extends AppCompatActivity {
method onCreate (line 25) | @Override
method onCreateOptionsMenu (line 40) | @Override
method onOptionsItemSelected (line 46) | @Override
method sendFeedback (line 54) | private void sendFeedback() {
method sendEmail (line 66) | void sendEmail() {
Condensed preview — 27 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (61K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 15,
"preview": "github: cketti\n"
},
{
"path": ".github/workflows/android.yml",
"chars": 273,
"preview": "name: Android CI\n\non: [push]\n\njobs:\n build:\n\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v1\n "
},
{
"path": ".gitignore",
"chars": 57,
"preview": ".gradle\n/local.properties\n/.idea/\n.DS_Store\n/build\n*.iml\n"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 2255,
"preview": "# Email Intent Builder\n\n[ && hasProperty(\"nexusPassword\"))) {\n return\n}\n\napply plugin: 'maven'\napply plugin:"
},
{
"path": "build.gradle",
"chars": 281,
"preview": "buildscript {\n repositories {\n mavenCentral()\n google()\n jcenter()\n }\n dependencies {\n "
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 202,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
},
{
"path": "gradle.properties",
"chars": 909,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 5764,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "gradlew.bat",
"chars": 2942,
"preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "library/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "library/build.gradle",
"chars": 1318,
"preview": "apply plugin: 'com.android.library'\n\nandroid {\n compileSdkVersion 28\n buildToolsVersion \"28.0.3\"\n\n defaultConfi"
},
{
"path": "library/src/main/AndroidManifest.xml",
"chars": 114,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"de.cketti.mailto\">\n\n</manifest>\n"
},
{
"path": "library/src/main/java/de/cketti/mailto/EmailIntentBuilder.java",
"chars": 9555,
"preview": "/*\n * Copyright 2015-2019 cketti\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "library/src/test/java/de/cketti/mailto/EmailIntentBuilderTest.java",
"chars": 9303,
"preview": "package de.cketti.mailto;\n\n\nimport java.util.Arrays;\n\nimport android.app.Activity;\nimport android.content.ActivityNotFou"
},
{
"path": "sample/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "sample/build.gradle",
"chars": 595,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 28\n buildToolsVersion \"28.0.3\"\n\n defaultC"
},
{
"path": "sample/src/main/AndroidManifest.xml",
"chars": 962,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "sample/src/main/java/de/cketti/mailto/sample/MainActivity.java",
"chars": 3189,
"preview": "package de.cketti.mailto.sample;\n\n\nimport android.os.Bundle;\nimport android.text.TextUtils;\nimport android.view.Menu;\nim"
},
{
"path": "sample/src/main/res/layout/activity_main.xml",
"chars": 3498,
"preview": "<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools"
},
{
"path": "sample/src/main/res/menu/activity_main.xml",
"chars": 212,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item\n "
},
{
"path": "sample/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "sample/src/main/res/values/strings.xml",
"chars": 673,
"preview": "<resources>\n <string name=\"app_name\">Email Intent Builder</string>\n\n <string name=\"button_label_send_email\">Send e"
},
{
"path": "sample/src/main/res/values/styles.xml",
"chars": 194,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "settings.gradle",
"chars": 30,
"preview": "include ':sample', ':library'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the cketti/EmailIntentBuilder GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 27 files (55.3 KB), approximately 13.7k tokens, and a symbol index with 61 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.