Skip to content

Commit

Permalink
Changed to android studio 3.5
Browse files Browse the repository at this point in the history
Fixed a bug in one time alarms where it was also set to the next day
  • Loading branch information
UriahShaulMandel committed Aug 23, 2019
1 parent 74d571d commit 58c7202
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 25 deletions.
112 changes: 109 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
for (int i = 0; i < daysCheckBoxes.length; i++)
daysCheckBoxes[i].setChecked((alarmDays | (D.Days.SUNDAY << i)) == alarmDays);
} else {
DateTime now = DateTime.now();
final DateTime now = DateTime.now();
chooser_hours.setNumber(now.getHourOfDay());
chooser_minutes.setNumber(now.getMinuteOfHour());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private void snooze() {
}

private void scheduleNextAlarm() {
AlarmScheduler.cancelAlarm(alarm.getKey(), this);
new Handler().postDelayed(() -> {
if (alarm.isEnabled()) {
if (alarm.getDays() == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,15 @@ else if (alarm.getDays() == (D.Days.ALL))
alarm_name.setText(alarm.getName());
alarm_switch.setChecked(alarm.isEnabled());
alarm_switch.setOnChangeListener(isChecked -> {
AlarmsDatabase.getInstance(AlarmsActivity.this)
.alarmsDatabaseDao().update(alarm.getKey(), isChecked);
alarm.setEnabled(isChecked);

if (isChecked) {
AlarmsDatabase.getInstance(AlarmsActivity.this)
.alarmsDatabaseDao().update(alarm.getKey(), true);
alarm.setEnabled(true);
AlarmScheduler.scheduleAlarm(alarm, AlarmsActivity.this);
} else {
AlarmsDatabase.getInstance(AlarmsActivity.this)
.alarmsDatabaseDao().update(alarm.getKey(), false);
alarm.setEnabled(false);
AlarmScheduler.cancelAlarm(alarm.getKey(), AlarmsActivity.this);

}

});

bt_edit.setOnClickListener((v) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.annotation.NonNull;

import com.bald.uriah.baldphone.activities.HomeScreenActivity;
import com.bald.uriah.baldphone.activities.alarms.AlarmsActivity;
import com.bald.uriah.baldphone.broadcast_receivers.AlarmReceiver;
import com.bald.uriah.baldphone.utils.D;
import com.bald.uriah.baldphone.utils.S;
Expand Down Expand Up @@ -151,12 +152,13 @@ private static void _cancelAlarm(int key, Context context) {

public static void scheduleAlarm(@NonNull Alarm alarm, @NonNull Context context) throws IllegalArgumentException {
synchronized (LOCK) {
S.logImportant("Scheduling an alarm!");
final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
final long nextTimeAlarmWillWorkInMs = nextTimeAlarmWillWorkInMs(alarm);
alarmManager.setAlarmClock(
new AlarmManager.AlarmClockInfo(
nextTimeAlarmWillWorkInMs,
PendingIntent.getActivity(context, 0, new Intent(context, HomeScreenActivity.class), 0)//TODO??
PendingIntent.getActivity(context, 0, new Intent(context, AlarmsActivity.class), 0)
),
getIntent(context, alarm.getKey())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.annotation.NonNull;

import com.bald.uriah.baldphone.activities.HomeScreenActivity;
import com.bald.uriah.baldphone.activities.pills.PillsActivity;
import com.bald.uriah.baldphone.broadcast_receivers.ReminderReceiver;
import com.bald.uriah.baldphone.utils.BPrefs;
import com.bald.uriah.baldphone.utils.D;
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void scheduleReminder(@NonNull Reminder reminder, @NonNull Context
alarmManager.setAlarmClock(
new AlarmManager.AlarmClockInfo(
nextTimeReminderWillWorkInMs,
PendingIntent.getActivity(context, 0, new Intent(context, HomeScreenActivity.class), 0)//TODO??
PendingIntent.getActivity(context, 0, new Intent(context, PillsActivity.class), 0)
),
getIntent(context, reminder.getId())
);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ buildscript {
}
dependencies {
// classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.0'

}
}
Expand Down
17 changes: 9 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
# under the License.
#

# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri Aug 23 02:24:11 IDT 2019
android.enableJetifier=true
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# under the License.
#

#Tue Apr 23 14:44:05 IDT 2019
#Fri Aug 23 02:25:32 IDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 comments on commit 58c7202

Please sign in to comment.