29
29
import com .instabug .library .invocation .InstabugInvocationMode ;
30
30
import com .instabug .library .logging .InstabugLog ;
31
31
import com .instabug .library .logging .InstabugNetworkLog ;
32
+ import com .instabug .library .ui .onboarding .WelcomeMessage ;
32
33
33
34
import org .json .JSONException ;
34
35
import org .json .JSONObject ;
40
41
import java .io .OutputStreamWriter ;
41
42
import java .net .HttpURLConnection ;
42
43
import java .net .URL ;
44
+ import java .util .Set ;
43
45
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 {
54
47
55
48
@ Override
56
49
protected void onCreate (Bundle savedInstanceState ) {
@@ -62,45 +55,10 @@ protected void onCreate(Bundle savedInstanceState) {
62
55
63
56
registerGCM ();
64
57
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
-
76
58
Toolbar toolbar = findViewById (R .id .toolbar );
77
59
setSupportActionBar (toolbar );
78
60
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 ();
104
62
}
105
63
106
64
private void registerGCM () {
@@ -109,46 +67,16 @@ private void registerGCM() {
109
67
startService (intent );
110
68
}
111
69
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 );
134
72
}
135
73
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 );
141
76
}
142
77
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 ();
152
80
}
153
81
154
82
public void onCrashTheAppClicked (View view ) {
@@ -165,71 +93,29 @@ public void onClick(DialogInterface dialog, int which) {
165
93
.show ();
166
94
}
167
95
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" );
175
98
}
176
99
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" );
184
102
}
185
103
186
- @ Override
187
- public boolean onCreateOptionsMenu (Menu menu ) {
188
- return true ;
104
+ public void showFeatureRequests (View view ) {
105
+ Instabug .showFeatureRequests ();
189
106
}
190
107
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 ));
194
110
}
195
111
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 ();
225
114
}
226
115
227
- public Intent getShareIntent () {
228
- String sharedText = "Check out this awesome sample app by @instabug\n \n https://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 );
233
119
}
234
120
235
121
private class FetchMoviesData extends AsyncTask <Void , Void , String > {
@@ -326,4 +212,5 @@ protected void onPostExecute(String s) {
326
212
Log .d ("Response" , s + "" );
327
213
}
328
214
}
215
+
329
216
}
0 commit comments