3
3
import android .app .AlertDialog ;
4
4
import android .content .DialogInterface ;
5
5
import android .content .Intent ;
6
+ import android .graphics .Color ;
6
7
import android .net .Uri ;
7
8
import android .os .Bundle ;
8
9
import android .support .design .widget .NavigationView ;
13
14
import android .view .Menu ;
14
15
import android .view .MenuItem ;
15
16
import android .view .View ;
17
+ import android .widget .AdapterView ;
18
+ import android .widget .ArrayAdapter ;
16
19
import android .widget .ImageView ;
20
+ import android .widget .Spinner ;
17
21
import android .widget .Toast ;
18
22
19
23
import com .example .instabug .BaseActivity ;
20
24
import com .example .instabug .R ;
21
25
import com .example .instabug .gcm .RegistrationIntentService ;
22
26
import com .instabug .library .Instabug ;
27
+ import com .instabug .library .invocation .InstabugInvocationMode ;
23
28
24
29
import butterknife .Bind ;
25
30
import butterknife .ButterKnife ;
@@ -32,8 +37,13 @@ public class MainActivity extends BaseActivity
32
37
DrawerLayout drawer ;
33
38
@ Bind (R .id .nav_view )
34
39
NavigationView navigationView ;
40
+ @ Bind (R .id .spinner )
41
+ Spinner spinner ;
35
42
ImageView headerImage ;
36
43
44
+ private static String [] colorNames = {"Red" , "Blue" , "Green" , "Yellow" };
45
+ private static int [] colors = {Color .RED , Color .BLUE , Color .GREEN , Color .YELLOW };
46
+
37
47
@ Override
38
48
protected void onCreate (Bundle savedInstanceState ) {
39
49
super .onCreate (savedInstanceState );
@@ -63,6 +73,21 @@ public void onClick(View v) {
63
73
navigationView .setCheckedItem (navigationView .getMenu ().getItem (0 ).getItemId ());
64
74
}
65
75
76
+ ArrayAdapter <String > dataAdapter = new ArrayAdapter <>(this , android .R .layout .simple_spinner_item , colorNames );
77
+ dataAdapter .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
78
+ spinner .setAdapter (dataAdapter );
79
+
80
+ spinner .setOnItemSelectedListener (new AdapterView .OnItemSelectedListener () {
81
+ @ Override
82
+ public void onItemSelected (AdapterView <?> parent , View view , int position , long id ) {
83
+ Instabug .setPrimaryColor (colors [position ]);
84
+ }
85
+
86
+ @ Override
87
+ public void onNothingSelected (AdapterView <?> parent ) {
88
+
89
+ }
90
+ });
66
91
}
67
92
68
93
private void registerGCM () {
@@ -76,6 +101,39 @@ public void onFeedbackFABClicked() {
76
101
Instabug .invoke ();
77
102
}
78
103
104
+ @ OnClick (R .id .show_intro_message )
105
+ public void onShowIntroMessageClicked () {
106
+ Instabug .showIntroMessage ();
107
+ }
108
+
109
+ @ OnClick (R .id .start_feedback )
110
+ public void onFeedbackClicked () {
111
+ Instabug .invoke (InstabugInvocationMode .NEW_FEEDBACK );
112
+ }
113
+
114
+ @ OnClick (R .id .start_bug_report )
115
+ public void onBugReportClicked () {
116
+ Instabug .invoke (InstabugInvocationMode .NEW_FEEDBACK );
117
+ }
118
+
119
+ @ OnClick (R .id .start_new_conversation )
120
+ public void onNewConversationClicked () {
121
+ Instabug .invoke (InstabugInvocationMode .NEW_CHAT );
122
+ }
123
+
124
+ @ OnClick (R .id .start_conversation_list )
125
+ public void onConversationListClicked () {
126
+ Instabug .invoke (InstabugInvocationMode .CHATS_LIST );
127
+ }
128
+
129
+ @ OnClick (R .id .show_new_messages_count )
130
+ public void onNewMessageCountClicked () {
131
+ Toast .makeText (this ,
132
+ "Number of unread messages: " +
133
+ String .valueOf (Instabug .getUnreadMessagesCount ()), Toast .LENGTH_SHORT )
134
+ .show ();
135
+ }
136
+
79
137
public void onHeaderImageClicked () {
80
138
Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("http://www.instabug.com" ));
81
139
startActivity (browserIntent );
0 commit comments