├── app
├── .gitignore
├── medicine
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── raw
│ │ │ │ └── cuco_sound.mp3
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_add.png
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_clear.png
│ │ │ │ ├── ic_filter_list.png
│ │ │ │ ├── ic_statistics.png
│ │ │ │ └── ic_arrow_drop_down.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_add.png
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_clear.png
│ │ │ │ ├── ic_filter_list.png
│ │ │ │ ├── ic_statistics.png
│ │ │ │ └── ic_arrow_drop_down.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_add.png
│ │ │ │ ├── ic_clear.png
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_statistics.png
│ │ │ │ ├── ic_filter_list.png
│ │ │ │ └── ic_arrow_drop_down.png
│ │ │ ├── drawable
│ │ │ │ ├── icon_blister.png
│ │ │ │ ├── icon_my_health.png
│ │ │ │ ├── image_reminder_take.png
│ │ │ │ ├── image_reminder_taken.png
│ │ │ │ ├── image_reminder_configure.png
│ │ │ │ ├── image_reminder_not_taken.png
│ │ │ │ ├── image_reminder_take_pressed.png
│ │ │ │ ├── image_reminder_take_disabled.png
│ │ │ │ ├── image_reminder_configure_pressed.png
│ │ │ │ ├── image_reminder_configure_disabled.png
│ │ │ │ ├── touch_feedback.xml
│ │ │ │ ├── background_status_medication.xml
│ │ │ │ ├── background_take_medication.xml
│ │ │ │ ├── background_configure_medication.xml
│ │ │ │ ├── drawable_underline.xml
│ │ │ │ ├── background_take_alarm_button.xml
│ │ │ │ ├── background_day_view.xml
│ │ │ │ ├── background_configure_alarm_button.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_add.png
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_clear.png
│ │ │ │ ├── ic_filter_list.png
│ │ │ │ ├── ic_statistics.png
│ │ │ │ └── ic_arrow_drop_down.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_add.png
│ │ │ │ ├── ic_clear.png
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_filter_list.png
│ │ │ │ ├── ic_statistics.png
│ │ │ │ └── ic_arrow_drop_down.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v21
│ │ │ │ ├── ic_arrow_drop_down.xml
│ │ │ │ ├── ic_done.xml
│ │ │ │ ├── ic_add.xml
│ │ │ │ ├── ic_filter_list.xml
│ │ │ │ ├── ic_clear.xml
│ │ │ │ └── ic_statistics.xml
│ │ │ ├── menu
│ │ │ │ ├── medicine_menu.xml
│ │ │ │ ├── history_menu.xml
│ │ │ │ └── filter_history.xml
│ │ │ └── layout
│ │ │ │ ├── component_day_view.xml
│ │ │ │ ├── activity_monthly_report.xml
│ │ │ │ ├── activity_reminder_actvity.xml
│ │ │ │ ├── fragment_medicine.xml
│ │ │ │ ├── activity_add_medicine.xml
│ │ │ │ ├── fragment_history.xml
│ │ │ │ ├── row_history.xml
│ │ │ │ ├── row_medicine.xml
│ │ │ │ ├── fragment_reminder.xml
│ │ │ │ ├── activity_medicine.xml
│ │ │ │ └── fragment_add_medicine.xml
│ │ ├── assets
│ │ │ └── fonts
│ │ │ │ ├── Roboto-Bold.ttf
│ │ │ │ ├── Roboto-Light.ttf
│ │ │ │ └── Roboto-Regular.ttf
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── gautam
│ │ │ │ └── medicinetime
│ │ │ │ ├── BasePresenter.java
│ │ │ │ ├── BaseView.java
│ │ │ │ ├── report
│ │ │ │ ├── FilterType.java
│ │ │ │ ├── MonthlyReportContract.java
│ │ │ │ ├── MonthlyReportActivity.java
│ │ │ │ ├── HistoryAdapter.java
│ │ │ │ ├── MonthlyReportPresenter.java
│ │ │ │ └── MonthlyReportFragment.java
│ │ │ │ ├── MedicineApp.java
│ │ │ │ ├── utils
│ │ │ │ ├── ScrollingCalendarBehavior.java
│ │ │ │ ├── FontUtil.java
│ │ │ │ └── ActivityUtils.java
│ │ │ │ ├── alarm
│ │ │ │ ├── ReminderContract.java
│ │ │ │ ├── ReminderPresenter.java
│ │ │ │ ├── ReminderActivity.java
│ │ │ │ └── ReminderFragment.java
│ │ │ │ ├── views
│ │ │ │ ├── RobotoBoldTextView.java
│ │ │ │ ├── RobotoLightTextView.java
│ │ │ │ ├── RobotoRegularTextView.java
│ │ │ │ └── DayViewCheckBox.java
│ │ │ │ ├── addmedicine
│ │ │ │ ├── AddMedicineContract.java
│ │ │ │ ├── AddMedicinePresenter.java
│ │ │ │ └── AddMedicineActivity.java
│ │ │ │ ├── data
│ │ │ │ └── source
│ │ │ │ │ ├── Pills.java
│ │ │ │ │ ├── MedicineDataSource.java
│ │ │ │ │ ├── History.java
│ │ │ │ │ ├── MedicineRepository.java
│ │ │ │ │ ├── MedicineAlarm.java
│ │ │ │ │ └── local
│ │ │ │ │ └── MedicinesLocalDataSource.java
│ │ │ │ └── medicine
│ │ │ │ ├── MedicineContract.java
│ │ │ │ ├── MedicineAdapter.java
│ │ │ │ ├── MedicinePresenter.java
│ │ │ │ ├── MedicineActivity.java
│ │ │ │ └── MedicineFragment.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── gautam
│ │ │ └── medicinetime
│ │ │ └── ExampleUnitTest.java
│ ├── mock
│ │ └── java
│ │ │ └── com.gautam.medicinetime
│ │ │ ├── Injection.java
│ │ │ └── data
│ │ │ └── FakeMedicineLocalDataSource.java
│ ├── prod
│ │ └── java
│ │ │ └── com.gautam.medicinetime
│ │ │ └── Injection.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── gautam
│ │ └── medicinetime
│ │ └── ExampleInstrumentedTest.java
├── prod
│ └── release
│ │ └── output.json
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── caches
│ └── build_file_checksums.ser
├── vcs.xml
├── runConfigurations.xml
├── modules.xml
├── misc.xml
└── codeStyles
│ └── Project.xml
├── arts
├── Screenshot_2017-08-03-16-16-06-694_com.gautam.medicinetime.mock.png
├── Screenshot_2017-08-03-16-16-17-091_com.gautam.medicinetime.mock.png
└── Screenshot_2017-08-03-16-16-28-924_com.gautam.medicinetime.mock.png
├── gradle.properties
├── .gitignore
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/medicine:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/medicine
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/raw/cuco_sound.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/raw/cuco_sound.mp3
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Roboto-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/assets/fonts/Roboto-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Roboto-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/assets/fonts/Roboto-Light.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_blister.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/icon_blister.png
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Roboto-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/assets/fonts/Roboto-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_my_health.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/icon_my_health.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_filter_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_filter_list.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_statistics.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_filter_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_filter_list.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_statistics.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_statistics.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_take.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_take.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_filter_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_filter_list.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_filter_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_filter_list.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_statistics.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_filter_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_filter_list.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_statistics.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_taken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_taken.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_arrow_drop_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-hdpi/ic_arrow_drop_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_arrow_drop_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-mdpi/ic_arrow_drop_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_arrow_drop_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xhdpi/ic_arrow_drop_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_configure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_configure.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_not_taken.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_not_taken.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxhdpi/ic_arrow_drop_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable-xxxhdpi/ic_arrow_drop_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_take_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_take_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_take_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_take_disabled.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_configure_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_configure_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_reminder_configure_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/app/src/main/res/drawable/image_reminder_configure_disabled.png
--------------------------------------------------------------------------------
/arts/Screenshot_2017-08-03-16-16-06-694_com.gautam.medicinetime.mock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/arts/Screenshot_2017-08-03-16-16-06-694_com.gautam.medicinetime.mock.png
--------------------------------------------------------------------------------
/arts/Screenshot_2017-08-03-16-16-17-091_com.gautam.medicinetime.mock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/arts/Screenshot_2017-08-03-16-16-17-091_com.gautam.medicinetime.mock.png
--------------------------------------------------------------------------------
/arts/Screenshot_2017-08-03-16-16-28-924_com.gautam.medicinetime.mock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gssinghgautam/Medicine-Time-/HEAD/arts/Screenshot_2017-08-03-16-16-28-924_com.gautam.medicinetime.mock.png
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | /**
4 | * Created by gautam on 12/07/17.
5 | */
6 |
7 | public interface BasePresenter {
8 |
9 | void start();
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | /**
4 | * Created by gautam on 12/07/17.
5 | */
6 |
7 | public interface BaseView {
8 |
9 | void setPresenter(T presenter);
10 | }
11 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/touch_feedback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/prod/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"outputFile":{"path":"/Users/gautam/Documents/Projects/MedicineTime/app/prod/release/app-prod-release.apk"},"properties":{"packageId":"com.gautam.medicinetime","split":""}}]
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Apr 21 12:55:27 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/FilterType.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | /**
4 | * Created by gautam on 13/07/17.
5 | */
6 |
7 | public enum FilterType {
8 |
9 | ALL_MEDICINES,
10 |
11 | TAKEN_MEDICINES,
12 |
13 | IGNORED_MEDICINES
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_arrow_drop_down.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_status_medication.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_take_medication.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03a9f4
4 | #2196f3
5 | #1976d2
6 |
7 | #4d4d4d
8 |
9 | #CFD8DC
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_configure_medication.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/medicine_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/history_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_done.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2dp
4 | 4dp
5 | 8dp
6 | 16dp
7 | 14sp
8 | 17sp
9 | 8dp
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_add.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/filter_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_filter_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_clear.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_statistics.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/gautam/medicinetime/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/drawable_underline.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
6 |
7 |
8 |
9 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_take_alarm_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_day_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/background_configure_alarm_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/mock/java/com.gautam.medicinetime/Injection.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 |
6 | import com.gautam.medicinetime.data.source.MedicineRepository;
7 | import com.gautam.medicinetime.data.source.local.MedicinesLocalDataSource;
8 |
9 | /**
10 | * Created by gautam on 13/07/17.
11 | */
12 |
13 | public class Injection {
14 |
15 | public static MedicineRepository provideMedicineRepository(@NonNull Context context) {
16 | return MedicineRepository.getInstance(MedicinesLocalDataSource.getInstance(context));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/prod/java/com.gautam.medicinetime/Injection.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 |
6 |
7 | import com.gautam.medicinetime.data.source.MedicineRepository;
8 | import com.gautam.medicinetime.data.source.local.MedicinesLocalDataSource;
9 |
10 |
11 | /**
12 | * Created by gautam on 13/05/17.
13 | */
14 |
15 | public class Injection {
16 |
17 | public static MedicineRepository provideMedicineRepository(@NonNull Context context) {
18 | return MedicineRepository.getInstance(MedicinesLocalDataSource.getInstance(context));
19 | }
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/MedicineApp.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | /**
7 | * Created by gautam on 12/07/17.
8 | */
9 |
10 | public class MedicineApp extends Application {
11 |
12 | private static Context mInstance;
13 |
14 |
15 | @Override
16 | public void onCreate() {
17 | super.onCreate();
18 | if (mInstance == null) {
19 | mInstance = getApplicationContext();
20 | }
21 | }
22 |
23 | public static Context getInstance() {
24 | return mInstance;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/component_day_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/utils/ScrollingCalendarBehavior.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.utils;
2 |
3 | import android.content.Context;
4 | import com.google.android.material.appbar.AppBarLayout;
5 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
6 | import android.util.AttributeSet;
7 | import android.view.MotionEvent;
8 |
9 | public class ScrollingCalendarBehavior extends AppBarLayout.Behavior {
10 |
11 | public ScrollingCalendarBehavior(Context context, AttributeSet attrs) {
12 | super(context, attrs);
13 | }
14 |
15 | @Override
16 | public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
17 | return false;/*super.onInterceptTouchEvent(parent, child, ev);*/
18 | }
19 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/gautam/medicinetime/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime;
2 |
3 | import android.content.Context;
4 | import androidx.test.platform.app.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getInstrumentation().getContext();
23 |
24 | assertEquals("com.gautam.medicinetime", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/alarm/ReminderContract.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.alarm;
2 |
3 | import com.gautam.medicinetime.BasePresenter;
4 | import com.gautam.medicinetime.BaseView;
5 | import com.gautam.medicinetime.data.source.History;
6 | import com.gautam.medicinetime.data.source.MedicineAlarm;
7 |
8 | /**
9 | * Created by gautam on 13/07/17.
10 | */
11 |
12 | public interface ReminderContract {
13 |
14 | interface View extends BaseView {
15 |
16 | void showMedicine(MedicineAlarm medicineAlarm);
17 |
18 | void showNoData();
19 |
20 | boolean isActive();
21 |
22 | void onFinish();
23 |
24 | }
25 |
26 | interface Presenter extends BasePresenter {
27 |
28 | void finishActivity();
29 |
30 | void onStart(long id);
31 |
32 | void loadMedicineById(long id);
33 |
34 | void addPillsToHistory(History history);
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/views/RobotoBoldTextView.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.views;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import androidx.appcompat.widget.AppCompatTextView;
6 | import android.util.AttributeSet;
7 |
8 | import com.gautam.medicinetime.utils.FontUtil;
9 |
10 |
11 | public class RobotoBoldTextView extends AppCompatTextView {
12 |
13 | public RobotoBoldTextView(Context context) {
14 | super(context);
15 | applyCustomFont();
16 | }
17 |
18 | public RobotoBoldTextView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | applyCustomFont();
21 | }
22 |
23 | public RobotoBoldTextView(Context context, AttributeSet attrs, int defStyle) {
24 | super(context, attrs, defStyle);
25 | applyCustomFont();
26 | }
27 |
28 | private void applyCustomFont() {
29 | Typeface customFont = FontUtil.getTypeface(FontUtil.ROBOTO_BOLD);
30 | setTypeface(customFont);
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/views/RobotoLightTextView.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.views;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import androidx.appcompat.widget.AppCompatTextView;
6 | import android.util.AttributeSet;
7 |
8 | import com.gautam.medicinetime.utils.FontUtil;
9 |
10 |
11 | public class RobotoLightTextView extends AppCompatTextView {
12 |
13 | public RobotoLightTextView(Context context) {
14 | super(context);
15 | applyCustomFont();
16 | }
17 |
18 | public RobotoLightTextView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | applyCustomFont();
21 | }
22 |
23 | public RobotoLightTextView(Context context, AttributeSet attrs, int defStyle) {
24 | super(context, attrs, defStyle);
25 | applyCustomFont();
26 | }
27 |
28 | private void applyCustomFont() {
29 | Typeface customFont = FontUtil.getTypeface(FontUtil.ROBOTO_LIGHT);
30 | setTypeface(customFont);
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/views/RobotoRegularTextView.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.views;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import androidx.appcompat.widget.AppCompatTextView;
6 | import android.util.AttributeSet;
7 |
8 | import com.gautam.medicinetime.utils.FontUtil;
9 |
10 |
11 | public class RobotoRegularTextView extends AppCompatTextView {
12 |
13 | public RobotoRegularTextView(Context context) {
14 | super(context);
15 | applyCustomFont();
16 | }
17 |
18 | public RobotoRegularTextView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | applyCustomFont();
21 | }
22 |
23 | public RobotoRegularTextView(Context context, AttributeSet attrs, int defStyle) {
24 | super(context, attrs, defStyle);
25 | applyCustomFont();
26 | }
27 |
28 | private void applyCustomFont() {
29 | Typeface customFont = FontUtil.getTypeface(FontUtil.ROBOTO_REGULAR);
30 | setTypeface(customFont);
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/views/DayViewCheckBox.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.views;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import androidx.core.content.ContextCompat;
6 | import androidx.appcompat.widget.AppCompatCheckBox;
7 | import android.util.AttributeSet;
8 |
9 | import com.gautam.medicinetime.R;
10 |
11 | /**
12 | * Created by gautam on 13/07/17.
13 | */
14 |
15 | public class DayViewCheckBox extends AppCompatCheckBox {
16 |
17 | private final Context context;
18 |
19 | public DayViewCheckBox(Context context) {
20 | super(context);
21 | this.context = context;
22 | }
23 |
24 | public DayViewCheckBox(Context context, AttributeSet attrs) {
25 | super(context, attrs);
26 | this.context = context;
27 | }
28 |
29 | @Override
30 | public void setChecked(boolean t){
31 | if(t) {
32 | this.setTextColor(Color.WHITE);
33 | } else {
34 | this.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
35 | }
36 | super.setChecked(t);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/utils/FontUtil.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.utils;
2 |
3 | import android.graphics.Typeface;
4 |
5 | import com.gautam.medicinetime.MedicineApp;
6 |
7 | import java.util.Hashtable;
8 |
9 | public class FontUtil {
10 |
11 | public static final String ROBOTO_REGULAR = "fonts/Roboto-Regular.ttf";
12 | public static final String ROBOTO_LIGHT = "fonts/Roboto-Light.ttf";
13 | public static final String ROBOTO_BOLD = "fonts/Roboto-Bold.ttf";
14 |
15 |
16 | // Constructor
17 | private FontUtil() { }
18 |
19 | // Cache fonts in hash table
20 | private static Hashtable fontCache = new Hashtable();
21 | public static Typeface getTypeface(String name) {
22 | Typeface tf = fontCache.get(name);
23 | if(tf == null) {
24 | try {
25 | tf = Typeface.createFromAsset(MedicineApp.getInstance().getAssets(), name);
26 | }
27 | catch (Exception e) {
28 | return null;
29 | }
30 | fontCache.put(name, tf);
31 | }
32 | return tf;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/addmedicine/AddMedicineContract.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.addmedicine;
2 |
3 | import com.gautam.medicinetime.BasePresenter;
4 | import com.gautam.medicinetime.BaseView;
5 | import com.gautam.medicinetime.data.source.MedicineAlarm;
6 | import com.gautam.medicinetime.data.source.Pills;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by gautam on 12/07/17.
12 | */
13 |
14 | public interface AddMedicineContract {
15 |
16 | interface View extends BaseView {
17 |
18 | void showEmptyMedicineError();
19 |
20 | void showMedicineList();
21 |
22 | boolean isActive();
23 |
24 | }
25 |
26 | interface Presenter extends BasePresenter{
27 |
28 |
29 | void saveMedicine(MedicineAlarm alarm, Pills pills);
30 |
31 |
32 | boolean isDataMissing();
33 |
34 | boolean isMedicineExits(String pillName);
35 |
36 | long addPills(Pills pills);
37 |
38 | Pills getPillsByName(String pillName);
39 |
40 | List getMedicineByPillName(String pillName);
41 |
42 | List tempIds();
43 |
44 | void deleteMedicineAlarm(long alarmId);
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/MonthlyReportContract.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | import com.gautam.medicinetime.BasePresenter;
4 | import com.gautam.medicinetime.BaseView;
5 | import com.gautam.medicinetime.data.source.History;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by gautam on 13/07/17.
10 | */
11 |
12 | public interface MonthlyReportContract {
13 |
14 | interface View extends BaseView {
15 |
16 | void setLoadingIndicator(boolean active);
17 |
18 | void showHistoryList(List historyList);
19 |
20 | void showLoadingError();
21 |
22 | void showNoHistory();
23 |
24 | void showTakenFilterLabel();
25 |
26 | void showIgnoredFilterLabel();
27 |
28 | void showAllFilterLabel();
29 |
30 | void showNoTakenHistory();
31 |
32 | void showNoIgnoredHistory();
33 |
34 | boolean isActive();
35 |
36 | void showFilteringPopUpMenu();
37 |
38 | }
39 |
40 | interface Presenter extends BasePresenter {
41 |
42 | void loadHistory(boolean showLoading);
43 |
44 | void setFiltering(FilterType filterType);
45 |
46 | FilterType getFilterType();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_monthly_report.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/Pills.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source;
2 |
3 | import com.gautam.medicinetime.data.source.MedicineAlarm;
4 |
5 | import java.util.Collections;
6 | import java.util.LinkedList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by gautam on 13/07/17.
11 | */
12 |
13 | public class Pills {
14 |
15 | private String pillName;
16 |
17 | private long pillId;
18 |
19 | private List medicineAlarms = new LinkedList();
20 |
21 | public Pills(){
22 |
23 | }
24 |
25 | public Pills(String pillName, long pillId) {
26 | this.pillName = pillName;
27 | this.pillId = pillId;
28 | }
29 |
30 | public String getPillName() { return pillName; }
31 |
32 | public void setPillName(String pillName) { this.pillName = pillName; }
33 |
34 | /**
35 | *
36 | * @param medicineAlarm
37 | * allows a new medicineAlarm sto be added to a preexisting medicineAlarm
38 | */
39 | public void addAlarm(MedicineAlarm medicineAlarm) {
40 | medicineAlarms.add(medicineAlarm);
41 | Collections.sort(medicineAlarms);
42 | }
43 |
44 | public long getPillId() {
45 | return pillId;
46 | }
47 |
48 | public void setPillId(long pillID) {
49 | this.pillId = pillID;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/medicine/MedicineContract.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.medicine;
2 |
3 | import android.content.Context;
4 |
5 | import com.gautam.medicinetime.BasePresenter;
6 | import com.gautam.medicinetime.BaseView;
7 | import com.gautam.medicinetime.data.source.MedicineAlarm;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by gautam on 13/07/17.
13 | */
14 |
15 | public interface MedicineContract {
16 |
17 | interface View extends BaseView{
18 |
19 | void showLoadingIndicator(boolean active);
20 |
21 | void showMedicineList(List medicineAlarmList);
22 |
23 | void showAddMedicine();
24 |
25 | void showMedicineDetails(long medId, String medName);
26 |
27 | void showLoadingMedicineError();
28 |
29 | void showNoMedicine();
30 |
31 | void showSuccessfullySavedMessage();
32 |
33 | void showMedicineDeletedSuccessfully();
34 |
35 | boolean isActive();
36 |
37 |
38 | }
39 |
40 | interface Presenter extends BasePresenter{
41 |
42 | void onStart(int day);
43 |
44 | void reload(int day);
45 |
46 | void result(int requestCode, int resultCode);
47 |
48 | void loadMedicinesByDay(int day, boolean showIndicator);
49 |
50 | void deleteMedicineAlarm(MedicineAlarm medicineAlarm, Context context);
51 |
52 | void addNewMedicine();
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/MedicineDataSource.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by gautam on 13/07/17.
7 | */
8 |
9 | public interface MedicineDataSource {
10 |
11 | interface LoadMedicineCallbacks {
12 |
13 | void onMedicineLoaded(List medicineAlarmList);
14 |
15 | void onDataNotAvailable();
16 | }
17 |
18 | interface GetTaskCallback {
19 |
20 | void onTaskLoaded(MedicineAlarm medicineAlarm);
21 |
22 | void onDataNotAvailable();
23 | }
24 |
25 | interface LoadHistoryCallbacks {
26 |
27 | void onHistoryLoaded(List historyList);
28 |
29 | void onDataNotAvailable();
30 | }
31 |
32 | void getMedicineHistory(LoadHistoryCallbacks loadHistoryCallbacks);
33 |
34 | void getMedicineAlarmById(long id, GetTaskCallback callback);
35 |
36 | void saveMedicine(MedicineAlarm medicineAlarm, Pills pills);
37 |
38 | void getMedicineListByDay(int day, LoadMedicineCallbacks callbacks);
39 |
40 | boolean medicineExits(String pillName);
41 |
42 | List tempIds();
43 |
44 | void deleteAlarm(long alarmId);
45 |
46 | List getMedicineByPillName(String pillName);
47 |
48 | List getAllAlarms(String pillName);
49 |
50 | Pills getPillsByName(String pillName);
51 |
52 | long savePills(Pills pills);
53 |
54 | void saveToHistory(History history);
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/utils/ActivityUtils.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import androidx.annotation.DrawableRes;
6 | import androidx.annotation.NonNull;
7 | import androidx.fragment.app.Fragment;
8 | import androidx.fragment.app.FragmentManager;
9 | import androidx.fragment.app.FragmentTransaction;
10 | import androidx.core.content.ContextCompat;
11 | import android.view.View;
12 |
13 |
14 | /**
15 | * Created by gautam on 13/07/17.
16 | */
17 |
18 | public class ActivityUtils {
19 |
20 | /**
21 | * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
22 | * performed by the {@code fragmentManager}.
23 | */
24 | public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
25 | @NonNull Fragment fragment, int frameId) {
26 | FragmentTransaction transaction = fragmentManager.beginTransaction();
27 | transaction.add(frameId, fragment);
28 | transaction.commit();
29 | }
30 |
31 | public static void setBackGround(Context context, View view, @DrawableRes int drawable) {
32 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
33 | view.setBackground(ContextCompat.getDrawable(context, drawable));
34 | } else {
35 | view.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable));
36 | }
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Medicine Time
3 | Medicine Name
4 | Enter Medicine
5 | Medicine Days
6 | Treatment deadline
7 | Continuous use
8 | Reminder
9 | NEW MEDICINE
10 | Every day
11 | No Medicine Added
12 | Error while loading medicineAlarms
13 | Medicine Added Successfully
14 | Medicine deleted Successfully
15 | It\'s Time to take your medicine
16 | IGNORED
17 | TAKEN
18 | ALL
19 | Filter
20 | All Medicines
21 | Medicines Ignored
22 | Medicine Taken
23 | No History Found
24 | You have not taken any medicine
25 | Well Done
26 | Monthly Report
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_reminder_actvity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
20 |
21 |
31 |
32 |
33 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **Medicine Time**
2 |
3 | _The Goal:_
4 |
5 | Medicine Time is an native android application meant to aid the forgetful and busy with remembering to take their daily medications. It is designed for users who need a little help keeping track of their medication schedule and who are dedicated to keeping the schedule. The application allows the user to store pill objects and multiple alarms for those pills. Alarms have one time of day and can occur on multiple days of the week. The user is able to view their pills in a today view and can select date to view medicines. In addition, the application stores the history of when each medication was taken; this will aid the user in keeping track of their medication usage.
6 |
7 |
8 | See GitHub issues. (https://github.com/gssinghgautam/Medicine-Time-/issues)
9 |
10 | Use Cases and What Each Button Does:
11 |
12 | In the Home page, you will see 1 buttons in the bottom right of the application. ######Plus sign: This will take you to the Add Activity where you will be able to create an alarm. The application will automatically link up all the alarms to a specific pill with the same Pill Name. If you attempt to create an alarm to a pill that does not exist, it will automatically create a pill object for you. ######Calendar sign: This will take you to the Schedule Activity where you can see all the pills and alarms organized by the day of week.
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - Help %s
5 | - Delete contact
6 | - Cancel
7 |
8 |
9 |
10 | - Every 24 hours
11 | - Every 12 hours
12 | - Every 8 hours
13 | - Every 6 hours
14 | - Every 4 hours
15 | - Every 2 hours
16 |
17 |
18 |
19 | - adhesive(s)
20 | - capsule(s)
21 | - cachet(s)
22 | - cream(s)
23 | - dragee(s)
24 | - emulsion(s)
25 | - pack(s)
26 | - gel(s)
27 | - drop(s)
28 | - inhalation(s)
29 | - shot(s)
30 | - lotion(s)
31 | - measure(s)
32 | - tablet(s)
33 | - powder(s)
34 | - ointment(s)
35 | - soap(s)
36 | - sachet(s)
37 | - unit(s)
38 | - solution(s)
39 | - spray(s)
40 | - suspension(s)
41 | - syrup(s)
42 |
43 |
44 | - 21+7
45 | - 22+6
46 | - 23+5
47 | - 24+4
48 | - 26+2
49 | - 28+0
50 | - 35+7
51 | - 42+7
52 | - 63+7
53 | - 84+7
54 | - 14+14
55 |
56 |
57 | - sun
58 | - mon
59 | - tue
60 | - wed
61 | - thu
62 | - fri
63 | - sat
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_medicine.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
25 |
26 |
33 |
34 |
41 |
42 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/alarm/ReminderPresenter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.alarm;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.gautam.medicinetime.data.source.History;
6 | import com.gautam.medicinetime.data.source.MedicineAlarm;
7 | import com.gautam.medicinetime.data.source.MedicineDataSource;
8 | import com.gautam.medicinetime.data.source.MedicineRepository;
9 |
10 | /**
11 | * Created by gautam on 13/07/17.
12 | */
13 |
14 | public class ReminderPresenter implements ReminderContract.Presenter {
15 |
16 | private final MedicineRepository mMedicineRepository;
17 |
18 | private final ReminderContract.View mReminderView;
19 |
20 | ReminderPresenter(@NonNull MedicineRepository medicineRepository, @NonNull ReminderContract.View reminderView) {
21 | this.mMedicineRepository = medicineRepository;
22 | this.mReminderView = reminderView;
23 |
24 | mReminderView.setPresenter(this);
25 | }
26 |
27 | @Override
28 | public void start() {
29 |
30 | }
31 |
32 | @Override
33 | public void finishActivity() {
34 | mReminderView.onFinish();
35 | }
36 |
37 | @Override
38 | public void onStart(long id) {
39 | loadMedicineById(id);
40 | }
41 |
42 | @Override
43 | public void loadMedicineById(long id) {
44 | loadMedicine(id);
45 | }
46 |
47 |
48 | private void loadMedicine(long id) {
49 | mMedicineRepository.getMedicineAlarmById(id, new MedicineDataSource.GetTaskCallback() {
50 | @Override
51 | public void onTaskLoaded(MedicineAlarm medicineAlarm) {
52 | if (!mReminderView.isActive()) {
53 | return;
54 | }
55 | if (medicineAlarm == null) {
56 | return;
57 | }
58 | mReminderView.showMedicine(medicineAlarm);
59 | }
60 |
61 | @Override
62 | public void onDataNotAvailable() {
63 | mReminderView.showNoData();
64 | }
65 | });
66 | }
67 |
68 | @Override
69 | public void addPillsToHistory(History history) {
70 | mMedicineRepository.saveToHistory(history);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 |
36 |
37 |
40 |
41 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_add_medicine.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
18 |
19 |
26 |
27 |
28 |
32 |
33 |
37 |
38 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
21 |
22 |
26 |
27 |
28 |
29 |
35 |
36 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/alarm/ReminderActivity.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.alarm;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | import androidx.appcompat.app.ActionBar;
7 | import androidx.appcompat.app.AppCompatActivity;
8 | import androidx.appcompat.widget.Toolbar;
9 | import android.view.MenuItem;
10 |
11 | import com.gautam.medicinetime.Injection;
12 | import com.gautam.medicinetime.R;
13 | import com.gautam.medicinetime.utils.ActivityUtils;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 | public class ReminderActivity extends AppCompatActivity {
19 |
20 | @BindView(R.id.toolbar)
21 | Toolbar toolbar;
22 | ReminderPresenter mReminderPresenter;
23 |
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_reminder_actvity);
29 | ButterKnife.bind(this);
30 | setSupportActionBar(toolbar);
31 | ActionBar actionBar = getSupportActionBar();
32 | if (actionBar != null) {
33 | actionBar.setDisplayHomeAsUpEnabled(true);
34 | }
35 |
36 | Intent intent = getIntent();
37 | if (!intent.hasExtra(ReminderFragment.EXTRA_ID)) {
38 | finish();
39 | return;
40 | }
41 | long id = intent.getLongExtra(ReminderFragment.EXTRA_ID, 0);
42 | ReminderFragment reminderFragment = (ReminderFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
43 | if (reminderFragment == null) {
44 | reminderFragment = ReminderFragment.newInstance(id);
45 | ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), reminderFragment, R.id.contentFrame);
46 | }
47 |
48 | //Create MedicinePresenter
49 | mReminderPresenter = new ReminderPresenter(Injection.provideMedicineRepository(ReminderActivity.this), reminderFragment);
50 | }
51 |
52 | @Override
53 | public boolean onOptionsItemSelected(MenuItem item) {
54 | if (item.getItemId() == android.R.id.home) {
55 | if (mReminderPresenter != null) {
56 | mReminderPresenter.finishActivity();
57 | }
58 | }
59 | return super.onOptionsItemSelected(item);
60 | }
61 |
62 | @Override
63 | public void onBackPressed() {
64 | if (mReminderPresenter != null) {
65 | mReminderPresenter.finishActivity();
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/MonthlyReportActivity.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.ActionBar;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import androidx.appcompat.widget.Toolbar;
7 | import android.view.MenuItem;
8 |
9 | import com.gautam.medicinetime.Injection;
10 | import com.gautam.medicinetime.R;
11 | import com.gautam.medicinetime.utils.ActivityUtils;
12 |
13 | import butterknife.BindView;
14 | import butterknife.ButterKnife;
15 |
16 | public class MonthlyReportActivity extends AppCompatActivity {
17 |
18 | private static final String CURRENT_FILTERING_TYPE = "current_filtering_type";
19 |
20 | @BindView(R.id.toolbar)
21 | Toolbar toolbar;
22 |
23 | private MonthlyReportPresenter presenter;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_monthly_report);
29 | ButterKnife.bind(this);
30 | setSupportActionBar(toolbar);
31 | ActionBar actionBar = getSupportActionBar();
32 | if (actionBar != null) {
33 | actionBar.setHomeAsUpIndicator(R.drawable.ic_clear);
34 | actionBar.setDisplayHomeAsUpEnabled(true);
35 | }
36 |
37 | //Create Fragment
38 | MonthlyReportFragment monthlyReportFragment = (MonthlyReportFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
39 | if (monthlyReportFragment == null) {
40 | monthlyReportFragment = MonthlyReportFragment.newInstance();
41 | ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), monthlyReportFragment, R.id.contentFrame);
42 | }
43 |
44 | //Create TaskPresenter
45 | presenter = new MonthlyReportPresenter(Injection.provideMedicineRepository(MonthlyReportActivity.this), monthlyReportFragment);
46 |
47 | //Load previous saved Instance
48 | if (savedInstanceState != null) {
49 | FilterType taskFilterType = (FilterType) savedInstanceState.getSerializable(CURRENT_FILTERING_TYPE);
50 | presenter.setFiltering(taskFilterType);
51 | }
52 | }
53 |
54 | @Override
55 | public boolean onOptionsItemSelected(MenuItem item) {
56 | if (item.getItemId() == android.R.id.home){
57 | onBackPressed();
58 | }
59 | return super.onOptionsItemSelected(item);
60 | }
61 |
62 | @Override
63 | public void onBackPressed() {
64 | super.onBackPressed();
65 | }
66 |
67 | @Override
68 | protected void onSaveInstanceState(Bundle outState) {
69 | outState.putSerializable(CURRENT_FILTERING_TYPE, presenter.getFilterType());
70 | super.onSaveInstanceState(outState);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | signingConfigs {
5 | config {
6 | keyAlias 'medicine'
7 | keyPassword 'test123'
8 | storeFile file('/Users/gautam/Documents/Projects/MedicineTime/app/medicine')
9 | storePassword 'test123'
10 | }
11 | }
12 | compileSdkVersion 29
13 | buildToolsVersion '29.0.3'
14 | defaultConfig {
15 | applicationId "com.gautam.medicinetime"
16 | minSdkVersion rootProject.ext.minSdkVersion
17 | targetSdkVersion rootProject.ext.targetSdkVersion
18 | versionCode 1
19 | versionName "1.0"
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21 | vectorDrawables.useSupportLibrary = true
22 | signingConfig signingConfigs.config
23 | }
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled true
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | signingConfig signingConfigs.config
33 | pseudoLocalesEnabled true
34 | proguardFile '/Users/gautam/Documents/Projects/MedicineTime/app/proguard-rules.pro'
35 | }
36 | }
37 | flavorDimensions "default"
38 | // If you need to add more flavors, consider using flavor dimensions.
39 | productFlavors {
40 | mock {
41 | applicationIdSuffix = ".mock"
42 | dimension "default"
43 | }
44 | prod {
45 | dimension "default"
46 | signingConfig signingConfigs.config
47 | }
48 | }
49 | // Remove mockRelease as it's not needed.
50 | android.variantFilter { variant ->
51 | if (variant.buildType.name == 'release'
52 | && variant.getFlavors().get(0).name == 'mock') {
53 | variant.setIgnore(true);
54 | }
55 | }
56 | }
57 |
58 | dependencies {
59 | implementation fileTree(include: ['*.jar'], dir: 'libs')
60 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
61 | exclude group: 'com.android.support', module: 'support-annotations'
62 | })
63 | androidTestImplementation "junit:junit:$rootProject.ext.junitVersion"
64 | implementation 'androidx.appcompat:appcompat:1.1.0'
65 | implementation 'androidx.cardview:cardview:1.0.0'
66 | implementation 'com.google.android.material:material:1.1.0'
67 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
68 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
69 | implementation "com.github.sundeepk:compact-calendar-view:$rootProject.compactCalendarViewVersion"
70 | implementation 'com.jakewharton:butterknife:10.2.1'
71 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
72 | }
73 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/gautam/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
27 | -keep public class * extends android.app.Activity
28 | -keep public class * extends android.app.Application
29 | -keep public class * extends android.app.Service
30 | -keep public class * extends android.content.BroadcastReceiver
31 | -keep public class * extends android.content.ContentProvider
32 | -keep public class * extends android.app.backup.BackupAgent
33 | -keep public class * extends android.preference.Preference
34 | -keep public class * extends android.support.v4.app.Fragment
35 | -keep public class * extends android.app.Fragment
36 | -keep public class * extends android.support.v4.app.DialogFragment
37 |
38 | # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
39 | -keepclasseswithmembernames class * {
40 | native ;
41 | }
42 |
43 | -keep public class * extends android.view.View {
44 | public (android.content.Context);
45 | public (android.content.Context, android.util.AttributeSet);
46 | public (android.content.Context, android.util.AttributeSet, int);
47 | public void set*(...);
48 | }
49 |
50 | -keepclasseswithmembers class * {
51 | public (android.content.Context, android.util.AttributeSet);
52 | }
53 |
54 | -keepclasseswithmembers class * {
55 | public (android.content.Context, android.util.AttributeSet, int);
56 | }
57 |
58 | -keepclassmembers class * extends android.app.Activity {
59 | public void *(android.view.View);
60 | }
61 |
62 | # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
63 | -keepclassmembers enum * {
64 | public static **[] values();
65 | public static ** valueOf(java.lang.String);
66 | }
67 |
68 | -keep class * implements android.os.Parcelable {
69 | public static final android.os.Parcelable$Creator *;
70 | }
71 |
72 | -keepclassmembers class **.R$* {
73 | public static ;
74 | }
75 |
76 | #Database table
77 | -keep class com.gautam.medicinetime.data.**
78 | -keepclassmembers class com.gautam.medicinetime.data.** { *; }
79 |
80 | #ButterKnife
81 | -keep class butterknife.*
82 | -keepclasseswithmembernames class * { @butterknife.* ; }
83 | -keepclasseswithmembernames class * { @butterknife.* ; }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/addmedicine/AddMedicinePresenter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.addmedicine;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.gautam.medicinetime.data.source.MedicineAlarm;
6 | import com.gautam.medicinetime.data.source.MedicineDataSource;
7 | import com.gautam.medicinetime.data.source.Pills;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by gautam on 12/07/17.
13 | */
14 |
15 | public class AddMedicinePresenter implements AddMedicineContract.Presenter, MedicineDataSource.GetTaskCallback {
16 |
17 | @NonNull
18 | private final MedicineDataSource mMedicineRepository;
19 |
20 | private final AddMedicineContract.View mAddMedicineView;
21 |
22 | private int mMedicineId;
23 |
24 | private boolean mIsDataMissing;
25 |
26 | public AddMedicinePresenter(int mMedicineId, @NonNull MedicineDataSource mMedicineRepository, AddMedicineContract.View mAddMedicineView, boolean mIsDataMissing) {
27 | this.mMedicineId = mMedicineId;
28 | this.mMedicineRepository = mMedicineRepository;
29 | this.mAddMedicineView = mAddMedicineView;
30 | this.mIsDataMissing = mIsDataMissing;
31 |
32 | mAddMedicineView.setPresenter(this);
33 | }
34 |
35 | private boolean isNewTask() {
36 | return mMedicineId <= 0;
37 | }
38 |
39 | @Override
40 | public void start() {
41 |
42 | }
43 |
44 | @Override
45 | public void saveMedicine(MedicineAlarm alarm, Pills pills) {
46 | mMedicineRepository.saveMedicine(alarm, pills);
47 | }
48 |
49 | @Override
50 | public boolean isDataMissing() {
51 | return mIsDataMissing;
52 | }
53 |
54 | @Override
55 | public boolean isMedicineExits(String pillName) {
56 | return mMedicineRepository.medicineExits(pillName);
57 | }
58 |
59 | @Override
60 | public long addPills(Pills pills) {
61 | return mMedicineRepository.savePills(pills);
62 | }
63 |
64 | @Override
65 | public Pills getPillsByName(String pillName) {
66 | return mMedicineRepository.getPillsByName(pillName);
67 | }
68 |
69 | @Override
70 | public List getMedicineByPillName(String pillName) {
71 | return mMedicineRepository.getMedicineByPillName(pillName);
72 | }
73 |
74 | @Override
75 | public List tempIds() {
76 | return mMedicineRepository.tempIds();
77 | }
78 |
79 | @Override
80 | public void deleteMedicineAlarm(long alarmId) {
81 | mMedicineRepository.deleteAlarm(alarmId);
82 | }
83 |
84 | @Override
85 | public void onTaskLoaded(MedicineAlarm medicineAlarm) {
86 | // The view may not be able to handle UI updates anymore
87 | /*if (mAddMedicineView.isActive()){
88 | mAddMedicineView.setDose(medicineAlarm.getDose());
89 | mAddMedicineView.setMedName(medicineAlarm.getMedicineName());
90 | mAddMedicineView.setDays(medicineAlarm.getDays());
91 | mAddMedicineView.setTime(medicineAlarm.getTime());
92 | }
93 | mIsDataMissing = false;*/
94 | }
95 |
96 | @Override
97 | public void onDataNotAvailable() {
98 | if (mAddMedicineView.isActive()) {
99 | mAddMedicineView.showEmptyMedicineError();
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/HistoryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 |
9 | import com.gautam.medicinetime.R;
10 | import com.gautam.medicinetime.data.source.History;
11 | import com.gautam.medicinetime.views.RobotoBoldTextView;
12 | import com.gautam.medicinetime.views.RobotoRegularTextView;
13 |
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 |
19 | /**
20 | * Created by gautam on 13/07/17.
21 | */
22 |
23 | public class HistoryAdapter extends RecyclerView.Adapter {
24 |
25 |
26 | private List mHistoryList;
27 |
28 | HistoryAdapter(List historyList) {
29 | setList(historyList);
30 | }
31 |
32 | void replaceData(List tasks) {
33 | setList(tasks);
34 | notifyDataSetChanged();
35 | }
36 |
37 | private void setList(List historyList) {
38 | this.mHistoryList = historyList;
39 | }
40 |
41 |
42 | @Override
43 | public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
44 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_history, parent, false);
45 | return new HistoryViewHolder(view);
46 | }
47 |
48 | @Override
49 | public void onBindViewHolder(HistoryViewHolder holder, int position) {
50 | History history = mHistoryList.get(position);
51 | if (history == null) {
52 | return;
53 | }
54 | holder.tvMedDate.setText(history.getFormattedDate());
55 | setMedicineAction(holder, history.getAction());
56 | holder.tvMedicineName.setText(history.getPillName());
57 | holder.tvDoseDetails.setText(history.getFormattedDose());
58 |
59 | }
60 |
61 | private void setMedicineAction(HistoryViewHolder holder, int action) {
62 | switch (action) {
63 | case 0:
64 | default:
65 | holder.ivMedicineAction.setVisibility(View.GONE);
66 | break;
67 | case 1:
68 | holder.ivMedicineAction.setVisibility(View.VISIBLE);
69 | holder.ivMedicineAction.setImageResource(R.drawable.image_reminder_taken);
70 | break;
71 | case 2:
72 | holder.ivMedicineAction.setImageResource(R.drawable.image_reminder_not_taken);
73 | holder.ivMedicineAction.setVisibility(View.VISIBLE);
74 | break;
75 | }
76 | }
77 |
78 | @Override
79 | public int getItemCount() {
80 | return (mHistoryList != null && !mHistoryList.isEmpty()) ? mHistoryList.size() : 0;
81 | }
82 |
83 | static class HistoryViewHolder extends RecyclerView.ViewHolder {
84 |
85 | @BindView(R.id.tv_med_date)
86 | RobotoBoldTextView tvMedDate;
87 |
88 | @BindView(R.id.tv_medicine_name)
89 | RobotoBoldTextView tvMedicineName;
90 |
91 | @BindView(R.id.tv_dose_details)
92 | RobotoRegularTextView tvDoseDetails;
93 |
94 | @BindView(R.id.iv_medicine_action)
95 | ImageView ivMedicineAction;
96 |
97 | HistoryViewHolder(View itemView) {
98 | super(itemView);
99 | ButterKnife.bind(this, itemView);
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/medicine/MedicineAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.medicine;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 |
11 | import com.gautam.medicinetime.R;
12 | import com.gautam.medicinetime.data.source.MedicineAlarm;
13 | import com.gautam.medicinetime.views.RobotoBoldTextView;
14 | import com.gautam.medicinetime.views.RobotoRegularTextView;
15 |
16 | import java.util.List;
17 |
18 | import butterknife.BindView;
19 | import butterknife.ButterKnife;
20 |
21 | /**
22 | * Created by gautam on 13/07/17.
23 | */
24 |
25 | public class MedicineAdapter extends RecyclerView.Adapter {
26 |
27 | private List medicineAlarmList;
28 | private OnItemClickListener onItemClickListener;
29 |
30 | public MedicineAdapter(List medicineAlarmList) {
31 | this.medicineAlarmList = medicineAlarmList;
32 | }
33 |
34 | public void replaceData(List medicineAlarmList) {
35 | this.medicineAlarmList = medicineAlarmList;
36 | notifyDataSetChanged();
37 | }
38 |
39 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
40 | this.onItemClickListener = onItemClickListener;
41 | }
42 |
43 | @NonNull
44 | @Override
45 | public MedicineViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
46 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_medicine, parent, false);
47 | return new MedicineViewHolder(view);
48 | }
49 |
50 | @Override
51 | public void onBindViewHolder(@NonNull MedicineViewHolder holder, int position) {
52 | final MedicineAlarm medicineAlarm = medicineAlarmList.get(position);
53 | if (medicineAlarm == null) {
54 | return;
55 | }
56 | holder.tvMedTime.setText(medicineAlarm.getStringTime());
57 | holder.tvMedicineName.setText(medicineAlarm.getPillName());
58 | holder.tvDoseDetails.setText(medicineAlarm.getFormattedDose());
59 | holder.ivAlarmDelete.setVisibility(View.VISIBLE);
60 | holder.ivAlarmDelete.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | if (onItemClickListener != null) {
64 | onItemClickListener.onMedicineDeleteClicked(medicineAlarm);
65 | }
66 | }
67 | });
68 | }
69 |
70 | @Override
71 | public int getItemCount() {
72 | return (medicineAlarmList != null && !medicineAlarmList.isEmpty()) ? medicineAlarmList.size() : 0;
73 | }
74 |
75 | static class MedicineViewHolder extends RecyclerView.ViewHolder {
76 |
77 | @BindView(R.id.tv_med_time)
78 | RobotoBoldTextView tvMedTime;
79 |
80 | @BindView(R.id.tv_medicine_name)
81 | RobotoBoldTextView tvMedicineName;
82 |
83 | @BindView(R.id.tv_dose_details)
84 | RobotoRegularTextView tvDoseDetails;
85 |
86 | @BindView(R.id.iv_medicine_action)
87 | ImageView ivMedicineAction;
88 |
89 | @BindView(R.id.iv_alarm_delete)
90 | ImageView ivAlarmDelete;
91 |
92 | MedicineViewHolder(View itemView) {
93 | super(itemView);
94 | ButterKnife.bind(this, itemView);
95 | }
96 | }
97 |
98 | interface OnItemClickListener {
99 | void onMedicineDeleteClicked(MedicineAlarm medicineAlarm);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/History.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source;
2 |
3 | import java.util.Locale;
4 |
5 | /**
6 | * Created by gautam on 13/07/17.
7 | */
8 |
9 | public class History {
10 |
11 | private int hourTaken;
12 |
13 | private int minuteTaken;
14 |
15 | private String dateString;
16 |
17 | private String pillName;
18 |
19 | private int action;
20 |
21 | private String doseQuantity;
22 |
23 | private String doseUnit;
24 |
25 | private int alarmId;
26 |
27 | public History() {
28 | }
29 |
30 | public History(int hourTaken, int minuteTaken, String dateString, String pillName, int action, String doseQuantity, String doseUnit, int alarmId) {
31 | this.hourTaken = hourTaken;
32 | this.minuteTaken = minuteTaken;
33 | this.dateString = dateString;
34 | this.pillName = pillName;
35 | this.action = action;
36 | this.doseQuantity = doseQuantity;
37 | this.doseUnit = doseUnit;
38 | this.alarmId = alarmId;
39 | }
40 |
41 | public void setDoseUnit(String doseUnit) {
42 | this.doseUnit = doseUnit;
43 | }
44 |
45 | public void setDoseQuantity(String doseQuantity) {
46 | this.doseQuantity = doseQuantity;
47 | }
48 |
49 | public String getDoseUnit() {
50 | return doseUnit;
51 | }
52 |
53 | public String getDoseQuantity() {
54 | return doseQuantity;
55 | }
56 |
57 | public int getHourTaken() {
58 | return hourTaken;
59 | }
60 |
61 | public void setHourTaken(int hourTaken) {
62 | this.hourTaken = hourTaken;
63 | }
64 |
65 | public int getMinuteTaken() {
66 | return minuteTaken;
67 | }
68 |
69 | public void setMinuteTaken(int minuteTaken) {
70 | this.minuteTaken = minuteTaken;
71 | }
72 |
73 | public String getAm_pmTaken() {
74 | return (hourTaken < 12) ? "am" : "pm";
75 | }
76 |
77 | public String getDateString() {
78 | return dateString;
79 | }
80 |
81 | public void setDateString(String dateString) {
82 | this.dateString = dateString;
83 | }
84 |
85 | public String getPillName() {
86 | return pillName;
87 | }
88 |
89 | public void setPillName(String pillName) {
90 | this.pillName = pillName;
91 | }
92 |
93 | public int getAction() {
94 | return action;
95 | }
96 |
97 | public void setAction(int action) {
98 | this.action = action;
99 | }
100 |
101 | public int getAlarmId() {
102 | return alarmId;
103 | }
104 |
105 | public void setAlarmId(int alarmId) {
106 | this.alarmId = alarmId;
107 | }
108 |
109 | /**
110 | * A helper method which returns the time of the alarm in string form
111 | * hour:minutes am/pm
112 | */
113 | public String getStringTime() {
114 | int nonMilitaryHour = hourTaken % 12;
115 | if (nonMilitaryHour == 0)
116 | nonMilitaryHour = 12;
117 | String min = Integer.toString(minuteTaken);
118 | if (minuteTaken < 10)
119 | min = "0" + minuteTaken;
120 | return String.format(Locale.getDefault(), "%d:%s %s", nonMilitaryHour, min, getAm_pmTaken());
121 | }
122 |
123 | public String getFormattedDate() {
124 | return String.format(Locale.getDefault(), "%s %s", dateString, getStringTime());
125 | }
126 |
127 | /**
128 | * A helper method which returns the formatted medicine dose
129 | * doseQuantity doseUnit
130 | */
131 | public String getFormattedDose() {
132 | return String.format(Locale.getDefault(), "%s %s", doseQuantity, doseUnit);
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/addmedicine/AddMedicineActivity.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.addmedicine;
2 |
3 | import android.os.PersistableBundle;
4 | import androidx.appcompat.app.ActionBar;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import androidx.appcompat.widget.Toolbar;
8 |
9 | import com.gautam.medicinetime.Injection;
10 | import com.gautam.medicinetime.R;
11 | import com.gautam.medicinetime.utils.ActivityUtils;
12 |
13 | public class AddMedicineActivity extends AppCompatActivity {
14 |
15 | public static final int REQUEST_ADD_TASK = 1;
16 |
17 | public static final String SHOULD_LOAD_DATA_FROM_REPO_KEY = "SHOULD_LOAD_DATA_FROM_REPO_KEY";
18 |
19 | public static final String EXTRA_TASK_ID = "task_extra_id";
20 | public static final String EXTRA_TASK_NAME = "task_extra_name";
21 |
22 | private AddMedicinePresenter mAddMedicinePresenter;
23 |
24 | private ActionBar mActionBar;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_add_medicine);
30 |
31 | //Setup toolbar
32 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
33 | setSupportActionBar(toolbar);
34 | mActionBar = getSupportActionBar();
35 | mActionBar.setDisplayHomeAsUpEnabled(true);
36 | mActionBar.setDisplayShowHomeEnabled(true);
37 |
38 | AddMedicineFragment addMedicineFragment = (AddMedicineFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
39 |
40 | int medId = getIntent().getIntExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID,0);
41 | String medName = getIntent().getStringExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_NAME);
42 |
43 | setToolbarTitle(medName);
44 |
45 |
46 | if (addMedicineFragment == null) {
47 | addMedicineFragment = AddMedicineFragment.newInstance();
48 |
49 | if (getIntent().hasExtra(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID)) {
50 | Bundle bundle = new Bundle();
51 | bundle.putInt(AddMedicineFragment.ARGUMENT_EDIT_MEDICINE_ID, medId);
52 | addMedicineFragment.setArguments(bundle);
53 | }
54 | ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
55 | addMedicineFragment, R.id.contentFrame);
56 | }
57 |
58 | boolean shouldLoadDataFromRepo = true;
59 | // Prevent the presenter from loading data from the repository if this is a config change.
60 | if (savedInstanceState != null) {
61 | // Data might not have loaded when the config change happen, so we saved the state.
62 | shouldLoadDataFromRepo = savedInstanceState.getBoolean(SHOULD_LOAD_DATA_FROM_REPO_KEY);
63 | }
64 |
65 | // // Create the presenter
66 | mAddMedicinePresenter = new AddMedicinePresenter(
67 | medId,
68 | Injection.provideMedicineRepository(getApplicationContext()),
69 | addMedicineFragment,
70 | shouldLoadDataFromRepo);
71 |
72 | }
73 |
74 | public void setToolbarTitle(String medicineName) {
75 | if (medicineName == null) {
76 | mActionBar.setTitle(getString(R.string.new_medicine));
77 | } else {
78 | mActionBar.setTitle(medicineName);
79 | }
80 | }
81 |
82 | @Override
83 | public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
84 | outState.putBoolean(SHOULD_LOAD_DATA_FROM_REPO_KEY, mAddMedicinePresenter.isDataMissing());
85 | super.onSaveInstanceState(outState, outPersistentState);
86 | }
87 |
88 | @Override
89 | public boolean onSupportNavigateUp() {
90 | onBackPressed();
91 | return true;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/MedicineRepository.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by gautam on 13/07/17.
9 | */
10 |
11 | public class MedicineRepository implements MedicineDataSource {
12 |
13 | private static MedicineRepository mInstance = null;
14 |
15 | private final MedicineDataSource localDataSource;
16 |
17 |
18 | private MedicineRepository(@NonNull MedicineDataSource localDataSource) {
19 | this.localDataSource = localDataSource;
20 | }
21 |
22 |
23 | public static MedicineRepository getInstance(MedicineDataSource localDataSource) {
24 | if (mInstance == null) {
25 | mInstance = new MedicineRepository(localDataSource);
26 | }
27 | return mInstance;
28 | }
29 |
30 | @Override
31 | public void getMedicineHistory(final LoadHistoryCallbacks loadHistoryCallbacks) {
32 | localDataSource.getMedicineHistory(new LoadHistoryCallbacks() {
33 | @Override
34 | public void onHistoryLoaded(List historyList) {
35 | loadHistoryCallbacks.onHistoryLoaded(historyList);
36 | }
37 |
38 | @Override
39 | public void onDataNotAvailable() {
40 | loadHistoryCallbacks.onDataNotAvailable();
41 | }
42 | });
43 | }
44 |
45 | @Override
46 | public void getMedicineAlarmById(long id, final GetTaskCallback callback) {
47 | localDataSource.getMedicineAlarmById(id, new GetTaskCallback() {
48 | @Override
49 | public void onTaskLoaded(MedicineAlarm medicineAlarm) {
50 | if (medicineAlarm == null) {
51 | return;
52 | }
53 | callback.onTaskLoaded(medicineAlarm);
54 | }
55 |
56 | @Override
57 | public void onDataNotAvailable() {
58 | callback.onDataNotAvailable();
59 | }
60 | });
61 | }
62 |
63 | @Override
64 | public void saveMedicine(MedicineAlarm medicineAlarm, Pills pills) {
65 | localDataSource.saveMedicine(medicineAlarm, pills);
66 | }
67 |
68 |
69 | @Override
70 | public void getMedicineListByDay(int day, final LoadMedicineCallbacks callbacks) {
71 | localDataSource.getMedicineListByDay(day, new LoadMedicineCallbacks() {
72 | @Override
73 | public void onMedicineLoaded(List medicineAlarmList) {
74 | callbacks.onMedicineLoaded(medicineAlarmList);
75 | }
76 |
77 | @Override
78 | public void onDataNotAvailable() {
79 | callbacks.onDataNotAvailable();
80 | }
81 | });
82 | }
83 |
84 | @Override
85 | public boolean medicineExits(String pillName) {
86 | return false;
87 | }
88 |
89 | @Override
90 | public List tempIds() {
91 | return localDataSource.tempIds();
92 | }
93 |
94 | @Override
95 | public void deleteAlarm(long alarmId) {
96 | localDataSource.deleteAlarm(alarmId);
97 | }
98 |
99 | @Override
100 | public List getMedicineByPillName(String pillName) {
101 | return localDataSource.getMedicineByPillName(pillName);
102 | }
103 |
104 | @Override
105 | public List getAllAlarms(String pillName) {
106 | return localDataSource.getAllAlarms(pillName);
107 | }
108 |
109 | @Override
110 | public Pills getPillsByName(String pillName) {
111 | return localDataSource.getPillsByName(pillName);
112 | }
113 |
114 | @Override
115 | public long savePills(Pills pills) {
116 | return localDataSource.savePills(pills);
117 | }
118 |
119 | @Override
120 | public void saveToHistory(History history) {
121 | localDataSource.saveToHistory(history);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
17 |
22 |
27 |
32 |
37 |
42 |
47 |
52 |
57 |
62 |
67 |
72 |
77 |
82 |
87 |
92 |
97 |
102 |
107 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/row_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
33 |
34 |
35 |
39 |
40 |
49 |
50 |
59 |
60 |
70 |
71 |
77 |
78 |
83 |
84 |
85 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/MedicineAlarm.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.util.Collections;
6 | import java.util.LinkedList;
7 | import java.util.List;
8 | import java.util.Locale;
9 |
10 | /**
11 | * Created by gautam on 12/07/17.
12 | */
13 |
14 | public class MedicineAlarm implements Comparable {
15 |
16 | private long id; // DB id number
17 |
18 | private int hour; //
19 |
20 | private int minute;
21 |
22 | private String pillName;
23 |
24 | private String doseQuantity;
25 |
26 | private String doseUnit;
27 |
28 | private String dateString;
29 |
30 | private int alarmId;
31 |
32 | public MedicineAlarm() {
33 |
34 | }
35 |
36 | public MedicineAlarm(long id, int hour, int minute, String pillName, String doseQuantity, String doseUnit, int alarmId) {
37 | this.id = id;
38 | this.hour = hour;
39 | this.minute = minute;
40 | this.pillName = pillName;
41 | this.doseQuantity = doseQuantity;
42 | this.doseUnit = doseUnit;
43 | this.alarmId = alarmId;
44 | }
45 |
46 | public String getDateString() {
47 | return dateString;
48 | }
49 |
50 | public void setDateString(String dateString) {
51 | this.dateString = dateString;
52 | }
53 |
54 | public String getDoseQuantity() {
55 | return doseQuantity;
56 | }
57 |
58 | public String getDoseUnit() {
59 | return doseUnit;
60 | }
61 |
62 | public void setDoseQuantity(String doseQuantity) {
63 | this.doseQuantity = doseQuantity;
64 | }
65 |
66 | public void setDoseUnit(String doseUnit) {
67 | this.doseUnit = doseUnit;
68 | }
69 |
70 | private List ids = new LinkedList();
71 |
72 | private boolean[] dayOfWeek = new boolean[7];
73 |
74 | public long getId() {
75 | return id;
76 | }
77 |
78 | public void setId(long id) {
79 | this.id = id;
80 | }
81 |
82 | public int getAlarmId() {
83 | return alarmId;
84 | }
85 |
86 | public void setAlarmId(int alarmId) {
87 | this.alarmId = alarmId;
88 | }
89 |
90 | public List getIds() {
91 | return Collections.unmodifiableList(ids);
92 | }
93 |
94 | public boolean[] getDayOfWeek() {
95 | return dayOfWeek;
96 | }
97 |
98 | public void setDayOfWeek(boolean[] dayOfWeek) {
99 | this.dayOfWeek = dayOfWeek;
100 | }
101 |
102 | public void addId(long id) {
103 | ids.add(id);
104 | }
105 |
106 | public int getHour() {
107 | return hour;
108 | }
109 |
110 | public void setHour(int hour) {
111 | this.hour = hour;
112 | }
113 |
114 | public int getMinute() {
115 | return minute;
116 | }
117 |
118 | public void setMinute(int minute) {
119 | this.minute = minute;
120 | }
121 |
122 | private String getAm_pm() {
123 | return (hour < 12) ? "am" : "pm";
124 | }
125 |
126 | public String getPillName() {
127 | return pillName;
128 | }
129 |
130 | public void setPillName(String pillName) {
131 | this.pillName = pillName;
132 | }
133 |
134 | /**
135 | * Overrides the compareTo() method so that alarms can be sorted by time of day from earliest to
136 | * latest.
137 | */
138 | @Override
139 | public int compareTo(@NonNull MedicineAlarm medicineAlarm) {
140 | if (hour < medicineAlarm.getHour())
141 | return -1;
142 | else if (hour > medicineAlarm.getHour())
143 | return 1;
144 | else {
145 | if (minute < medicineAlarm.getMinute())
146 | return -1;
147 | else if (minute > medicineAlarm.getMinute())
148 | return 1;
149 | else
150 | return 0;
151 | }
152 | }
153 |
154 | /**
155 | * A helper method which returns the time of the alarm in string form
156 | * hour:minutes am/pm
157 | */
158 | public String getStringTime() {
159 | int nonMilitaryHour = hour % 12;
160 | if (nonMilitaryHour == 0)
161 | nonMilitaryHour = 12;
162 | String min = Integer.toString(minute);
163 | if (minute < 10)
164 | min = "0" + minute;
165 | return String.format(Locale.getDefault(), "%d:%s %s", nonMilitaryHour, min, getAm_pm());
166 | }
167 |
168 | /**
169 | * A helper method which returns the formatted medicine dose
170 | * doseQuantity doseUnit
171 | */
172 | public String getFormattedDose() {
173 | return String.format(Locale.getDefault(), "%s %s", doseQuantity, doseUnit);
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/row_medicine.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
33 |
34 |
35 |
39 |
40 |
49 |
50 |
59 |
60 |
70 |
71 |
77 |
78 |
83 |
84 |
85 |
95 |
96 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/medicine/MedicinePresenter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.medicine;
2 |
3 | import android.app.Activity;
4 | import android.app.AlarmManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.util.Log;
9 |
10 | import androidx.annotation.NonNull;
11 |
12 | import com.gautam.medicinetime.addmedicine.AddMedicineActivity;
13 | import com.gautam.medicinetime.alarm.ReminderActivity;
14 | import com.gautam.medicinetime.alarm.ReminderFragment;
15 | import com.gautam.medicinetime.data.source.MedicineAlarm;
16 | import com.gautam.medicinetime.data.source.MedicineDataSource;
17 | import com.gautam.medicinetime.data.source.MedicineRepository;
18 |
19 | import java.util.Collections;
20 | import java.util.List;
21 | import java.util.Objects;
22 |
23 | import static android.content.Context.ALARM_SERVICE;
24 |
25 | /**
26 | * Created by gautam on 13/07/17.
27 | */
28 |
29 | public class MedicinePresenter implements MedicineContract.Presenter {
30 |
31 | private final MedicineRepository mMedicineRepository;
32 |
33 | private final MedicineContract.View mMedView;
34 |
35 |
36 | MedicinePresenter(@NonNull MedicineRepository medicineRepository, @NonNull MedicineContract.View medView) {
37 | this.mMedicineRepository = medicineRepository;
38 | this.mMedView = medView;
39 | medView.setPresenter(this);
40 | }
41 |
42 | @Override
43 | public void loadMedicinesByDay(int day, boolean showIndicator) {
44 | loadListByDay(day, showIndicator);
45 | }
46 |
47 | @Override
48 | public void deleteMedicineAlarm(MedicineAlarm medicineAlarm, Context context) {
49 | List alarms = mMedicineRepository.getAllAlarms(medicineAlarm.getPillName());
50 | for (MedicineAlarm alarm : alarms) {
51 | mMedicineRepository.deleteAlarm(alarm.getId());
52 | /** This intent invokes the activity ReminderActivity, which in turn opens the AlertAlarm window */
53 | Intent intent = new Intent(context, ReminderActivity.class);
54 | intent.putExtra(ReminderFragment.EXTRA_ID, alarm.getAlarmId());
55 |
56 | PendingIntent operation = PendingIntent.getActivity(context, alarm.getAlarmId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
57 |
58 |
59 | /** Getting a reference to the System Service ALARM_SERVICE */
60 | AlarmManager alarmManager = (AlarmManager) Objects.requireNonNull(context).getSystemService(ALARM_SERVICE);
61 | if (alarmManager != null) {
62 | alarmManager.cancel(operation);
63 | }
64 | }
65 | mMedView.showMedicineDeletedSuccessfully();
66 | }
67 |
68 | @Override
69 | public void start() {
70 |
71 | }
72 |
73 | @Override
74 | public void onStart(int day) {
75 | Log.d("TAG", "onStart: " + day);
76 | loadMedicinesByDay(day, true);
77 | }
78 |
79 | @Override
80 | public void reload(int day) {
81 | Log.d("TAG", "reload: " + day);
82 | loadListByDay(day, true);
83 | }
84 |
85 | @Override
86 | public void result(int requestCode, int resultCode) {
87 | if (AddMedicineActivity.REQUEST_ADD_TASK == requestCode && Activity.RESULT_OK == resultCode) {
88 | mMedView.showSuccessfullySavedMessage();
89 | }
90 | }
91 |
92 | @Override
93 | public void addNewMedicine() {
94 | mMedView.showAddMedicine();
95 | }
96 |
97 | private void loadListByDay(int day, final boolean showLoadingUi) {
98 | if (showLoadingUi)
99 | mMedView.showLoadingIndicator(true);
100 |
101 | mMedicineRepository.getMedicineListByDay(day, new MedicineDataSource.LoadMedicineCallbacks() {
102 | @Override
103 | public void onMedicineLoaded(List medicineAlarmList) {
104 | processMedicineList(medicineAlarmList);
105 | // The view may not be able to handle UI updates anymore
106 | if (!mMedView.isActive()) {
107 | return;
108 | }
109 | if (showLoadingUi) {
110 | mMedView.showLoadingIndicator(false);
111 | }
112 | }
113 |
114 | @Override
115 | public void onDataNotAvailable() {
116 | if (!mMedView.isActive()) {
117 | return;
118 | }
119 | if (showLoadingUi) {
120 | mMedView.showLoadingIndicator(false);
121 | }
122 |
123 | mMedView.showNoMedicine();
124 | }
125 | });
126 | }
127 |
128 | private void processMedicineList(List medicineAlarmList) {
129 |
130 | if (medicineAlarmList.isEmpty()) {
131 | // Show a message indicating there are no tasks for that filter type.
132 | mMedView.showNoMedicine();
133 | } else {
134 | //Show the list of Medicines
135 | Collections.sort(medicineAlarmList);
136 | mMedView.showMedicineList(medicineAlarmList);
137 | }
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_reminder.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
33 |
34 |
35 |
39 |
40 |
49 |
50 |
59 |
60 |
70 |
71 |
77 |
78 |
83 |
84 |
85 |
92 |
93 |
94 |
101 |
102 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/data/source/local/MedicinesLocalDataSource.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data.source.local;
2 |
3 | import android.content.Context;
4 |
5 | import com.gautam.medicinetime.data.source.History;
6 | import com.gautam.medicinetime.data.source.MedicineAlarm;
7 | import com.gautam.medicinetime.data.source.MedicineDataSource;
8 | import com.gautam.medicinetime.data.source.Pills;
9 |
10 | import java.net.URISyntaxException;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by gautam on 13/07/17.
15 | */
16 |
17 | public class MedicinesLocalDataSource implements MedicineDataSource {
18 |
19 | private static MedicinesLocalDataSource mInstance;
20 |
21 | private MedicineDBHelper mDbHelper;
22 |
23 |
24 | private MedicinesLocalDataSource(Context context) {
25 | mDbHelper = new MedicineDBHelper(context);
26 | }
27 |
28 | public static MedicinesLocalDataSource getInstance(Context context) {
29 | if (mInstance == null) {
30 | mInstance = new MedicinesLocalDataSource(context);
31 | }
32 | return mInstance;
33 | }
34 |
35 |
36 | @Override
37 | public void getMedicineHistory(LoadHistoryCallbacks loadHistoryCallbacks) {
38 | List historyList = mDbHelper.getHistory();
39 | loadHistoryCallbacks.onHistoryLoaded(historyList);
40 | }
41 |
42 | @Override
43 | public void getMedicineAlarmById(long id, GetTaskCallback callback) {
44 |
45 | try {
46 | MedicineAlarm medicineAlarm = getAlarmById(id);
47 | if (medicineAlarm != null) {
48 | callback.onTaskLoaded(medicineAlarm);
49 | } else {
50 | callback.onDataNotAvailable();
51 | }
52 | } catch (URISyntaxException e) {
53 | e.printStackTrace();
54 | callback.onDataNotAvailable();
55 | }
56 |
57 | }
58 |
59 | @Override
60 | public void saveMedicine(MedicineAlarm medicineAlarm, Pills pill) {
61 | mDbHelper.createAlarm(medicineAlarm, pill.getPillId());
62 | }
63 |
64 | @Override
65 | public void getMedicineListByDay(int day, LoadMedicineCallbacks callbacks) {
66 | List medicineAlarmList = mDbHelper.getAlarmsByDay(day);
67 | callbacks.onMedicineLoaded(medicineAlarmList);
68 | }
69 |
70 | @Override
71 | public boolean medicineExits(String pillName) {
72 | for (Pills pill : getPills()) {
73 | if (pill.getPillName().equals(pillName))
74 | return true;
75 | }
76 | return false;
77 | }
78 |
79 | @Override
80 | public List tempIds() {
81 | return null;
82 | }
83 |
84 | @Override
85 | public void deleteAlarm(long alarmId) {
86 | deleteAlarmById(alarmId);
87 | }
88 |
89 | @Override
90 | public List getMedicineByPillName(String pillName) {
91 | try {
92 | return getMedicineByPill(pillName);
93 | } catch (URISyntaxException e) {
94 | e.printStackTrace();
95 | return null;
96 | }
97 | }
98 |
99 | @Override
100 | public List getAllAlarms(String pillName) {
101 | try {
102 | return getAllAlarmsByName(pillName);
103 | } catch (URISyntaxException e) {
104 | e.printStackTrace();
105 | return null;
106 | }
107 | }
108 |
109 | @Override
110 | public Pills getPillsByName(String pillName) {
111 | return getPillByName(pillName);
112 | }
113 |
114 | @Override
115 | public long savePills(Pills pills) {
116 | return savePill(pills);
117 | }
118 |
119 | @Override
120 | public void saveToHistory(History history) {
121 | mDbHelper.createHistory(history);
122 | }
123 |
124 | private List getPills() {
125 | return mDbHelper.getAllPills();
126 | }
127 |
128 | private long savePill(Pills pill) {
129 | long pillId = mDbHelper.createPill(pill);
130 | pill.setPillId(pillId);
131 | return pillId;
132 | }
133 |
134 | private Pills getPillByName(String pillName) {
135 | return mDbHelper.getPillByName(pillName);
136 | }
137 |
138 | private List getMedicineByPill(String pillName) throws URISyntaxException {
139 | return mDbHelper.getAllAlarmsByPill(pillName);
140 | }
141 |
142 | private List getAllAlarmsByName(String pillName) throws URISyntaxException {
143 | return mDbHelper.getAllAlarms(pillName);
144 | }
145 |
146 | public void deletePill(String pillName) throws URISyntaxException {
147 | mDbHelper.deletePill(pillName);
148 | }
149 |
150 | private void deleteAlarmById(long alarmId) {
151 | mDbHelper.deleteAlarm(alarmId);
152 | }
153 |
154 | public void addToHistory(History h) {
155 | mDbHelper.createHistory(h);
156 | }
157 |
158 | public List getHistory() {
159 | return mDbHelper.getHistory();
160 | }
161 |
162 | private MedicineAlarm getAlarmById(long alarm_id) throws URISyntaxException {
163 | return mDbHelper.getAlarmById(alarm_id);
164 | }
165 |
166 | public int getDayOfWeek(long alarm_id) throws URISyntaxException {
167 | return mDbHelper.getDayOfWeek(alarm_id);
168 | }
169 |
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/MonthlyReportPresenter.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.gautam.medicinetime.data.source.History;
6 | import com.gautam.medicinetime.data.source.MedicineDataSource;
7 | import com.gautam.medicinetime.data.source.MedicineRepository;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by gautam on 13/07/17.
14 | */
15 |
16 | public class MonthlyReportPresenter implements MonthlyReportContract.Presenter {
17 |
18 |
19 | private final MedicineRepository mMedicineRepository;
20 |
21 | private final MonthlyReportContract.View mMonthlyReportView;
22 |
23 | private FilterType mCurrentFilteringType = FilterType.ALL_MEDICINES;
24 |
25 | public MonthlyReportPresenter(@NonNull MedicineRepository medicineRepository, MonthlyReportContract.View monthlyReportView) {
26 | this.mMedicineRepository = medicineRepository;
27 | this.mMonthlyReportView = monthlyReportView;
28 | mMonthlyReportView.setPresenter(this);
29 | }
30 |
31 |
32 | @Override
33 | public void start() {
34 | loadHistory(true);
35 | }
36 |
37 |
38 | @Override
39 | public void loadHistory(boolean showLoading) {
40 | loadHistoryFromDb(showLoading);
41 | }
42 |
43 | private void loadHistoryFromDb(final boolean showLoading) {
44 | if (showLoading) {
45 | mMonthlyReportView.setLoadingIndicator(true);
46 | }
47 | mMedicineRepository.getMedicineHistory(new MedicineDataSource.LoadHistoryCallbacks() {
48 | @Override
49 | public void onHistoryLoaded(List historyList) {
50 | List historyShowList = new ArrayList<>();
51 |
52 | //We will filter the History based on request type
53 | for (History history : historyList) {
54 | switch (mCurrentFilteringType) {
55 | case ALL_MEDICINES:
56 | historyShowList.add(history);
57 | break;
58 | case TAKEN_MEDICINES:
59 | if (history.getAction() == 1) {
60 | historyShowList.add(history);
61 | }
62 | break;
63 | case IGNORED_MEDICINES:
64 | if (history.getAction() == 2) {
65 | historyShowList.add(history);
66 | }
67 | break;
68 | }
69 | }
70 | processHistory(historyShowList);
71 | if (!mMonthlyReportView.isActive()) {
72 | return;
73 | }
74 | if (showLoading) {
75 | mMonthlyReportView.setLoadingIndicator(false);
76 | }
77 |
78 | }
79 |
80 | @Override
81 | public void onDataNotAvailable() {
82 | if (!mMonthlyReportView.isActive()) {
83 | return;
84 | }
85 | if (showLoading) {
86 | mMonthlyReportView.setLoadingIndicator(false);
87 | }
88 | mMonthlyReportView.showLoadingError();
89 | }
90 | });
91 |
92 | }
93 |
94 | private void processHistory(List historyList) {
95 |
96 | if (historyList.isEmpty()) {
97 | // Show a message indicating there are no history for that filter type.
98 | processEmptyHistory();
99 | } else {
100 | //Show the list of history
101 | mMonthlyReportView.showHistoryList(historyList);
102 | //Set filter label's text
103 | showFilterLabel();
104 | }
105 | }
106 |
107 | private void showFilterLabel() {
108 | switch (mCurrentFilteringType) {
109 | case ALL_MEDICINES:
110 | mMonthlyReportView.showAllFilterLabel();
111 | break;
112 | case TAKEN_MEDICINES:
113 | mMonthlyReportView.showTakenFilterLabel();
114 | break;
115 | case IGNORED_MEDICINES:
116 | mMonthlyReportView.showIgnoredFilterLabel();
117 | break;
118 | default:
119 | mMonthlyReportView.showAllFilterLabel();
120 | }
121 | }
122 |
123 |
124 | private void processEmptyHistory() {
125 | switch (mCurrentFilteringType) {
126 | case ALL_MEDICINES:
127 | mMonthlyReportView.showNoHistory();
128 | break;
129 | case TAKEN_MEDICINES:
130 | mMonthlyReportView.showNoTakenHistory();
131 | break;
132 | case IGNORED_MEDICINES:
133 | mMonthlyReportView.showNoIgnoredHistory();
134 | break;
135 | default:
136 | mMonthlyReportView.showNoHistory();
137 | break;
138 | }
139 | }
140 |
141 |
142 | @Override
143 | public void setFiltering(FilterType filterType) {
144 | mCurrentFilteringType = filterType;
145 | }
146 |
147 | @Override
148 | public FilterType getFilterType() {
149 | return mCurrentFilteringType;
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_medicine.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
28 |
29 |
36 |
37 |
48 |
49 |
50 |
57 |
58 |
67 |
68 |
77 |
78 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
99 |
100 |
109 |
110 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/medicine/MedicineActivity.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.medicine;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import com.google.android.material.appbar.AppBarLayout;
6 | import com.google.android.material.appbar.CollapsingToolbarLayout;
7 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
8 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
9 | import androidx.core.view.ViewCompat;
10 | import androidx.appcompat.app.AppCompatActivity;
11 | import androidx.appcompat.widget.Toolbar;
12 | import android.view.Menu;
13 | import android.view.MenuItem;
14 | import android.widget.FrameLayout;
15 | import android.widget.ImageView;
16 | import android.widget.RelativeLayout;
17 | import android.widget.TextView;
18 |
19 | import com.gautam.medicinetime.Injection;
20 | import com.gautam.medicinetime.R;
21 | import com.gautam.medicinetime.report.MonthlyReportActivity;
22 | import com.gautam.medicinetime.utils.ActivityUtils;
23 | import com.github.sundeepk.compactcalendarview.CompactCalendarView;
24 |
25 | import java.text.SimpleDateFormat;
26 | import java.util.Calendar;
27 | import java.util.Date;
28 | import java.util.Locale;
29 | import java.util.TimeZone;
30 |
31 | import butterknife.BindView;
32 | import butterknife.ButterKnife;
33 | import butterknife.OnClick;
34 |
35 | public class MedicineActivity extends AppCompatActivity {
36 |
37 |
38 | @BindView(R.id.compactcalendar_view)
39 | CompactCalendarView mCompactCalendarView;
40 |
41 | @BindView(R.id.date_picker_text_view)
42 | TextView datePickerTextView;
43 |
44 | @BindView(R.id.date_picker_button)
45 | RelativeLayout datePickerButton;
46 |
47 | @BindView(R.id.toolbar)
48 | Toolbar toolbar;
49 |
50 | @BindView(R.id.collapsingToolbarLayout)
51 | CollapsingToolbarLayout collapsingToolbarLayout;
52 |
53 | @BindView(R.id.app_bar_layout)
54 | AppBarLayout appBarLayout;
55 |
56 | @BindView(R.id.contentFrame)
57 | FrameLayout contentFrame;
58 |
59 | @BindView(R.id.fab_add_task)
60 | FloatingActionButton fabAddTask;
61 |
62 | @BindView(R.id.coordinatorLayout)
63 | CoordinatorLayout coordinatorLayout;
64 |
65 | @BindView(R.id.date_picker_arrow)
66 | ImageView arrow;
67 |
68 | private MedicinePresenter presenter;
69 |
70 | private SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd", /*Locale.getDefault()*/Locale.ENGLISH);
71 |
72 | private boolean isExpanded = false;
73 |
74 | @Override
75 | protected void onCreate(Bundle savedInstanceState) {
76 | super.onCreate(savedInstanceState);
77 | setContentView(R.layout.activity_medicine);
78 | ButterKnife.bind(this);
79 | setSupportActionBar(toolbar);
80 |
81 | mCompactCalendarView.setLocale(TimeZone.getDefault(), /*Locale.getDefault()*/Locale.ENGLISH);
82 |
83 | mCompactCalendarView.setShouldDrawDaysHeader(true);
84 |
85 | mCompactCalendarView.setListener(new CompactCalendarView.CompactCalendarViewListener() {
86 | @Override
87 | public void onDayClick(Date dateClicked) {
88 | setSubtitle(dateFormat.format(dateClicked));
89 | Calendar calendar = Calendar.getInstance();
90 | calendar.setTime(dateClicked);
91 |
92 | int day = calendar.get(Calendar.DAY_OF_WEEK);
93 |
94 | if (isExpanded) {
95 | ViewCompat.animate(arrow).rotation(0).start();
96 | } else {
97 | ViewCompat.animate(arrow).rotation(180).start();
98 | }
99 | isExpanded = !isExpanded;
100 | appBarLayout.setExpanded(isExpanded, true);
101 | presenter.reload(day);
102 | }
103 |
104 | @Override
105 | public void onMonthScroll(Date firstDayOfNewMonth) {
106 | setSubtitle(dateFormat.format(firstDayOfNewMonth));
107 | }
108 | });
109 | setCurrentDate(new Date());
110 | MedicineFragment medicineFragment = (MedicineFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
111 | if (medicineFragment == null) {
112 | medicineFragment = MedicineFragment.newInstance();
113 | ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), medicineFragment, R.id.contentFrame);
114 | }
115 |
116 | //Create MedicinePresenter
117 | presenter = new MedicinePresenter(Injection.provideMedicineRepository(MedicineActivity.this), medicineFragment);
118 | }
119 |
120 | @Override
121 | public boolean onCreateOptionsMenu(Menu menu) {
122 | getMenuInflater().inflate(R.menu.medicine_menu, menu);
123 | return true;
124 | }
125 |
126 | @Override
127 | public boolean onOptionsItemSelected(MenuItem item) {
128 | if (item.getItemId() == R.id.menu_stats) {
129 | Intent intent = new Intent(this, MonthlyReportActivity.class);
130 | startActivity(intent);
131 | }
132 | return super.onOptionsItemSelected(item);
133 | }
134 |
135 | public void setCurrentDate(Date date) {
136 | setSubtitle(dateFormat.format(date));
137 | mCompactCalendarView.setCurrentDate(date);
138 | }
139 |
140 | public void setSubtitle(String subtitle) {
141 | datePickerTextView.setText(subtitle);
142 | }
143 |
144 | @OnClick(R.id.date_picker_button)
145 | void onDatePickerButtonClicked() {
146 | if (isExpanded) {
147 | ViewCompat.animate(arrow).rotation(0).start();
148 | } else {
149 | ViewCompat.animate(arrow).rotation(180).start();
150 | }
151 |
152 | isExpanded = !isExpanded;
153 | appBarLayout.setExpanded(isExpanded, true);
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/app/src/mock/java/com.gautam.medicinetime/data/FakeMedicineLocalDataSource.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.data;
2 |
3 | import androidx.annotation.VisibleForTesting;
4 |
5 | import com.gautam.medicinetime.data.source.History;
6 | import com.gautam.medicinetime.data.source.MedicineAlarm;
7 | import com.gautam.medicinetime.data.source.MedicineDataSource;
8 | import com.gautam.medicinetime.data.source.Pills;
9 |
10 | import java.text.SimpleDateFormat;
11 | import java.util.ArrayList;
12 | import java.util.Calendar;
13 | import java.util.Date;
14 | import java.util.LinkedHashMap;
15 | import java.util.List;
16 | import java.util.Locale;
17 | import java.util.Map;
18 | import java.util.Random;
19 |
20 |
21 | /**
22 | * Created by gautam on 13/05/17.
23 | */
24 |
25 | public class FakeMedicineLocalDataSource implements MedicineDataSource {
26 |
27 | private static FakeMedicineLocalDataSource INSTANCE;
28 |
29 | private static final Map MEDICINE_SERVICE_DATA;
30 |
31 | private static final Map HISTORY_SERVICE_DATA;
32 |
33 | private static final Map PILLS_SERVICE_DATA;
34 |
35 |
36 | //Prevent from direct Instantiation
37 | private FakeMedicineLocalDataSource() {
38 |
39 | }
40 |
41 | static {
42 | MEDICINE_SERVICE_DATA = new LinkedHashMap<>();
43 | HISTORY_SERVICE_DATA = new LinkedHashMap<>();
44 | PILLS_SERVICE_DATA = new LinkedHashMap<>();
45 |
46 | Calendar mCurrentTime = Calendar.getInstance();
47 | int hour = mCurrentTime.get(Calendar.HOUR_OF_DAY);
48 | int minute = mCurrentTime.get(Calendar.MINUTE);
49 |
50 | Date date = mCurrentTime.getTime();
51 | String dateString = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(date);
52 |
53 | addPills("Paracetamol", 1);
54 | addPills("Crocin", 2);
55 | int alarmId = new Random().nextInt(100);
56 | addMedicine(1, hour, minute, "Paracetamol", "1.0", "tablet(s)", alarmId);
57 | addMedicine(2, hour + 2, minute + 1, "Crocin", "2.0", "capsule(s)", alarmId);
58 |
59 | addHistory(hour, minute, dateString, "Crocin", 2, "2.0", "capsule(s)", alarmId);
60 | addHistory(hour + 2, minute + 1, dateString, "Paracetamol", 1, "1.0", "tablet(s)", alarmId);
61 | }
62 |
63 |
64 | private static void addMedicine(long id, int hour, int minute, String pillName, String doseQuantity, String doseUnit, int alarmId) {
65 |
66 | MedicineAlarm medicineAlarm = new MedicineAlarm(id, hour, minute, pillName, doseQuantity, doseUnit, alarmId);
67 | MEDICINE_SERVICE_DATA.put(String.valueOf(id), medicineAlarm);
68 | }
69 |
70 | private static void addHistory(int hourTaken, int minuteTaken, String dateString, String pillName, int action, String doseQuantity, String doseUnit, int alarmId) {
71 | History history = new History(hourTaken, minuteTaken, dateString, pillName, action, doseQuantity, doseUnit, alarmId);
72 | HISTORY_SERVICE_DATA.put(pillName, history);
73 | }
74 |
75 | private static void addPills(String pillName, long pillId) {
76 | Pills pills = new Pills(pillName, pillId);
77 | PILLS_SERVICE_DATA.put(String.valueOf(pillId), pills);
78 | }
79 |
80 | public static FakeMedicineLocalDataSource getInstance() {
81 | if (INSTANCE == null) {
82 | INSTANCE = new FakeMedicineLocalDataSource();
83 | }
84 | return INSTANCE;
85 | }
86 |
87 | @VisibleForTesting
88 | public void addMedicines(MedicineAlarm... medicineAlarms) {
89 | for (MedicineAlarm medicineAlarm : medicineAlarms) {
90 | MEDICINE_SERVICE_DATA.put(String.valueOf(medicineAlarm.getId()), medicineAlarm);
91 | }
92 | }
93 |
94 | public void addMedicine(MedicineAlarm... medicineAlarms) {
95 | for (MedicineAlarm medicineAlarm : medicineAlarms) {
96 | MEDICINE_SERVICE_DATA.put(String.valueOf(medicineAlarm.getId()), medicineAlarm);
97 | }
98 | }
99 |
100 | @Override
101 | public void getMedicineHistory(LoadHistoryCallbacks loadHistoryCallbacks) {
102 | loadHistoryCallbacks.onHistoryLoaded(new ArrayList(HISTORY_SERVICE_DATA.values()));
103 | }
104 |
105 | @Override
106 | public void getMedicineAlarmById(long id, GetTaskCallback callback) {
107 | callback.onTaskLoaded(MEDICINE_SERVICE_DATA.get(String.valueOf(id)));
108 | }
109 |
110 | @Override
111 | public void saveMedicine(MedicineAlarm medicineAlarm, Pills pills) {
112 | medicineAlarm.addId(pills.getPillId());
113 | MEDICINE_SERVICE_DATA.put(String.valueOf(pills.getPillId()), medicineAlarm);
114 | }
115 |
116 | @Override
117 | public void getMedicineListByDay(int day, LoadMedicineCallbacks callbacks) {
118 | callbacks.onMedicineLoaded(new ArrayList<>(MEDICINE_SERVICE_DATA.values()));
119 | }
120 |
121 | @Override
122 | public boolean medicineExits(String pillName) {
123 | return false;
124 | }
125 |
126 | @Override
127 | public List tempIds() {
128 | return null;
129 | }
130 |
131 | @Override
132 | public void deleteAlarm(long alarmId) {
133 | MEDICINE_SERVICE_DATA.remove(String.valueOf(alarmId));
134 | }
135 |
136 | @Override
137 | public List getMedicineByPillName(String pillName) {
138 | List medicineAlarms = new ArrayList<>();
139 | for (Map.Entry entry : MEDICINE_SERVICE_DATA.entrySet()) {
140 | MedicineAlarm medicineAlarm = entry.getValue();
141 | if (medicineAlarm.getPillName().equalsIgnoreCase(pillName)) {
142 | medicineAlarms.add(medicineAlarm);
143 | }
144 | }
145 | return medicineAlarms;
146 | }
147 |
148 | @Override
149 | public List getAllAlarms(String pillName) {
150 | List medicineAlarms = new ArrayList<>();
151 | for (Map.Entry entry : MEDICINE_SERVICE_DATA.entrySet()) {
152 | MedicineAlarm medicineAlarm = entry.getValue();
153 | if (medicineAlarm.getPillName().equalsIgnoreCase(pillName)) {
154 | medicineAlarms.add(medicineAlarm);
155 | }
156 | }
157 | return medicineAlarms;
158 | }
159 |
160 | @Override
161 | public Pills getPillsByName(String pillName) {
162 | for (Map.Entry entry : PILLS_SERVICE_DATA.entrySet()) {
163 | Pills pills = entry.getValue();
164 | if (pills.getPillName().equalsIgnoreCase(pillName)) {
165 | return pills;
166 | }
167 | }
168 | return null;
169 | }
170 |
171 | @Override
172 | public long savePills(Pills pills) {
173 | PILLS_SERVICE_DATA.put(String.valueOf(pills.getPillId()), pills);
174 | return pills.getPillId();
175 | }
176 |
177 | @Override
178 | public void saveToHistory(History history) {
179 | HISTORY_SERVICE_DATA.put(String.valueOf(history.getPillName()), history);
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/report/MonthlyReportFragment.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.report;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.Nullable;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.recyclerview.widget.LinearLayoutManager;
7 | import androidx.appcompat.widget.PopupMenu;
8 | import androidx.recyclerview.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.Menu;
11 | import android.view.MenuInflater;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.ImageView;
16 | import android.widget.LinearLayout;
17 | import android.widget.ProgressBar;
18 | import android.widget.TextView;
19 |
20 | import com.gautam.medicinetime.R;
21 | import com.gautam.medicinetime.data.source.History;
22 | import com.gautam.medicinetime.views.RobotoLightTextView;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | import butterknife.BindView;
28 | import butterknife.ButterKnife;
29 | import butterknife.Unbinder;
30 |
31 | /**
32 | * Created by gautam on 13/07/17.
33 | */
34 |
35 | public class MonthlyReportFragment extends Fragment implements MonthlyReportContract.View {
36 |
37 | @BindView(R.id.rv_history_list)
38 | RecyclerView rvHistoryList;
39 |
40 | @BindView(R.id.progressLoader)
41 | ProgressBar progressLoader;
42 |
43 | @BindView(R.id.noMedIcon)
44 | ImageView noMedIcon;
45 |
46 | @BindView(R.id.noMedText)
47 | RobotoLightTextView noMedText;
48 |
49 | @BindView(R.id.no_med_view)
50 | View noMedView;
51 |
52 | Unbinder unbinder;
53 |
54 | @BindView(R.id.filteringLabel)
55 | TextView filteringLabel;
56 |
57 | @BindView(R.id.tasksLL)
58 | LinearLayout tasksLL;
59 |
60 | private HistoryAdapter mHistoryAdapter;
61 |
62 | private MonthlyReportContract.Presenter presenter;
63 |
64 | public static MonthlyReportFragment newInstance() {
65 | Bundle args = new Bundle();
66 | MonthlyReportFragment fragment = new MonthlyReportFragment();
67 | fragment.setArguments(args);
68 | return fragment;
69 | }
70 |
71 | @Override
72 | public void onCreate(@Nullable Bundle savedInstanceState) {
73 | super.onCreate(savedInstanceState);
74 | mHistoryAdapter = new HistoryAdapter(new ArrayList());
75 | setHasOptionsMenu(true);
76 | }
77 |
78 | private void setAdapter() {
79 | rvHistoryList.setAdapter(mHistoryAdapter);
80 | rvHistoryList.setLayoutManager(new LinearLayoutManager(getContext()));
81 | rvHistoryList.setHasFixedSize(true);
82 | }
83 |
84 | @Nullable
85 | @Override
86 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
87 | View view = inflater.inflate(R.layout.fragment_history, container, false);
88 | unbinder = ButterKnife.bind(this, view);
89 | setAdapter();
90 | return view;
91 | }
92 |
93 | @Override
94 | public void onResume() {
95 | super.onResume();
96 | presenter.start();
97 | }
98 |
99 | @Override
100 | public void setPresenter(MonthlyReportContract.Presenter presenter) {
101 | this.presenter = presenter;
102 | }
103 |
104 | @Override
105 | public void setLoadingIndicator(boolean active) {
106 | if (getView() == null) {
107 | return;
108 | }
109 | progressLoader.setVisibility(active ? View.VISIBLE : View.GONE);
110 | }
111 |
112 | @Override
113 | public void showHistoryList(List historyList) {
114 | mHistoryAdapter.replaceData(historyList);
115 | tasksLL.setVisibility(View.VISIBLE);
116 | noMedView.setVisibility(View.GONE);
117 | }
118 |
119 | @Override
120 | public void showLoadingError() {
121 |
122 | }
123 |
124 | @Override
125 | public void showNoHistory() {
126 | showNoHistoryView(
127 | getString(R.string.no_history),
128 | R.drawable.icon_my_health
129 | );
130 | }
131 |
132 | @Override
133 | public void showTakenFilterLabel() {
134 | filteringLabel.setText(R.string.taken_label);
135 | }
136 |
137 | @Override
138 | public void showIgnoredFilterLabel() {
139 | filteringLabel.setText(R.string.ignore_label);
140 | }
141 |
142 | @Override
143 | public void showAllFilterLabel() {
144 | filteringLabel.setText(R.string.all_label);
145 | }
146 |
147 | @Override
148 | public void showNoTakenHistory() {
149 | showNoHistoryView(
150 | getString(R.string.no_taken_med_history),
151 | R.drawable.icon_my_health
152 | );
153 | }
154 |
155 | @Override
156 | public void showNoIgnoredHistory() {
157 | showNoHistoryView(
158 | getString(R.string.no_ignored_history),
159 | R.drawable.icon_my_health
160 | );
161 | }
162 |
163 | @Override
164 | public boolean isActive() {
165 | return isAdded();
166 | }
167 |
168 | @Override
169 | public void showFilteringPopUpMenu() {
170 | PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter));
171 | popup.getMenuInflater().inflate(R.menu.filter_history, popup.getMenu());
172 |
173 | popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
174 | @Override
175 | public boolean onMenuItemClick(MenuItem item) {
176 | switch (item.getItemId()) {
177 | case R.id.all:
178 | presenter.setFiltering(FilterType.ALL_MEDICINES);
179 | break;
180 | case R.id.taken:
181 | presenter.setFiltering(FilterType.TAKEN_MEDICINES);
182 | break;
183 | case R.id.ignored:
184 | presenter.setFiltering(FilterType.IGNORED_MEDICINES);
185 | break;
186 | }
187 | presenter.loadHistory(true);
188 | return true;
189 | }
190 | });
191 | popup.show();
192 | }
193 |
194 | @Override
195 | public void onDestroyView() {
196 | super.onDestroyView();
197 | unbinder.unbind();
198 | }
199 |
200 | @Override
201 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
202 | inflater.inflate(R.menu.history_menu, menu);
203 | }
204 |
205 | @Override
206 | public boolean onOptionsItemSelected(MenuItem item) {
207 | switch (item.getItemId()) {
208 | case R.id.menu_filter:
209 | showFilteringPopUpMenu();
210 | break;
211 | }
212 | return true;
213 | }
214 |
215 | private void showNoHistoryView(String mainText, int iconRes) {
216 | tasksLL.setVisibility(View.GONE);
217 | noMedView.setVisibility(View.VISIBLE);
218 |
219 | noMedText.setText(mainText);
220 | noMedIcon.setImageDrawable(getResources().getDrawable(iconRes));
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/medicine/MedicineFragment.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.medicine;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
10 | import com.google.android.material.snackbar.Snackbar;
11 |
12 | import androidx.fragment.app.Fragment;
13 | import androidx.recyclerview.widget.LinearLayoutManager;
14 | import androidx.recyclerview.widget.RecyclerView;
15 |
16 | import android.util.Log;
17 | import android.view.LayoutInflater;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.widget.ImageView;
21 | import android.widget.ProgressBar;
22 | import android.widget.TextView;
23 |
24 | import com.gautam.medicinetime.R;
25 | import com.gautam.medicinetime.addmedicine.AddMedicineActivity;
26 | import com.gautam.medicinetime.data.source.MedicineAlarm;
27 | import com.gautam.medicinetime.views.RobotoLightTextView;
28 |
29 | import java.util.ArrayList;
30 | import java.util.Calendar;
31 | import java.util.List;
32 | import java.util.Objects;
33 |
34 | import butterknife.BindView;
35 | import butterknife.ButterKnife;
36 | import butterknife.OnClick;
37 | import butterknife.Unbinder;
38 |
39 | /**
40 | * Created by gautam on 13/07/17.
41 | */
42 |
43 | public class MedicineFragment extends Fragment implements MedicineContract.View, MedicineAdapter.OnItemClickListener {
44 |
45 | @BindView(R.id.medicine_list)
46 | RecyclerView rvMedList;
47 |
48 | Unbinder unbinder;
49 |
50 | @BindView(R.id.noMedIcon)
51 | ImageView noMedIcon;
52 |
53 | @BindView(R.id.noMedText)
54 | RobotoLightTextView noMedText;
55 |
56 | @BindView(R.id.add_med_now)
57 | TextView addMedNow;
58 |
59 | @BindView(R.id.no_med_view)
60 | View noMedView;
61 |
62 | @BindView(R.id.progressLoader)
63 | ProgressBar progressLoader;
64 |
65 |
66 | private MedicineContract.Presenter presenter;
67 |
68 | private MedicineAdapter medicineAdapter;
69 |
70 |
71 | public MedicineFragment() {
72 |
73 | }
74 |
75 | public static MedicineFragment newInstance() {
76 | Bundle args = new Bundle();
77 | MedicineFragment fragment = new MedicineFragment();
78 | fragment.setArguments(args);
79 | return fragment;
80 | }
81 |
82 | @Override
83 | public void onCreate(@Nullable Bundle savedInstanceState) {
84 | super.onCreate(savedInstanceState);
85 | medicineAdapter = new MedicineAdapter(new ArrayList<>(0));
86 | }
87 |
88 | @Nullable
89 | @Override
90 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
91 | View view = inflater.inflate(R.layout.fragment_medicine, container, false);
92 | unbinder = ButterKnife.bind(this, view);
93 | setAdapter();
94 | return view;
95 | }
96 |
97 | @Override
98 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
99 | super.onActivityCreated(savedInstanceState);
100 | FloatingActionButton fab = Objects.requireNonNull(getActivity()).findViewById(R.id.fab_add_task);
101 | fab.setImageResource(R.drawable.ic_add);
102 | fab.setOnClickListener(v -> presenter.addNewMedicine());
103 | }
104 |
105 | private void setAdapter() {
106 | rvMedList.setAdapter(medicineAdapter);
107 | rvMedList.setLayoutManager(new LinearLayoutManager(getContext()));
108 | rvMedList.setHasFixedSize(true);
109 | medicineAdapter.setOnItemClickListener(this);
110 | }
111 |
112 | @Override
113 | public void onResume() {
114 | super.onResume();
115 | Calendar calendar = Calendar.getInstance();
116 | int day = calendar.get(Calendar.DAY_OF_WEEK);
117 | presenter.onStart(day);
118 | }
119 |
120 | @Override
121 | public void setPresenter(MedicineContract.Presenter presenter) {
122 | this.presenter = presenter;
123 | }
124 |
125 | @Override
126 | public void showLoadingIndicator(boolean active) {
127 | if (getView() == null) {
128 | return;
129 | }
130 | progressLoader.setVisibility(active ? View.VISIBLE : View.GONE);
131 | }
132 |
133 | @Override
134 | public void showMedicineList(List medicineAlarmList) {
135 | medicineAdapter.replaceData(medicineAlarmList);
136 | rvMedList.setVisibility(View.VISIBLE);
137 | noMedView.setVisibility(View.GONE);
138 | }
139 |
140 | @Override
141 | public void showAddMedicine() {
142 | Intent intent = new Intent(getContext(), AddMedicineActivity.class);
143 | startActivityForResult(intent, AddMedicineActivity.REQUEST_ADD_TASK);
144 | }
145 |
146 |
147 | @Override
148 | public void showMedicineDetails(long taskId, String medName) {
149 | Intent intent = new Intent(getContext(), AddMedicineActivity.class);
150 | intent.putExtra(AddMedicineActivity.EXTRA_TASK_ID, taskId);
151 | intent.putExtra(AddMedicineActivity.EXTRA_TASK_NAME, medName);
152 | startActivity(intent);
153 | }
154 |
155 |
156 | @Override
157 | public void showLoadingMedicineError() {
158 | showMessage(getString(R.string.loading_tasks_error));
159 | }
160 |
161 | @Override
162 | public void showNoMedicine() {
163 | showNoTasksViews(
164 | getResources().getString(R.string.no_medicine_added)
165 | );
166 | }
167 |
168 | @Override
169 | public void showSuccessfullySavedMessage() {
170 | showMessage(getString(R.string.successfully_saved_me_message));
171 | }
172 |
173 | @Override
174 | public void showMedicineDeletedSuccessfully() {
175 | showMessage(getString(R.string.successfully_deleted_message));
176 | Calendar calendar = Calendar.getInstance();
177 | int day = calendar.get(Calendar.DAY_OF_WEEK);
178 | presenter.onStart(day);
179 | }
180 |
181 | private void showMessage(String message) {
182 | if (getView() != null)
183 | Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).show();
184 | }
185 |
186 | @Override
187 | public boolean isActive() {
188 | return isAdded();
189 | }
190 |
191 | @Override
192 | public void onDestroyView() {
193 | super.onDestroyView();
194 | unbinder.unbind();
195 | }
196 |
197 | @OnClick(R.id.add_med_now)
198 | void addMedicine() {
199 | showAddMedicine();
200 | }
201 |
202 | private void showNoTasksViews(String mainText) {
203 | rvMedList.setVisibility(View.GONE);
204 | noMedView.setVisibility(View.VISIBLE);
205 | noMedText.setText(mainText);
206 | noMedIcon.setImageDrawable(getResources().getDrawable(R.drawable.icon_my_health));
207 | addMedNow.setVisibility(View.VISIBLE);
208 | }
209 |
210 | @Override
211 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
212 | presenter.result(requestCode, resultCode);
213 | }
214 |
215 | @Override
216 | public void onMedicineDeleteClicked(MedicineAlarm medicineAlarm) {
217 | presenter.deleteMedicineAlarm(medicineAlarm, getActivity());
218 | }
219 | }
220 |
221 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gautam/medicinetime/alarm/ReminderFragment.java:
--------------------------------------------------------------------------------
1 | package com.gautam.medicinetime.alarm;
2 |
3 |
4 | import android.content.Intent;
5 | import android.media.MediaPlayer;
6 | import android.os.Bundle;
7 | import android.os.Vibrator;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.LinearLayout;
15 | import android.widget.Toast;
16 |
17 | import com.gautam.medicinetime.R;
18 | import com.gautam.medicinetime.data.source.History;
19 | import com.gautam.medicinetime.data.source.MedicineAlarm;
20 | import com.gautam.medicinetime.medicine.MedicineActivity;
21 | import com.gautam.medicinetime.views.RobotoBoldTextView;
22 | import com.gautam.medicinetime.views.RobotoRegularTextView;
23 |
24 | import java.text.SimpleDateFormat;
25 | import java.util.Calendar;
26 | import java.util.Date;
27 | import java.util.Locale;
28 |
29 | import butterknife.BindView;
30 | import butterknife.ButterKnife;
31 | import butterknife.OnClick;
32 | import butterknife.Unbinder;
33 |
34 | import static android.content.Context.VIBRATOR_SERVICE;
35 |
36 | /**
37 | * Created by gautam on 13/07/17.
38 | */
39 |
40 | public class ReminderFragment extends Fragment implements ReminderContract.View {
41 |
42 | public static final String EXTRA_ID = "extra_id";
43 |
44 | @BindView(R.id.tv_med_time)
45 | RobotoBoldTextView tvMedTime;
46 |
47 | @BindView(R.id.tv_medicine_name)
48 | RobotoBoldTextView tvMedicineName;
49 |
50 | @BindView(R.id.tv_dose_details)
51 | RobotoRegularTextView tvDoseDetails;
52 |
53 | @BindView(R.id.iv_ignore_med)
54 | ImageView ivIgnoreMed;
55 |
56 | @BindView(R.id.iv_take_med)
57 | ImageView ivTakeMed;
58 |
59 | @BindView(R.id.linearLayout)
60 | LinearLayout linearLayout;
61 |
62 | Unbinder unbinder;
63 |
64 | private MedicineAlarm medicineAlarm;
65 |
66 | private long id;
67 |
68 | private MediaPlayer mMediaPlayer;
69 |
70 | private Vibrator mVibrator;
71 |
72 | private ReminderContract.Presenter presenter;
73 |
74 | static ReminderFragment newInstance(long id) {
75 | Bundle args = new Bundle();
76 | args.putLong(EXTRA_ID, id);
77 | ReminderFragment fragment = new ReminderFragment();
78 | fragment.setArguments(args);
79 | return fragment;
80 | }
81 |
82 | @Override
83 | public void onCreate(@Nullable Bundle savedInstanceState) {
84 | super.onCreate(savedInstanceState);
85 | id = getArguments().getLong(EXTRA_ID);
86 | }
87 |
88 | @Nullable
89 | @Override
90 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
91 | View view = inflater.inflate(R.layout.fragment_reminder, container, false);
92 | unbinder = ButterKnife.bind(this, view);
93 | return view;
94 | }
95 |
96 | @Override
97 | public void setPresenter(ReminderContract.Presenter presenter) {
98 | this.presenter = presenter;
99 | }
100 |
101 | @Override
102 | public void showMedicine(MedicineAlarm medicineAlarm) {
103 | this.medicineAlarm = medicineAlarm;
104 | mVibrator = (Vibrator) getContext().getSystemService(VIBRATOR_SERVICE);
105 | long[] pattern = {0, 1000, 10000};
106 | mVibrator.vibrate(pattern, 0);
107 |
108 | mMediaPlayer = MediaPlayer.create(getContext(), R.raw.cuco_sound);
109 | mMediaPlayer.setLooping(true);
110 | mMediaPlayer.start();
111 |
112 | tvMedTime.setText(medicineAlarm.getStringTime());
113 | tvMedicineName.setText(medicineAlarm.getPillName());
114 | tvDoseDetails.setText(medicineAlarm.getFormattedDose());
115 | }
116 |
117 | @Override
118 | public void showNoData() {
119 | //
120 | }
121 |
122 | @Override
123 | public void onResume() {
124 | super.onResume();
125 | presenter.onStart(id);
126 | }
127 |
128 | @OnClick(R.id.iv_take_med)
129 | void onMedTakeClick() {
130 | onMedicineTaken();
131 | stopMedialPlayer();
132 | stopVibrator();
133 | }
134 |
135 | @OnClick(R.id.iv_ignore_med)
136 | void onMedIgnoreClick() {
137 | onMedicineIgnored();
138 | stopMedialPlayer();
139 | stopVibrator();
140 | }
141 |
142 | private void stopMedialPlayer() {
143 | if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
144 | mMediaPlayer.stop();
145 | mMediaPlayer.release();
146 | }
147 | }
148 |
149 | private void stopVibrator() {
150 | if (mVibrator != null) {
151 | mVibrator.cancel();
152 | }
153 | }
154 |
155 | private void onMedicineTaken() {
156 | History history = new History();
157 |
158 | Calendar takeTime = Calendar.getInstance();
159 | Date date = takeTime.getTime();
160 | String dateString = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(date);
161 |
162 | int hour = takeTime.get(Calendar.HOUR_OF_DAY);
163 | int minute = takeTime.get(Calendar.MINUTE);
164 | String am_pm = (hour < 12) ? "am" : "pm";
165 |
166 | history.setHourTaken(hour);
167 | history.setMinuteTaken(minute);
168 | history.setDateString(dateString);
169 | history.setPillName(medicineAlarm.getPillName());
170 | history.setAction(1);
171 | history.setDoseQuantity(medicineAlarm.getDoseQuantity());
172 | history.setDoseUnit(medicineAlarm.getDoseUnit());
173 |
174 | presenter.addPillsToHistory(history);
175 |
176 | String stringMinute;
177 | if (minute < 10)
178 | stringMinute = "0" + minute;
179 | else
180 | stringMinute = "" + minute;
181 |
182 | int nonMilitaryHour = hour % 12;
183 | if (nonMilitaryHour == 0)
184 | nonMilitaryHour = 12;
185 |
186 | Toast.makeText(getContext(), medicineAlarm.getPillName() + " was taken at " + nonMilitaryHour + ":" + stringMinute + " " + am_pm + ".", Toast.LENGTH_SHORT).show();
187 |
188 | Intent returnHistory = new Intent(getContext(), MedicineActivity.class);
189 | startActivity(returnHistory);
190 | getActivity().finish();
191 | }
192 |
193 |
194 | private void onMedicineIgnored() {
195 | History history = new History();
196 |
197 | Calendar takeTime = Calendar.getInstance();
198 | Date date = takeTime.getTime();
199 | String dateString = new SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(date);
200 |
201 | int hour = takeTime.get(Calendar.HOUR_OF_DAY);
202 | int minute = takeTime.get(Calendar.MINUTE);
203 | String am_pm = (hour < 12) ? "am" : "pm";
204 |
205 | history.setHourTaken(hour);
206 | history.setMinuteTaken(minute);
207 | history.setDateString(dateString);
208 | history.setPillName(medicineAlarm.getPillName());
209 | history.setAction(2);
210 | history.setDoseQuantity(medicineAlarm.getDoseQuantity());
211 | history.setDoseUnit(medicineAlarm.getDoseUnit());
212 |
213 | presenter.addPillsToHistory(history);
214 |
215 | String stringMinute;
216 | if (minute < 10)
217 | stringMinute = "0" + minute;
218 | else
219 | stringMinute = "" + minute;
220 |
221 | int nonMilitaryHour = hour % 12;
222 | if (nonMilitaryHour == 0)
223 | nonMilitaryHour = 12;
224 |
225 | Toast.makeText(getContext(), medicineAlarm.getPillName() + " was ignored at " + nonMilitaryHour + ":" + stringMinute + " " + am_pm + ".", Toast.LENGTH_SHORT).show();
226 |
227 | Intent returnHistory = new Intent(getContext(), MedicineActivity.class);
228 | startActivity(returnHistory);
229 | getActivity().finish();
230 | }
231 |
232 |
233 | @Override
234 | public boolean isActive() {
235 | return isAdded();
236 | }
237 |
238 | @Override
239 | public void onFinish() {
240 | stopMedialPlayer();
241 | stopVibrator();
242 | getActivity().finish();
243 | }
244 |
245 | @Override
246 | public void onDestroyView() {
247 | super.onDestroyView();
248 | unbinder.unbind();
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_add_medicine.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
27 |
28 |
34 |
35 |
40 |
41 |
42 |
43 |
44 |
52 |
53 |
57 |
58 |
64 |
65 |
66 |
71 |
72 |
78 |
79 |
89 |
90 |
100 |
101 |
102 |
112 |
113 |
123 |
124 |
134 |
135 |
145 |
146 |
147 |
157 |
158 |
159 |
160 |
161 |
162 |
170 |
171 |
175 |
176 |
182 |
183 |
187 |
188 |
200 |
201 |
212 |
213 |
214 |
222 |
223 |
224 |
225 |
226 |
--------------------------------------------------------------------------------