Skip to content
Snippets Groups Projects
Commit f5a5cbfc authored by Lennart Goedhart's avatar Lennart Goedhart Committed by GitHub
Browse files

Merge pull request #117 from jotomo/clearing-usb-disconnect-notification

Clear USB disconnect notification on USB reconnect
parents 9600f5b4 74ebb320
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,7 @@ import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class MainActivity extends AppCompatActivity implements OnSharedPreferenceChangeListener, OnEulaAgreedTo {
private static final String TAG = MainActivity.class.getSimpleName();
public static final int USB_DISCONNECT_NOFICATION_ID = 1;
public static final float MMOLXLFACTOR = 18.016f;
public static int batLevel = 0;
......@@ -461,8 +462,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
private void showDisconnectionNotification(String title, String message) {
int notifyId = 1;
NotificationCompat.Builder mBuilder =
(NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setPriority(NotificationCompat.PRIORITY_MAX)
......@@ -487,8 +486,12 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// notifyId allows you to update the notification later on.
mNotificationManager.notify(notifyId, mBuilder.build());
mNotificationManager.notify(USB_DISCONNECT_NOFICATION_ID, mBuilder.build());
}
private void clearDisconnectionNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(MainActivity.USB_DISCONNECT_NOFICATION_ID);
}
@Override
......@@ -934,6 +937,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
} else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
Log.d(TAG, "USB plugged in");
if (mEnableCgmService) {
clearDisconnectionNotification();
}
if (hasUsbPermission()) {
// Give the USB a little time to warm up first
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment