Skip to content

Commit b3cb780

Browse files
committed
adding manual controls for instabug SDK
1 parent 899b34f commit b3cb780

File tree

3 files changed

+136
-5
lines changed

3 files changed

+136
-5
lines changed

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.AlertDialog;
44
import android.content.DialogInterface;
55
import android.content.Intent;
6+
import android.graphics.Color;
67
import android.net.Uri;
78
import android.os.Bundle;
89
import android.support.design.widget.NavigationView;
@@ -13,13 +14,17 @@
1314
import android.view.Menu;
1415
import android.view.MenuItem;
1516
import android.view.View;
17+
import android.widget.AdapterView;
18+
import android.widget.ArrayAdapter;
1619
import android.widget.ImageView;
20+
import android.widget.Spinner;
1721
import android.widget.Toast;
1822

1923
import com.example.instabug.BaseActivity;
2024
import com.example.instabug.R;
2125
import com.example.instabug.gcm.RegistrationIntentService;
2226
import com.instabug.library.Instabug;
27+
import com.instabug.library.invocation.InstabugInvocationMode;
2328

2429
import butterknife.Bind;
2530
import butterknife.ButterKnife;
@@ -32,8 +37,13 @@ public class MainActivity extends BaseActivity
3237
DrawerLayout drawer;
3338
@Bind(R.id.nav_view)
3439
NavigationView navigationView;
40+
@Bind(R.id.spinner)
41+
Spinner spinner;
3542
ImageView headerImage;
3643

44+
private static String[] colorNames = {"Red", "Blue", "Green", "Yellow"};
45+
private static int[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW};
46+
3747
@Override
3848
protected void onCreate(Bundle savedInstanceState) {
3949
super.onCreate(savedInstanceState);
@@ -63,6 +73,21 @@ public void onClick(View v) {
6373
navigationView.setCheckedItem(navigationView.getMenu().getItem(0).getItemId());
6474
}
6575

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+
});
6691
}
6792

6893
private void registerGCM() {
@@ -76,6 +101,39 @@ public void onFeedbackFABClicked() {
76101
Instabug.invoke();
77102
}
78103

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+
79137
public void onHeaderImageClicked() {
80138
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.instabug.com"));
81139
startActivity(browserIntent);
Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
7+
android:gravity="center"
8+
android:orientation="vertical"
89
android:paddingBottom="@dimen/activity_vertical_margin"
910
android:paddingLeft="@dimen/activity_horizontal_margin"
1011
android:paddingRight="@dimen/activity_horizontal_margin"
@@ -15,8 +16,73 @@
1516

1617
<TextView
1718
android:layout_width="match_parent"
18-
android:layout_height="match_parent"
19+
android:layout_height="wrap_content"
1920
android:gravity="center"
20-
android:text="@string/hello_world"/>
21+
android:text="@string/hello_world" />
2122

22-
</RelativeLayout>
23+
<Button
24+
android:id="@+id/show_intro_message"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:padding="10dp"
28+
android:text="@string/action_show_intro_message" />
29+
30+
<Button
31+
android:id="@+id/start_bug_report"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:padding="10dp"
35+
android:text="@string/action_send_bug_report" />
36+
37+
<Button
38+
android:id="@+id/start_feedback"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:padding="10dp"
42+
android:text="@string/action_send_feedback" />
43+
44+
<Button
45+
android:id="@+id/start_new_conversation"
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
android:padding="10dp"
49+
android:text="@string/action_start_new_conversation" />
50+
51+
<Button
52+
android:id="@+id/start_conversation_list"
53+
android:layout_width="match_parent"
54+
android:layout_height="wrap_content"
55+
android:padding="10dp"
56+
android:text="@string/action_show_conversation_list" />
57+
58+
<Button
59+
android:id="@+id/show_new_messages_count"
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content"
62+
android:padding="10dp"
63+
android:text="@string/action_show_new_messages_count" />
64+
65+
66+
<LinearLayout
67+
android:layout_width="match_parent"
68+
android:layout_height="wrap_content"
69+
android:orientation="horizontal">
70+
71+
<TextView
72+
android:layout_width="0dp"
73+
android:layout_height="wrap_content"
74+
android:layout_weight="1"
75+
android:gravity="center"
76+
android:text="@string/action_primary_color" />
77+
78+
<Spinner
79+
android:id="@+id/spinner"
80+
android:layout_width="0dp"
81+
android:layout_height="wrap_content"
82+
android:layout_weight="1"
83+
android:padding="10dp" />
84+
85+
</LinearLayout>
86+
87+
88+
</LinearLayout>

app/src/main/res/values/strings.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@
1919
<string name="maps">Maps</string>
2020
<string name="opengl">Open GL</string>
2121
<string name="tabs">Tabs</string>
22+
<string name="action_send_bug_report">Send Bug Report</string>
23+
<string name="action_send_feedback">Send Feedback</string>
24+
<string name="action_start_new_conversation">Start new conversation</string>
25+
<string name="action_show_conversation_list">Show conversation list</string>
26+
<string name="action_show_new_messages_count">Show new messages count</string>
27+
<string name="action_primary_color">Choose primary color</string>
28+
<string name="action_show_intro_message">Show intro message</string>
2229
</resources>

0 commit comments

Comments
 (0)