Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: reminder type selector #32

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ab79bac
remove naggingSwitch and comment code that uses it
maxcutlyp Jun 11, 2022
97fef60
add dependency: https://github.com/kelmer44/fabmenus/
maxcutlyp Jun 12, 2022
0742f7d
add placeholder FAB to layout
maxcutlyp Jun 12, 2022
ae66157
Add persistence to reminderType selection
maxcutlyp Jun 13, 2022
4ed1d92
make reminder type button smaller
maxcutlyp Jun 15, 2022
b7a3d0e
increase size of icons and label
maxcutlyp Jun 15, 2022
c764b83
change fab pressed colour to grey
maxcutlyp Jun 15, 2022
9ce7979
add fabmenus as submodule dependency
maxcutlyp Jun 15, 2022
9b25eeb
use local dependency
maxcutlyp Jun 15, 2022
572bf58
switch to new submodule branch
maxcutlyp Jun 15, 2022
5342912
change fab icon colour according to selection
maxcutlyp Jun 15, 2022
50bc888
revert changes to Reminder
maxcutlyp Jun 20, 2022
42e789f
add "coming soon" toast for alarm reminders
maxcutlyp Jun 20, 2022
0b2bdc7
add dependency to fix an issue involving FAB menus in the designer
maxcutlyp Jun 20, 2022
4519f83
switch interpolator from overshoot to accelerate_quint
maxcutlyp Jun 20, 2022
4f4b038
roll back to older version of core-ktx
maxcutlyp Jun 20, 2022
d608161
align reminder type FAB with date plus button
maxcutlyp Jun 20, 2022
fed1026
add long click action for nagging FAB
maxcutlyp Jun 20, 2022
35b74be
generalise onClick/onLongClick methods
maxcutlyp Jun 20, 2022
1939d9e
use selected reminder type long click listener for main FAB
maxcutlyp Jun 20, 2022
8cfc874
import bell and alarm icon SVG paths from Android SystemUI
maxcutlyp Jun 20, 2022
8f7849b
update LICENSE.md to include ringer and alarm icons
maxcutlyp Jun 20, 2022
c9dc616
add nagging reminder icon
maxcutlyp Jun 22, 2022
bec0f63
change FAB animation interpolator and time
maxcutlyp Jun 22, 2022
c201944
add setColorsWithoutSettingCurrentColor method
maxcutlyp Jun 22, 2022
644ab9c
remove ripple effect from FAB and menu labels
maxcutlyp Jun 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = app/lib/SectionedRecyclerViewAdapter
url = https://github.com/felixwiemuth/SectionedRecyclerViewAdapter
branch = feature/multipleItemViewTypes
[submodule "fabmenus"]
path = app/lib/fabmenus
url = https://github.com/maxcutlyp/fabmenus
branch = SimpleReminder-changes
1 change: 1 addition & 0 deletions .idea/vcs.xml

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

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ android {

versionName = versionCodeMajor + "." + versionCodeMinor + "." + versionCodePoint + "-" + releaseChannel + "-" + gitDescription

minSdkVersion 16
minSdkVersion 21
targetSdkVersion 27

archivesBaseName = "SimpleReminder_" + versionName
Expand Down Expand Up @@ -93,5 +93,7 @@ dependencies {
implementation project(':sectionedrecyclerviewadapter')
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
implementation 'androidx.core:core-ktx:1.8.0'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luckily this will anyway be included because of the switch to Kotlin (I'll try to push my maintenance work soon).

testImplementation 'junit:junit:4.13.2'
}
implementation project(':fabmenus')
}
1 change: 1 addition & 0 deletions app/lib/fabmenus
Submodule fabmenus added at 9da20f
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ private void setupActivityWithReminder(Intent intent) {
if (reminder.getStatus() == Reminder.Status.SCHEDULED) {
setSelectedDateTimeAndSelectionMode(reminder.getCalendar());
}
naggingSwitch.setChecked(reminder.isNagging());

// TODO: once data.Reminder has a reminderType field, use something like
// updateReminderTypeFabMenu(reminder.getReminderType());
// instead of the else case below

if (reminder.isNagging()) {
naggingRepeatInterval = reminder.getNaggingRepeatInterval();
updateReminderTypeFabMenu(ReminderType.NAGGING);
} else {
updateReminderTypeFabMenu(ReminderType.NORMAL);
}
reminderToUpdate = reminderId;
} catch (ReminderManager.ReminderNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package felixwiemuth.simplereminder.ui;

import android.app.DatePickerDialog;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
Expand All @@ -34,11 +35,16 @@
import android.widget.TimePicker;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.content.res.AppCompatResources;

import com.kelmer.android.fabmenu.fab.FloatingActionButton;
import com.kelmer.android.fabmenu.linear.AdvancedFabMenu;

import java.util.Calendar;
import java.util.EnumMap;

import felixwiemuth.simplereminder.Prefs;
import felixwiemuth.simplereminder.R;
Expand All @@ -50,14 +56,16 @@
*/
public abstract class ReminderDialogActivity extends AppCompatActivity {
protected AutoCompleteTextView nameTextView;
protected SwitchCompat naggingSwitch;
private AdvancedFabMenu reminderTypeFabMenu;
private Button addButton;
private Button dateMinusButton;
private Button datePlusButton;
private TextView dateDisplay;
private TimePicker timePicker;

private DateSelectionMode dateSelectionMode;
protected ReminderType reminderType;
private final EnumMap<ReminderType, ReminderTypeFabInfo> reminderTypeMap = new EnumMap<>(ReminderType.class);
/**
* The currently selected date. It is an invariant that after every user interaction this
* date is in the future (except initially, before changing time or date).
Expand All @@ -77,6 +85,27 @@ private enum DateSelectionMode {
MANUAL
}

protected enum ReminderType {
NORMAL,
NAGGING,
ALARM,
}

/**
* Simple helper class to connect info about reminder type FABs. Should be only used in the context of reminderTypeMap.
*/
private static class ReminderTypeFabInfo {
public FloatingActionButton fab;
public int viewIdRes;
public Drawable icon;

public ReminderTypeFabInfo(@Nullable FloatingActionButton fab, int viewIdRes, Drawable icon) {
this.fab = fab;
this.viewIdRes = viewIdRes;
this.icon = icon;
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -98,16 +127,42 @@ protected void onCreate(Bundle savedInstanceState) {
selectedDate.get(Calendar.DAY_OF_MONTH)
).show());

naggingSwitch = findViewById(R.id.naggingSwitch);
naggingSwitch.setOnClickListener(v -> {
if (naggingSwitch.isChecked()) {
showToastNaggingRepeatInterval();
reminderType = ReminderType.NORMAL;
reminderTypeFabMenu = findViewById(R.id.reminder_type_menu);

reminderTypeMap.put(ReminderType.NORMAL, new ReminderTypeFabInfo(null,
R.id.reminder_type_normal,
AppCompatResources.getDrawable(this, R.drawable.ic_reminder_type_normal)));
reminderTypeMap.put(ReminderType.NAGGING, new ReminderTypeFabInfo(null,
R.id.reminder_type_nagging,
AppCompatResources.getDrawable(this, R.drawable.ic_reminder_type_nagging)));
reminderTypeMap.put(ReminderType.ALARM, new ReminderTypeFabInfo(null,
R.id.reminder_type_alarm,
AppCompatResources.getDrawable(this, R.drawable.ic_reminder_type_alarm)));

for (ReminderType type : ReminderType.values()) {
ReminderTypeFabInfo fabInfo = reminderTypeMap.get(type);
assert fabInfo != null; // if another type is added to ReminderType later, this assertion will trip
FloatingActionButton fab = findViewById(fabInfo.viewIdRes);

// TODO: remove if-block when alarm reminders are implemented
if (type.equals(ReminderType.ALARM)) {
fab.setOnClickListener(v -> {
Toast.makeText(this, R.string.add_reminder_toast_alarm_coming_soon, Toast.LENGTH_SHORT).show();
});
} else {
fab.setOnClickListener(v -> {
reminderType = type;
reminderTypeFabMenu.close(true);

updateReminderTypeFabMenu(type);
});
}
});
naggingSwitch.setOnLongClickListener(view -> {
showChooseNaggingRepeatIntervalDialog();
return true;
});

fabInfo.fab = fab;
}
updateReminderTypeFabMenu(reminderType);

timePicker = findViewById(R.id.timePicker);

nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
Expand Down Expand Up @@ -143,6 +198,29 @@ protected void onCreate(Bundle savedInstanceState) {
renderSelectedDate();
}

protected void updateReminderTypeFabMenu(ReminderType newType) {
ReminderTypeFabInfo fi = reminderTypeMap.get(newType);
assert fi != null; // if another type is added to ReminderType later, this assertion will trip
reminderTypeFabMenu.setIcon(fi.icon);
reminderTypeFabMenu.menuButton.setColors(
fi.fab.getColorNormal(),
reminderTypeFabMenu.menuButton.getColorPressed(),
reminderTypeFabMenu.menuButton.getColorRipple());
reminderTypeFabMenu.menuButton.updateBackground();

for (ReminderType type : ReminderType.values()) {
ReminderTypeFabInfo fabInfo = reminderTypeMap.get(type);
assert fabInfo != null;
FloatingActionButton fab = fabInfo.fab;

if (newType.equals(type)) {
fab.showProgressBar();
} else {
fab.hideProgress();
}
}
}

/**
* Given an hour and minute, returns a date representing the next occurrence of this time within the next 24 hours. The seconds are set to 0, milliseconds become the value within the current second.
*/
Expand Down Expand Up @@ -330,7 +408,7 @@ private void showChooseNaggingRepeatIntervalDialog() {
naggingRepeatInterval = naggingRepeatIntervalNumberPicker.getValue();
// Show the toast about the set nagging repeat interval (also when nagging was already enabled)
showToastNaggingRepeatInterval();
naggingSwitch.setChecked(true); // Note: this does not trigger the on-cilck listener.
// naggingSwitch.setChecked(true); // Note: this does not trigger the on-cilck listener.
})
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {})
.show();
Expand All @@ -344,8 +422,9 @@ protected Reminder.ReminderBuilder buildReminderWithTimeTextNagging() {
Reminder.ReminderBuilder reminderBuilder = Reminder.builder()
.date(selectedDate.getTime())
.text(nameTextView.getText().toString());
// TODO: add ReminderType

if (naggingSwitch.isChecked()) {
if (reminderType.equals(ReminderType.NAGGING)) {
reminderBuilder.naggingRepeatInterval(naggingRepeatInterval);
}

Expand Down
28 changes: 28 additions & 0 deletions app/src/main/res/drawable/ic_reminder_type_alarm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2018-2022 Felix Wiemuth and contributors (see CONTRIBUTORS.md)
~
~ 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/>.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path
android:pathData="M 8.368 1.932 L 8.02 2.892 Q 7.648 2.712 7.258 2.604 A 2.762 2.762 0 0 0 6.89 2.53 Q 6.7 2.505 6.486 2.498 A 4.885 4.885 0 0 0 6.34 2.496 A 2.541 2.541 0 0 0 5.392 2.671 A 2.398 2.398 0 0 0 4.966 2.892 A 2.54 2.54 0 0 0 4.202 3.682 A 3.237 3.237 0 0 0 4.012 4.032 Q 3.664 4.776 3.664 5.832 A 5.024 5.024 0 0 0 3.738 6.715 A 3.711 3.711 0 0 0 4.006 7.596 A 3.081 3.081 0 0 0 4.436 8.295 A 2.571 2.571 0 0 0 4.954 8.772 Q 5.56 9.192 6.34 9.192 A 4.046 4.046 0 0 0 6.817 9.165 Q 7.114 9.13 7.36 9.048 Q 7.792 8.904 8.2 8.676 L 8.548 9.624 A 4.507 4.507 0 0 1 8.009 9.869 A 5.747 5.747 0 0 1 7.534 10.026 A 4.031 4.031 0 0 1 6.938 10.145 Q 6.598 10.188 6.208 10.188 A 3.886 3.886 0 0 1 5.089 10.032 A 3.355 3.355 0 0 1 4.276 9.666 A 3.432 3.432 0 0 1 3.091 8.413 A 4.19 4.19 0 0 1 2.968 8.178 Q 2.507 7.226 2.5 5.918 A 7.525 7.525 0 0 1 2.5 5.88 Q 2.5 4.596 2.974 3.606 A 3.796 3.796 0 0 1 3.812 2.45 A 3.583 3.583 0 0 1 4.318 2.058 A 3.525 3.525 0 0 1 5.84 1.529 A 4.475 4.475 0 0 1 6.352 1.5 A 5.477 5.477 0 0 1 6.959 1.532 A 4.224 4.224 0 0 1 7.444 1.614 A 4.587 4.587 0 0 1 8.341 1.919 A 4.265 4.265 0 0 1 8.368 1.932 Z"
android:strokeWidth="0"
android:fillColor="#fff"
android:strokeColor="#fff" />
</vector>
28 changes: 28 additions & 0 deletions app/src/main/res/drawable/ic_reminder_type_nagging.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2018-2022 Felix Wiemuth and contributors (see CONTRIBUTORS.md)
~
~ 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/>.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path
android:pathData="M 3.5 10.172 L 3.5 1.82 Q 3.915 1.773 4.529 1.737 A 29.919 29.919 0 0 1 4.544 1.736 Q 5.168 1.7 5.972 1.7 A 6.517 6.517 0 0 1 6.863 1.757 Q 7.315 1.819 7.683 1.951 A 2.712 2.712 0 0 1 8.336 2.282 Q 9.134 2.843 9.163 3.788 A 2.343 2.343 0 0 1 9.164 3.86 A 2.046 2.046 0 0 1 9.089 4.426 A 1.656 1.656 0 0 1 8.81 4.982 A 2.194 2.194 0 0 1 8.344 5.427 Q 8.099 5.603 7.784 5.744 A 3.626 3.626 0 0 1 8.34 5.991 Q 8.758 6.223 9.02 6.542 A 1.83 1.83 0 0 1 9.424 7.514 A 2.414 2.414 0 0 1 9.44 7.796 A 2.32 2.32 0 0 1 9.262 8.72 Q 9.039 9.238 8.54 9.614 A 2.962 2.962 0 0 1 7.655 10.059 Q 6.929 10.292 5.924 10.292 A 26.62 26.62 0 0 1 4.954 10.275 A 22.508 22.508 0 0 1 4.538 10.256 A 27.291 27.291 0 0 1 4.228 10.237 Q 3.788 10.208 3.5 10.172 Z M 6.008 6.308 L 4.64 6.308 L 4.64 9.272 Q 5.276 9.344 6.008 9.344 Q 6.709 9.344 7.208 9.179 A 2.072 2.072 0 0 0 7.676 8.96 A 1.305 1.305 0 0 0 8.086 8.557 Q 8.246 8.303 8.271 7.97 A 1.68 1.68 0 0 0 8.276 7.844 A 1.407 1.407 0 0 0 8.171 7.292 Q 8.039 6.979 7.74 6.754 A 1.683 1.683 0 0 0 7.688 6.716 A 2.004 2.004 0 0 0 7.127 6.452 Q 6.862 6.371 6.541 6.336 A 4.874 4.874 0 0 0 6.008 6.308 Z M 4.64 2.684 L 4.64 5.42 L 5.96 5.42 A 3.679 3.679 0 0 0 6.564 5.374 Q 6.882 5.321 7.14 5.207 A 1.831 1.831 0 0 0 7.466 5.024 A 1.463 1.463 0 0 0 7.795 4.71 A 1.147 1.147 0 0 0 8.024 4.004 A 1.296 1.296 0 0 0 7.943 3.536 Q 7.822 3.22 7.519 3.009 A 1.477 1.477 0 0 0 7.472 2.978 Q 6.92 2.624 5.96 2.624 Q 5.564 2.624 5.24 2.642 Q 4.916 2.66 4.64 2.684 Z"
android:strokeWidth="0"
android:fillColor="#fff"
android:strokeColor="#fff" />
</vector>
28 changes: 28 additions & 0 deletions app/src/main/res/drawable/ic_reminder_type_normal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2018-2022 Felix Wiemuth and contributors (see CONTRIBUTORS.md)
~
~ 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/>.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path
android:pathData="M 9.976 9.6 L 8.932 10.02 L 7.996 7.62 L 4.108 7.62 L 3.172 9.996 L 2.2 9.6 L 5.488 1.5 L 6.736 1.5 L 9.976 9.6 Z M 6.052 2.628 L 4.468 6.66 L 7.624 6.66 L 6.052 2.628 Z"
android:strokeWidth="0"
android:fillColor="#fff"
android:strokeColor="#fff" />
</vector>
Loading