diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..94946c6 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/animated_vector_drawable_25_1_0.xml b/.idea/libraries/animated_vector_drawable_25_1_0.xml new file mode 100644 index 0000000..04eaa82 --- /dev/null +++ b/.idea/libraries/animated_vector_drawable_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/answers_shim_0_0_6.xml b/.idea/libraries/answers_shim_0_0_6.xml new file mode 100644 index 0000000..ed4c218 --- /dev/null +++ b/.idea/libraries/answers_shim_0_0_6.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/appcompat_v7_25_1_0.xml b/.idea/libraries/appcompat_v7_25_1_0.xml new file mode 100644 index 0000000..b742040 --- /dev/null +++ b/.idea/libraries/appcompat_v7_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/cardview_v7_25_1_0.xml b/.idea/libraries/cardview_v7_25_1_0.xml new file mode 100644 index 0000000..58c989a --- /dev/null +++ b/.idea/libraries/cardview_v7_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/design_25_1_0.xml b/.idea/libraries/design_25_1_0.xml new file mode 100644 index 0000000..9eb960e --- /dev/null +++ b/.idea/libraries/design_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/library_2_5_7.xml b/.idea/libraries/library_2_5_7.xml new file mode 100644 index 0000000..3995ffe --- /dev/null +++ b/.idea/libraries/library_2_5_7.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/material_about_library_1_5_0.xml b/.idea/libraries/material_about_library_1_5_0.xml new file mode 100644 index 0000000..4711fb0 --- /dev/null +++ b/.idea/libraries/material_about_library_1_5_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/recyclerview_v7_25_1_0.xml b/.idea/libraries/recyclerview_v7_25_1_0.xml new file mode 100644 index 0000000..b9e2e36 --- /dev/null +++ b/.idea/libraries/recyclerview_v7_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_annotations_25_1_0.xml b/.idea/libraries/support_annotations_25_1_0.xml new file mode 100644 index 0000000..cbd775e --- /dev/null +++ b/.idea/libraries/support_annotations_25_1_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_compat_25_1_0.xml b/.idea/libraries/support_compat_25_1_0.xml new file mode 100644 index 0000000..80e4086 --- /dev/null +++ b/.idea/libraries/support_compat_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_core_ui_25_1_0.xml b/.idea/libraries/support_core_ui_25_1_0.xml new file mode 100644 index 0000000..42d0aba --- /dev/null +++ b/.idea/libraries/support_core_ui_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_core_utils_25_1_0.xml b/.idea/libraries/support_core_utils_25_1_0.xml new file mode 100644 index 0000000..4e2fd6f --- /dev/null +++ b/.idea/libraries/support_core_utils_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_fragment_25_1_0.xml b/.idea/libraries/support_fragment_25_1_0.xml new file mode 100644 index 0000000..7d8e2d4 --- /dev/null +++ b/.idea/libraries/support_fragment_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_media_compat_25_1_0.xml b/.idea/libraries/support_media_compat_25_1_0.xml new file mode 100644 index 0000000..1572795 --- /dev/null +++ b/.idea/libraries/support_media_compat_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_25_1_0.xml b/.idea/libraries/support_v4_25_1_0.xml new file mode 100644 index 0000000..9652c57 --- /dev/null +++ b/.idea/libraries/support_v4_25_1_0.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_vector_drawable_25_1_0.xml b/.idea/libraries/support_vector_drawable_25_1_0.xml new file mode 100644 index 0000000..860cf14 --- /dev/null +++ b/.idea/libraries/support_vector_drawable_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/transition_25_1_0.xml b/.idea/libraries/transition_25_1_0.xml new file mode 100644 index 0000000..37e0254 --- /dev/null +++ b/.idea/libraries/transition_25_1_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..93f5422 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9601e1c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..754c566 --- /dev/null +++ b/build.gradle @@ -0,0 +1,24 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + maven { url "https://jitpack.io" } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..e6a8356 --- /dev/null +++ b/circle.yml @@ -0,0 +1,12 @@ +dependencies: + pre: + - echo y | android update sdk --no-ui --all --filter tools,platform-tools,android-24 + - echo y | android update sdk --no-ui --all --filter build-tools-24.0.2 + +test: + override: + # run lint (tests will come next ...) + - ./gradlew :library:check + + # copy results + - cp -r library/build/outputs $CIRCLE_ARTIFACTS diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..1d3591c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..04e285f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 28 10:00:20 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# 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 + +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" ] ; 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, switch paths to Windows format before running java +if $cygwin ; 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=$((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 + +# 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 "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@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 + +@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=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 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% + +: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 diff --git a/library/.gitignore b/library/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/library/.gitignore @@ -0,0 +1 @@ +/build diff --git a/library/build.gradle b/library/build.gradle new file mode 100644 index 0000000..dcadbd7 --- /dev/null +++ b/library/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 24 + buildToolsVersion "24.0.2" + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile 'com.github.daniel-stoneuk:material-about-library:1.5.0' + compile('io.branch.sdk.android:library:2.5.7') { + exclude module: 'answers.shim' + } +} diff --git a/library/findbugs_exclude.xml b/library/findbugs_exclude.xml new file mode 100644 index 0000000..f13278c --- /dev/null +++ b/library/findbugs_exclude.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro new file mode 100644 index 0000000..8a2f402 --- /dev/null +++ b/library/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Android\sdk/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/library/quality.gradle b/library/quality.gradle new file mode 100644 index 0000000..12aa9e4 --- /dev/null +++ b/library/quality.gradle @@ -0,0 +1,50 @@ +apply plugin: 'findbugs' +apply plugin: 'pmd' + +findbugs { + ignoreFailures = false + reportsDir = file("$project.buildDir/outputs/") + reportLevel = "medium" + effort = "max" +} + +pmd { + ignoreFailures = false + reportsDir = file("$project.buildDir/outputs/") +} + +task findbugs(type: FindBugs, dependsOn: "assembleDebug") { + description 'Run findbugs' + group 'verification' + + classes = fileTree("$project.buildDir/intermediates/classes/debug") + source = fileTree('src/main/java') + classpath = files() + + effort = 'max' + + excludeFilter = file("$project.projectDir/findbugs_exclude.xml") + + reports { + xml.enabled = false + html.enabled = true + } +} + +task pmd(type: Pmd, dependsOn: "assembleDebug") { + description 'Run pmd' + group 'verification' + + ruleSets = ["java-basic", "java-braces", "java-strings", "java-design", "java-unusedcode"] + source = fileTree('src/main/java') + + reports { + xml.enabled = false + html.enabled = true + } +} + +check.doLast { + project.tasks.getByName("findbugs").execute() + project.tasks.getByName("pmd").execute() +} diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml new file mode 100644 index 0000000..3b15948 --- /dev/null +++ b/library/src/main/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java b/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java new file mode 100644 index 0000000..8529e3c --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/AboutConfig.java @@ -0,0 +1,49 @@ +package com.eggheadgames.aboutbox; + +import android.content.Context; + +public class AboutConfig { + + public enum BuildType {AMAZON, GOOGLE} + + private static AboutConfig aboutConfig; + + public static AboutConfig getInstance() { + if (aboutConfig == null) { + aboutConfig = new AboutConfig(); + } + return aboutConfig; + } + + // general info + public String appName; + public int appIcon; + public String version; + public String aboutLabelTitle; + public String logUiEventName; + public String facebookUserName; + public String twitterUserName; + public String webHomePage; + public String appPublisher; + public String companyHtmlPath; + public String privacyHtmlPath; + public String acknowledgmentHtmlPath; + public BuildType buildType; + + public Context context; + + // custom analytics and dialog + public IAnalytic analytics; + public IDialog dialog; + + // email + public String emailAddress; + public String emailSubject; + public String emailBody; + + // share + public String shareMessageTitle; + public String shareMessage; + public String sharingTitle; + +} diff --git a/library/src/main/java/com/eggheadgames/aboutbox/IAnalytic.java b/library/src/main/java/com/eggheadgames/aboutbox/IAnalytic.java new file mode 100644 index 0000000..9e831ab --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/IAnalytic.java @@ -0,0 +1,8 @@ +package com.eggheadgames.aboutbox; + +public interface IAnalytic { + void logUiEvent(String action, String label); + + void logException(Exception e, boolean fatal); +} + diff --git a/library/src/main/java/com/eggheadgames/aboutbox/IDialog.java b/library/src/main/java/com/eggheadgames/aboutbox/IDialog.java new file mode 100644 index 0000000..730010a --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/IDialog.java @@ -0,0 +1,7 @@ +package com.eggheadgames.aboutbox; + +import android.support.v7.app.AppCompatActivity; + +public interface IDialog { + void open(AppCompatActivity activity, String url, String tag); +} diff --git a/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java b/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java new file mode 100644 index 0000000..776eef4 --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java @@ -0,0 +1,270 @@ +package com.eggheadgames.aboutbox.activity; + +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.widget.Toast; + +import com.danielstone.materialaboutlibrary.MaterialAboutActivity; +import com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem; +import com.danielstone.materialaboutlibrary.model.MaterialAboutCard; +import com.danielstone.materialaboutlibrary.model.MaterialAboutList; +import com.danielstone.materialaboutlibrary.model.MaterialAboutTitleItem; +import com.eggheadgames.aboutbox.AboutConfig; +import com.eggheadgames.aboutbox.R; +import com.eggheadgames.aboutbox.share.EmailUtil; +import com.eggheadgames.aboutbox.share.ShareUtil; + +public class AboutActivity extends MaterialAboutActivity { + + public static void launch(Activity activity) { + Intent intent = new Intent(activity, AboutActivity.class); + activity.startActivity(intent); + } + + @Override + protected MaterialAboutList getMaterialAboutList(Context context) { + + final AboutConfig config = AboutConfig.getInstance(); + + MaterialAboutCard.Builder generalInfoCardBuilder = new MaterialAboutCard.Builder(); + + generalInfoCardBuilder.addItem(new MaterialAboutTitleItem.Builder() + .text(config.appName) + .icon(config.appIcon) + .build()); + + generalInfoCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.version) + .subText(config.version) + .build()); + + + MaterialAboutCard.Builder supportCardBuilder = new MaterialAboutCard.Builder(); + supportCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.contact_support) + .icon(R.drawable.ic_email_black) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + EmailUtil.contactUs(AboutActivity.this); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Contact"); + } + } + }) + .build()); + + + MaterialAboutCard.Builder shareCardBuilder = new MaterialAboutCard.Builder(); + shareCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.leave_review) + .icon(R.drawable.ic_review) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + openApp(config.context.getPackageName(), config.buildType == AboutConfig.BuildType.GOOGLE); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Review"); + } + } + }) + .build()); + shareCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.share) + .icon(R.drawable.ic_share_black) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + ShareUtil.share(AboutActivity.this); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Share"); + } + } + }) + .build()); + + + MaterialAboutCard.Builder aboutCardBuilder = new MaterialAboutCard.Builder(); + aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.try_other_apps) + .icon(R.drawable.ic_try_other_apps) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + openPublisher(config.buildType == AboutConfig.BuildType.GOOGLE, config.appPublisher); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Try Other Apps"); + } + } + }) + .build()); + aboutCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(config.aboutLabelTitle) + .icon(R.drawable.ic_about_black) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + if (config.dialog == null) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.companyHtmlPath))); + } else { + config.dialog.open(AboutActivity.this, config.companyHtmlPath, config.aboutLabelTitle); + } + + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, config.aboutLabelTitle); + } + } + }) + .build()); + + + MaterialAboutCard.Builder socialNetworksCardBuilder = new MaterialAboutCard.Builder(); + socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.facebook_label) + .subText(config.facebookUserName) + .icon(R.drawable.ic_facebook_24) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + getOpenFacebookIntent(AboutActivity.this, config.facebookUserName); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Facebook"); + } + } + }) + .build()); + socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.twitter_label) + .subText(config.twitterUserName) + .icon(R.drawable.ic_twitter_24dp) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + startTwitter(AboutActivity.this, config.twitterUserName); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Twitter"); + } + } + }) + .build()); + + socialNetworksCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.web_label) + .subText(config.webHomePage.replace("https://", "").replace("http://", "").replace("/", "")) + .icon(R.drawable.ic_web_black_24dp) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.webHomePage))); + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Website"); + } + } + }) + .build()); + + MaterialAboutCard.Builder privacyCardBuilder = new MaterialAboutCard.Builder(); + privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.privacy_policy) + .icon(R.drawable.ic_privacy) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + if (config.dialog == null) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.privacyHtmlPath))); + } else { + config.dialog.open(AboutActivity.this, config.privacyHtmlPath, getString(R.string.privacy_policy)); + } + + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Privacy"); + } + } + }) + .build()); + privacyCardBuilder.addItem(new MaterialAboutActionItem.Builder() + .text(R.string.acknowledgment) + .icon(R.drawable.ic_acknowledgment) + .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { + @Override + public void onClick() { + if (config.dialog == null) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(config.acknowledgmentHtmlPath))); + } else { + config.dialog.open(AboutActivity.this, config.acknowledgmentHtmlPath, getString(R.string.acknowledgment)); + } + + if (config.analytics != null) { + config.analytics.logUiEvent(config.logUiEventName, "Acknowlegement"); + } + } + }) + .build()); + + + return new MaterialAboutList.Builder() + .addCard(generalInfoCardBuilder.build()) + .addCard(supportCardBuilder.build()) + .addCard(shareCardBuilder.build()) + .addCard(aboutCardBuilder.build()) + .addCard(socialNetworksCardBuilder.build()) + .addCard(privacyCardBuilder.build()) + .build(); + } + + @Override + protected CharSequence getActivityTitle() { + return getString(R.string.about_screen_title); + } + + public static void getOpenFacebookIntent(Activity context, String name) { + Intent intent; + try { + context.getPackageManager().getPackageInfo("com.facebook.katana", 0); + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + name)); + } catch (Exception e) { + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + name)); + } + context.startActivity(intent); + } + + + public static void startTwitter(Activity context, String name) { + Intent intent; + try { + context.getPackageManager().getPackageInfo("com.twitter.android", 0); + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?screen_name=" + name)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + } catch (Exception e) { + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + name)); + } + context.startActivity(intent); + } + + public void openApp(String packageName, boolean googlePlay) {//true if Google Play, false if Amazon Store + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "market://details?id=" : "amzn://apps/android?p=") + packageName))); + } catch (ActivityNotFoundException e1) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "http://play.google.com/store/apps/details?id=" : "http://www.amazon.com/gp/mas/dl/android?p=") + packageName))); + } catch (ActivityNotFoundException e2) { + Toast.makeText(this, "You don't have any app that can open this link", Toast.LENGTH_SHORT).show(); + } + } + } + + public void openPublisher(boolean googlePlay, String publisher) {//true if Google Play, false if Amazon Store + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "market://search?q=pub:" : "amzn://apps/android?showAll=1&p=") + publisher))); + } catch (ActivityNotFoundException e1) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse((googlePlay ? "http://play.google.com/store/search?q=pub:" : "http://www.amazon.com/gp/mas/dl/android?showAll=1&p=") + publisher))); + } catch (ActivityNotFoundException e2) { + Toast.makeText(this, "You don't have any app that can open this link", Toast.LENGTH_SHORT).show(); + } + } + } +} diff --git a/library/src/main/java/com/eggheadgames/aboutbox/share/EmailUtil.java b/library/src/main/java/com/eggheadgames/aboutbox/share/EmailUtil.java new file mode 100644 index 0000000..a186245 --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/share/EmailUtil.java @@ -0,0 +1,43 @@ +package com.eggheadgames.aboutbox.share; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; + +import com.eggheadgames.aboutbox.AboutConfig; +import com.eggheadgames.aboutbox.BuildConfig; + +public final class EmailUtil { + + private EmailUtil() { + // Utility class + } + + public static void contactUs(Activity activity) { + AboutConfig config = AboutConfig.getInstance(); + + final Uri mailto = Uri.fromParts("mailto", config.emailAddress, null); + + final String emailSubject; + + if ("google".equals(BuildConfig.FLAVOR)) { + emailSubject = config.emailSubject + "G"; + } else if ("amazon".equals(BuildConfig.FLAVOR)) { + emailSubject = config.emailSubject + "K"; + } else { + emailSubject = config.emailSubject; + } + + try { + Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailto); + emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); + emailIntent.putExtra(Intent.EXTRA_TEXT, config.emailBody); + activity.startActivity(Intent.createChooser(emailIntent, "Send email...")); + } catch (Exception e) { + if (config.analytics != null) { + config.analytics.logException(e, false); + } + } + + } +} diff --git a/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java b/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java new file mode 100644 index 0000000..364c9ab --- /dev/null +++ b/library/src/main/java/com/eggheadgames/aboutbox/share/ShareUtil.java @@ -0,0 +1,66 @@ +package com.eggheadgames.aboutbox.share; + +import android.app.Activity; +import android.text.TextUtils; + +import com.eggheadgames.aboutbox.AboutConfig; + +import io.branch.indexing.BranchUniversalObject; +import io.branch.referral.Branch; +import io.branch.referral.BranchError; +import io.branch.referral.SharingHelper; +import io.branch.referral.util.LinkProperties; +import io.branch.referral.util.ShareSheetStyle; + +public final class ShareUtil { + + private ShareUtil() { + // Utility class + } + + public static void share(Activity activity) { + BranchUniversalObject branchUniversalObject = new BranchUniversalObject(); + final AboutConfig config = AboutConfig.getInstance(); + + ShareSheetStyle shareSheetStyle = new ShareSheetStyle(activity, config.shareMessageTitle, + config.shareMessage) + .setCopyUrlStyle(activity.getResources().getDrawable(android.R.drawable.ic_menu_send), + "Copy", "Added to clipboard") + .setMoreOptionStyle(activity.getResources().getDrawable(android.R.drawable.ic_menu_search), "Show more") + .addPreferredSharingOption(SharingHelper.SHARE_WITH.FACEBOOK) + .addPreferredSharingOption(SharingHelper.SHARE_WITH.EMAIL) + .setSharingTitle(config.sharingTitle); + + branchUniversalObject.showShareSheet(activity, + new LinkProperties(), shareSheetStyle, new Branch.BranchLinkShareListener() { + @Override + public void onShareLinkDialogLaunched() { + //nothing + } + + @Override + public void onShareLinkDialogDismissed() { + if (config.analytics != null) { + config.analytics.logUiEvent("Share", "Dismissed"); + } + } + + @Override + public void onLinkShareResponse(String sharedLink, String sharedChannel, BranchError error) { + if (config.analytics != null) { + if (error == null || TextUtils.isEmpty(error.getMessage())) { + config.analytics.logUiEvent("Share", sharedChannel); + } else { + config.analytics.logUiEvent("Share Failure", error.getMessage()); + } + } + } + + @Override + public void onChannelSelected(String channelName) { + //nothing + } + }); + + } +} diff --git a/library/src/main/res/drawable/ic_about_black.xml b/library/src/main/res/drawable/ic_about_black.xml new file mode 100644 index 0000000..0154a30 --- /dev/null +++ b/library/src/main/res/drawable/ic_about_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_acknowledgment.xml b/library/src/main/res/drawable/ic_acknowledgment.xml new file mode 100644 index 0000000..e1b8d12 --- /dev/null +++ b/library/src/main/res/drawable/ic_acknowledgment.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_email_black.xml b/library/src/main/res/drawable/ic_email_black.xml new file mode 100644 index 0000000..2d2e0e3 --- /dev/null +++ b/library/src/main/res/drawable/ic_email_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_facebook_24.xml b/library/src/main/res/drawable/ic_facebook_24.xml new file mode 100644 index 0000000..80472d1 --- /dev/null +++ b/library/src/main/res/drawable/ic_facebook_24.xml @@ -0,0 +1,12 @@ + + + + diff --git a/library/src/main/res/drawable/ic_privacy.xml b/library/src/main/res/drawable/ic_privacy.xml new file mode 100644 index 0000000..9a14b68 --- /dev/null +++ b/library/src/main/res/drawable/ic_privacy.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_review.xml b/library/src/main/res/drawable/ic_review.xml new file mode 100644 index 0000000..42c9e29 --- /dev/null +++ b/library/src/main/res/drawable/ic_review.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_share_black.xml b/library/src/main/res/drawable/ic_share_black.xml new file mode 100644 index 0000000..4f8dba1 --- /dev/null +++ b/library/src/main/res/drawable/ic_share_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_try_other_apps.xml b/library/src/main/res/drawable/ic_try_other_apps.xml new file mode 100644 index 0000000..59ddfb3 --- /dev/null +++ b/library/src/main/res/drawable/ic_try_other_apps.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/drawable/ic_twitter_24dp.xml b/library/src/main/res/drawable/ic_twitter_24dp.xml new file mode 100644 index 0000000..ba9d5cd --- /dev/null +++ b/library/src/main/res/drawable/ic_twitter_24dp.xml @@ -0,0 +1,16 @@ + + + + diff --git a/library/src/main/res/drawable/ic_web_black_24dp.xml b/library/src/main/res/drawable/ic_web_black_24dp.xml new file mode 100644 index 0000000..c4bfb99 --- /dev/null +++ b/library/src/main/res/drawable/ic_web_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml new file mode 100644 index 0000000..7176b8d --- /dev/null +++ b/library/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #FF4081 + #3F51B5 + #303F9F + \ No newline at end of file diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml new file mode 100644 index 0000000..041b81c --- /dev/null +++ b/library/src/main/res/values/strings.xml @@ -0,0 +1,15 @@ + + AboutBox + Leave Review + Contact Support + Try Other Apps + Version + Facebook + Twitter + Web + Acknowledgment + Privacy Policy + About + Share + + diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml new file mode 100644 index 0000000..41c850f --- /dev/null +++ b/library/src/main/res/values/styles.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d8f14a1 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':library'