-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Julesssss/develop
Close 3.0 release
- Loading branch information
Showing
66 changed files
with
2,470 additions
and
1,209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ Thumbs.db | |
.gradle | ||
build/ | ||
*.iml | ||
|
||
app/google-services\.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/src/main/java/website/julianrosser/birthdays/AlarmsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package website.julianrosser.birthdays; | ||
|
||
import android.app.AlarmManager; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import java.util.ArrayList; | ||
|
||
import website.julianrosser.birthdays.model.Birthday; | ||
import website.julianrosser.birthdays.recievers.NotificationBuilderReceiver; | ||
import website.julianrosser.birthdays.services.SetAlarmsService; | ||
|
||
public class AlarmsHelper { | ||
|
||
public static void setAllNotificationAlarms(Context context) { | ||
Intent serviceIntent = new Intent(context, SetAlarmsService.class); | ||
context.startService(serviceIntent); | ||
} | ||
|
||
public static void cancelAllAlarms(Context context, ArrayList<Birthday> birthdays) { | ||
for (Birthday b: birthdays) { | ||
cancelAlarm(context, b.getName().hashCode()); | ||
} | ||
} | ||
|
||
// This builds an identical PendingIntent to the alarm and cancels when | ||
public static void cancelAlarm(Context context, int id) { | ||
|
||
// CreateIntent to start the AlarmNotificationReceiver | ||
Intent mNotificationReceiverIntent = new Intent(context, | ||
NotificationBuilderReceiver.class); | ||
|
||
// Create pending Intent exactly as it was set previously | ||
PendingIntent mNotificationReceiverPendingIntent = PendingIntent | ||
.getBroadcast(context.getApplicationContext(), | ||
id, | ||
mNotificationReceiverIntent, | ||
PendingIntent.FLAG_UPDATE_CURRENT); | ||
|
||
// Cancel alarm | ||
AlarmManager mAlarmManager = (AlarmManager) context.getApplicationContext().getSystemService(Context.ALARM_SERVICE); | ||
if (mAlarmManager != null) { | ||
mAlarmManager.cancel(mNotificationReceiverPendingIntent); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/src/main/java/website/julianrosser/birthdays/Preferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package website.julianrosser.birthdays; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
public class Preferences { | ||
|
||
private static final String SHARED_PREFERENCE_KEY = "BirthdayReminderPreferences"; | ||
private static final String KEY_USING_FIREBASE = "USING_FIREBASE"; | ||
private static final String SHOULD_DISPLAY_WELCOME_SCREEN = "DISPLAY_WELCOME_SCREEN"; | ||
|
||
public static synchronized void setIsUsingFirebase(Context context, boolean usingFirebase) { | ||
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCE_KEY, 0); | ||
SharedPreferences.Editor editor = prefs.edit(); | ||
editor.putBoolean(KEY_USING_FIREBASE, usingFirebase); | ||
editor.commit(); | ||
} | ||
|
||
public static synchronized boolean isUsingFirebase(Context context) { | ||
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCE_KEY, 0); | ||
return prefs.getBoolean(KEY_USING_FIREBASE, false); | ||
} | ||
|
||
public static synchronized void setShouldShowWelcomeScreen(Context context, boolean shouldShowWelcomeScreen) { | ||
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCE_KEY, 0); | ||
SharedPreferences.Editor editor = prefs.edit(); | ||
editor.putBoolean(SHOULD_DISPLAY_WELCOME_SCREEN, shouldShowWelcomeScreen); | ||
editor.commit(); | ||
} | ||
|
||
public static synchronized boolean shouldShowWelcomeScreen(Context context) { | ||
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCE_KEY, 0); | ||
return prefs.getBoolean(SHOULD_DISPLAY_WELCOME_SCREEN, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.