Skip to content

Commit f52145e

Browse files
authored
Merge pull request #11 from AdevintaSpain/integration
Integrate upstream changes
2 parents 8a5dbdd + 34ecb12 commit f52145e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1060
-178
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ $RECYCLE.BIN/
120120
# Icon must end with two \r
121121
Icon
122122

123-
124123
# Thumbnails
125124
._*
126125

@@ -148,4 +147,8 @@ Temporary Items
148147
build/
149148

150149
# Ignore Gradle GUI config
151-
gradle-app.setting
150+
gradle-app.setting
151+
152+
# VSCode
153+
.classpath
154+
.project

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## 6.0.0
2+
3+
##### Breaking
4+
- Updated to [Braze Android SDK 9.0.0](https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#900).
5+
6+
## 5.0.0
7+
8+
##### Fixed
9+
- Fixes an issue where purchases would be logged for any `track` payload with `products` included. After this fix, a `track` payload must either contain `revenue` or have the event name `Order Completed` to result in a logged purchase to Braze.
10+
- Fixes an issue where `anonymousId` and `userId` could be set as custom attributes when calling `identify()`.
11+
12+
## 4.0.0
13+
14+
##### Breaking
15+
- Log separate purchases for each `product` in the `products` array in a `track` call.
16+
- In the past we always used the event name as the Braze product ID.
17+
- Now if a track call has the event name `Order Completed` or key `revenue` included in `properties` and has a `products` array, we will log each object in the array as a separate purchase using `productId` as the Braze product ID. `price` and `quantity` will be read from the individual array if available and all non-Braze recognized fields from the high level `properties` and each individual array will be combined and sent as event properties.
18+
- If there is no `products` array we will continue using the event name as the Braze product ID if the key `revenue` is included in `properties`.
19+
20+
## 3.0.0
21+
22+
##### Breaking
23+
- Updated to [Braze Android SDK 6.0.0](https://github.com/Appboy/appboy-android-sdk/blob/master/CHANGELOG.md#600).
24+
25+
##### Changed
26+
- The `campaign` property value is now casted to `ValueMap` instead of its `Properties` subclass.
27+
- See https://github.com/Appboy/appboy-segment-android/pull/19. Thanks @ciaranmul!
28+
- The `appboy-sample` sample app is now located within this repo instead of a separate standalone repo.
29+
- The SDK code has been moved into a directory called `appboy-segment-integration`.
30+
31+
## 2.5.2
32+
33+
##### Fixed
34+
- Fixed potential for null pointer exception in the `identify()` method resulting from a null value for `Appboy.getCurrentUser()`.
35+
136
## 2.5.1
237

338
##### Added

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2018 Braze, Inc.
1+
Copyright (c) 2020 Braze, Inc.
22
All rights reserved.
33

44
* The use of source code or binaries contained within Braze's sample apps, documentation, stub APIs and other related utilities is permitted only to enable testing and quality assurance of integrations with the Braze platform by current customers of Braze.

appboy-sample/app/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 29
5+
buildToolsVersion "29.0.0"
6+
7+
defaultConfig {
8+
applicationId "com.appboy.segment.appboysample"
9+
minSdkVersion 16
10+
targetSdkVersion 29
11+
versionCode 1
12+
versionName "1.0.0"
13+
}
14+
compileOptions {
15+
sourceCompatibility JavaVersion.VERSION_1_8
16+
targetCompatibility JavaVersion.VERSION_1_8
17+
}
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
}
25+
26+
// Grabs the first line of the changelog to get the current version. Expects the line to start with Markdown syntax
27+
// (ex: ## major.minor.build)
28+
def changelogFile = new File("../public/CHANGELOG.md")
29+
if (changelogFile.exists()) {
30+
changelogFile.withReader {
31+
version = it.readLine().substring(3)
32+
}
33+
logger.lifecycle("Setting version to last recorded version in `../appboy-segment-integration/CHANGELOG.md`: " + version)
34+
} else {
35+
version = "+"
36+
logger.lifecycle("Setting version to highest version found in local maven cache: " + version)
37+
}
38+
39+
dependencies {
40+
implementation fileTree(dir: 'libs', include: ['*.jar'])
41+
implementation 'com.android.support:appcompat-v7:28.0.0'
42+
implementation 'com.android.support:design:28.0.0'
43+
implementation('com.segment.analytics.android:analytics:4.3.1') {
44+
transitive = true
45+
}
46+
implementation "com.appboy:appboy-segment-integration:${version}"
47+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/brianwheeler/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.appboy.segment.appboysample" >
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme"
13+
android:name=".AppboySegmentApplication">
14+
<activity
15+
android:name=".MainActivity"
16+
android:label="@string/app_name"
17+
android:theme="@style/AppTheme.NoActionBar" >
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity android:name="com.appboy.ui.AppboyWebViewActivity" />
24+
</application>
25+
</manifest>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.appboy.segment.appboysample;
2+
3+
import android.app.Application;
4+
import android.util.Log;
5+
6+
import com.appboy.Constants;
7+
import com.appboy.support.AppboyLogger;
8+
import com.segment.analytics.Analytics;
9+
import com.segment.analytics.android.integrations.appboy.AppboyIntegration;
10+
11+
public class AppboySegmentApplication extends Application {
12+
private static final String TAG = String.format("%s.%s", Constants.APPBOY_LOG_TAG_PREFIX, AppboySegmentApplication.class.getName());
13+
private static final String WRITE_KEY = @"YOUR_WRITE_KEY";
14+
private static final String APPBOY_KEY = "Appboy";
15+
public static boolean sAppboySegmentEnabled = false;
16+
17+
@Override public void onCreate() {
18+
super.onCreate();
19+
AppboyLogger.setLogLevel(Log.VERBOSE);
20+
Analytics.Builder builder = new Analytics.Builder(this, WRITE_KEY);
21+
builder.use(AppboyIntegration.FACTORY);
22+
builder.logLevel(Analytics.LogLevel.VERBOSE);
23+
Analytics.setSingletonInstance(builder.build());
24+
25+
Analytics.with(this).onIntegrationReady(APPBOY_KEY, new Analytics.Callback() {
26+
@Override
27+
public void onReady(Object instance) {
28+
Log.i(TAG, "analytics.onIntegrationReady() called");
29+
sAppboySegmentEnabled = true;
30+
}
31+
});
32+
}
33+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package com.appboy.segment.appboysample;
2+
3+
import android.content.Context;
4+
import android.support.v4.app.Fragment;
5+
import android.support.v4.app.FragmentManager;
6+
import android.support.v4.app.FragmentTransaction;
7+
import android.os.Bundle;
8+
import android.util.Log;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.support.v7.widget.Toolbar;
11+
import android.view.Menu;
12+
import android.view.MenuItem;
13+
import android.view.inputmethod.InputMethodManager;
14+
import android.widget.Toast;
15+
16+
import com.appboy.Constants;
17+
import com.appboy.support.AppboyLogger;
18+
import com.appboy.ui.AppboyFeedFragment;
19+
20+
public class MainActivity extends AppCompatActivity {
21+
private static final String TAG = String.format("%s.%s", Constants.APPBOY_LOG_TAG_PREFIX, MainActivity.class.getName());
22+
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
27+
AppboyLogger.setLogLevel(Log.VERBOSE);
28+
setContentView(R.layout.activity_main);
29+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
30+
setSupportActionBar(toolbar);
31+
32+
final FragmentManager fragmentManager = getSupportFragmentManager();
33+
Fragment currentFragment = fragmentManager.findFragmentById(R.id.root);
34+
35+
if (currentFragment == null) {
36+
fragmentManager.beginTransaction().add(R.id.root, new MainFragment()).commit();
37+
}
38+
}
39+
40+
@Override
41+
public boolean onCreateOptionsMenu(Menu menu) {
42+
// Inflate the menu; this adds items to the action bar if it is present.
43+
getMenuInflater().inflate(R.menu.menu_main, menu);
44+
return true;
45+
}
46+
47+
@Override
48+
public boolean onOptionsItemSelected(MenuItem item) {
49+
if (!AppboySegmentApplication.sAppboySegmentEnabled) {
50+
Toast.makeText(this, "Appboy integration disabled. Doing nothing.", Toast.LENGTH_LONG).show();
51+
return super.onOptionsItemSelected(item);
52+
}
53+
// Handle action bar item clicks here. The action bar will
54+
// automatically handle clicks on the Home/Up button, so long
55+
// as you specify a parent activity in AndroidManifest.xml.
56+
int id = item.getItemId();
57+
if (id == R.id.newsfeed) {
58+
replaceCurrentFragment(new AppboyFeedFragment());
59+
return true;
60+
}
61+
return super.onOptionsItemSelected(item);
62+
}
63+
64+
private void replaceCurrentFragment(Fragment newFragment) {
65+
FragmentManager fragmentManager = getSupportFragmentManager();
66+
Fragment currentFragment = fragmentManager.findFragmentById(R.id.root);
67+
68+
if (currentFragment != null && currentFragment.getClass().equals(newFragment.getClass())) {
69+
Log.i(TAG, String.format("Fragment of type %s is already the active fragment. Ignoring request to replace " +
70+
"current fragment.", currentFragment.getClass()));
71+
return;
72+
}
73+
74+
hideSoftKeyboard();
75+
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
76+
fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
77+
android.R.anim.fade_in, android.R.anim.fade_out);
78+
fragmentTransaction.replace(R.id.root, newFragment, newFragment.getClass().toString());
79+
if (currentFragment != null) {
80+
fragmentTransaction.addToBackStack(newFragment.getClass().toString());
81+
} else {
82+
fragmentTransaction.addToBackStack(null);
83+
}
84+
fragmentTransaction.commit();
85+
}
86+
87+
private void hideSoftKeyboard() {
88+
if (getCurrentFocus() != null) {
89+
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
90+
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
91+
InputMethodManager.RESULT_UNCHANGED_SHOWN);
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)