Skip to content

Commit

Permalink
Merge pull request #5 from Julesssss/develop
Browse files Browse the repository at this point in the history
Close 3.0 release
  • Loading branch information
Julesssss authored Mar 4, 2018
2 parents e408d4d + cd6110b commit d7b576f
Show file tree
Hide file tree
Showing 66 changed files with 2,470 additions and 1,209 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ Thumbs.db
.gradle
build/
*.iml

app/google-services\.json
4 changes: 2 additions & 2 deletions BirthdayReminder.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="BirthdayReminder" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="BirthdayReminder" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand All @@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
41 changes: 26 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "website.julianrosser.birthdays"
minSdkVersion 11
targetSdkVersion 23
versionCode 241
versionName "2.4.1"
versionCode 300
versionName "3.0.0"
}

buildTypes {
Expand All @@ -19,6 +20,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions { disable "MissingTranslation" }
}
buildTypes.each {
it.buildConfigField 'String', 'GOOGLE_SIGN_IN_KEY', GOOGLE_SIGN_IN_KEY
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
Expand All @@ -30,15 +34,22 @@ android {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-crash:9.0.0'

}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
12 changes: 8 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


<application
android:name="BirthdayReminder"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -28,10 +29,6 @@
android:name=".activities.BirthdayListActivity"
android:label="@string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />

Expand Down Expand Up @@ -93,6 +90,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.BirthdayListActivity" />
</activity>

<activity android:name=".activities.WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
48 changes: 48 additions & 0 deletions app/src/main/java/website/julianrosser/birthdays/AlarmsHelper.java
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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import android.app.Application;

import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class BirthdayReminder extends Application {

// Application reference
private static BirthdayReminder sInstance;
private FirebaseDatabase mFirebaseDatabase;
private DatabaseReference mDatabase;
private FirebaseUser currentUser;

public static BirthdayReminder getInstance() {
return sInstance;
Expand All @@ -15,6 +22,32 @@ public static BirthdayReminder getInstance() {
public void onCreate() {
super.onCreate();
sInstance = this;
initializeFirebase();
}

private void initializeFirebase() {
FirebaseApp.initializeApp(this);
mFirebaseDatabase = FirebaseDatabase.getInstance();
mFirebaseDatabase.setPersistenceEnabled(true);
mDatabase = mFirebaseDatabase.getReference();
}

public DatabaseReference getDatabaseReference() {
if (mDatabase == null) {
if (mFirebaseDatabase == null) {
mFirebaseDatabase = FirebaseDatabase.getInstance();
}
mDatabase = mFirebaseDatabase.getReference();
}
return mDatabase;
}

public void setUser(FirebaseUser currentUser) {
this.currentUser = currentUser;
}

public FirebaseUser getCurrentUser() {
return currentUser;
}

}
10 changes: 10 additions & 0 deletions app/src/main/java/website/julianrosser/birthdays/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ public class Constants {
*/
public static final String FILENAME = "birthdays.json";

public static int DEFAULT_YEAR_OF_BIRTH = 1990;
public static long DAY_IN_MILLIS = 86400000L; // / 86,400,000 milliseconds in a day
public static long HOUR_IN_MILLIS = 3600000L; // Amount of milliseconds in an hour

public static int INTENT_FROM_NOTIFICATION = 30;
public static int CONTACT_PERMISSION_CODE = 3;
public static String INTENT_FROM_KEY = "intent_from_key";
public static String GOOGLE_SIGN_IN_KEY = "1072707269724-3v8qbbu86kmfs252eu44amna8cpqqj9c.apps.googleusercontent.com";

/**
* Firebase constants
*/
public static String TABLE_BIRTHDAYS = "birthdays";

}
35 changes: 35 additions & 0 deletions app/src/main/java/website/julianrosser/birthdays/Preferences.java
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);
}
}
20 changes: 20 additions & 0 deletions app/src/main/java/website/julianrosser/birthdays/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.util.TypedValue;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -13,14 +15,22 @@ public static Date stringToDate(String birthdayString) {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
if (birthdayString.startsWith("-")) {
birthdayString = birthdayString.replaceFirst("-", "1990");
}
date = format.parse(birthdayString);
date.setYear(date.getYear() + 1900);
System.out.println(date);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
return date;
}

public static boolean hasYearOfBirth(String birthdayString) {
return ! birthdayString.startsWith("-");
}

public static String getDateSuffix(int date) {
if (date == 11 || date == 12 || date == 13) {
return "th";
Expand Down Expand Up @@ -48,4 +58,14 @@ public static int getHighlightColor(Context context) {
return R.color.blue_accent_400;
}
}

public static boolean isStringEmpty(String s) {
return s == null || s.equals("");
}

// Helper method for getting exact pixel size for device from density independent pixels
public static int getPixelsFromDP(Context context, int px) {
Resources r = context.getResources();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, px, r.getDisplayMetrics());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.google.firebase.analytics.FirebaseAnalytics;

public class BaseActivity extends AppCompatActivity {
abstract public class BaseActivity extends AppCompatActivity {

private FirebaseAnalytics mFirebaseAnalytics;

Expand Down
Loading

0 comments on commit d7b576f

Please sign in to comment.