Skip to content

Commit

Permalink
Refactor, bug fix, removed night images, added tint in xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Djonique committed Nov 6, 2017
1 parent 297fc53 commit 4826d49
Show file tree
Hide file tree
Showing 31 changed files with 69 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}

/**
* Sets up UI depending on person's data
* Set up UI depending on person's data
*/
private void setupUI() {
setSeasonImage();
Expand Down Expand Up @@ -260,7 +260,7 @@ void starEditActivity() {
}

/**
* Sets up image depending on month
* Set up image depending on month
*/
private void setSeasonImage() {
Calendar calendar = Calendar.getInstance();
Expand Down Expand Up @@ -324,21 +324,21 @@ void makeCall() {
@OnClick(R.id.imagebutton_detail_chat)
void sendMessage() {
mFirebaseAnalytics.logEvent(Constants.SEND_MESSAGE, new Bundle());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType(Constants.TYPE_SMS);
intent.putExtra(Constants.ADDRESS, phoneNumber);
intent.setData(Uri.parse(Constants.SMSTO + phoneNumber));
Intent intent = new Intent(Intent.ACTION_VIEW)
.setType(Constants.TYPE_SMS)
.putExtra(Constants.ADDRESS, phoneNumber)
.setData(Uri.parse(Constants.SMSTO + phoneNumber));
startActivity(Intent.createChooser(intent, null));
}

@OnClick(R.id.imagebutton_detail_email)
void sendEmail() {
mFirebaseAnalytics.logEvent(Constants.SEND_EMAIL, new Bundle());
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType(Constants.TYPE_EMAIL);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.happy_birthday));
intent.setData(Uri.parse(Constants.MAILTO + email));
Intent intent = new Intent(Intent.ACTION_SENDTO)
.setType(Constants.TYPE_EMAIL)
.putExtra(Intent.EXTRA_EMAIL, new String[]{email})
.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.happy_birthday))
.setData(Uri.parse(Constants.MAILTO + email));
startActivity(Intent.createChooser(intent, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void onBackPressed() {
}

/**
* Sets up UI depending on person's data
* Set up UI depending on person's data
*/
private void setupUI() {
etName.setText(person.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void onCreate(Bundle savedInstanceState) {
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

/*
* Sets summary for additional notification
* Set summary for additional notification
*/
findPreference(Constants.ADDITIONAL_NOTIFICATION_KEY).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
Expand All @@ -206,7 +206,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
});

/*
* Sets summary for ringtone
* Set summary for ringtone
*/
Preference ringtonePreference = findPreference(Constants.RINGTONE_KEY);
try {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/djonique/birdays/ad/Ad.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onAdLoaded() {
}

/**
* Sets up bottom padding of view under AdMob banner
* Set up bottom padding of view under AdMob banner
*/
private static void setupContentViewPadding(View view, int padding) {
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public void onBindViewHolder(final CardViewHolder holder, int position) {
holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, DetailActivity.class);
intent.putExtra(Constants.TIME_STAMP, person.getTimeStamp());
Intent intent = new Intent(context, DetailActivity.class)
.putExtra(Constants.TIME_STAMP, person.getTimeStamp());
context.startActivity(intent);
if (context instanceof MainActivity) {
((MainActivity) context).overridePendingTransition(R.anim.activity_secondary_in, R.anim.activity_primary_out);
Expand All @@ -126,10 +126,10 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
mFirebaseAnalytics.logEvent(Constants.SEND_EMAIL, new Bundle());
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType(Constants.TYPE_EMAIL);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.happy_birthday));
Intent intent = new Intent(Intent.ACTION_SENDTO)
.setType(Constants.TYPE_EMAIL)
.putExtra(Intent.EXTRA_EMAIL, new String[]{email})
.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.happy_birthday));
intent.setData(Uri.parse(Constants.MAILTO + email));
context.startActivity(Intent.createChooser(intent, null));
}
Expand All @@ -154,10 +154,10 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
mFirebaseAnalytics.logEvent(Constants.SEND_MESSAGE, new Bundle());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType(Constants.TYPE_SMS);
intent.putExtra(Constants.ADDRESS, phoneNumber);
intent.setData(Uri.parse(Constants.SMSTO + phoneNumber));
Intent intent = new Intent(Intent.ACTION_VIEW)
.setType(Constants.TYPE_SMS)
.putExtra(Constants.ADDRESS, phoneNumber)
.setData(Uri.parse(Constants.SMSTO + phoneNumber));
context.startActivity(Intent.createChooser(intent, null));
}
});
Expand Down Expand Up @@ -247,11 +247,8 @@ static class CardViewHolder extends RecyclerView.ViewHolder {
tvAge = itemView.findViewById(R.id.textview_card_age);
tvDaysLeft = itemView.findViewById(R.id.textview_card_left);
btnEmail = itemView.findViewById(R.id.imagebutton_card_email);
btnEmail.setImageResource(R.drawable.ic_email_blue_green_24dp);
btnChat = itemView.findViewById(R.id.imagebutton_card_chat);
btnChat.setImageResource(R.drawable.ic_chat_blue_green_24dp);
btnCall = itemView.findViewById(R.id.imagebutton_card_call);
btnCall.setImageResource(R.drawable.ic_call_blue_green_24dp);
}
}
}
9 changes: 0 additions & 9 deletions app/src/main/java/com/djonique/birdays/alarm/AlarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public AlarmHelper(Context context) {
/**
* Set up both alarms main and additional
*/

public void setAlarms(Person person) {
try {
setAlarm(person);
Expand All @@ -67,7 +66,6 @@ public void setAlarms(Person person) {
/**
* Set up main alarm
*/

private void setAlarm(Person person) {
Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra(Constants.NAME, person.getName());
Expand All @@ -85,7 +83,6 @@ private void setAlarm(Person person) {
/**
* Set up additional alarm
*/

private void setAdditionalAlarm(Person person) {
additionalNotificationOffset = Long.parseLong(preferences.getString(Constants.ADDITIONAL_NOTIFICATION_KEY, "0"));

Expand All @@ -107,7 +104,6 @@ private void setAdditionalAlarm(Person person) {
/**
* Set up correct alarm for Android API 19 (without delay) and Android API 23+ with Doze
*/

private void setAlarmDependingOnApi(AlarmManager alarmManager,
long triggerAtMillis,
PendingIntent pendingIntent) {
Expand All @@ -123,7 +119,6 @@ private void setAlarmDependingOnApi(AlarmManager alarmManager,
/**
* Configures text for additional notification
*/

private String setWhen(long offset) {
String[] dates = context.getResources().getStringArray(R.array.additional_notification_delay);
String[] entryValues = context.getResources().getStringArray(R.array.additional_notification_entry_values);
Expand All @@ -139,7 +134,6 @@ private String setWhen(long offset) {
/**
* Removes all alarms
*/

public void removeAlarms(long timeStamp) {
removeAlarm(timeStamp);
additionalNotificationOffset = Long.parseLong(preferences.getString(Constants.ADDITIONAL_NOTIFICATION_KEY, "0"));
Expand All @@ -151,7 +145,6 @@ public void removeAlarms(long timeStamp) {
/**
* Removes main alarm
*/

private void removeAlarm(long timeStamp) {
Intent intent = new Intent(context, AlarmReceiver.class);

Expand All @@ -164,7 +157,6 @@ private void removeAlarm(long timeStamp) {
/**
* Removes additional alarm
*/

private void removeAdditionalAlarm(long timeStamp) {
Intent intent = new Intent(context, AlarmReceiver.class);

Expand All @@ -179,7 +171,6 @@ private void removeAdditionalAlarm(long timeStamp) {
/**
* Set up time for triggering alarm
*/

private long setupCalendarYear(Person person, long offset) {
long now = Calendar.getInstance().getTimeInMillis();
long notificationTime = preferences.getLong(Constants.NOTIFICATION_TIME_KEY, defaultNotificationTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void onReceive(Context context, Intent intent) {
/**
* Creates intent to open DetailActivity on notification click
*/

private Intent getResultIntent(Context context, long timeStamp, Intent intent) {
Intent resultIntent = new Intent(context, DetailActivity.class);
resultIntent.putExtra(Constants.TIME_STAMP, timeStamp);
Expand All @@ -89,7 +88,6 @@ private Intent getResultIntent(Context context, long timeStamp, Intent intent) {
/**
* Creates notification channel for Android API 26+
*/

private void createNotificationChannel(Context context) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
Expand All @@ -106,7 +104,6 @@ private void createNotificationChannel(Context context) {
/**
* Builds default notification
*/

private NotificationCompat.Builder buildNotification(Context context, String title, String text) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID);
builder.setContentTitle(title);
Expand All @@ -122,7 +119,6 @@ private NotificationCompat.Builder buildNotification(Context context, String tit
/**
* Avoids FileUriExposedException on Android API 24+
*/

private void setDefaultsAndRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
Expand All @@ -138,7 +134,6 @@ private void setDefaultsAndRingtone(NotificationCompat.Builder builder, Uri ring
/**
* Set up notification tone, vibration and lights for notification
*/

private void setRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
builder.setDefaults(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_LIGHTS);
builder.setSound(ringtoneUri);
Expand All @@ -147,7 +142,6 @@ private void setRingtone(NotificationCompat.Builder builder, Uri ringtoneUri) {
/**
* Returns URI for picked in the settings notification tone
*/

private Uri getRingtoneUri(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String ringtone = preferences.getString(Constants.RINGTONE_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private String writeXml(List<Person> persons) {
xmlSerializer.startTag(null, DATE);
xmlSerializer.text(String.valueOf(person.getDate()));
xmlSerializer.endTag(null, DATE);
// unknown year
// year unknown
xmlSerializer.startTag(null, YEAR_UNKNOWN);
xmlSerializer.text(String.valueOf(person.isYearUnknown()));
xmlSerializer.endTag(null, YEAR_UNKNOWN);
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/com/djonique/birdays/models/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@ public class Person implements Item {
private long date, timeStamp;
private boolean yearUnknown;

// Default constructor
/**
* Default constructor
*/
public Person() {
this.timeStamp = new Date().getTime();
}

// Constructor for database with famous persons
/**
* Constructor for database with famous persons
*/
public Person(String name, long date) {
this.name = name;
this.date = date;
}

// Constructor for importing from Contacts
/**
* Constructor for importing from Contacts
*/
public Person(String name, long date, boolean yearUnknown, String phoneNumber, String email) {
this.name = name;
this.date = date;
Expand All @@ -46,7 +52,9 @@ public Person(String name, long date, boolean yearUnknown, String phoneNumber, S
this.timeStamp = new Date().getTime();
}

// Constructor for DbQueryManager
/**
* Constructor for DbQueryManager
*/
public Person(String name, long date, boolean yearUnknown, String phoneNumber, String email,
long timeStamp) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public DatePickerManager(Activity activity, Calendar calendar) {
/**
* Shows material calendar on API 24 devices instead of spinner
*/

public void showDialog(DatePickerDialog.OnDateSetListener androidCallback,
com.wdullaer.materialdatetimepicker.date.DatePickerDialog.OnDateSetListener libCallback) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
Expand All @@ -55,7 +54,6 @@ public void showDialog(DatePickerDialog.OnDateSetListener androidCallback,
/**
* Configures android DatePickerDialog
*/

private void showDatePickerDialog(DatePickerDialog.OnDateSetListener callback) {
android.app.DatePickerDialog datePickerDialog = new android.app.DatePickerDialog(
activity,
Expand All @@ -70,7 +68,6 @@ private void showDatePickerDialog(DatePickerDialog.OnDateSetListener callback) {
/**
* Configures DatePickerDialog by Wouter Dullaert
*/

private void showMdtpDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog.OnDateSetListener callback) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
com.wdullaer.materialdatetimepicker.date.DatePickerDialog dpd =
Expand All @@ -87,7 +84,6 @@ private void showMdtpDialog(com.wdullaer.materialdatetimepicker.date.DatePickerD
/**
* Set correct theme for day/night modes
*/

private int setTheme(boolean nightMode) {
if (nightMode) {
return AlertDialog.THEME_HOLO_DARK;
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/res/drawable-night/ic_calendar_blue_green_24dp.xml

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/drawable-night/ic_call_blue_green_24dp.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/drawable-night/ic_chat_blue_green_24dp.xml

This file was deleted.

Loading

0 comments on commit 4826d49

Please sign in to comment.