Skip to content

Commit

Permalink
Merge pull request #17 from WrichikBasu/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
WrichikBasu authored Nov 13, 2020
2 parents 7acbcc1 + 8f889fe commit 828df70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "in.basulabs.shakealarmclock"
minSdkVersion 21
targetSdkVersion 30
versionCode 12
versionName "1.2.9"
versionCode 13
versionName "1.2.10"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

private void onPowerButtonPressed() {
Intent intent;
int powerBtnAction = sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_POWER_BTN_OPERATION,
ConstantsAndStatics.DISMISS);
int powerBtnAction = sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_POWER_BTN_OPERATION, ConstantsAndStatics.DISMISS);
if (powerBtnAction == ConstantsAndStatics.DISMISS) {
intent = new Intent(ConstantsAndStatics.ACTION_CANCEL_ALARM);
sendBroadcast(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void onReceive(Context context, Intent intent) {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
assert notificationManager != null;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(NOTIFICATION_ID, buildSnoozeNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE);
} else {
Expand All @@ -80,8 +83,6 @@ public int onStartCommand(Intent intent, int flags, int startId) {
intentFilter.addAction(ConstantsAndStatics.ACTION_CANCEL_ALARM);
registerReceiver(broadcastReceiver, intentFilter);

notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Service_SnoozeAlarm myInstance = this;

ZonedDateTime alarmDateTime = ZonedDateTime.of(LocalDateTime.of(
Expand Down Expand Up @@ -128,7 +129,6 @@ private void createNotificationChannel() {
NotificationChannel channel = new NotificationChannel(Integer.toString(NOTIFICATION_ID), "in.basulabs.shakealarmclock Notifications", importance);
//NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
channel.setSound(null, null);
assert notificationManager != null;
notificationManager.createNotificationChannel(channel);
}
}
Expand All @@ -155,8 +155,7 @@ private Notification buildSnoozeNotification() {
//-----------------------------------------------------------------------------------------------------

private void updateNotification() {
Intent intent = new Intent()
.setAction(ConstantsAndStatics.ACTION_CANCEL_ALARM);
Intent intent = new Intent().setAction(ConstantsAndStatics.ACTION_CANCEL_ALARM);
PendingIntent contentPendingIntent = PendingIntent.getBroadcast(this, 5017, intent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, Integer.toString(NOTIFICATION_ID))
Expand Down

0 comments on commit 828df70

Please sign in to comment.