diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..b8b8b90a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "chore" + prefix-development: "chore" + include: "scope" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..8cae8a84 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,12 @@ +name: PR + +on: + pull_request: + branches: [ main ] + +jobs: + call-pr-workflow: + uses: FossifyOrg/.github/.github/workflows/pr.yml@main + with: + test_task: ":library:testDebugUnitTest" + run_detekt: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1f9a7ddd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + name: Create release + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + with: + fetch-depth: 0 + + - name: Get next version + id: version + uses: ietf-tools/semver-action@000ddb2ebacad350ff2a15382a344dc05ea4c0a4 + with: + token: ${{ github.token }} + branch: ${{ github.event.repository.default_branch }} + noNewCommitBehavior: 'warn' + noVersionBumpBehavior: 'warn' + patchList: fix, bugfix, perf, refactor, test, tests, chore + + - name: Create and push tag + if: ${{ steps.version.outputs.nextStrict }} + run: | + set -euo pipefail + git config user.name "fossifybot[bot]" + git config user.email "212866877+fossifybot[bot]@users.noreply.github.com" + new_version="${{ steps.version.outputs.nextStrict }}" + echo "Creating tag: $new_version" + git tag -a "$new_version" -m "$new_version" + git push origin "$new_version" + echo "Created and pushed tag: $new_version" diff --git a/README.md b/README.md index 19e00a3a..a925aa56 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,3 @@ -# Android SMS/MMS Sending Library - -![Promo](https://raw.githubusercontent.com/klinker41/android-smsmms/master/android-messaging.png) - -These are the APIs that Google has so far left out of the Android ecosystem for easily sending any type of message without digging through source code and what not. - -If you've got a better way to do things, send me a pull request! The library was created specifically for [Sliding Messaging Pro](https://play.google.com/store/apps/details?id=com.klinker.android.messaging_donate&hl=en) and [EvolveSMS](https://play.google.com/store/apps/details?id=com.klinker.android.evolve_sms&hl=en) and some things work the way they do specifically for those apps. - -It's now used in [Pulse](https://play.google.com/store/apps/details?id=xyz.klinker.messenger) as well. - ---- - ## Library Overview Sending messages is very easy to do. @@ -110,7 +98,7 @@ For full details on how to implement, please check out the sample application. I To include in your gradle project: ```groovy -compile 'com.klinkerapps:android-smsmms:5.2.6' +compile 'org.fossify:mmslib:1.0.0' ``` --- diff --git a/android-messaging.png b/android-messaging.png deleted file mode 100644 index f479f998..00000000 Binary files a/android-messaging.png and /dev/null differ diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 98180032..00000000 --- a/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -buildscript { - repositories { - google() - mavenCentral() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' - } -} - -allprojects { - repositories { - google() - mavenCentral() - jcenter() - maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..af7affe3 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,21 @@ +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath("com.android.tools.build:gradle:8.11.1") + } +} + +allprojects { + repositories { + google() + mavenCentral() + maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } + } +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..3f6f2ce0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.parallel=true +org.gradle.caching=true +android.useAndroidX=true +android.nonTransitiveRClass=true +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 3c7abdf1..9bbc975c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bc41d8d3..37f853b1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Tue Dec 30 08:21:22 CST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip diff --git a/gradlew b/gradlew index 91a7e269..faf93008 100755 --- a/gradlew +++ b/gradlew @@ -1,79 +1,129 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# 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\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - 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" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -82,83 +132,120 @@ 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. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + 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 fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "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 +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac 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 +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # 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\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg 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 -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# 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"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282a..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@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 +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -8,26 +26,30 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@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= - set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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 +if %ERRORLEVEL% equ 0 goto execute -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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,54 +57,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute -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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_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=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -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% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..bb8a4f69 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1 @@ +jdk: openjdk17 diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index 6f893976..00000000 --- a/library/build.gradle +++ /dev/null @@ -1,46 +0,0 @@ -apply plugin: 'com.android.library' - -dependencies { - implementation 'com.klinkerapps:logger:1.0.3' - implementation 'com.squareup.okhttp:okhttp:2.5.0' - implementation 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' -} - -android { - compileSdk 34 - - defaultConfig { - minSdkVersion 22 - targetSdkVersion 34 - } - - lintOptions { - abortOnError false - } - - useLibrary 'org.apache.http.legacy' -} - -apply plugin: 'signing' - -def isReleaseBuild() { - return !VERSION_NAME.contains("SNAPSHOT") -} - -def getReleaseRepositoryUrl() { - return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL - : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" -} - -def getSnapshotRepositoryUrl() { - return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL - : "https://oss.sonatype.org/content/repositories/snapshots/" -} - -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} - -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} diff --git a/library/build.gradle.kts b/library/build.gradle.kts new file mode 100644 index 00000000..f5135799 --- /dev/null +++ b/library/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("com.android.library") + id("maven-publish") +} + +group = "org.fossify" +version = "1.0.0" + +android { + compileSdk = 34 + namespace = "com.klinker.android.send_message" + + defaultConfig { + minSdk = 26 + } + + lint { + abortOnError = false + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + @Suppress("DEPRECATION") + useLibrary("org.apache.http.legacy") + + publishing { + singleVariant("release") { + withSourcesJar() + } + } +} + +dependencies { + implementation("com.klinkerapps:logger:1.0.3") + implementation("com.squareup.okhttp:okhttp:2.5.0") + implementation("com.squareup.okhttp:okhttp-urlconnection:2.5.0") +} + +afterEvaluate { + publishing { + publications { + create("release") { + from(components["release"]) + } + } + } +} diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index d221b0f2..a8e5e143 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/library/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java b/library/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java index 3dba61b4..963cbd10 100644 --- a/library/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java +++ b/library/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java @@ -77,6 +77,11 @@ public boolean isAddressBlocked(Context context, String address) { return false; } + public boolean isContentBlocked(Context context, String content) { + // Subclasses can override this to screen messages based on content. + return false; + } + public abstract void onMessageReceived(Context context, Uri messageUri); public abstract void onError(Context context, String error); @@ -115,7 +120,8 @@ public final void onReceive(final Context context, final Intent intent) { final MmsConfig.Overridden mmsConfig = new MmsConfig.Overridden(new MmsConfig(context), null); final String address = parseSenderAddressFromPdu(context, response, locationUrl, mmsConfig); - if (isAddressBlocked(context, address)) { + final String content = MmsTextExtractor.extractTextFromPdu(response, mmsConfig.getSupportMmsContentDisposition()); + if (isAddressBlocked(context, address) || isContentBlocked(context, content)) { // Delete the corresponding NotificationInd. SqliteWrapper.delete(context, context.getContentResolver(), diff --git a/library/src/main/java/com/klinker/android/send_message/MmsTextExtractor.java b/library/src/main/java/com/klinker/android/send_message/MmsTextExtractor.java new file mode 100644 index 00000000..6d525a8b --- /dev/null +++ b/library/src/main/java/com/klinker/android/send_message/MmsTextExtractor.java @@ -0,0 +1,143 @@ +package com.klinker.android.send_message; + +import android.text.Html; +import android.text.TextUtils; + +import com.google.android.mms.ContentType; +import com.google.android.mms.pdu_alt.CharacterSets; +import com.google.android.mms.pdu_alt.EncodedStringValue; +import com.google.android.mms.pdu_alt.GenericPdu; +import com.google.android.mms.pdu_alt.PduBody; +import com.google.android.mms.pdu_alt.PduHeaders; +import com.google.android.mms.pdu_alt.PduParser; +import com.google.android.mms.pdu_alt.PduPart; +import com.google.android.mms.pdu_alt.RetrieveConf; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +public final class MmsTextExtractor { + + private static final Set EXCLUDED_TEXT_TYPES = new java.util.HashSet<>(); + + static { + EXCLUDED_TEXT_TYPES.add("application/smil"); + EXCLUDED_TEXT_TYPES.add("application/vnd.wap.smil"); + EXCLUDED_TEXT_TYPES.add("text/xml"); + EXCLUDED_TEXT_TYPES.add("application/xml"); + EXCLUDED_TEXT_TYPES.add("text/vcard"); + EXCLUDED_TEXT_TYPES.add("text/x-vcard"); + EXCLUDED_TEXT_TYPES.add("text/calendar"); + EXCLUDED_TEXT_TYPES.add("text/x-vcalendar"); + EXCLUDED_TEXT_TYPES.add("text/rtf"); + } + + private MmsTextExtractor() { + } + + public static String extractTextFromPdu(byte[] data, boolean supportContentDisposition) { + GenericPdu pdu = new PduParser(data, supportContentDisposition).parse(); + return extractTextFromPdu(pdu); + } + + public static String extractTextFromPdu(GenericPdu pdu) { + if (pdu == null || pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF) { + return ""; // nothing to filter + } + + RetrieveConf retrieveConf = (RetrieveConf) pdu; + List pieces = new ArrayList<>(4); + + // subject + EncodedStringValue subject = retrieveConf.getSubject(); + if (subject != null) { + String subjectString = subject.getString(); + if (!TextUtils.isEmpty(subjectString)) pieces.add(subjectString); + } + + // text parts + PduBody body = retrieveConf.getBody(); + if (body != null) { + int parts = body.getPartsNum(); + for (int i = 0; i < parts; i++) { + PduPart part = body.getPart(i); + String contentType = safeAscii(part.getContentType()); + if (contentType == null) continue; + if (isTextLike(contentType)) { + String text = decodePartToString(part, contentType); + if (!TextUtils.isEmpty(text)) { + pieces.add(text); + } + } + } + } + + if (pieces.isEmpty()) return ""; + return TextUtils.join("\n", pieces); + } + + private static String safeAscii(byte[] bytes) { + if (bytes == null) return null; + return new String(bytes, StandardCharsets.US_ASCII); + } + + private static boolean isTextLike(String contentType) { + if (contentType == null) return false; + String ct = contentType.trim().toLowerCase(Locale.ROOT); + if (EXCLUDED_TEXT_TYPES.contains(ct)) { + // filter out some text-like types that aren't directly visible + return false; + } + + return ContentType.isTextType(contentType) + || "application/xhtml+xml".equalsIgnoreCase(contentType) + || "application/vnd.wap.xhtml+xml".equalsIgnoreCase(contentType); + } + + private static String decodePartToString(PduPart part, String contentType) { + byte[] data = part.getData(); + if (data == null || data.length == 0) return ""; + String charsetName = null; + try { + int charset = part.getCharset(); + if (charset != 0) charsetName = CharacterSets.getMimeName(charset); + } catch (Throwable ignored) { + } + + Charset charset; + try { + charset = charsetName != null ? Charset.forName(charsetName) : StandardCharsets.UTF_8; + } catch (Throwable ignored) { + charset = StandardCharsets.UTF_8; + } + + String string = new String(data, charset); + if ( + "text/html".equalsIgnoreCase(contentType) + || "application/xhtml+xml".equalsIgnoreCase(contentType) + || "application/vnd.wap.xhtml+xml".equalsIgnoreCase(contentType) + ) { + string = stripHtmlTags(string); + } + return string; + } + + private static String stripHtmlTags(String html) { + if (TextUtils.isEmpty(html)) return html; + String noTags = html.replaceAll("(?is)]*>.*?", "") + .replaceAll("(?is)]*>.*?", "") + .replaceAll("(?is)<[^>]+>", " "); + String collapsed = noTags.replaceAll("\\s{2,}", " ").trim(); + + try { + CharSequence formattedString = Html.fromHtml(collapsed, Html.FROM_HTML_MODE_LEGACY); + return formattedString == null ? collapsed : formattedString.toString(); + } catch (Throwable t) { + return collapsed; + } + } +} \ No newline at end of file diff --git a/sample/.gitignore b/sample/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/sample/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/sample/build.gradle b/sample/build.gradle deleted file mode 100644 index 01064f89..00000000 --- a/sample/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'com.android.application' - -allprojects { - repositories { - mavenCentral() - maven { - url 'https://oss.sonatype.org/content/repositories/snapshots/' - } - } -} - -android { - compileSdkVersion 31 - - defaultConfig { - applicationId "com.klinker.android.send_message.sample" - minSdkVersion 22 - targetSdkVersion 31 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - lintOptions { - abortOnError false - } -} - -dependencies { - implementation project(":library") - implementation 'com.android.support:recyclerview-v7:28.0.0' - implementation 'com.klinkerapps:logger:1.0.3' -} diff --git a/sample/proguard-rules.pro b/sample/proguard-rules.pro deleted file mode 100644 index 5cd77c54..00000000 --- a/sample/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/jacob/Programs/android-sdk-linux/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml deleted file mode 100644 index e22c0146..00000000 --- a/sample/src/main/AndroidManifest.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/HeadlessSmsSendService.java b/sample/src/main/java/com/klinker/android/messaging_sample/HeadlessSmsSendService.java deleted file mode 100644 index aca534dd..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/HeadlessSmsSendService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -/** - * Needed to make default sms app for testing - */ -public class HeadlessSmsSendService extends Service { - - @Override - public IBinder onBind(Intent intent) { - return null; - } - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/LogAdapter.java b/sample/src/main/java/com/klinker/android/messaging_sample/LogAdapter.java deleted file mode 100644 index bf7d2dc2..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/LogAdapter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.app.AlertDialog; -import android.content.Context; -import android.os.Handler; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import java.util.List; - -public class LogAdapter extends RecyclerView.Adapter { - - private List mDataset; - private Handler mHandler; - - public LogAdapter(List myDataset) { - mDataset = myDataset; - mHandler = new Handler(); - } - - @Override - public LogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - final Context context = parent.getContext(); - TextView v = (TextView) LayoutInflater.from(context) - .inflate(android.R.layout.simple_list_item_1, parent, false); - final ViewHolder vh = new ViewHolder(v); - - v.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String dataClicked = mDataset.get(vh.position); - - new AlertDialog.Builder(context) - .setMessage(dataClicked) - .setPositiveButton("OK", null) - .show(); - } - }); - - return vh; - } - - @Override - public void onBindViewHolder(ViewHolder holder, int position) { - holder.mTextView.setText(mDataset.get(position)); - holder.position = position; - } - - @Override - public int getItemCount() { - return mDataset.size(); - } - - public void addItem(String item) { - mDataset.add(0, item); - - // ensure we are on the ui thread - mHandler.post(new Runnable() { - @Override - public void run() { - try { - notifyItemInserted(0); - } catch (IllegalStateException e) { - // Cannot call this method while recyclerview is computing a layout or scrolling - } - } - }); - } - - public static class ViewHolder extends RecyclerView.ViewHolder { - public TextView mTextView; - public int position; - - public ViewHolder(TextView v) { - super(v); - mTextView = v; - mTextView.setTextSize(10); - } - } - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/MainActivity.java b/sample/src/main/java/com/klinker/android/messaging_sample/MainActivity.java deleted file mode 100644 index 20d8e68a..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/MainActivity.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.app.Activity; -import android.content.Intent; -import android.graphics.BitmapFactory; -import android.os.Build; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.provider.Telephony; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.Toast; - -import com.klinker.android.logger.Log; -import com.klinker.android.logger.OnLogListener; -import com.klinker.android.send_message.ApnUtils; -import com.klinker.android.send_message.BroadcastUtils; -import com.klinker.android.send_message.Message; -import com.klinker.android.send_message.Transaction; -import com.klinker.android.send_message.Utils; - -import java.util.ArrayList; - -public class MainActivity extends Activity { - - private Settings settings; - - private Button setDefaultAppButton; - private Button selectApns; - private EditText fromField; - private EditText toField; - private EditText messageField; - private ImageView imageToSend; - private Button sendButton; - private RecyclerView log; - - private LogAdapter logAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (PreferenceManager.getDefaultSharedPreferences(this) - .getBoolean("request_permissions", true) && - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - startActivity(new Intent(this, PermissionActivity.class)); - finish(); - return; - } - - setContentView(R.layout.activity_main); - - initSettings(); - initViews(); - initActions(); - initLogging(); - - BroadcastUtils.sendExplicitBroadcast(this, new Intent(), "test action"); - } - - private void initSettings() { - settings = Settings.get(this); - - if (TextUtils.isEmpty(settings.getMmsc()) && - Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - initApns(); - } - } - - private void initApns() { - ApnUtils.initDefaultApns(this, new ApnUtils.OnApnFinishedListener() { - @Override - public void onFinished() { - settings = Settings.get(MainActivity.this, true); - } - }); - } - - private void initViews() { - setDefaultAppButton = (Button) findViewById(R.id.set_as_default); - selectApns = (Button) findViewById(R.id.apns); - fromField = (EditText) findViewById(R.id.from); - toField = (EditText) findViewById(R.id.to); - messageField = (EditText) findViewById(R.id.message); - imageToSend = (ImageView) findViewById(R.id.image); - sendButton = (Button) findViewById(R.id.send); - log = (RecyclerView) findViewById(R.id.log); - } - - private void initActions() { - if (Utils.isDefaultSmsApp(this)) { - setDefaultAppButton.setVisibility(View.GONE); - } else { - setDefaultAppButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - setDefaultSmsApp(); - } - }); - } - - selectApns.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - initApns(); - } - }); - - fromField.setText(Utils.getMyPhoneNumber(this)); - toField.setText(Utils.getMyPhoneNumber(this)); - - imageToSend.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - toggleSendImage(); - } - }); - - sendButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - sendMessage(); - } - }); - - log.setHasFixedSize(false); - log.setLayoutManager(new LinearLayoutManager(this)); - logAdapter = new LogAdapter(new ArrayList()); - log.setAdapter(logAdapter); - } - - private void initLogging() { - Log.setDebug(true); - Log.setPath("messenger_log.txt"); - Log.setLogListener(new OnLogListener() { - @Override - public void onLogged(String tag, String message) { - //logAdapter.addItem(tag + ": " + message); - } - }); - } - - private void setDefaultSmsApp() { - setDefaultAppButton.setVisibility(View.GONE); - Intent intent = - new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); - intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, - getPackageName()); - startActivity(intent); - } - - private void toggleSendImage() { - if (imageToSend.isEnabled()) { - imageToSend.setEnabled(false); - imageToSend.setAlpha(0.3f); - } else { - imageToSend.setEnabled(true); - imageToSend.setAlpha(1.0f); - } - } - - public void sendMessage() { - new Thread(new Runnable() { - @Override - public void run() { - com.klinker.android.send_message.Settings sendSettings = new com.klinker.android.send_message.Settings(); - sendSettings.setMmsc(settings.getMmsc()); - sendSettings.setProxy(settings.getMmsProxy()); - sendSettings.setPort(settings.getMmsPort()); - sendSettings.setUseSystemSending(true); - - Transaction transaction = new Transaction(MainActivity.this, sendSettings); - - Message message = new Message(messageField.getText().toString(), toField.getText().toString()); - - if (imageToSend.isEnabled()) { - message.setImage(BitmapFactory.decodeResource(getResources(), R.drawable.android)); - } - - try { - transaction.sendNewMessage(message); - } catch (Exception e) { - e.printStackTrace(); - String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : "Failed to send message"; - Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show(); - } - } - }).start(); - } - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceivedReceiverImpl.java b/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceivedReceiverImpl.java deleted file mode 100644 index 63275408..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceivedReceiverImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.klinker.android.messaging_sample; - -import android.content.Context; -import android.net.Uri; -import android.util.Log; - -import com.klinker.android.send_message.MmsReceivedReceiver; - -public class MmsReceivedReceiverImpl extends MmsReceivedReceiver { - - @Override - public void onMessageReceived(Context context, Uri messageUri) { - Log.v("MmsReceived", "message received: " + messageUri.toString()); - } - - @Override - public void onError(Context context, String error) { - Log.v("MmsReceived", "error: " + error); - } - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceiver.java b/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceiver.java deleted file mode 100644 index a50c3c4f..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/MmsReceiver.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import com.android.mms.transaction.PushReceiver; - -/** - * Needed to make default sms app for testing - */ -public class MmsReceiver extends PushReceiver { - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/PermissionActivity.java b/sample/src/main/java/com/klinker/android/messaging_sample/PermissionActivity.java deleted file mode 100644 index 8bc5ae56..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/PermissionActivity.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2015 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.Manifest; -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.view.Menu; -import android.view.MenuItem; - -import com.klinker.android.messaging_sample.R; - -public class PermissionActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - requestPermissions(new String[]{ - Manifest.permission.READ_SMS, - Manifest.permission.SEND_SMS, - Manifest.permission.RECEIVE_SMS, - Manifest.permission.RECEIVE_MMS, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.CHANGE_NETWORK_STATE - }, 0); - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - PreferenceManager.getDefaultSharedPreferences(this).edit() - .putBoolean("request_permissions", false) - .commit(); - - startActivity(new Intent(this, MainActivity.class)); - finish(); - } - -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/Settings.java b/sample/src/main/java/com/klinker/android/messaging_sample/Settings.java deleted file mode 100644 index 8c429361..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/Settings.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; - -public class Settings { - - private static Settings settings; - - private static final String MMSC_PREF = "mmsc_url"; - private static final String MMS_PROXY_PREF = "mms_proxy"; - private static final String MMS_PORT_PREF = "mms_port"; - - private String mmsc; - private String mmsProxy; - private String mmsPort; - - public static Settings get(Context context) { - return get(context, false); - } - - public static Settings get(Context context, boolean forceReload) { - if (settings == null || forceReload) { - settings = init(context); - } - - return settings; - } - - private Settings() { - } - - private static Settings init(Context context) { - Settings settings = new Settings(); - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - - settings.mmsc = sharedPreferences.getString(MMSC_PREF, ""); - settings.mmsProxy = sharedPreferences.getString(MMS_PROXY_PREF, ""); - settings.mmsPort = sharedPreferences.getString(MMS_PORT_PREF, ""); - - return settings; - } - - public String getMmsc() { - return mmsc; - } - - public String getMmsProxy() { - return mmsProxy; - } - - public String getMmsPort() { - return mmsPort; - } -} diff --git a/sample/src/main/java/com/klinker/android/messaging_sample/SmsReceiver.java b/sample/src/main/java/com/klinker/android/messaging_sample/SmsReceiver.java deleted file mode 100644 index 42d0f09d..00000000 --- a/sample/src/main/java/com/klinker/android/messaging_sample/SmsReceiver.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2014 Jacob Klinker - * - * 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.klinker.android.messaging_sample; - -import android.app.Notification; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.support.v4.app.NotificationManagerCompat; -import android.telephony.SmsMessage; - -/** - * Needed to make default sms app for testing - */ -public class SmsReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - Object[] smsExtra = (Object[]) intent.getExtras().get("pdus"); - String body = ""; - - for (int i = 0; i < smsExtra.length; ++i) { - SmsMessage sms = SmsMessage.createFromPdu((byte[]) smsExtra[i]); - body += sms.getMessageBody(); - } - - Notification notification = new Notification.Builder(context) - .setContentText(body) - .setContentTitle("New Message") - .setSmallIcon(R.drawable.ic_alert) - .setStyle(new Notification.BigTextStyle().bigText(body)) - .build(); - NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context); - notificationManagerCompat.notify(1, notification); - } - -} diff --git a/sample/src/main/res/drawable-xxhdpi/android.jpg b/sample/src/main/res/drawable-xxhdpi/android.jpg deleted file mode 100644 index fae74ef9..00000000 Binary files a/sample/src/main/res/drawable-xxhdpi/android.jpg and /dev/null differ diff --git a/sample/src/main/res/drawable-xxhdpi/ic_launcher.png b/sample/src/main/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 4df18946..00000000 Binary files a/sample/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml deleted file mode 100644 index 33569fe6..00000000 --- a/sample/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - -