Skip to content

Commit

Permalink
Merge pull request #9 from WrichikBasu/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
WrichikBasu authored Nov 2, 2020
2 parents 769af81 + c74152d commit 1ef039e
Show file tree
Hide file tree
Showing 18 changed files with 800 additions and 348 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 9
versionName "1.2.6"
versionCode 10
versionName "1.2.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-feature android:name="android.hardware.audio.output" android:required="true"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/>

<application
android:name=".MyApplication"
android:allowBackup="true"
Expand All @@ -38,14 +41,12 @@
<service
android:name=".Service_SnoozeAlarm"
android:enabled="true"
android:exported="false"
android:process=":RingAlarm"/>
android:exported="false"/>

<service
android:name=".Service_RingAlarm"
android:enabled="true"
android:exported="false"
android:process=":RingAlarm"/>
android:exported="false"/>

<receiver
android:name=".AlarmBroadcastReceiver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
alarmDatabase = AlarmDatabase.getInstance(this);
viewModel = new ViewModelProvider(this).get(ViewModel_AlarmsList.class);

SharedPreferences sharedPreferences = getSharedPreferences(ConstantsAndStatics.SHARED_PREF_FILE_NAME,
MODE_PRIVATE);
SharedPreferences sharedPreferences = getSharedPreferences(ConstantsAndStatics.SHARED_PREF_FILE_NAME, MODE_PRIVATE);

viewModel.init(alarmDatabase);

Expand Down Expand Up @@ -291,9 +290,6 @@ private void deleteOrDeactivateAlarm(int mode, int hour, int mins) {

int alarmID = viewModel.getAlarmId(alarmDatabase, hour, mins);

// Kill any foreground service based on this alarm:
ConstantsAndStatics.killServices(this, alarmID);

PendingIntent pendingIntent = PendingIntent.getBroadcast(Activity_AlarmsList.this, alarmID, intent,
PendingIntent.FLAG_NO_CREATE);

Expand All @@ -309,7 +305,6 @@ private void deleteOrDeactivateAlarm(int mode, int hour, int mins) {
viewModel.toggleAlarmState(alarmDatabase, hour, mins, 0);
}


ConstantsAndStatics.schedulePeriodicWork(this);
}

Expand All @@ -324,13 +319,11 @@ private void deleteOrDeactivateAlarm(int mode, int hour, int mins) {
*/
private void toggleAlarmState(int hour, int mins, final int newAlarmState) {

if (newAlarmState == 0) {
ConstantsAndStatics.killServices(this, viewModel.getAlarmId(alarmDatabase, hour, mins));
ConstantsAndStatics.killServices(this, viewModel.getAlarmId(alarmDatabase, hour, mins));

if (newAlarmState == 0) {
deleteOrDeactivateAlarm(MODE_DEACTIVATE_ONLY, hour, mins);
} else {
ConstantsAndStatics.killServices(this, viewModel.getAlarmId(alarmDatabase, hour, mins));

addOrActivateAlarm(MODE_ACTIVATE_EXISTING_ALARM, viewModel.getAlarmEntity(alarmDatabase, hour, mins),
viewModel.getRepeatDays(alarmDatabase, hour, mins));
}
Expand Down Expand Up @@ -483,11 +476,9 @@ private void checkForUpdates() {
dialog.cancel();

try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=in.basulabs" +
".shakealarmclock")));
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=in.basulabs.shakealarmclock")));
} catch (android.content.ActivityNotFoundException exception) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google" +
".com/store/apps/details?id=in.basulabs.shakealarmclock")));
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=in.basulabs.shakealarmclock")));
}
})
.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
/**
* An activity to manage activity actions for this app.
* <p>
* This activity has no display and is transparent. It handles incoming intents and finishes itself in {@link
* #onCreate(Bundle)}.
* This activity has no display and is transparent. It handles incoming intents and finishes itself in {@link #onCreate(Bundle)}.
* <p>
* The following activity actions are handled:
* <ul>
Expand Down Expand Up @@ -129,10 +128,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

case AlarmClock.ACTION_DISMISS_ALARM:

Intent intent2 = new Intent(this, Activity_AlarmsList.class);
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent2);
if (Service_RingAlarm.isThisServiceRunning && Service_RingAlarm.alarmID != - 1) {
Intent intent1 = new Intent(this, Service_RingAlarm.class);
stopService(intent1);
} else if (Service_SnoozeAlarm.isThisServiceRunning && Service_SnoozeAlarm.alarmID != - 1) {
Intent intent1 = new Intent(this, Service_SnoozeAlarm.class);
stopService(intent1);
} else {
Intent intent2 = new Intent(this, Activity_AlarmsList.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent2);
}

break;

Expand Down
Loading

0 comments on commit 1ef039e

Please sign in to comment.