Skip to content

Commit 75cfb21

Browse files
authored
Merge pull request #96 from Instabug/update-sample-app
Updating sample app
2 parents 456baf0 + 261914e commit 75cfb21

36 files changed

+284
-1229
lines changed

app/build.gradle

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion '26.0.2'
4+
compileSdkVersion 27
65

76
defaultConfig {
87
applicationId "com.example.instabug"
98
minSdkVersion 15
10-
targetSdkVersion 26
9+
targetSdkVersion 27
1110
versionCode 1
1211
versionName "1.0"
1312
multiDexEnabled true
@@ -41,21 +40,25 @@ repositories {
4140

4241
dependencies {
4342
implementation fileTree(dir: 'libs', include: ['*.jar'])
44-
implementation 'com.android.support:multidex:1.0.2'
45-
implementation 'com.android.support:design:26.0.2'
46-
implementation 'com.android.support:appcompat-v7:26.0.2'
47-
// TODO if you use a lower version than 9.0.0 (min is 7.5.0) you should uncomment the exclude line to avoid errors
48-
implementation 'com.google.android.gms:play-services:11.4.2'
43+
implementation 'com.android.support:multidex:1.0.3'
44+
implementation "com.android.support:design:$rootProject.ext.androidSupport"
45+
implementation "com.android.support:appcompat-v7:$rootProject.ext.androidSupport"
46+
47+
implementation 'com.google.firebase:firebase-core:16.0.0'
48+
implementation 'com.google.firebase:firebase-messaging:17.0.0'
49+
4950
// TODO add the following 2 lines if you exclude io.reactivex from Instabug
5051
// implementation 'io.reactivex:rxjava:1.0.13'
5152
// implementation 'io.reactivex:rxandroid:1.0.1'
52-
implementation('com.instabug.library:instabug:4.11.1') {
53+
implementation('com.instabug.library:instabug:4.15.0') {
5354
// TODO uncomment this line to exclude RxJava from Instabug and use your own version
5455
// exclude group: 'io.reactivex'
5556

5657
// TODO uncomment next line if you're facing compilation issue in build.gradle about gms different versions
5758
// exclude group: 'com.android.support'
5859
}
60+
implementation 'petrov.kristiyan:colorpicker-library:1.1.8'
61+
5962

6063

6164
}

app/proguard-rules.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18-
-dontwarn butterknife.internal.**
18+
-dontwarn butterknife.internal.**
19+
-keep class com.google.firebase.provider.FirebaseInitProvider
20+
-keep class com.example.instabug.**

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<category android:name="android.intent.category.LAUNCHER" />
3737
</intent-filter>
3838
</activity>
39-
40-
<activity android:name=".ui.activities.GoogleMapsActivity" />
39+
<activity android:name=".ui.activities.SettingsActivity"
40+
android:theme="@style/AppTheme.NoActionBar"/>
4141

4242
<meta-data
4343
android:name="com.google.android.gms.version"
@@ -46,32 +46,21 @@
4646
android:name="com.google.android.geo.API_KEY"
4747
android:value="AIzaSyD1NsFNyD12H_4lzgzth7lUxUAbZzyKEL4" />
4848

49-
<activity android:name=".ui.activities.OpenGLActivity" />
50-
51-
<receiver
52-
android:name="com.google.android.gms.gcm.GcmReceiver"
53-
android:exported="true"
54-
android:permission="com.google.android.c2dm.permission.SEND">
55-
<intent-filter>
56-
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
57-
<category android:name="com.example.instabug" />
58-
</intent-filter>
59-
</receiver>
60-
6149
<service
62-
android:name="com.example.instabug.gcm.InstabugGCMListenerService"
50+
android:name="com.example.instabug.fcm.InstabugFCMListenerService"
6351
android:exported="false">
6452
<intent-filter>
6553
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
6654
</intent-filter>
6755
</service>
56+
6857
<service
69-
android:name="com.example.instabug.gcm.InstabugInstanceIDListenerService"
58+
android:name="com.example.instabug.fcm.InstabugInstanceIDListenerService"
7059
android:exported="false">
7160
<intent-filter>
7261
<action android:name="com.google.android.gms.iid.InstanceID" />
7362
</intent-filter>
7463
</service>
75-
<service android:name="com.example.instabug.gcm.RegistrationIntentService"/>
64+
<service android:name="com.example.instabug.fcm.RegistrationIntentService"/>
7665
</application>
7766
</manifest>
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
package com.example.instabug;
22

33
import android.app.Application;
4+
import android.content.Context;
45
import android.support.multidex.MultiDex;
56

67
import com.instabug.library.Instabug;
78
import com.instabug.library.InstabugColorTheme;
89
import com.instabug.library.InstabugCustomTextPlaceHolder;
9-
import com.instabug.library.bugreporting.model.ReportCategory;
1010
import com.instabug.library.internal.module.InstabugLocale;
1111
import com.instabug.library.invocation.InstabugInvocationEvent;
12+
import com.instabug.library.ui.onboarding.WelcomeMessage;
1213

13-
import java.util.ArrayList;
1414
import java.util.Locale;
1515

1616

1717
public class SampleApplication extends Application {
18+
@Override
19+
protected void attachBaseContext(Context base) {
20+
super.attachBaseContext(base);
21+
MultiDex.install(this);
22+
}
23+
1824
@Override
1925
public void onCreate() {
2026
super.onCreate();
21-
MultiDex.install(this);
2227

2328
//initialing instabug
24-
new Instabug.Builder(this, "f501f761142981d54b1fdea93963a934")
29+
new Instabug.Builder(this, "48ad905e141bc665d064945f423aa414")
2530
.setInvocationEvent(InstabugInvocationEvent.SHAKE)
2631
.build();
2732

28-
//adding some customizations
29-
Instabug.setEmailFieldRequired(false);
3033
//Choosing instabug theme
3134
Instabug.setTheme(InstabugColorTheme.InstabugColorThemeLight);
3235
//Choosing type of attachments allowed
3336
//1. initial screenshot, 2. extra screenshot, 3. image from gallery, 4. voice note
3437
//5. screen record
35-
Instabug.setAttachmentTypesEnabled(true, true, true, true, true);
36-
//For setting instabug bug intro message enabled or disabled
37-
Instabug.setIntroMessageEnabled(false);
38+
Instabug.setWelcomeMessageState(WelcomeMessage.State.LIVE);
3839

3940
// TODO the following are 3 acceptable ways to force Locale in Instabug (last one is the only 1 applied)
4041
Instabug.setLocale(new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(),
4142
InstabugLocale.SIMPLIFIED_CHINESE.getCountry()));
4243
Instabug.setLocale(new Locale(InstabugLocale.FRENCH.getCode()));
43-
Instabug.setLocale(Locale.GERMAN);
44+
Instabug.setLocale(Locale.ENGLISH);
4445

4546
//To show instabug debug logs if necessary
4647
Instabug.setDebugEnabled(true);
@@ -52,21 +53,9 @@ public void onCreate() {
5253

5354
Instabug.setCustomTextPlaceHolders(placeHolder);
5455

55-
//Setting report categories
56-
ArrayList<ReportCategory> reportCategories = new ArrayList<>();
57-
reportCategories.add(
58-
ReportCategory.getInstance().withLabel("Map").withIcon(android.R.drawable
59-
.ic_dialog_map));
60-
reportCategories.add(ReportCategory.getInstance()
61-
.withLabel("Alert")
62-
.withIcon(android.R.drawable.ic_dialog_alert));
63-
reportCategories.add(
64-
ReportCategory.getInstance().withLabel("Mail").withIcon(android.R.drawable
65-
.ic_dialog_email));
66-
67-
Instabug.setReportCategories(reportCategories);
68-
6956
//setting user attributes
7057
Instabug.setUserAttribute("USER_TYPE", "instabug user");
58+
59+
Instabug.setAutoScreenRecordingEnabled(true);
7160
}
7261
}

app/src/main/java/com/example/instabug/gcm/InstabugGCMListenerService.java renamed to app/src/main/java/com/example/instabug/fcm/InstabugFCMListenerService.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package com.example.instabug.gcm;
1+
package com.example.instabug.fcm;
22

33
import com.example.instabug.R;
44
import com.example.instabug.ui.activities.MainActivity;
5-
import com.google.android.gms.gcm.GcmListenerService;
5+
import com.google.firebase.messaging.FirebaseMessagingService;
6+
import com.google.firebase.messaging.RemoteMessage;
67
import com.instabug.library.Instabug;
78

89
import android.app.NotificationManager;
@@ -11,44 +12,37 @@
1112
import android.content.Intent;
1213
import android.media.RingtoneManager;
1314
import android.net.Uri;
14-
import android.os.Bundle;
1515
import android.support.v4.app.NotificationCompat;
1616
import android.util.Log;
1717

1818
/**
1919
* Created by vezikon on 6/27/16.
2020
*/
21-
public class InstabugGCMListenerService extends GcmListenerService {
22-
private static final String TAG = "InstabugGCMListenerService";
21+
public class InstabugFCMListenerService extends FirebaseMessagingService {
22+
private static final String TAG = "FCMListenerService";
2323

24-
/**
25-
* Called when message is received.
26-
*
27-
* @param from SenderID of the sender.
28-
* @param data Data bundle containing message data as key/value pairs.
29-
* For Set of keys use data.keySet().
30-
*/
31-
// [START receive_message]
3224
@Override
33-
public void onMessageReceived(String from, Bundle data) {
34-
String message = data.getString("message");
35-
Log.d(TAG, "From: " + from);
25+
public void onMessageReceived(RemoteMessage remoteMessage) {
26+
super.onMessageReceived(remoteMessage);
27+
28+
String message = remoteMessage.getData().get("message");
29+
Log.d(TAG, "From: " + remoteMessage.getFrom());
3630
Log.d(TAG, "Message: " + message);
3731

3832
//Check first if notification related to Instabug or not
39-
if(Instabug.isInstabugNotification(data)){
33+
if (Instabug.isInstabugNotification(remoteMessage.getData())) {
4034
//Shown notification related to Instabug
41-
Instabug.showNotification(data);
42-
}else {
35+
Instabug.showNotification(remoteMessage.getData());
36+
} else {
4337
sendNotification(message);
4438
}
39+
4540
}
46-
// [END receive_message]
4741

4842
/**
49-
* Create and show a simple notification containing the received GCM message.
43+
* Create and show a simple notification containing the received FCM message.
5044
*
51-
* @param message GCM message received.
45+
* @param message FCM message received.
5246
*/
5347
private void sendNotification(String message) {
5448
Intent intent = new Intent(this, MainActivity.class);
@@ -59,7 +53,7 @@ private void sendNotification(String message) {
5953
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
6054
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
6155
.setSmallIcon(R.mipmap.ic_launcher)
62-
.setContentTitle("GCM Message")
56+
.setContentTitle("FCM Message")
6357
.setContentText(message)
6458
.setAutoCancel(true)
6559
.setSound(defaultSoundUri)

app/src/main/java/com/example/instabug/gcm/InstabugInstanceIDListenerService.java renamed to app/src/main/java/com/example/instabug/fcm/InstabugInstanceIDListenerService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package com.example.instabug.gcm;
1+
package com.example.instabug.fcm;
22

33
import android.content.Intent;
44

5-
import com.google.android.gms.iid.InstanceIDListenerService;
5+
import com.google.firebase.iid.FirebaseInstanceIdService;
66

77
/**
88
* Created by vezikon on 6/27/16.
99
*/
10-
public class InstabugInstanceIDListenerService extends InstanceIDListenerService {
10+
public class InstabugInstanceIDListenerService extends FirebaseInstanceIdService {
1111

1212
private static final String TAG = "InstabugInstanceIDLS";
1313

app/src/main/java/com/example/instabug/gcm/QuickstartPreferences.java renamed to app/src/main/java/com/example/instabug/fcm/QuickstartPreferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.instabug.gcm;
1+
package com.example.instabug.fcm;
22

33
/**
44
* Created by vezikon on 6/27/16.

app/src/main/java/com/example/instabug/gcm/RegistrationIntentService.java renamed to app/src/main/java/com/example/instabug/fcm/RegistrationIntentService.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
package com.example.instabug.gcm;
1+
package com.example.instabug.fcm;
22

33
import android.app.IntentService;
44
import android.content.Intent;
55
import android.content.SharedPreferences;
66
import android.preference.PreferenceManager;
77
import android.support.v4.content.LocalBroadcastManager;
88
import android.util.Log;
9-
import com.google.android.gms.gcm.GoogleCloudMessaging;
10-
import com.google.android.gms.iid.InstanceID;
9+
import com.google.firebase.iid.FirebaseInstanceId;
1110
import com.instabug.library.Instabug;
1211

1312

@@ -28,17 +27,15 @@ protected void onHandleIntent(Intent intent) {
2827
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
2928

3029
try {
31-
// [START register_for_gcm]
30+
// [START register_for_fcm]
3231
// Initially this call goes out to the network to retrieve the token, subsequent calls
3332
// are local.
34-
// R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
33+
// R.string.fcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
3534
// See https://developers.google.com/cloud-messaging/android/start for details on this file.
3635
// [START get_token]
37-
InstanceID instanceID = InstanceID.getInstance(this);
38-
String token = instanceID.getToken(QuickstartPreferences.SENDER_ID,
39-
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
36+
String token = FirebaseInstanceId.getInstance().getToken();
4037
// [END get_token]
41-
Log.i(TAG, "GCM Registration Token: " + token);
38+
Log.i(TAG, "FCM Registration Token: " + token);
4239

4340
// TODO: Implement this method to send any registration to your app's servers.
4441
sendRegistrationToServer(token);
@@ -47,7 +44,7 @@ protected void onHandleIntent(Intent intent) {
4744
// sent to your server. If the boolean is false, send the token to your server,
4845
// otherwise your server should have already received the token.
4946
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
50-
// [END register_for_gcm]
47+
// [END register_for_fcm]
5148
} catch (Exception e) {
5249
Log.d(TAG, "Failed to complete token refresh", e);
5350
// If an exception happens while fetching the new token or updating our registration data
@@ -62,7 +59,7 @@ protected void onHandleIntent(Intent intent) {
6259
/**
6360
* Persist registration to third-party servers.
6461
*
65-
* Modify this method to associate the user's GCM registration token with any server-side account
62+
* Modify this method to associate the user's FCM registration token with any server-side account
6663
* maintained by your application.
6764
*
6865
* @param token The new token.

0 commit comments

Comments
 (0)