Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Najm/sync repo #6

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gradle
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: android
sudo: required
dist: trusty

env:
global:
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=28.0.3

android:
components:
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS
- android-$ANDROID_API
licenses:
- '.+'

script: gradle clean test

before_install:
- yes | sdkmanager "platforms;android-28"
- wget https://services.gradle.org/distributions/gradle-5.3-bin.zip
- unzip -qq gradle-5.3-bin.zip
- export GRADLE_HOME=$PWD/gradle-5.3
- export PATH=$GRADLE_HOME/bin:$PATH
- gradle -v
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This repository contains the [Button](https://www.usebutton.com/) integration fo

```groovy
dependencies {
compile 'com.mparticle:android-button-kit:5+'
implementation 'com.mparticle:android-button-kit:5+'
}
```
2. Follow the mParticle Android SDK [quick-start](https://github.com/mParticle/mparticle-android-sdk), then rebuild and launch your app, and verify that you see `"Button detected"` in the output of `adb logcat`.
Expand Down
20 changes: 20 additions & 0 deletions build.gradle
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

buildscript {
if (!project.hasProperty('version') || project.version.equals('unspecified')) {
project.version = '+'
}

repositories {
google()
mavenLocal()
Expand All @@ -9,11 +14,26 @@ buildscript {
}
}

repositories {
google()
}

apply plugin: 'com.mparticle.kit'

android {
defaultConfig {
minSdkVersion 15
consumerProguardFiles 'consumer-proguard.pro'
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
api 'com.usebutton.merchant:button-merchant:1.1.2'

testImplementation 'com.squareup.assertj:assertj-android:1.2.0'
}
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Button Kit sample app

Sample app that can be used to test mParticle Button integration or for local kit development.

## Getting started

#### 1. Clone the repository

```bash
git clone git@github.com:mparticle-integrations/mparticle-android-integration-button.git
```

#### 2. Configure mParticle key and secret in `~/.gradle/gradle.properties`
```bash
mParticleKey=...
mParticleSecret=...
```

#### 3. Build and install sample app

```bash
./gradlew installDebug
```

***

## Frequently Asked Questions

#### Receiving the following error: `Bad API request - is the correct API key and secret configured?`
Confirm that mParticle SDK credentials are being properly retrieved in the `build.gradle` file as well as if the credentials themselves are correct.
If you recently issued new credentials, try re-installing the sample app as the credentials may have been cached.

#### ButtonKit is not initializing
Confirm the following:
1. The proper package name (e.g. `com.example.buttonkit`) is shown in the mParticle Dashboard.
2. There exists an input (the sample/test app) and an output (Button integration from mParticle marketplace) and that it is active.
3. The Button integration is configured properly with a valid [Application ID](https://app.usebutton.com/account/login/?next=/settings/organization) in the mParticle Dashboard.
4. You are not behind a proxy (e.g. Charles Proxy).
63 changes: 63 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
buildscript {
ext.kotlin_version = '1.2.50'

repositories {
google()
mavenLocal()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28

defaultConfig {
applicationId "com.example.buttonkit"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

all {
buildConfigField("String", "MP_KEY", '"' + mParticleKey + '"')
buildConfigField("String", "MP_SECRET", '"' + mParticleSecret + '"')
}
}
}

repositories {
jcenter()
google()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

// In production, import the ButtonKit like so:
// implementation 'com.mparticle:android-button-kit:5.4.4'

// Otherwise, for development, you can import the current root project
implementation(rootProject) {
exclude group: 'com.android.support', module: 'customtabs'
exclude group: 'com.android.support', module: 'support-media-compat'
exclude group: 'com.android.support', module: 'support-v4'
}
}
21 changes: 21 additions & 0 deletions sample/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
36 changes: 36 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.buttonkit">

<application
android:name=".SampleApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".IntentActivity"
android:parentActivityName=".MainActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>

<data android:scheme="https"/>
<data android:host="christmas.bttn.io"/>
<data android:pathPattern=".*"/>
</intent-filter>
</activity>
</application>

</manifest>
22 changes: 22 additions & 0 deletions sample/src/main/java/com/example/buttonkit/IntentActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.buttonkit

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.mparticle.MParticle
import com.mparticle.kits.ButtonKit
import kotlinx.android.synthetic.main.activity_intent.tv_attribution_token

class IntentActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_intent)

actionBar?.setDisplayShowHomeEnabled(true)

val button = MParticle.getInstance().getKitInstance(
MParticle.ServiceProviders.BUTTON) as ButtonKit?

tv_attribution_token.text = button?.attributionToken
}
}
31 changes: 31 additions & 0 deletions sample/src/main/java/com/example/buttonkit/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.buttonkit

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
import com.mparticle.MParticle
import com.mparticle.kits.ButtonKit
import kotlinx.android.synthetic.main.activity_main.bt_attribution_refresh
import kotlinx.android.synthetic.main.activity_main.tv_attribution_token

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val button = MParticle.getInstance().getKitInstance(
MParticle.ServiceProviders.BUTTON) as ButtonKit?

bt_attribution_refresh.setOnClickListener {
val token = button?.attributionToken

if (!TextUtils.isEmpty(token)) {
tv_attribution_token.text = token
} else {
tv_attribution_token.text = getString(R.string.label_default_token)
}
}

}
}
42 changes: 42 additions & 0 deletions sample/src/main/java/com/example/buttonkit/SampleApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.example.buttonkit

import android.app.Application
import android.content.Intent
import android.net.Uri
import android.util.Log
import com.mparticle.AttributionError
import com.mparticle.AttributionListener
import com.mparticle.AttributionResult
import com.mparticle.MParticle
import com.mparticle.MParticleOptions

class SampleApplication : Application() , AttributionListener{

private val TAG = "ButtonKitSample"

override fun onCreate() {
super.onCreate()

val options = MParticleOptions.builder(this)
.credentials(BuildConfig.MP_KEY, BuildConfig.MP_SECRET)
.environment(MParticle.Environment.AutoDetect)
.attributionListener(this@SampleApplication)
.logLevel(MParticle.LogLevel.VERBOSE)
.build()
MParticle.start(options)
}

override fun onResult(result: AttributionResult?) {
if (result?.serviceProviderId == MParticle.ServiceProviders.BUTTON) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(result.link))
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
}

override fun onError(error: AttributionError?) {
if (error?.serviceProviderId == MParticle.ServiceProviders.BUTTON) {
Log.e(TAG, "Attribution error: " + error.message)
}
}
}
34 changes: 34 additions & 0 deletions sample/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
android:width="108dp">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>
Loading