Skip to content

Commit

Permalink
Merge pull request #299 from spacecowboy/defaultdate
Browse files Browse the repository at this point in the history
Change default notification time to (today + 1hour)
  • Loading branch information
spacecowboy committed Sep 2, 2015
2 parents 0a39816 + 5cea125 commit 8ba17fc
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {
// Version number
def versionMajor = 5 // Major UI overhauls
def versionMinor = 5 // Some new functionality
def versionPatch = 5 // Bug fixes
def versionPatch = 6 // Bug fixes
def versionBuild = 0 // Bump for dogfood builds, public betas, etc.

// Version name from git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/*
* Copyright (c) 2014 Jonas Kalderstam.
* Copyright (c) 2015 Jonas Kalderstam.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* http://www.apache.org/licenses/LICENSE-2.0
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.nononsenseapps.notepad.fragments;
Expand Down Expand Up @@ -524,16 +525,6 @@ void onAddReminder() {
return;
}
final Notification not = new Notification(mTask._id);
// TODO remove this, no need to default
// final Calendar local = Calendar.getInstance();
// local.add(Calendar.MINUTE, 1);
// final long soon = local.getTimeInMillis();
// if (mTask.due == null || mTask.due < soon) {
// not.time = soon;
// }
// else {
// not.time = mTask.due;
// }
not.save(getActivity(), true);

// add item to UI
Expand Down
74 changes: 45 additions & 29 deletions app/src/main/java/com/nononsenseapps/ui/NotificationItemHelper.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
package com.nononsenseapps.ui;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/*
* Copyright (c) 2015 Jonas Kalderstam.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import com.nononsenseapps.helpers.TimeFormatter;
import com.nononsenseapps.notepad.ActivityLocation;
import com.nononsenseapps.notepad.BuildConfig;
import com.nononsenseapps.notepad.R;
import com.nononsenseapps.notepad.database.Notification;
import com.nononsenseapps.notepad.database.Task;
import com.nononsenseapps.notepad.fragments.TaskDetailFragment;
import com.nononsenseapps.ui.WeekDaysView.onCheckedDaysChangeListener;
import com.android.datetimepicker.time.TimePickerDialog;
import com.android.datetimepicker.time.TimePickerDialog.OnTimeSetListener;
import com.android.datetimepicker.time.RadialPickerLayout;
import com.android.datetimepicker.date.DatePickerDialog;
import com.android.datetimepicker.date.DatePickerDialog.OnDateSetListener;
package com.nononsenseapps.ui;

import android.content.Context;
import android.content.Intent;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;

import com.android.datetimepicker.date.DatePickerDialog;
import com.android.datetimepicker.date.DatePickerDialog.OnDateSetListener;
import com.android.datetimepicker.time.RadialPickerLayout;
import com.android.datetimepicker.time.TimePickerDialog;
import com.android.datetimepicker.time.TimePickerDialog.OnTimeSetListener;
import com.nononsenseapps.helpers.TimeFormatter;
import com.nononsenseapps.notepad.ActivityLocation;
import com.nononsenseapps.notepad.BuildConfig;
import com.nononsenseapps.notepad.R;
import com.nononsenseapps.notepad.database.Notification;
import com.nononsenseapps.notepad.database.Task;
import com.nononsenseapps.notepad.fragments.TaskDetailFragment;
import com.nononsenseapps.ui.WeekDaysView.onCheckedDaysChangeListener;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
* Handle setting up all the listeners for a Notification list item
Expand Down Expand Up @@ -86,15 +103,14 @@ private static void showViews(final View... views) {
private static void setTime(final Context context, final Notification not,
final Task mTask) {
final GregorianCalendar cal = TimeFormatter.getLocalCalendar(context);
// Start with date
if (mTask.due != null) {
// Start with date, either due date or today (default)
// If due date is in the past, default to today + 1hour
if (mTask.due != null && mTask.due > cal.getTimeInMillis()) {
cal.setTimeInMillis(mTask.due);
} else {
cal.add(Calendar.DAY_OF_YEAR, 1);
// Default to today, set time one hour from now
cal.add(Calendar.HOUR_OF_DAY, 1);
}
// Now set a reasonable time of day like 9 AM
cal.set(Calendar.HOUR_OF_DAY, 9);
cal.set(Calendar.MINUTE, 0);

// And set time on notification
not.time = cal.getTimeInMillis();
Expand Down

0 comments on commit 8ba17fc

Please sign in to comment.