cleanup Debug activity a bit, add Spinner and remove a lot of buttons

This commit is contained in:
Andreas Shimokawa 2016-10-03 20:51:28 +02:00
parent 5bdc7933b3
commit ed343778ee
2 changed files with 64 additions and 155 deletions

View File

@ -13,13 +13,17 @@ import android.support.v4.app.RemoteInput;
import android.support.v4.content.LocalBroadcastManager;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -39,8 +43,8 @@ public class DebugActivity extends GBActivity {
private static final String ACTION_REPLY
= "nodomain.freeyourgadget.gadgetbridge.DebugActivity.action.reply";
private Button sendSMSButton;
private Button sendEmailButton;
private Spinner sendTypeSpinner;
private Button sendButton;
private Button incomingCallButton;
private Button outgoingCallButton;
private Button startCallButton;
@ -75,10 +79,6 @@ public class DebugActivity extends GBActivity {
}
}
};
private Button sendChatButton;
private Button sendTelegramButton;
private Button sendTwitterButton;
private Button sendFacebookButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -93,79 +93,26 @@ public class DebugActivity extends GBActivity {
registerReceiver(mReceiver, filter); // for ACTION_REPLY
editContent = (EditText) findViewById(R.id.editContent);
sendSMSButton = (Button) findViewById(R.id.sendSMSButton);
sendSMSButton.setOnClickListener(new View.OnClickListener() {
ArrayList<String> spinnerArray = new ArrayList<>();
for (NotificationType notificationType : NotificationType.values()) {
spinnerArray.add(notificationType.name());
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
sendTypeSpinner = (Spinner) findViewById(R.id.sendTypeSpinner);
sendTypeSpinner.setAdapter(spinnerArrayAdapter);
sendButton = (Button) findViewById(R.id.sendButton);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.phoneNumber = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.SMS;
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}
});
sendEmailButton = (Button) findViewById(R.id.sendEmailButton);
sendEmailButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.sender = getResources().getText(R.string.app_name).toString();
notificationSpec.subject = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.EMAIL;
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}
});
sendChatButton = (Button) findViewById(R.id.sendChatButton);
sendChatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.sender = getResources().getText(R.string.app_name).toString();
notificationSpec.subject = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.CHAT;
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}
});
sendTelegramButton = (Button) findViewById(R.id.sendTelegramButton);
sendTelegramButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.sender = getResources().getText(R.string.app_name).toString();
notificationSpec.subject = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.TELEGRAM;
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}
});
sendTwitterButton = (Button) findViewById(R.id.sendTwitterButton);
sendTwitterButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.sender = getResources().getText(R.string.app_name).toString();
notificationSpec.subject = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.TWITTER;
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}
});
sendFacebookButton = (Button) findViewById(R.id.sendFacebookButton);
sendFacebookButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.sender = getResources().getText(R.string.app_name).toString();
notificationSpec.subject = editContent.getText().toString();
notificationSpec.body = editContent.getText().toString();
notificationSpec.type = NotificationType.FACEBOOK;
String testString = editContent.getText().toString();
notificationSpec.phoneNumber = testString;
notificationSpec.body = testString;
notificationSpec.sender = testString;
notificationSpec.subject = testString;
notificationSpec.type = NotificationType.values()[sendTypeSpinner.getSelectedItemPosition()];
notificationSpec.id = -1;
GBApplication.deviceService().onNotification(notificationSpec);
}

View File

@ -20,9 +20,9 @@
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="15"
android:alignmentMode="alignMargins">
android:alignmentMode="alignMargins"
android:columnCount="2"
android:rowCount="15">
<TextView
android:id="@+id/textView"
@ -35,60 +35,6 @@
android:text="Message / Caller"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/sendSMSButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="fill_horizontal"
android:layout_row="2"
android:text="SMS" />
<Button
android:id="@+id/sendEmailButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="fill_horizontal"
android:layout_row="2"
android:text="E-Mail"/>
<Button
android:id="@+id/sendChatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_row="2"
android:text="Chat"/>
<Button
android:id="@+id/sendTelegramButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="fill_horizontal"
android:layout_row="3"
android:text="Telegram" />
<Button
android:id="@+id/sendTwitterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="fill_horizontal"
android:layout_row="3"
android:text="Twitter"/>
<Button
android:id="@+id/sendFacebookButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="fill_horizontal"
android:layout_row="3"
android:text="Facebook"/>
<EditText
android:id="@+id/editContent"
android:layout_width="wrap_content"
@ -101,15 +47,23 @@
android:inputType="textMultiLine"
android:text="Test" />
<Button
android:id="@+id/testNotificationButton"
android:layout_width="match_parent"
<Spinner
android:id="@+id/sendTypeSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="3"
android:layout_gravity="fill_horizontal"
android:layout_row="11"
android:text="create test notification" />
android:layout_row="2"
android:text="send as SMS" />
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="fill_horizontal"
android:layout_row="2"
android:text="Send" />
<Button
android:id="@+id/incomingCallButton"
@ -117,7 +71,7 @@
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="fill_horizontal"
android:layout_row="4"
android:layout_row="3"
android:text="incoming call" />
<Button
@ -126,9 +80,8 @@
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="fill_horizontal"
android:layout_row="4"
android:text="outgoing call"
android:layout_columnSpan="2" />
android:layout_row="3"
android:text="outgoing call" />
<Button
android:id="@+id/startCallButton"
@ -136,7 +89,7 @@
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="fill_horizontal"
android:layout_row="5"
android:layout_row="4"
android:text="start call" />
<Button
@ -145,18 +98,16 @@
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="fill_horizontal"
android:layout_row="5"
android:text="end call"
android:layout_columnSpan="2" />
android:layout_row="4"
android:text="end call" />
<Button
android:id="@+id/setTimeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="1"
android:layout_gravity="fill_horizontal"
android:layout_row="6"
android:layout_row="5"
android:text="set time" />
<Button
@ -164,29 +115,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:layout_row="6"
android:layout_row="5"
android:text="set music info" />
<Button
android:id="@+id/HearRateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="3"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:layout_row="9"
android:layout_row="6"
android:text="Heart Rate Test" />
<Button
android:id="@+id/rebootButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="3"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:layout_row="12"
android:layout_row="7"
android:text="reboot" />
<Button
android:id="@+id/testNotificationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:layout_row="8"
android:text="create test notification" />
</GridLayout>
</ScrollView>