Skip to content

Commit 1ce432c

Browse files
committed
- Do network request on app start to use InstabugNetworkLogs
- Remove Unused views - Changing default locale to English - Remove Deprecated API calls - Updating SDK to latest version
1 parent 9ea189f commit 1ce432c

29 files changed

+219
-1146
lines changed

app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ dependencies {
4949
// TODO add the following 2 lines if you exclude io.reactivex from Instabug
5050
// implementation 'io.reactivex:rxjava:1.0.13'
5151
// implementation 'io.reactivex:rxandroid:1.0.1'
52-
implementation('com.instabug.library:instabug:4.14.0') {
52+
implementation('com.instabug.library:instabug:4.15.0') {
5353
// TODO uncomment this line to exclude RxJava from Instabug and use your own version
5454
// exclude group: 'io.reactivex'
5555

5656
// TODO uncomment next line if you're facing compilation issue in build.gradle about gms different versions
5757
// exclude group: 'com.android.support'
5858
}
59+
implementation 'petrov.kristiyan:colorpicker-library:1.1.8'
60+
5961

6062

6163
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 4 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,8 +46,6 @@
4646
android:name="com.google.android.geo.API_KEY"
4747
android:value="AIzaSyD1NsFNyD12H_4lzgzth7lUxUAbZzyKEL4" />
4848

49-
<activity android:name=".ui.activities.OpenGLActivity" />
50-
5149
<receiver
5250
android:name="com.google.android.gms.gcm.GcmReceiver"
5351
android:exported="true"

app/src/main/java/com/example/instabug/SampleApplication.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
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

1314
import java.util.ArrayList;
1415
import java.util.Locale;
@@ -21,26 +22,22 @@ public void onCreate() {
2122
MultiDex.install(this);
2223

2324
//initialing instabug
24-
new Instabug.Builder(this, "f501f761142981d54b1fdea93963a934")
25+
new Instabug.Builder(this, "48ad905e141bc665d064945f423aa414")
2526
.setInvocationEvent(InstabugInvocationEvent.SHAKE)
2627
.build();
2728

28-
//adding some customizations
29-
Instabug.setEmailFieldRequired(false);
3029
//Choosing instabug theme
3130
Instabug.setTheme(InstabugColorTheme.InstabugColorThemeLight);
3231
//Choosing type of attachments allowed
3332
//1. initial screenshot, 2. extra screenshot, 3. image from gallery, 4. voice note
3433
//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);
34+
Instabug.setWelcomeMessageState(WelcomeMessage.State.LIVE);
3835

3936
// TODO the following are 3 acceptable ways to force Locale in Instabug (last one is the only 1 applied)
4037
Instabug.setLocale(new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(),
4138
InstabugLocale.SIMPLIFIED_CHINESE.getCountry()));
4239
Instabug.setLocale(new Locale(InstabugLocale.FRENCH.getCode()));
43-
Instabug.setLocale(Locale.GERMAN);
40+
Instabug.setLocale(Locale.ENGLISH);
4441

4542
//To show instabug debug logs if necessary
4643
Instabug.setDebugEnabled(true);
@@ -52,20 +49,6 @@ public void onCreate() {
5249

5350
Instabug.setCustomTextPlaceHolders(placeHolder);
5451

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-
6952
//setting user attributes
7053
Instabug.setUserAttribute("USER_TYPE", "instabug user");
7154

app/src/main/java/com/example/instabug/ui/activities/GoogleMapsActivity.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

app/src/main/java/com/example/instabug/ui/activities/MainActivity.java

Lines changed: 24 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.instabug.library.invocation.InstabugInvocationMode;
3030
import com.instabug.library.logging.InstabugLog;
3131
import com.instabug.library.logging.InstabugNetworkLog;
32+
import com.instabug.library.ui.onboarding.WelcomeMessage;
3233

3334
import org.json.JSONException;
3435
import org.json.JSONObject;
@@ -40,17 +41,9 @@
4041
import java.io.OutputStreamWriter;
4142
import java.net.HttpURLConnection;
4243
import java.net.URL;
44+
import java.util.Set;
4345

44-
public class MainActivity extends BaseActivity
45-
implements NavigationView.OnNavigationItemSelectedListener {
46-
47-
DrawerLayout drawer;
48-
NavigationView navigationView;
49-
Spinner spinner;
50-
ImageView headerImage;
51-
52-
private static String[] colorNames = {"Red", "Blue", "Green", "Yellow"};
53-
private static int[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW};
46+
public class MainActivity extends BaseActivity {
5447

5548
@Override
5649
protected void onCreate(Bundle savedInstanceState) {
@@ -62,45 +55,10 @@ protected void onCreate(Bundle savedInstanceState) {
6255

6356
registerGCM();
6457

65-
drawer = findViewById(R.id.drawer_layout);
66-
navigationView = findViewById(R.id.nav_view);
67-
spinner = findViewById(R.id.spinner);
68-
headerImage = navigationView.getHeaderView(0).findViewById(R.id.headerImageView);
69-
headerImage.setOnClickListener(new View.OnClickListener() {
70-
@Override
71-
public void onClick(View v) {
72-
onHeaderImageClicked();
73-
}
74-
});
75-
7658
Toolbar toolbar = findViewById(R.id.toolbar);
7759
setSupportActionBar(toolbar);
7860

79-
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
80-
drawer.setDrawerListener(toggle);
81-
toggle.syncState();
82-
83-
navigationView.setNavigationItemSelectedListener(this);
84-
85-
if (savedInstanceState == null) {
86-
navigationView.setCheckedItem(navigationView.getMenu().getItem(0).getItemId());
87-
}
88-
89-
ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, colorNames);
90-
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
91-
spinner.setAdapter(dataAdapter);
92-
93-
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
94-
@Override
95-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
96-
Instabug.setPrimaryColor(colors[position]);
97-
}
98-
99-
@Override
100-
public void onNothingSelected(AdapterView<?> parent) {
101-
102-
}
103-
});
61+
doNetworkRequest();
10462
}
10563

10664
private void registerGCM() {
@@ -109,46 +67,16 @@ private void registerGCM() {
10967
startService(intent);
11068
}
11169

112-
public void onFeedbackFABClicked(View view) {
113-
Instabug.invoke();
114-
}
115-
116-
public void onShowIntroMessageClicked(View view) {
117-
Instabug.showIntroMessage();
118-
}
119-
120-
public void onFeedbackClicked(View view) {
121-
Instabug.invoke(InstabugInvocationMode.NEW_FEEDBACK);
122-
}
123-
124-
public void onBugReportClicked(View view) {
125-
Instabug.invoke(InstabugInvocationMode.NEW_FEEDBACK);
126-
}
127-
128-
public void onNewConversationClicked(View view) {
129-
Instabug.invoke(InstabugInvocationMode.NEW_CHAT);
130-
}
131-
132-
public void onConversationListClicked(View view) {
133-
Instabug.invoke(InstabugInvocationMode.CHATS_LIST);
70+
public void onShowLiveOnboardingMessageClicked(View view) {
71+
Instabug.showWelcomeMessage(WelcomeMessage.State.LIVE);
13472
}
13573

136-
public void onNewMessageCountClicked(View view) {
137-
Toast.makeText(this,
138-
"Number of unread messages: " +
139-
String.valueOf(Instabug.getUnreadMessagesCount()), Toast.LENGTH_SHORT)
140-
.show();
74+
public void onShowBetaOnboardingMessageClicked(View view) {
75+
Instabug.showWelcomeMessage(WelcomeMessage.State.BETA);
14176
}
14277

143-
public void onSendHandledExceptionClicked(View view) {
144-
new AlertDialog.Builder(MainActivity.this)
145-
.setMessage("Do you want to report a handled NullPointerException")
146-
.setPositiveButton("Why not?", new DialogInterface.OnClickListener() {
147-
@Override
148-
public void onClick(DialogInterface dialog, int which) {
149-
Instabug.reportException(new NullPointerException(), "Handled Exception");
150-
}
151-
}).show();
78+
public void onShowInstabugClicked(View view) {
79+
Instabug.invoke();
15280
}
15381

15482
public void onCrashTheAppClicked(View view) {
@@ -165,71 +93,29 @@ public void onClick(DialogInterface dialog, int which) {
16593
.show();
16694
}
16795

168-
public void onDoNetworkRequestClicked(View view) {
169-
new FetchMoviesData().execute();
170-
}
171-
172-
public void onHeaderImageClicked() {
173-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instabug.com"));
174-
startActivity(browserIntent);
96+
public void showNPSSurvey(View view) {
97+
Instabug.showSurvey("ulUaFocMCejDr3Ldd8VBaA");
17598
}
17699

177-
@Override
178-
public void onBackPressed() {
179-
if (drawer.isDrawerOpen(GravityCompat.START)) {
180-
drawer.closeDrawer(GravityCompat.START);
181-
} else {
182-
super.onBackPressed();
183-
}
100+
public void showMultipleQuestionSurvey(View view) {
101+
Instabug.showSurvey("AGI5OH47k3eEAIKj-yKDWA");
184102
}
185103

186-
@Override
187-
public boolean onCreateOptionsMenu(Menu menu) {
188-
return true;
104+
public void showFeatureRequests(View view) {
105+
Instabug.showFeatureRequests();
189106
}
190107

191-
@Override
192-
public boolean onOptionsItemSelected(MenuItem item) {
193-
return super.onOptionsItemSelected(item);
108+
public void onShowSettingsClicked(View view) {
109+
startActivity(new Intent(this, SettingsActivity.class));
194110
}
195111

196-
@Override
197-
public boolean onNavigationItemSelected(MenuItem item) {
198-
int id = item.getItemId();
199-
if (id == R.id.nav_home) {
200-
AlertDialog alertDialog = new AlertDialog.Builder(this)
201-
.setMessage("Do you want to get a NullPointerException, because that's how " +
202-
"you get a NullPointerException :D")
203-
.setPositiveButton("Why not?", new DialogInterface.OnClickListener() {
204-
@Override
205-
public void onClick(DialogInterface dialog, int which) {
206-
throw new NullPointerException("Test issue in Instabug Sample app");
207-
}
208-
}).show();
209-
Instabug.setDialog(alertDialog);
210-
} else if (id == R.id.nav_maps) {
211-
startActivity(new Intent(this, GoogleMapsActivity.class));
212-
} else if (id == R.id.nav_openGl) {
213-
startActivity(new Intent(this, OpenGLActivity.class));
214-
} else if (id == R.id.nav_share) {
215-
startActivity(Intent.createChooser(getShareIntent(), getResources().getString(R.string.share_to_friends)));
216-
} else if (id == R.id.nav_about) {
217-
Instabug.showIntroMessage();
218-
// TODO click about to show dialog to test screenshot with dialogs
219-
Toast.makeText(this, "Coming soon", Toast.LENGTH_SHORT).show();
220-
}
221-
222-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
223-
drawer.closeDrawer(GravityCompat.START);
224-
return true;
112+
public void doNetworkRequest() {
113+
new FetchMoviesData().execute();
225114
}
226115

227-
public Intent getShareIntent() {
228-
String sharedText = "Check out this awesome sample app by @instabug\n\nhttps://github.com/Instabug/android-sample";
229-
Intent shareIntent = new Intent(Intent.ACTION_SEND);
230-
shareIntent.setType("text/plain");
231-
shareIntent.putExtra(Intent.EXTRA_TEXT, sharedText);
232-
return shareIntent;
116+
public void onHeaderImageClicked() {
117+
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instabug.com"));
118+
startActivity(browserIntent);
233119
}
234120

235121
private class FetchMoviesData extends AsyncTask<Void, Void, String> {
@@ -326,4 +212,5 @@ protected void onPostExecute(String s) {
326212
Log.d("Response", s + "");
327213
}
328214
}
215+
329216
}

0 commit comments

Comments
 (0)