2018-02-26 14:27:32 +01:00
|
|
|
/* Copyright (C) 2015-2018 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
2018-08-29 21:30:23 +02:00
|
|
|
Gobbetti, Frank Slezak, ivanovlev, Kasha, Lem Dulfo, Pavel Elagin, Steffen
|
|
|
|
Liebergeld
|
2017-03-10 14:53:19 +01:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.activities;
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2018-08-28 14:03:57 +02:00
|
|
|
import android.app.AlertDialog;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.app.NotificationManager;
|
2015-09-02 22:43:22 +02:00
|
|
|
import android.app.PendingIntent;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
2018-08-28 14:03:57 +02:00
|
|
|
import android.content.DialogInterface;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
2018-08-28 14:03:57 +02:00
|
|
|
import android.net.Uri;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.os.Bundle;
|
2015-03-27 11:23:30 +01:00
|
|
|
import android.support.v4.app.NavUtils;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.support.v4.app.NotificationCompat;
|
2016-01-09 15:33:18 +01:00
|
|
|
import android.support.v4.app.RemoteInput;
|
2016-04-24 17:34:36 +02:00
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
2015-03-27 11:23:30 +01:00
|
|
|
import android.view.MenuItem;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.view.View;
|
2016-10-03 20:51:28 +02:00
|
|
|
import android.widget.ArrayAdapter;
|
2015-02-07 12:58:18 +01:00
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.EditText;
|
2016-10-03 20:51:28 +02:00
|
|
|
import android.widget.Spinner;
|
2015-07-08 23:03:34 +02:00
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-08-28 14:03:57 +02:00
|
|
|
import java.io.File;
|
2018-11-05 23:27:29 +01:00
|
|
|
import java.io.Serializable;
|
2016-10-03 20:51:28 +02:00
|
|
|
import java.util.ArrayList;
|
2018-03-31 16:21:25 +02:00
|
|
|
import java.util.Objects;
|
2016-10-03 20:51:28 +02:00
|
|
|
|
2015-08-03 23:09:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
2018-11-05 23:27:29 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
2016-04-04 20:08:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
2016-04-24 17:34:36 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
2016-04-04 20:08:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
2016-06-08 20:32:32 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
2015-09-24 14:45:21 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
2018-03-31 16:21:25 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
2018-12-16 16:05:13 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
2015-08-21 00:58:18 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2018-08-28 14:03:57 +02:00
|
|
|
import static android.content.Intent.EXTRA_SUBJECT;
|
2018-02-14 21:27:24 +01:00
|
|
|
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_ID;
|
|
|
|
|
2017-09-03 01:02:31 +02:00
|
|
|
public class DebugActivity extends AbstractGBActivity {
|
2015-07-08 23:03:34 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(DebugActivity.class);
|
|
|
|
|
2016-01-09 15:33:18 +01:00
|
|
|
private static final String EXTRA_REPLY = "reply";
|
|
|
|
private static final String ACTION_REPLY
|
|
|
|
= "nodomain.freeyourgadget.gadgetbridge.DebugActivity.action.reply";
|
|
|
|
|
2016-10-03 20:51:28 +02:00
|
|
|
private Spinner sendTypeSpinner;
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2015-12-08 23:42:58 +01:00
|
|
|
private EditText editContent;
|
2015-11-23 23:04:46 +01:00
|
|
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
2015-02-07 12:58:18 +01:00
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2018-03-31 16:21:25 +02:00
|
|
|
switch (Objects.requireNonNull(intent.getAction())) {
|
2016-04-24 17:34:36 +02:00
|
|
|
case ACTION_REPLY: {
|
2016-01-09 15:33:18 +01:00
|
|
|
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
|
|
|
|
CharSequence reply = remoteInput.getCharSequence(EXTRA_REPLY);
|
|
|
|
LOG.info("got wearable reply: " + reply);
|
|
|
|
GB.toast(context, "got wearable reply: " + reply, Toast.LENGTH_SHORT, GB.INFO);
|
|
|
|
break;
|
2016-04-24 17:34:36 +02:00
|
|
|
}
|
2018-11-05 23:27:29 +01:00
|
|
|
case DeviceService.ACTION_REALTIME_SAMPLES:
|
|
|
|
handleRealtimeSample(intent.getSerializableExtra(DeviceService.EXTRA_REALTIME_SAMPLE));
|
|
|
|
break;
|
2018-03-31 16:21:25 +02:00
|
|
|
default:
|
|
|
|
LOG.info("ignoring intent action " + intent.getAction());
|
2016-04-24 17:34:36 +02:00
|
|
|
break;
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-05 23:27:29 +01:00
|
|
|
private void handleRealtimeSample(Serializable extra) {
|
|
|
|
if (extra instanceof ActivitySample) {
|
|
|
|
ActivitySample sample = (ActivitySample) extra;
|
|
|
|
GB.toast(this, "Heart Rate measured: " + sample.getHeartRate(), Toast.LENGTH_LONG, GB.INFO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-07 12:58:18 +01:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_debug);
|
|
|
|
|
2016-01-09 15:33:18 +01:00
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
|
filter.addAction(ACTION_REPLY);
|
2018-11-05 23:27:29 +01:00
|
|
|
filter.addAction(DeviceService.ACTION_REALTIME_SAMPLES);
|
2016-04-24 17:34:36 +02:00
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
|
|
|
|
registerReceiver(mReceiver, filter); // for ACTION_REPLY
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
editContent = findViewById(R.id.editContent);
|
2016-10-03 20:51:28 +02:00
|
|
|
|
|
|
|
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);
|
2018-03-31 16:21:25 +02:00
|
|
|
sendTypeSpinner = findViewById(R.id.sendTypeSpinner);
|
2016-10-03 20:51:28 +02:00
|
|
|
sendTypeSpinner.setAdapter(spinnerArrayAdapter);
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button sendButton = findViewById(R.id.sendButton);
|
2016-10-03 20:51:28 +02:00
|
|
|
sendButton.setOnClickListener(new View.OnClickListener() {
|
2016-10-02 23:04:59 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
NotificationSpec notificationSpec = new NotificationSpec();
|
2016-10-03 20:51:28 +02:00
|
|
|
String testString = editContent.getText().toString();
|
|
|
|
notificationSpec.phoneNumber = testString;
|
|
|
|
notificationSpec.body = testString;
|
|
|
|
notificationSpec.sender = testString;
|
|
|
|
notificationSpec.subject = testString;
|
|
|
|
notificationSpec.type = NotificationType.values()[sendTypeSpinner.getSelectedItemPosition()];
|
2017-09-19 13:24:31 +02:00
|
|
|
notificationSpec.pebbleColor = notificationSpec.type.color;
|
2016-10-02 23:04:59 +02:00
|
|
|
GBApplication.deviceService().onNotification(notificationSpec);
|
|
|
|
}
|
|
|
|
});
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button incomingCallButton = findViewById(R.id.incomingCallButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
incomingCallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-04-04 20:08:34 +02:00
|
|
|
CallSpec callSpec = new CallSpec();
|
|
|
|
callSpec.command = CallSpec.CALL_INCOMING;
|
|
|
|
callSpec.number = editContent.getText().toString();
|
|
|
|
GBApplication.deviceService().onSetCallState(callSpec);
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
});
|
2018-03-31 16:21:25 +02:00
|
|
|
Button outgoingCallButton = findViewById(R.id.outgoingCallButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
outgoingCallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-04-04 20:08:34 +02:00
|
|
|
CallSpec callSpec = new CallSpec();
|
|
|
|
callSpec.command = CallSpec.CALL_OUTGOING;
|
|
|
|
callSpec.number = editContent.getText().toString();
|
|
|
|
GBApplication.deviceService().onSetCallState(callSpec);
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button startCallButton = findViewById(R.id.startCallButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
startCallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-04-04 20:08:34 +02:00
|
|
|
CallSpec callSpec = new CallSpec();
|
|
|
|
callSpec.command = CallSpec.CALL_START;
|
|
|
|
GBApplication.deviceService().onSetCallState(callSpec);
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
});
|
2018-03-31 16:21:25 +02:00
|
|
|
Button endCallButton = findViewById(R.id.endCallButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
endCallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-04-04 20:08:34 +02:00
|
|
|
CallSpec callSpec = new CallSpec();
|
|
|
|
callSpec.command = CallSpec.CALL_END;
|
|
|
|
GBApplication.deviceService().onSetCallState(callSpec);
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button rebootButton = findViewById(R.id.rebootButton);
|
2015-05-17 21:58:08 +02:00
|
|
|
rebootButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2018-12-16 16:05:13 +01:00
|
|
|
GBApplication.deviceService().onReset(GBDeviceProtocol.RESET_FLAGS_REBOOT);
|
2015-05-17 21:58:08 +02:00
|
|
|
}
|
|
|
|
});
|
2018-12-16 16:05:13 +01:00
|
|
|
|
|
|
|
Button factoryResetButton = findViewById(R.id.factoryResetButton);
|
|
|
|
factoryResetButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
new AlertDialog.Builder(DebugActivity.this)
|
|
|
|
.setCancelable(true)
|
|
|
|
.setTitle(R.string.debugactivity_really_factoryreset_title)
|
|
|
|
.setMessage(R.string.debugactivity_really_factoryreset)
|
|
|
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
GBApplication.deviceService().onReset(GBDeviceProtocol.RESET_FLAGS_FACTORY_RESET);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button heartRateButton = findViewById(R.id.HeartRateButton);
|
|
|
|
heartRateButton.setOnClickListener(new View.OnClickListener() {
|
2015-12-28 14:38:56 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-03-04 23:07:41 +01:00
|
|
|
GB.toast("Measuring heart rate, please wait...", Toast.LENGTH_LONG, GB.INFO);
|
2016-02-29 22:05:29 +01:00
|
|
|
GBApplication.deviceService().onHeartRateTest();
|
2015-12-28 14:38:56 +01:00
|
|
|
}
|
|
|
|
});
|
2015-05-17 21:58:08 +02:00
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button setMusicInfoButton = findViewById(R.id.setMusicInfoButton);
|
2015-02-08 23:53:40 +01:00
|
|
|
setMusicInfoButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2016-04-04 20:08:34 +02:00
|
|
|
MusicSpec musicSpec = new MusicSpec();
|
2017-01-24 19:04:06 +01:00
|
|
|
String testString = editContent.getText().toString();
|
|
|
|
musicSpec.artist = testString + "(artist)";
|
|
|
|
musicSpec.album = testString + "(album)";
|
|
|
|
musicSpec.track = testString + "(track)";
|
2016-04-04 20:08:34 +02:00
|
|
|
musicSpec.duration = 10;
|
|
|
|
musicSpec.trackCount = 5;
|
|
|
|
musicSpec.trackNr = 2;
|
|
|
|
|
|
|
|
GBApplication.deviceService().onSetMusicInfo(musicSpec);
|
2016-06-08 20:32:32 +02:00
|
|
|
|
|
|
|
MusicStateSpec stateSpec = new MusicStateSpec();
|
|
|
|
stateSpec.position = 0;
|
|
|
|
stateSpec.state = 0x01; // playing
|
|
|
|
stateSpec.playRate = 100;
|
|
|
|
stateSpec.repeat = 1;
|
|
|
|
stateSpec.shuffle = 1;
|
|
|
|
|
|
|
|
GBApplication.deviceService().onSetMusicState(stateSpec);
|
2015-02-08 23:53:40 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button setTimeButton = findViewById(R.id.setTimeButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
setTimeButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2015-08-21 00:58:18 +02:00
|
|
|
GBApplication.deviceService().onSetTime();
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button testNotificationButton = findViewById(R.id.testNotificationButton);
|
2015-02-07 12:58:18 +01:00
|
|
|
testNotificationButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
testNotification();
|
|
|
|
}
|
|
|
|
});
|
2016-10-11 23:27:56 +02:00
|
|
|
|
2018-11-01 15:04:16 +01:00
|
|
|
Button testPebbleKitNotificationButton = findViewById(R.id.testPebbleKitNotificationButton);
|
|
|
|
testPebbleKitNotificationButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
testPebbleKitNotification();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
Button fetchDebugLogsButton = findViewById(R.id.fetchDebugLogsButton);
|
|
|
|
fetchDebugLogsButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_DEBUGLOGS);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Button testNewFunctionalityButton = findViewById(R.id.testNewFunctionality);
|
2016-10-11 23:27:56 +02:00
|
|
|
testNewFunctionalityButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
testNewFunctionality();
|
|
|
|
}
|
|
|
|
});
|
2018-08-28 14:03:57 +02:00
|
|
|
|
|
|
|
Button shareLogButton = findViewById(R.id.shareLog);
|
|
|
|
shareLogButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
showWarning();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showWarning() {
|
|
|
|
new AlertDialog.Builder(this)
|
|
|
|
.setCancelable(true)
|
|
|
|
.setTitle(R.string.warning)
|
|
|
|
.setMessage(R.string.share_log_warning)
|
|
|
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2018-12-16 16:05:13 +01:00
|
|
|
shareLog();
|
2018-08-28 14:03:57 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.show();
|
2016-10-11 23:27:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void testNewFunctionality() {
|
|
|
|
GBApplication.deviceService().onTestNewFunction();
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
|
2018-08-28 14:03:57 +02:00
|
|
|
private void shareLog() {
|
|
|
|
String fileName = GBApplication.getLogPath();
|
|
|
|
if(fileName != null && fileName.length() > 0) {
|
|
|
|
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
|
|
|
|
emailIntent.setType("*/*");
|
|
|
|
emailIntent.putExtra(EXTRA_SUBJECT, "Gadgetbridge log file");
|
|
|
|
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileName)));
|
|
|
|
startActivity(Intent.createChooser(emailIntent, "Share File"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-07 12:58:18 +01:00
|
|
|
private void testNotification() {
|
2015-09-02 22:43:22 +02:00
|
|
|
Intent notificationIntent = new Intent(getApplicationContext(), DebugActivity.class);
|
|
|
|
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
|
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
|
|
|
|
notificationIntent, 0);
|
|
|
|
|
2015-02-07 12:58:18 +01:00
|
|
|
NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
2016-01-09 15:33:18 +01:00
|
|
|
|
|
|
|
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_REPLY)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Intent replyIntent = new Intent(ACTION_REPLY);
|
|
|
|
|
|
|
|
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(this, 0, replyIntent, 0);
|
|
|
|
|
|
|
|
NotificationCompat.Action action =
|
|
|
|
new NotificationCompat.Action.Builder(android.R.drawable.ic_input_add, "Reply", replyPendingIntent)
|
|
|
|
.addRemoteInput(remoteInput)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender().addAction(action);
|
|
|
|
|
2018-02-14 21:27:24 +01:00
|
|
|
NotificationCompat.Builder ncomp = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
|
2016-01-09 15:33:18 +01:00
|
|
|
.setContentTitle(getString(R.string.test_notification))
|
|
|
|
.setContentText(getString(R.string.this_is_a_test_notification_from_gadgetbridge))
|
|
|
|
.setTicker(getString(R.string.this_is_a_test_notification_from_gadgetbridge))
|
|
|
|
.setSmallIcon(R.drawable.ic_notification)
|
|
|
|
.setAutoCancel(true)
|
|
|
|
.setContentIntent(pendingIntent)
|
|
|
|
.extend(wearableExtender);
|
|
|
|
|
2018-03-31 16:21:25 +02:00
|
|
|
if (nManager != null) {
|
|
|
|
nManager.notify((int) System.currentTimeMillis(), ncomp.build());
|
|
|
|
}
|
2015-02-07 12:58:18 +01:00
|
|
|
}
|
|
|
|
|
2018-11-01 15:04:16 +01:00
|
|
|
private void testPebbleKitNotification() {
|
|
|
|
Intent pebbleKitIntent = new Intent("com.getpebble.action.SEND_NOTIFICATION");
|
|
|
|
pebbleKitIntent.putExtra("messageType", "PEBBLE_ALERT");
|
|
|
|
pebbleKitIntent.putExtra("notificationData", "[{\"title\":\"PebbleKitTest\",\"body\":\"sent from Gadgetbridge\"}]");
|
|
|
|
getApplicationContext().sendBroadcast(pebbleKitIntent);
|
|
|
|
}
|
|
|
|
|
2015-03-27 11:23:30 +01:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case android.R.id.home:
|
|
|
|
NavUtils.navigateUpFromSameTask(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
2015-02-07 12:58:18 +01:00
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
2016-04-24 17:34:36 +02:00
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
2015-02-07 12:58:18 +01:00
|
|
|
unregisterReceiver(mReceiver);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|