Merge pull request #30 from brarcher/notification

Notification updates
This commit is contained in:
Branden Archer
2017-12-27 19:50:54 -05:00
committed by GitHub
6 changed files with 30 additions and 41 deletions

View File

@@ -105,27 +105,21 @@ public class ListenActivity extends Activity
setContentView(R.layout.activity_listen); setContentView(R.layout.activity_listen);
ListenActivity.this.runOnUiThread(new Runnable() NotificationCompat.Builder mBuilder =
{ new NotificationCompat.Builder(ListenActivity.this)
@Override .setOngoing(true)
public void run() .setSmallIcon(R.drawable.listening_notification)
{ .setContentTitle(getString(R.string.app_name))
NotificationCompat.Builder mBuilder = .setContentText(getString(R.string.listening));
new NotificationCompat.Builder(ListenActivity.this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.listening));
_mNotifyMgr.notify(mNotificationId, mBuilder.build());
_mNotifyMgr.notify(mNotificationId, mBuilder.build()); final TextView connectedText = (TextView) findViewById(R.id.connectedTo);
connectedText.setText(_name);
final TextView connectedText = (TextView) findViewById(R.id.connectedTo); final TextView statusText = (TextView) findViewById(R.id.textStatus);
connectedText.setText(_name); statusText.setText(R.string.listening);
final TextView statusText = (TextView) findViewById(R.id.textStatus);
statusText.setText(R.string.listening);
}
});
_listenThread = new Thread(new Runnable() _listenThread = new Thread(new Runnable()
{ {
@@ -166,7 +160,8 @@ public class ListenActivity extends Activity
statusText.setText(R.string.disconnected); statusText.setText(R.string.disconnected);
NotificationCompat.Builder mBuilder = NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(ListenActivity.this) new NotificationCompat.Builder(ListenActivity.this)
.setSmallIcon(R.drawable.ic_launcher) .setOngoing(false)
.setSmallIcon(R.drawable.listening_notification)
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.disconnected)); .setContentText(getString(R.string.disconnected));
_mNotifyMgr.notify(mNotificationId, mBuilder.build()); _mNotifyMgr.notify(mNotificationId, mBuilder.build());

View File

@@ -167,30 +167,24 @@ public class MonitorActivity extends Activity
}); });
_serviceThread.start(); _serviceThread.start();
MonitorActivity.this.runOnUiThread(new Runnable() final TextView addressText = (TextView) findViewById(R.id.address);
{
@Override // Use the application context to get WifiManager, to avoid leak before Android 5.1
public void run() final WifiManager wifiManager =
{ (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
final TextView addressText = (TextView) findViewById(R.id.address); final WifiInfo info = wifiManager.getConnectionInfo();
final int address = info.getIpAddress();
if(address != 0)
{
@SuppressWarnings("deprecation")
final String ipAddress = Formatter.formatIpAddress(address);
addressText.setText(ipAddress);
}
else
{
addressText.setText(R.string.wifiNotConnected);
}
// Use the application context to get WifiManager, to avoid leak before Android 5.1
final WifiManager wifiManager =
(WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
final WifiInfo info = wifiManager.getConnectionInfo();
final int address = info.getIpAddress();
if(address != 0)
{
@SuppressWarnings("deprecation")
final String ipAddress = Formatter.formatIpAddress(address);
addressText.setText(ipAddress);
}
else
{
addressText.setText(R.string.wifiNotConnected);
}
}
});
} }
@Override @Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB