├── .idea
├── .name
├── .gitignore
├── dictionaries
│ └── Ribas.xml
├── compiler.xml
├── vcs.xml
├── deploymentTargetDropDown.xml
└── gradle.xml
├── app
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── modules.xml
│ ├── misc.xml
│ └── gradle.xml
├── src
│ ├── main
│ │ ├── ic_launcher-playstore.png
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── app_logo.png
│ │ │ │ ├── app_logo_login.png
│ │ │ │ ├── shape_button_color2.xml
│ │ │ │ ├── shape_button_color1.xml
│ │ │ │ ├── ic_home.xml
│ │ │ │ ├── ic_add_task.xml
│ │ │ │ ├── ic_check.xml
│ │ │ │ ├── ic_check_.xml
│ │ │ │ ├── ic_import.xml
│ │ │ │ ├── custom_default_input.xml
│ │ │ │ ├── ic_add.xml
│ │ │ │ ├── ic_close.xml
│ │ │ │ ├── custom_shape_list_clicked.xml
│ │ │ │ ├── custom_shape_list_default.xml
│ │ │ │ ├── custom_input_login.xml
│ │ │ │ ├── custom_invalid_input.xml
│ │ │ │ ├── gradient_background.xml
│ │ │ │ ├── custom_secundary_default_input.xml
│ │ │ │ ├── ic_costumer.xml
│ │ │ │ ├── ic_add_event.xml
│ │ │ │ ├── ic_calendar.xml
│ │ │ │ ├── ic_profile.xml
│ │ │ │ ├── ic_assignment.xml
│ │ │ │ └── ic_spending.xml
│ │ │ ├── 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
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ ├── delete_menu.xml
│ │ │ │ ├── update_delete_menu.xml
│ │ │ │ └── bottom_nav_menu.xml
│ │ │ ├── anim
│ │ │ │ ├── rotate_close_anim.xml
│ │ │ │ ├── rotate_open_anim.xml
│ │ │ │ ├── from_bottom_center_anim.xml
│ │ │ │ ├── from_bottom_left_anim.xml
│ │ │ │ ├── from_bottom_right_anim.xml
│ │ │ │ ├── to_bottom_center_anim.xml
│ │ │ │ ├── to_bottom_left_anim.xml
│ │ │ │ └── to_bottom_right_anim.xml
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── custom_secundary_invalid_input.xml
│ │ │ └── layout
│ │ │ │ ├── activity_splash.xml
│ │ │ │ ├── dialog_calendar.xml
│ │ │ │ ├── item_job_and_client.xml
│ │ │ │ ├── item_category.xml
│ │ │ │ ├── fragment_report_daily.xml
│ │ │ │ ├── custom_loading_dialog.xml
│ │ │ │ ├── item_days_week_button.xml
│ │ │ │ ├── fragment_report_period.xml
│ │ │ │ ├── fragment_report_monthly.xml
│ │ │ │ ├── item_new_expense.xml
│ │ │ │ ├── fragment_new_category.xml
│ │ │ │ ├── fragment_job_list.xml
│ │ │ │ ├── custom_loading_buttom.xml
│ │ │ │ ├── fragment_list_event.xml
│ │ │ │ ├── item_report.xml
│ │ │ │ ├── fragment_list_client.xml
│ │ │ │ └── fragment_new_client.xml
│ │ ├── java
│ │ │ └── br
│ │ │ │ └── com
│ │ │ │ └── beautystyle
│ │ │ │ ├── repository
│ │ │ │ ├── ResultsCallBack.java
│ │ │ │ ├── ConstantsRepository.java
│ │ │ │ ├── Resource.java
│ │ │ │ ├── OpeningHoursRepository.java
│ │ │ │ └── UserRepository.java
│ │ │ │ ├── ui
│ │ │ │ ├── adapter
│ │ │ │ │ ├── ConstantsAdapter.java
│ │ │ │ │ └── recyclerview
│ │ │ │ │ │ └── listener
│ │ │ │ │ │ └── AdapterListener.java
│ │ │ │ ├── activity
│ │ │ │ │ └── ContantsActivity.java
│ │ │ │ ├── ProgressBottom.java
│ │ │ │ ├── ListDaysView.java
│ │ │ │ └── fragment
│ │ │ │ │ ├── ConstantFragment.java
│ │ │ │ │ ├── TimePickerFragment.java
│ │ │ │ │ ├── CalendarViewFragment.java
│ │ │ │ │ ├── ProfileFragment.java
│ │ │ │ │ └── report
│ │ │ │ │ └── DailyReportFragment.java
│ │ │ │ ├── util
│ │ │ │ ├── SortByJobName.java
│ │ │ │ ├── ConstantsUtil.java
│ │ │ │ ├── SortByClientName.java
│ │ │ │ ├── SortByEventStartTime.java
│ │ │ │ ├── TimeUtil.java
│ │ │ │ ├── CoinUtil.java
│ │ │ │ ├── CalendarUtil.java
│ │ │ │ ├── MoneyTextWatcher.java
│ │ │ │ └── CreateListsUtil.java
│ │ │ │ ├── retrofit
│ │ │ │ ├── NoConnectivityException.java
│ │ │ │ ├── service
│ │ │ │ │ ├── UserService.java
│ │ │ │ │ ├── BlockTimeService.java
│ │ │ │ │ ├── JobService.java
│ │ │ │ │ ├── CategoryService.java
│ │ │ │ │ ├── CostumerService.java
│ │ │ │ │ ├── ReportService.java
│ │ │ │ │ ├── EventService.java
│ │ │ │ │ └── ExpenseService.java
│ │ │ │ ├── callback
│ │ │ │ │ ├── CallbackMessages.java
│ │ │ │ │ ├── CallBackWithoutReturn.java
│ │ │ │ │ └── CallBackReturn.java
│ │ │ │ ├── model
│ │ │ │ │ ├── form
│ │ │ │ │ │ ├── UserLoginForm.java
│ │ │ │ │ │ └── EventForm.java
│ │ │ │ │ └── dto
│ │ │ │ │ │ ├── EventTimeNotAvailableDto.java
│ │ │ │ │ │ ├── EventWithClientAndJobsDto.java
│ │ │ │ │ │ └── UserDto.java
│ │ │ │ ├── webclient
│ │ │ │ │ ├── UserWebClient.java
│ │ │ │ │ ├── BlockTimeWebClient.java
│ │ │ │ │ └── ReportWebClient.java
│ │ │ │ └── NetworkConnectionInterceptor.java
│ │ │ │ ├── BeautyStyleApplication.java
│ │ │ │ ├── database
│ │ │ │ ├── converters
│ │ │ │ │ ├── LocalDateConverter.java
│ │ │ │ │ ├── BigDecimalConverter.java
│ │ │ │ │ └── LocalTimeConverter.java
│ │ │ │ ├── dao
│ │ │ │ │ ├── RoomEventWithJobsDao.java
│ │ │ │ │ ├── RoomUserDao.java
│ │ │ │ │ ├── RoomOpeningHoursDao.java
│ │ │ │ │ ├── RoomBlockTimeDao.java
│ │ │ │ │ ├── RoomJobDao.java
│ │ │ │ │ ├── RoomCustomerDao.java
│ │ │ │ │ ├── RoomCategoryDao.java
│ │ │ │ │ ├── RoomExpenseDao.java
│ │ │ │ │ └── RoomEventDao.java
│ │ │ │ ├── DatabaseModule.java
│ │ │ │ ├── rxjava
│ │ │ │ │ ├── OpeningHoursRxJava.java
│ │ │ │ │ ├── BlockTimeRxJava.java
│ │ │ │ │ ├── CategoryRxJava.java
│ │ │ │ │ ├── JobRxJava.java
│ │ │ │ │ ├── CostumerRxJava.java
│ │ │ │ │ ├── ExpenseRxJava.java
│ │ │ │ │ └── EventRxJava.java
│ │ │ │ ├── BeautyStyleDatabase.java
│ │ │ │ └── references
│ │ │ │ │ └── EventWithClientAndJobs.java
│ │ │ │ ├── BeautyStyleModule.java
│ │ │ │ ├── ViewModel
│ │ │ │ ├── JobViewModel.java
│ │ │ │ ├── CategoryViewModel.java
│ │ │ │ ├── factory
│ │ │ │ │ ├── JobFactory.java
│ │ │ │ │ ├── UserFactory.java
│ │ │ │ │ ├── EventFactory.java
│ │ │ │ │ ├── ReportFactory.java
│ │ │ │ │ ├── ExpenseFactory.java
│ │ │ │ │ ├── CategoryFactory.java
│ │ │ │ │ ├── CostumerFactory.java
│ │ │ │ │ └── BlockTimeFactory.java
│ │ │ │ ├── CostumerViewModel.java
│ │ │ │ ├── UserViewModel.java
│ │ │ │ ├── BlockTimeViewModel.java
│ │ │ │ ├── ExpenseViewModel.java
│ │ │ │ └── EventViewModel.java
│ │ │ │ ├── model
│ │ │ │ ├── entity
│ │ │ │ │ ├── TypeOfReport.java
│ │ │ │ │ ├── EventJobCrossRef.java
│ │ │ │ │ ├── User.java
│ │ │ │ │ ├── Category.java
│ │ │ │ │ ├── OpeningHours.java
│ │ │ │ │ ├── BlockTime.java
│ │ │ │ │ ├── Expense.java
│ │ │ │ │ └── Job.java
│ │ │ │ └── util
│ │ │ │ │ └── Report.java
│ │ │ │ └── ApplicationComponent.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── br
│ │ │ └── com
│ │ │ └── beautystyle
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── br
│ │ └── com
│ │ └── beautystyle
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── sampledata
│ └── beautystyle.json
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
├── gradle.properties
└── gradlew.bat
/.idea/.name:
--------------------------------------------------------------------------------
1 | Beauty Style
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/dictionaries/Ribas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/drawable/app_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_logo_login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/drawable/app_logo_login.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/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/RibeiroRibas/app-android-agendamento/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/RibeiroRibas/app-android-agendamento/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/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/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/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F2D8E3
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/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/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RibeiroRibas/app-android-agendamento/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/repository/ResultsCallBack.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.repository;
2 |
3 | public interface ResultsCallBack {
4 |
5 | void onSuccess(T result);
6 | void onError(String error);
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/adapter/ConstantsAdapter.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.adapter;
2 |
3 | public interface ConstantsAdapter {
4 | String ITEM_MENU_REMOVE = "Excluir";
5 | String ITEM_MENU_UPDATE = "Editar";
6 | String BLOCK_TIME = "HORÁRIO BLOQUEADO";
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button_color2.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button_color1.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
--------------------------------------------------------------------------------
/app/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/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/menu/delete_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/update_delete_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_task.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate_close_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate_open_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3 | repositories {
4 | google()
5 | mavenCentral()
6 | maven { url 'https://jitpack.io' }
7 | jcenter() // Warning: this repository is going to shut down soon
8 | }
9 | }
10 | rootProject.name = "Beauty Style"
11 | include ':app'
12 |
--------------------------------------------------------------------------------
/app/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_import.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/SortByJobName.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import java.util.Comparator;
4 |
5 | import br.com.beautystyle.model.entity.Job;
6 |
7 | public class SortByJobName implements Comparator {
8 | @Override
9 | public int compare(Job o1, Job o2) {
10 | return o1.getName().compareToIgnoreCase(o2.getName());
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_default_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/ConstantsUtil.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | public interface ConstantsUtil {
4 | String DD_MM_YYYY = "dd/MM/yyyy";
5 | String MMMM = "MMMM";
6 | String MMMM_YYYY = "MMMM / yyyy";
7 | String YYYY = "yyyy";
8 | String DD = "dd";
9 | String E = "E";
10 | String DESIRED_FORMAT = "R$ ";
11 | String REMOVE_SYMBOL = "";
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/NoConnectivityException.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit;
2 |
3 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.NO_INTERNET_CONNECTION;
4 |
5 | import java.io.IOException;
6 |
7 | public class NoConnectivityException extends IOException {
8 |
9 | @Override
10 | public String getMessage() {
11 | return NO_INTERNET_CONNECTION;
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/SortByClientName.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import java.util.Comparator;
4 |
5 | import br.com.beautystyle.model.entity.Customer;
6 |
7 | public class SortByClientName implements Comparator {
8 |
9 | @Override
10 | public int compare(Customer o1, Customer o2) {
11 | return o1.getName().compareToIgnoreCase(o2.getName());
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_shape_list_clicked.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/BeautyStyleApplication.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle;
2 |
3 | import android.app.Application;
4 |
5 | public class BeautyStyleApplication extends Application {
6 |
7 | public ApplicationComponent applicationComponent;
8 |
9 | @Override
10 | public void onCreate() {
11 | super.onCreate();
12 | applicationComponent = DaggerApplicationComponent.factory().create(this);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_shape_list_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/UserService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import br.com.beautystyle.retrofit.model.dto.UserDto;
4 | import br.com.beautystyle.retrofit.model.form.UserLoginForm;
5 | import retrofit2.Call;
6 | import retrofit2.http.Body;
7 | import retrofit2.http.POST;
8 |
9 | public interface UserService {
10 |
11 | @POST("auth")
12 | Call auth(@Body UserLoginForm login);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_input_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_invalid_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gradient_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_secundary_default_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/custom_secundary_invalid_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_costumer.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/activity/ContantsActivity.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.activity;
2 |
3 | public interface ContantsActivity {
4 |
5 | int REQUEST_CODE_INSERT_EVENT = 1;
6 | int REQUEST_CODE_UPDATE_EVENT = 2;
7 | int REQUEST_CODE_UPDATE_EXPENSE = 3;
8 | int REQUEST_CODE_INSERT_EXPENSE = 4;
9 | int INVALID_POSITION = -1;
10 | String KEY_CLICK_FAB_NAVIGATION = "fabNavigation";
11 | String TAG_EVENT_DURATION = "eventDuration";
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/test/java/br/com/beautystyle/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/callback/CallbackMessages.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.callback;
2 |
3 | public interface CallbackMessages {
4 |
5 | String MESSAGE_ERROR = "Ocorreu um erro";
6 | String NO_INTERNET_CONNECTION = "Internet Indisponível";
7 | String MESSAGE_SERVER_ERROR = "Erro no Servidor";
8 | String BAD_CREDENTIALS = "Email ou Senha Inválidos";
9 | String DURATION_TIME_IS_NOT_AVAILABLE = "Tempo de duração excede o tempo disponível na agenda!";
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/SortByEventStartTime.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import java.util.Comparator;
4 |
5 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
6 |
7 |
8 | public class SortByEventStartTime implements Comparator {
9 |
10 | @Override
11 | public int compare(EventWithClientAndJobs o1, EventWithClientAndJobs o2) {
12 | return o1.getEvent().getStartTime().compareTo(o2.getEvent().getStartTime());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_event.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_calendar.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_profile.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/converters/LocalDateConverter.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.converters;
2 |
3 | import androidx.room.TypeConverter;
4 |
5 | import java.time.LocalDate;
6 |
7 | public class LocalDateConverter {
8 |
9 | @TypeConverter
10 | public static LocalDate fromLong(Long date) {
11 | return date == null ? null : LocalDate.ofEpochDay(date);
12 | }
13 |
14 | @TypeConverter
15 | public static Long fromLocalDate(LocalDate date) {
16 | return date == null ? null : date.toEpochDay();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jul 08 15:40:25 BRT 2022
2 | =
3 |
4 | =
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
6 |
7 |
8 | =
9 | =
10 | =
11 | =
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/ProgressBottom.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui;
2 |
3 | import android.view.View;
4 | import android.widget.ProgressBar;
5 |
6 | public class ProgressBottom {
7 |
8 | private final View progressbar;
9 |
10 | public ProgressBottom(ProgressBar progressBar) {
11 | progressbar = progressBar;
12 | }
13 |
14 | public void buttonActivated() {
15 | progressbar.setVisibility(View.VISIBLE);
16 | }
17 |
18 | public void buttonFinished() {
19 | progressbar.setVisibility(View.GONE);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/repository/ConstantsRepository.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.repository;
2 |
3 | public interface ConstantsRepository {
4 |
5 | String TOKEN_SHARED_PREFERENCES = "token";
6 | String TENANT_SHARED_PREFERENCES = "companyId";
7 | String PROFILE_SHARED_PREFERENCES = "profile";
8 | String EMAIL_SHARED_PREFERENCES = "email";
9 | String IS_LOGGED_SHARED_PREFERENCES = "isLogged";
10 | String USER_SHARED_PREFERENCES = "user_preferences";
11 | String USER_PREMIUM = "ROLE_PREMIUM_ACCOUNT";
12 | String FREE_ACCOUNT = "ROLE_FREE_ACCOUNT";
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/from_bottom_center_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
15 |
16 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/from_bottom_left_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
15 |
16 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/from_bottom_right_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
15 |
16 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_assignment.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/BeautyStyleModule.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle;
2 |
3 | import static br.com.beautystyle.repository.ConstantsRepository.USER_SHARED_PREFERENCES;
4 |
5 | import android.content.Context;
6 | import android.content.SharedPreferences;
7 |
8 | import javax.inject.Singleton;
9 |
10 | import dagger.Module;
11 | import dagger.Provides;
12 |
13 | @Module
14 | public class BeautyStyleModule {
15 |
16 | @Singleton
17 | @Provides
18 | public SharedPreferences providesSharedPreferences( Context context){
19 | return context.getSharedPreferences(USER_SHARED_PREFERENCES,Context.MODE_PRIVATE);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/to_bottom_center_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
17 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/to_bottom_left_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
17 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/to_bottom_right_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
17 |
18 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_spending.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/JobViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.ViewModel;
5 |
6 | import java.util.List;
7 |
8 | import br.com.beautystyle.model.entity.Job;
9 | import br.com.beautystyle.repository.JobRepository;
10 | import br.com.beautystyle.repository.Resource;
11 |
12 | public class JobViewModel extends ViewModel {
13 |
14 | private final JobRepository repository;
15 |
16 | public JobViewModel(JobRepository repository) {
17 | this.repository = repository;
18 | }
19 |
20 | public LiveData>> getAllLiveData() {
21 | return repository.getAllLiveData();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/converters/BigDecimalConverter.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.converters;
2 |
3 | import androidx.room.TypeConverter;
4 |
5 | import java.math.BigDecimal;
6 | import java.math.RoundingMode;
7 |
8 | public class BigDecimalConverter {
9 |
10 | @TypeConverter
11 | public static BigDecimal fromLong(Long value) {
12 | return value == null ? null : new BigDecimal(value)
13 | .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
14 | }
15 |
16 | @TypeConverter
17 | public static Long fromBigDecimal(BigDecimal value) {
18 | return value == null ? null : value.multiply(new BigDecimal(100))
19 | .longValueExact();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomEventWithJobsDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Insert;
5 | import androidx.room.OnConflictStrategy;
6 | import androidx.room.Query;
7 |
8 | import java.util.List;
9 |
10 | import br.com.beautystyle.model.entity.EventJobCrossRef;
11 | import io.reactivex.rxjava3.core.Completable;
12 |
13 | @Dao
14 | public interface RoomEventWithJobsDao {
15 |
16 | @Insert(onConflict = OnConflictStrategy.REPLACE)
17 | Completable insert(List eventJobCrossRef);
18 |
19 | @Query("DELETE FROM EventJobCrossRef WHERE eventId IN (:eventIds)")
20 | Completable deleteAllByIds(Long[] eventIds);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/DatabaseModule.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database;
2 |
3 | import static br.com.beautystyle.database.DatabaseMigrations.ALL_MIGRATIONS;
4 |
5 | import android.content.Context;
6 |
7 | import androidx.room.Room;
8 |
9 | import javax.inject.Singleton;
10 |
11 | import dagger.Module;
12 | import dagger.Provides;
13 |
14 | @Module
15 | public class DatabaseModule {
16 |
17 | @Singleton
18 | @Provides
19 | public BeautyStyleDatabase providesLocalDataBase(Context context){
20 | return Room
21 | .databaseBuilder(context, BeautyStyleDatabase.class, "beautyStyle.db")
22 | .addMigrations(ALL_MIGRATIONS)
23 | .build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF37BC
4 | #FEE2F5
5 | #FF000000
6 | #FFFFFFFF
7 | #FF3700B3
8 | #F5F5F5
9 | #FFFF00
10 | #FF0000
11 | #228C22
12 | #808080
13 | #d8d9d8
14 | @color/pink
15 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomUserDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Insert;
5 | import androidx.room.OnConflictStrategy;
6 | import androidx.room.Query;
7 | import androidx.room.Update;
8 |
9 | import br.com.beautystyle.model.entity.User;
10 | import io.reactivex.rxjava3.core.Completable;
11 | import io.reactivex.rxjava3.core.Single;
12 |
13 | @Dao
14 | public interface RoomUserDao {
15 |
16 |
17 | @Insert(onConflict = OnConflictStrategy.REPLACE)
18 | Completable insert(User user);
19 |
20 | @Update
21 | Completable update(User user);
22 |
23 | @Query("SELECT * FROM user u WHERE u.email =:email")
24 | Single getByEmail(String email);
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/CategoryViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.ViewModel;
5 |
6 | import java.util.List;
7 |
8 | import br.com.beautystyle.model.entity.Category;
9 | import br.com.beautystyle.repository.CategoryRepository;
10 | import br.com.beautystyle.repository.Resource;
11 |
12 | public class CategoryViewModel extends ViewModel {
13 |
14 | private final CategoryRepository repository;
15 |
16 | public CategoryViewModel(CategoryRepository repository) {
17 | this.repository = repository;
18 | }
19 |
20 | public LiveData>> getAllLiveData() {
21 | return repository.getAllLiveData();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomOpeningHoursDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Insert;
5 | import androidx.room.OnConflictStrategy;
6 | import androidx.room.Query;
7 |
8 | import java.util.List;
9 |
10 | import br.com.beautystyle.model.entity.OpeningHours;
11 | import io.reactivex.rxjava3.core.Completable;
12 | import io.reactivex.rxjava3.core.Single;
13 |
14 | @Dao
15 | public interface RoomOpeningHoursDao {
16 |
17 | @Query("SELECT * FROM OpeningHours WHERE tenant= :tenant")
18 | Single> getAll(Long tenant);
19 |
20 | @Insert(onConflict = OnConflictStrategy.REPLACE)
21 | Completable insertAll(List openingHours);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/converters/LocalTimeConverter.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.converters;
2 |
3 | import androidx.room.TypeConverter;
4 |
5 | import java.time.LocalTime;
6 | import java.time.format.DateTimeFormatter;
7 |
8 | public class LocalTimeConverter {
9 |
10 | @TypeConverter
11 | public static LocalTime fromString(String time) {
12 | DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("H:mm");
13 | return LocalTime.parse(time, timeFormatter);
14 | }
15 |
16 | @TypeConverter
17 | public static String fromLocalTime(LocalTime time) {
18 | DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("H:mm");
19 | return time == null ? null : time.format(timeFormatter);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/TypeOfReport.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import java.util.List;
4 | import java.util.stream.Collectors;
5 | import java.util.stream.Stream;
6 |
7 | public enum TypeOfReport {
8 |
9 | MONTHLY("Mensal"), DAILY("Diário"), BYPERIOD("Por período");
10 |
11 | private final String description;
12 |
13 | TypeOfReport(String description) {
14 | this.description = description;
15 | }
16 |
17 | public String getDescription() {
18 | return description;
19 | }
20 |
21 | public static List getTypeOfReportList() {
22 | return Stream.of(values())
23 | .map(TypeOfReport::getDescription)
24 | .collect(Collectors.toList());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/JobFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.JobViewModel;
8 | import br.com.beautystyle.repository.JobRepository;
9 |
10 | public class JobFactory implements ViewModelProvider.Factory {
11 |
12 | private final JobRepository repository;
13 |
14 | public JobFactory(JobRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new JobViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/UserFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.UserViewModel;
8 | import br.com.beautystyle.repository.UserRepository;
9 |
10 | public class UserFactory implements ViewModelProvider.Factory {
11 |
12 | private final UserRepository repository;
13 |
14 | public UserFactory(UserRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new UserViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/EventFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.EventViewModel;
8 | import br.com.beautystyle.repository.EventRepository;
9 |
10 | public class EventFactory implements ViewModelProvider.Factory {
11 |
12 | private final EventRepository repository;
13 |
14 | public EventFactory(EventRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new EventViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/ReportFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.ReportViewModel;
8 | import br.com.beautystyle.repository.ReportRepository;
9 |
10 | public class ReportFactory implements ViewModelProvider.Factory {
11 |
12 | private final ReportRepository repository;
13 |
14 | public ReportFactory(ReportRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new ReportViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/ExpenseFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.ExpenseViewModel;
8 | import br.com.beautystyle.repository.ExpenseRepository;
9 |
10 | public class ExpenseFactory implements ViewModelProvider.Factory {
11 |
12 | private final ExpenseRepository repository;
13 |
14 | public ExpenseFactory(ExpenseRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new ExpenseViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/CategoryFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.CategoryViewModel;
8 | import br.com.beautystyle.repository.CategoryRepository;
9 |
10 | public class CategoryFactory implements ViewModelProvider.Factory {
11 |
12 | private final CategoryRepository repository;
13 |
14 | public CategoryFactory(CategoryRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new CategoryViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/BlockTimeService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import br.com.beautystyle.model.entity.BlockTime;
4 | import retrofit2.Call;
5 | import retrofit2.http.Body;
6 | import retrofit2.http.DELETE;
7 | import retrofit2.http.Header;
8 | import retrofit2.http.POST;
9 | import retrofit2.http.PUT;
10 | import retrofit2.http.Path;
11 |
12 | public interface BlockTimeService {
13 |
14 | @POST("block_time")
15 | Call insert(@Body BlockTime blockTime, @Header("Authorization") String token);
16 |
17 | @PUT("block_time/{id}")
18 | Call update(@Path("id") Long id, @Body BlockTime blockTime, @Header("Authorization") String token);
19 |
20 | @DELETE("block_time/{id}")
21 | Call delete(@Path("id") Long id, @Header("Authorization") String token);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/CostumerFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.CostumerViewModel;
8 | import br.com.beautystyle.repository.ClientRepository;
9 |
10 | public class CostumerFactory implements ViewModelProvider.Factory {
11 |
12 | private final ClientRepository repository;
13 |
14 | public CostumerFactory(ClientRepository clientRepository) {
15 | this.repository = clientRepository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new CostumerViewModel(repository);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/factory/BlockTimeFactory.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel.factory;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.lifecycle.ViewModel;
5 | import androidx.lifecycle.ViewModelProvider;
6 |
7 | import br.com.beautystyle.ViewModel.BlockTimeViewModel;
8 | import br.com.beautystyle.repository.BlockTimeRepository;
9 |
10 | public class BlockTimeFactory implements ViewModelProvider.Factory {
11 |
12 | private final BlockTimeRepository repository;
13 |
14 | public BlockTimeFactory(BlockTimeRepository repository) {
15 | this.repository = repository;
16 | }
17 |
18 | @SuppressWarnings("unchecked")
19 | @NonNull
20 | @Override
21 | public T create(@NonNull Class aClass) {
22 | return (T) new BlockTimeViewModel(repository);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/sampledata/beautystyle.json:
--------------------------------------------------------------------------------
1 | {
2 | "beautystyle": [
3 | {
4 | "Client": "Grace Hopper",
5 | "Hour" : "7:00 - 8:00",
6 | "Service": "Pintar a unha da mão \n \n Pintar a Unha do pé ",
7 | "Price" : "R$30,00 \n \n R$30,00",
8 | "Date": "29/10/2021"
9 | },
10 | {
11 | "Client": "Ada Lovelace",
12 | "Hour" : "8:00 - 9:30",
13 | "Service": "Alongamento",
14 | "Price" : "R$120,00",
15 | "Date": "29/10/2021"
16 | },
17 | {
18 | "Client": "Joana Dark",
19 | "Hour" : "9:30 10:00",
20 | "Service": "Pintar a unha da mão",
21 | "Price" : "R$30,00",
22 | "Date": "29/10/2021"
23 | },
24 | {
25 | "Client": "Maria do relento",
26 | "Hour" : "10:00 - 12:00",
27 | "Service": "Manutenção",
28 | "Price" : "R$150,00",
29 | "Date": "29/10/2021"
30 | }
31 | ]
32 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/br/com/beautystyle/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.example.beautystyle", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/model/form/UserLoginForm.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.model.form;
2 |
3 | import br.com.beautystyle.model.entity.User;
4 |
5 | public class UserLoginForm {
6 |
7 | private String email;
8 | private String password;
9 |
10 | public UserLoginForm(String email, String password) {
11 | this.email = email;
12 | this.password = password;
13 | }
14 |
15 | public UserLoginForm(User user) {
16 | this.email = user.getEmail();
17 | this.password = user.getPassword();
18 | }
19 |
20 | public String getEmail() {
21 | return email;
22 | }
23 |
24 | public void setEmail(String email) {
25 | this.email = email;
26 | }
27 |
28 | public String getPassword() {
29 | return password;
30 | }
31 |
32 | public void setPassword(String password) {
33 | this.password = password;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/JobService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.util.List;
4 |
5 | import br.com.beautystyle.model.entity.Job;
6 | import retrofit2.Call;
7 | import retrofit2.http.Body;
8 | import retrofit2.http.DELETE;
9 | import retrofit2.http.GET;
10 | import retrofit2.http.Header;
11 | import retrofit2.http.POST;
12 | import retrofit2.http.PUT;
13 | import retrofit2.http.Path;
14 |
15 | public interface JobService {
16 |
17 | @GET("job")
18 | Call> getAll(@Header("Authorization") String token);
19 |
20 | @POST("job")
21 | Call insert(@Body Job job, @Header("Authorization") String token);
22 |
23 | @PUT("job/{id}")
24 | Call update(@Path("id") Long id,@Body Job job, @Header("Authorization") String token);
25 |
26 | @DELETE("job/{id}")
27 | Call delete(@Path("id") Long id, @Header("Authorization") String token);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_job_and_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/CostumerViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.lifecycle.LiveData;
6 | import androidx.lifecycle.ViewModel;
7 |
8 | import java.util.List;
9 |
10 | import br.com.beautystyle.model.entity.Customer;
11 | import br.com.beautystyle.repository.ClientRepository;
12 | import br.com.beautystyle.repository.Resource;
13 |
14 | public class CostumerViewModel extends ViewModel {
15 |
16 | private final ClientRepository repository;
17 |
18 |
19 | public CostumerViewModel(ClientRepository repository) {
20 | this.repository = repository;
21 | }
22 |
23 | public LiveData>> getAllLiveData() {
24 | return repository.getAllLiveData();
25 | }
26 |
27 | public LiveData> getContactListFromSmartphone(Context context) {
28 | return repository.getContactListFromSmartphone(context);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/UserViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.ViewModel;
5 |
6 | import br.com.beautystyle.retrofit.model.form.UserLoginForm;
7 | import br.com.beautystyle.retrofit.model.dto.UserDto;
8 | import br.com.beautystyle.model.entity.User;
9 | import br.com.beautystyle.repository.Resource;
10 | import br.com.beautystyle.repository.UserRepository;
11 |
12 | public class UserViewModel extends ViewModel {
13 |
14 | private final UserRepository repository;
15 |
16 | public UserViewModel(UserRepository repository) {
17 | this.repository = repository;
18 | }
19 |
20 | public LiveData> getByEmail(String email) {
21 | return repository.getByEmail(email);
22 | }
23 |
24 | public LiveData> authUser(UserLoginForm userLoginForm) {
25 | return repository.authUser(userLoginForm);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/CategoryService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.util.List;
4 |
5 | import br.com.beautystyle.model.entity.Category;
6 | import retrofit2.Call;
7 | import retrofit2.http.Body;
8 | import retrofit2.http.DELETE;
9 | import retrofit2.http.GET;
10 | import retrofit2.http.Header;
11 | import retrofit2.http.POST;
12 | import retrofit2.http.PUT;
13 | import retrofit2.http.Path;
14 |
15 | public interface CategoryService {
16 |
17 | @GET("category")
18 | Call> getAll(@Header("Authorization") String token);
19 |
20 | @POST("category")
21 | Call insert(@Body Category category, @Header("Authorization") String token);
22 |
23 | @PUT("category/{id}")
24 | Call update(@Path("id") Long id, @Body Category category, @Header("Authorization") String token);
25 |
26 | @DELETE("category/{id}")
27 | Call delete(@Path("id") Long id, @Header("Authorization") String token);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomBlockTimeDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.OnConflictStrategy;
7 | import androidx.room.Query;
8 | import androidx.room.Update;
9 |
10 | import java.time.LocalDate;
11 | import java.util.List;
12 |
13 | import br.com.beautystyle.model.entity.BlockTime;
14 | import io.reactivex.rxjava3.core.Completable;
15 | import io.reactivex.rxjava3.core.Single;
16 |
17 | @Dao
18 | public interface RoomBlockTimeDao {
19 |
20 | @Query("SELECT * FROM BlockTime WHERE tenant=:tenant AND date=:date ")
21 | Single> getAll(Long tenant, LocalDate date);
22 |
23 | @Insert(onConflict = OnConflictStrategy.REPLACE)
24 | Single> insertAll(List blockTimes);
25 |
26 | @Delete
27 | Completable delete(BlockTime blockTimes);
28 |
29 | @Update
30 | Completable update(BlockTime category);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/model/dto/EventTimeNotAvailableDto.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.model.dto;
2 |
3 | import java.time.LocalTime;
4 |
5 | public class EventTimeNotAvailableDto {
6 |
7 | private String statusCode;
8 | private String message;
9 | private LocalTime data;
10 |
11 | public EventTimeNotAvailableDto() {
12 | }
13 |
14 | public EventTimeNotAvailableDto(String error) {
15 | this.message = error;
16 | }
17 |
18 | public String getStatusCode() {
19 | return statusCode;
20 | }
21 |
22 | public void setStatusCode(String statusCode) {
23 | this.statusCode = statusCode;
24 | }
25 |
26 | public String getMessage() {
27 | return message;
28 | }
29 |
30 | public void setMessage(String message) {
31 | this.message = message;
32 | }
33 |
34 | public LocalTime getData() {
35 | return data;
36 | }
37 |
38 | public void setData(LocalTime endTime) {
39 | this.data = endTime;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/BlockTimeViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.ViewModel;
5 |
6 | import br.com.beautystyle.model.entity.BlockTime;
7 | import br.com.beautystyle.repository.BlockTimeRepository;
8 | import br.com.beautystyle.repository.Resource;
9 |
10 | public class BlockTimeViewModel extends ViewModel {
11 |
12 | private final BlockTimeRepository blockTimeRepository;
13 |
14 | public BlockTimeViewModel(BlockTimeRepository blockTimeRepository) {
15 | this.blockTimeRepository = blockTimeRepository;
16 | }
17 |
18 | public LiveData> insert(BlockTime blockTime) {
19 | return blockTimeRepository.insert(blockTime);
20 | }
21 |
22 | public LiveData> delete(BlockTime blockTime) {
23 | return blockTimeRepository.delete(blockTime);
24 | }
25 |
26 | public LiveData> update(BlockTime blockTime) {
27 | return blockTimeRepository.update(blockTime);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/repository/Resource.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.repository;
2 |
3 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.DURATION_TIME_IS_NOT_AVAILABLE;
4 |
5 | public class Resource {
6 | private T data;
7 | private String error;
8 |
9 | public Resource(T data, String error) {
10 | this.data = data;
11 | this.error = error;
12 | }
13 |
14 |
15 | public T getData() {
16 | return data;
17 | }
18 |
19 | public void setData(T data) {
20 | this.data = data;
21 | }
22 |
23 | public String getError() {
24 | return error;
25 | }
26 |
27 | public void setError(String error) {
28 | this.error = error;
29 | }
30 |
31 | public boolean isDataNotNull() {
32 | return this.data!=null;
33 | }
34 |
35 | public boolean isErrorNotNull() {
36 | return this.error!=null;
37 | }
38 |
39 | public boolean isDurationTimeNotAvailable() {
40 | return error.contains(DURATION_TIME_IS_NOT_AVAILABLE);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomJobDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.Query;
7 | import androidx.room.Update;
8 |
9 | import java.util.List;
10 |
11 | import br.com.beautystyle.model.entity.Job;
12 | import io.reactivex.rxjava3.core.Completable;
13 | import io.reactivex.rxjava3.core.Observable;
14 | import io.reactivex.rxjava3.core.Single;
15 |
16 | @Dao
17 | public interface RoomJobDao {
18 |
19 | @Query("SELECT * FROM Job WHERE tenant= :tenant")
20 | Single> getAll(Long tenant);
21 |
22 | @Update
23 | Completable update(Job service);
24 |
25 | @Delete
26 | Completable delete(Job service);
27 |
28 | @Insert
29 | Single> insertAll(List response);
30 |
31 | @Update
32 | Completable updateAll(List updateJobs);
33 |
34 | @Query("SELECT * FROM Job WHERE tenant= :tenant")
35 | Observable> getAllLiveData(Long tenant);
36 |
37 | @Insert
38 | Completable insert(Job job);
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/TimeUtil.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import java.time.LocalTime;
4 | import java.time.format.DateTimeFormatter;
5 | import java.util.List;
6 |
7 | public class TimeUtil {
8 |
9 | private static DateTimeFormatter timeFormatter;
10 |
11 | public static String formatLocalTime(LocalTime time) {
12 | timeFormatter = DateTimeFormatter.ofPattern("H:mm");
13 | return time.format(timeFormatter);
14 | }
15 |
16 | public static LocalTime sumTimeOfJobs(List listTimeService) {
17 | LocalTime timeOfDuration = LocalTime.of(0, 0, 0);
18 | for (LocalTime timeOfService : listTimeService) {
19 | timeOfDuration = timeOfDuration.plusHours(timeOfService.getHour());
20 | timeOfDuration = timeOfDuration.plusMinutes(timeOfService.getMinute());
21 | }
22 | return timeOfDuration;
23 | }
24 |
25 | public static LocalTime formatDurationService(String duration) {
26 | timeFormatter = DateTimeFormatter.ofPattern("H:mm");
27 | return LocalTime.parse(duration, timeFormatter);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/CostumerService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.util.List;
4 |
5 | import br.com.beautystyle.model.entity.Customer;
6 | import retrofit2.Call;
7 | import retrofit2.http.Body;
8 | import retrofit2.http.DELETE;
9 | import retrofit2.http.GET;
10 | import retrofit2.http.Header;
11 | import retrofit2.http.POST;
12 | import retrofit2.http.PUT;
13 | import retrofit2.http.Path;
14 |
15 | public interface CostumerService {
16 |
17 | @GET("customer")
18 | Call> getAll(@Header("Authorization") String token);
19 |
20 | @POST("customer")
21 | Call insert(@Body Customer customer, @Header("Authorization") String token);
22 |
23 | @POST("customer/insert_all")
24 | Call> insertAll(@Body List customer, @Header("Authorization") String token);
25 |
26 | @PUT("customer/{id}")
27 | Call update(@Body Customer customer, @Header("Authorization") String token);
28 |
29 | @DELETE("customer/{id}")
30 | Call delete(@Path("id") long id, @Header("Authorization") String token);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/adapter/recyclerview/listener/AdapterListener.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.adapter.recyclerview.listener;
2 |
3 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
4 | import br.com.beautystyle.model.entity.Category;
5 | import br.com.beautystyle.model.entity.Customer;
6 | import br.com.beautystyle.model.entity.Expense;
7 | import br.com.beautystyle.model.entity.Job;
8 |
9 | public class AdapterListener {
10 |
11 | public interface OnExpenseClickListener {
12 | void onItemClick(Expense expense, int position);
13 | }
14 |
15 | public interface OnClientClickListener {
16 | void onItemClick(Customer customer);
17 | }
18 | public interface OnEventClickListener {
19 | void onItemClick(EventWithClientAndJobs event);
20 | }
21 |
22 | public interface OnJobClickListener {
23 | void onItemClick(Job job, boolean isSelected);
24 | }
25 |
26 | public interface OnCategoryClickListener {
27 | void onItemClick(String name);
28 | }
29 |
30 | public interface OnCategoryLongClickListener {
31 | boolean onItemClick(Category category);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomCustomerDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.Query;
7 | import androidx.room.Update;
8 |
9 | import java.util.List;
10 |
11 | import br.com.beautystyle.model.entity.Customer;
12 | import io.reactivex.rxjava3.core.Completable;
13 | import io.reactivex.rxjava3.core.Observable;
14 | import io.reactivex.rxjava3.core.Single;
15 |
16 |
17 | @Dao
18 | public interface RoomCustomerDao {
19 |
20 | @Query("SELECT * FROM Customer WHERE tenant= :tenant")
21 | Single> getAll(Long tenant);
22 |
23 | @Query("SELECT * FROM Customer WHERE tenant= :tenant")
24 | Observable> getAllObservable(Long tenant);
25 |
26 | @Update
27 | Completable update(Customer customer);
28 |
29 | @Delete
30 | Completable delete(Customer customer);
31 |
32 | @Insert
33 | Single> insertAll(List customerList);
34 |
35 | @Update
36 | Completable updateAll(List updatedCustomerList);
37 |
38 | @Insert
39 | Completable insert(Customer customer);
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/webclient/UserWebClient.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.webclient;
2 |
3 | import javax.inject.Inject;
4 |
5 | import br.com.beautystyle.retrofit.model.form.UserLoginForm;
6 | import br.com.beautystyle.retrofit.model.dto.UserDto;
7 | import br.com.beautystyle.repository.ResultsCallBack;
8 | import br.com.beautystyle.retrofit.callback.CallBackReturn;
9 | import br.com.beautystyle.retrofit.service.UserService;
10 | import retrofit2.Call;
11 |
12 | public class UserWebClient {
13 |
14 | @Inject
15 | UserService service;
16 |
17 | @Inject
18 | public UserWebClient() {
19 | }
20 |
21 | public void authUser(UserLoginForm login, ResultsCallBack callBack) {
22 | Call callAuth = service.auth(login);
23 | callAuth.enqueue(new CallBackReturn<>(new CallBackReturn.CallBackResponse() {
24 | @Override
25 | public void onSuccess(UserDto response) {
26 | callBack.onSuccess(response);
27 | }
28 |
29 | @Override
30 | public void onError(String error) {
31 | callBack.onError(error);
32 | }
33 | }));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/ReportService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import br.com.beautystyle.model.util.Report;
7 | import retrofit2.Call;
8 | import retrofit2.http.GET;
9 | import retrofit2.http.Header;
10 | import retrofit2.http.Path;
11 |
12 | public interface ReportService {
13 |
14 | @GET("report/{id}/{startDate}/{endDate}")
15 | Call> getReportByPeriod(@Path("startDate") LocalDate startDate,
16 | @Path("endDate") LocalDate endDate,
17 | @Path("id") Long tenant,
18 | @Header("Authorization") String token);
19 |
20 | @GET("report/{companyId}")
21 | Call> getYearsList(@Path("companyId") Long tenant,
22 | @Header("Authorization") String token);
23 |
24 | @GET("report/{id}/{date}")
25 | Call> getReportByDate(@Path("date") LocalDate date,
26 | @Path("id") Long tenant,
27 | @Header("Authorization") String token);
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/CoinUtil.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import static br.com.beautystyle.util.MoneyTextWatcher.getCurrencySymbol;
4 |
5 | import java.math.BigDecimal;
6 | import java.text.DecimalFormat;
7 | import java.text.NumberFormat;
8 | import java.util.Locale;
9 |
10 | public class CoinUtil {
11 |
12 | private static final String PORTUGUESE = "pt";
13 | private static final String BRASIL = "br";
14 | private static final String DEFAULT_FORMAT = "R$";
15 |
16 | public static String format(BigDecimal value, String desiredFormat){
17 | NumberFormat formatoBr = DecimalFormat.getCurrencyInstance(
18 | new Locale(PORTUGUESE, BRASIL));
19 | return formatoBr.format(value)
20 | .replace(DEFAULT_FORMAT, desiredFormat);
21 | }
22 |
23 | public static String formatPriceSave(String price) {
24 |
25 | String replaceable = String.format("[%s,.\\s]", getCurrencySymbol());
26 | String cleanString = price.replaceAll(replaceable, "");
27 | StringBuilder stringBuilder = new StringBuilder(cleanString.replaceAll(" ", ""));
28 |
29 | return String.valueOf(stringBuilder.insert(cleanString.length() - 2, '.'));
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomCategoryDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.OnConflictStrategy;
7 | import androidx.room.Query;
8 | import androidx.room.Update;
9 |
10 | import java.util.List;
11 |
12 | import br.com.beautystyle.model.entity.Category;
13 | import io.reactivex.rxjava3.core.Completable;
14 | import io.reactivex.rxjava3.core.Observable;
15 | import io.reactivex.rxjava3.core.Single;
16 |
17 | @Dao
18 | public interface RoomCategoryDao {
19 |
20 | @Query("SELECT * FROM category WHERE tenant= :tenant")
21 | Observable> getAllObservable(Long tenant);
22 |
23 | @Query("SELECT * FROM category WHERE tenant= :tenant")
24 | Single> getAllSingle(Long tenant);
25 |
26 | @Insert(onConflict = OnConflictStrategy.REPLACE)
27 | Completable insert(Category category);
28 |
29 | @Update
30 | Completable update(Category category);
31 |
32 | @Delete
33 | Completable delete(Category category);
34 |
35 | @Insert(onConflict = OnConflictStrategy.REPLACE)
36 | Single> insertAll(List categoriesFromApi);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/model/dto/EventWithClientAndJobsDto.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.model.dto;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
7 | import br.com.beautystyle.model.entity.BlockTime;
8 |
9 | public class EventWithClientAndJobsDto {
10 |
11 | private List events;
12 | private List blockTimes;
13 |
14 | public EventWithClientAndJobsDto() {
15 | events = new ArrayList<>();
16 | blockTimes = new ArrayList<>();
17 | }
18 |
19 | public EventWithClientAndJobsDto(List events, List blockTimes) {
20 | this.events = events;
21 | this.blockTimes = blockTimes;
22 | }
23 |
24 | public List getEvents() {
25 | return events;
26 | }
27 |
28 | public void setEvents(List events) {
29 | this.events = events;
30 | }
31 |
32 | public List getBlockTimes() {
33 | return blockTimes;
34 | }
35 |
36 | public void setBlockTimes(List blockTimes) {
37 | this.blockTimes = blockTimes;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/repository/OpeningHoursRepository.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.repository;
2 |
3 | import static br.com.beautystyle.repository.ConstantsRepository.TENANT_SHARED_PREFERENCES;
4 |
5 | import android.content.SharedPreferences;
6 |
7 | import androidx.lifecycle.MutableLiveData;
8 |
9 | import java.util.List;
10 |
11 | import javax.inject.Inject;
12 |
13 | import br.com.beautystyle.database.rxjava.OpeningHoursRxJava;
14 | import br.com.beautystyle.model.entity.OpeningHours;
15 | import io.reactivex.rxjava3.core.Completable;
16 | import io.reactivex.rxjava3.core.Single;
17 |
18 | public class OpeningHoursRepository {
19 |
20 | @Inject
21 | OpeningHoursRxJava dao;
22 | private final Long tenant;
23 | private final MutableLiveData>> mutableLiveData = new MutableLiveData<>();
24 |
25 | @Inject
26 | public OpeningHoursRepository(SharedPreferences preferences) {
27 | tenant = preferences.getLong(TENANT_SHARED_PREFERENCES, 0);
28 | }
29 |
30 | public Single> getAll() {
31 | return dao.getAll(tenant);
32 | }
33 |
34 | public Completable insertAll(List openingHours) {
35 | return dao.insertAll(openingHours);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/CalendarUtil.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import static br.com.beautystyle.util.ConstantsUtil.DD_MM_YYYY;
4 | import static br.com.beautystyle.util.ConstantsUtil.MMMM;
5 |
6 | import java.time.LocalDate;
7 | import java.time.format.DateTimeFormatter;
8 | import java.time.format.FormatStyle;
9 |
10 | public class CalendarUtil {
11 |
12 | public static LocalDate selectedDate = LocalDate.now();
13 |
14 | public static String formatMonth(LocalDate date) {
15 | String formatDate = formatLocalDate(date, MMMM);
16 | return formatDate.substring(0, 1).toUpperCase().concat(formatDate.substring(1));
17 | }
18 |
19 | public static String formatLocalDate(LocalDate date, String format) {
20 | DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
21 | return df.format(date);
22 | }
23 |
24 | public static String formatDateLong() {
25 | DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
26 | return df.format(selectedDate);
27 | }
28 |
29 | public static LocalDate fromStringToLocalDate(String date){
30 | DateTimeFormatter df = DateTimeFormatter.ofPattern(DD_MM_YYYY);
31 | return LocalDate.parse(date,df);
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/OpeningHoursRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.util.List;
4 |
5 | import javax.inject.Inject;
6 |
7 | import br.com.beautystyle.database.BeautyStyleDatabase;
8 | import br.com.beautystyle.database.dao.RoomOpeningHoursDao;
9 | import br.com.beautystyle.model.entity.OpeningHours;
10 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
11 | import io.reactivex.rxjava3.core.Completable;
12 | import io.reactivex.rxjava3.core.Single;
13 | import io.reactivex.rxjava3.schedulers.Schedulers;
14 |
15 | public class OpeningHoursRxJava {
16 |
17 | private final RoomOpeningHoursDao dao;
18 |
19 | @Inject
20 | public OpeningHoursRxJava(BeautyStyleDatabase database) {
21 | this.dao = database.getRoomOpeningHoursDao();
22 | }
23 |
24 | public Single> getAll(Long tenant) {
25 | return dao.getAll(tenant)
26 | .observeOn(AndroidSchedulers.mainThread())
27 | .subscribeOn(Schedulers.io());
28 | }
29 |
30 | public Completable insertAll(List ope) {
31 | return dao.insertAll(ope)
32 | .observeOn(AndroidSchedulers.mainThread())
33 | .subscribeOn(Schedulers.io());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_report_daily.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_loading_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/ListDaysView.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 |
5 | import java.time.LocalDate;
6 |
7 | import br.com.beautystyle.ui.adapter.recyclerview.ListDaysAdapter;
8 | import br.com.beautystyle.util.CalendarUtil;
9 |
10 | public class ListDaysView {
11 |
12 | private ListDaysAdapter adapter;
13 | private RecyclerView dayOfMonth;
14 | private int toPosition = 365;
15 |
16 | public void setAdapter(RecyclerView dayOfMonth, ListDaysAdapter.OnDayListener context) {
17 | this.adapter = new ListDaysAdapter(context);
18 | dayOfMonth.setAdapter(adapter);
19 | this.dayOfMonth = dayOfMonth;
20 | adapter.update();
21 | changeScrollPosition();
22 | }
23 |
24 | public void changeScrollPosition() {
25 | int fromPosition = getPosition(CalendarUtil.selectedDate);
26 | toPosition = toPosition < fromPosition ? fromPosition + 2 : fromPosition - 2;
27 | dayOfMonth.scrollToPosition(toPosition);
28 | toPosition = fromPosition;
29 | }
30 |
31 | // simula um click na lista de dias
32 | public void toScrollPosition(LocalDate date) {
33 | adapter.onClickViewHolder(date);
34 | }
35 |
36 | public int getPosition(LocalDate date) {
37 | return adapter.getPosition(date);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/EventService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.time.LocalDate;
4 |
5 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
6 | import br.com.beautystyle.retrofit.model.dto.EventWithClientAndJobsDto;
7 | import br.com.beautystyle.retrofit.model.form.EventForm;
8 | import retrofit2.Call;
9 | import retrofit2.http.Body;
10 | import retrofit2.http.DELETE;
11 | import retrofit2.http.GET;
12 | import retrofit2.http.Header;
13 | import retrofit2.http.POST;
14 | import retrofit2.http.PUT;
15 | import retrofit2.http.Path;
16 |
17 | public interface EventService {
18 |
19 | @GET("event/by_professional/{eventDate}")
20 | Call getByDate(@Path("eventDate") LocalDate eventDate,
21 | @Header("Authorization") String token);
22 |
23 | @POST("event/by_professional")
24 | Call insert(@Body EventForm event,
25 | @Header("Authorization") String token);
26 |
27 | @PUT("event/by_professional/{id}")
28 | Call update(@Path("id") Long id,
29 | @Body EventForm event,
30 | @Header("Authorization") String token);
31 |
32 | @DELETE("event/by_professional/{id}")
33 | Call delete(@Path("id") Long id, @Header("Authorization") String token);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/EventJobCrossRef.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import static androidx.room.ForeignKey.CASCADE;
4 |
5 | import androidx.room.ColumnInfo;
6 | import androidx.room.Entity;
7 | import androidx.room.ForeignKey;
8 | import androidx.room.Ignore;
9 |
10 | import java.util.Objects;
11 |
12 |
13 | @Entity(primaryKeys = {"eventId", "jobId"}
14 | , foreignKeys = {
15 | @ForeignKey(onDelete = CASCADE, entity = Event.class,
16 | parentColumns = "eventId", childColumns = "eventId")}
17 | )
18 | public class EventJobCrossRef {
19 |
20 | @ColumnInfo(index = true)
21 | public long eventId;
22 | @ColumnInfo(index = true)
23 | public long jobId;
24 |
25 | @Ignore
26 | public EventJobCrossRef(long eventId, long jobId) {
27 | this.eventId = eventId;
28 | this.jobId = jobId;
29 | }
30 |
31 | public EventJobCrossRef() {
32 | }
33 |
34 | public long getEventId() {
35 | return eventId;
36 | }
37 |
38 | @Override
39 | public boolean equals(Object o) {
40 | if (this == o) return true;
41 | if (o == null || getClass() != o.getClass()) return false;
42 | EventJobCrossRef that = (EventJobCrossRef) o;
43 | return eventId == that.eventId && jobId == that.jobId;
44 | }
45 |
46 | @Override
47 | public int hashCode() {
48 | return Objects.hash(eventId, jobId);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomExpenseDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.OnConflictStrategy;
7 | import androidx.room.Query;
8 | import androidx.room.Transaction;
9 | import androidx.room.Update;
10 |
11 | import java.time.LocalDate;
12 | import java.util.List;
13 |
14 | import br.com.beautystyle.model.entity.Expense;
15 | import io.reactivex.rxjava3.core.Completable;
16 | import io.reactivex.rxjava3.core.Single;
17 |
18 | @Dao
19 | public interface RoomExpenseDao {
20 |
21 | @Delete
22 | Completable delete(Expense selectedExpense);
23 |
24 | @Insert(onConflict = OnConflictStrategy.REPLACE)
25 | Single insert(Expense expense);
26 |
27 | @Update
28 | Completable update(Expense expense);
29 |
30 | @Insert(onConflict = OnConflictStrategy.REPLACE)
31 | Single> insertAll(List response);
32 |
33 | @Query("SELECT e.expenseDate FROM expense e WHERE tenant= :tenant")
34 | Single> getYearsList(Long tenant);
35 |
36 | @Query("SELECT * FROM expense e WHERE tenant= :tenant AND e.expenseDate >= :startDate AND e.expenseDate <= :endDate")
37 | Single> getByPeriod(LocalDate startDate, LocalDate endDate, Long tenant);
38 |
39 | @Transaction
40 | @Query("SELECT * FROM expense e WHERE e.expenseDate = :date AND tenant= :tenant")
41 | Single> getByDate(LocalDate date, Long tenant);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/User.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import static br.com.beautystyle.repository.ConstantsRepository.USER_PREMIUM;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.room.Entity;
7 | import androidx.room.Ignore;
8 | import androidx.room.PrimaryKey;
9 |
10 | import java.util.List;
11 |
12 | import br.com.beautystyle.retrofit.model.form.UserLoginForm;
13 |
14 | @Entity
15 | public class User {
16 |
17 | @NonNull
18 | @PrimaryKey
19 | private String email="";
20 | private String password;
21 | private String profile;
22 |
23 | @Ignore
24 | public User(UserLoginForm userLoginForm, List profiles) {
25 | this.email = userLoginForm.getEmail();
26 | this.password = userLoginForm.getPassword();
27 | this.profile = profiles.get(0);
28 | }
29 |
30 | public User() {
31 | }
32 |
33 | public void setEmail(@NonNull String email) {
34 | this.email = email;
35 | }
36 |
37 | public void setPassword(String password) {
38 | this.password = password;
39 | }
40 |
41 | @NonNull
42 | public String getEmail() {
43 | return email;
44 | }
45 |
46 | public String getPassword() {
47 | return password;
48 | }
49 |
50 | public String getProfile() {
51 | return profile;
52 | }
53 |
54 | public void setProfile(String profile) {
55 | this.profile = profile;
56 | }
57 |
58 | public boolean isPremiumAccount() {
59 | return profile.equals(USER_PREMIUM);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_days_week_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/dao/RoomEventDao.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.dao;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.Query;
7 | import androidx.room.Transaction;
8 | import androidx.room.Update;
9 |
10 | import java.time.LocalDate;
11 | import java.util.List;
12 |
13 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
14 | import br.com.beautystyle.model.entity.Event;
15 | import io.reactivex.rxjava3.core.Completable;
16 | import io.reactivex.rxjava3.core.Single;
17 |
18 | @Dao
19 | public interface RoomEventDao {
20 |
21 | @Transaction
22 | @Query("SELECT * FROM Event ev WHERE ev.eventDate = :date AND tenant= :tenant")
23 | Single> getByDate(LocalDate date, Long tenant);
24 |
25 | @Insert
26 | Single insert(Event event);
27 |
28 | @Delete
29 | Completable delete(Event event);
30 |
31 | @Update
32 | Completable update(Event event);
33 |
34 | @Insert
35 | Single> insertAll(List convert);
36 |
37 | @Update
38 | Completable updateAll(List eventList);
39 |
40 | @Transaction
41 | @Query("SELECT * FROM event e WHERE tenant= :tenant AND " +
42 | "e.eventDate >= :startDate AND e.eventDate <= :endDate")
43 | Single> getByPeriod(LocalDate startDate,LocalDate endDate, Long tenant);
44 |
45 | @Query("SELECT e.eventDate FROM event e WHERE tenant= :tenant")
46 | Single> getYearsList(Long tenant);
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/callback/CallBackWithoutReturn.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.callback;
2 |
3 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.NO_INTERNET_CONNECTION;
4 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.MESSAGE_ERROR;
5 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.MESSAGE_SERVER_ERROR;
6 |
7 | import br.com.beautystyle.retrofit.NoConnectivityException;
8 | import retrofit2.Call;
9 | import retrofit2.Callback;
10 | import retrofit2.Response;
11 | import retrofit2.internal.EverythingIsNonNull;
12 |
13 | public class CallBackWithoutReturn implements Callback {
14 |
15 | private final CallBackResponse callBack;
16 |
17 | public CallBackWithoutReturn(CallBackResponse callBack) {
18 | this.callBack = callBack;
19 | }
20 |
21 | @Override
22 | @EverythingIsNonNull
23 | public void onResponse(Call call, Response response) {
24 | if(response.isSuccessful()){
25 | callBack.onSuccess();
26 | }else{
27 | callBack.onError(MESSAGE_ERROR);
28 | }
29 | }
30 |
31 | @Override
32 | @EverythingIsNonNull
33 | public void onFailure(Call call, Throwable t) {
34 | if(t instanceof NoConnectivityException) {
35 | callBack.onError(NO_INTERNET_CONNECTION);
36 | }else{
37 | callBack.onError(MESSAGE_SERVER_ERROR + " " + t.getMessage());
38 | }
39 | }
40 |
41 | public interface CallBackResponse {
42 | void onSuccess();
43 | void onError(String erro);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/model/dto/UserDto.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.model.dto;
2 |
3 | import java.util.List;
4 |
5 | import br.com.beautystyle.model.entity.OpeningHours;
6 |
7 | public class UserDto {
8 |
9 | private String token;
10 | private String type;
11 | private Long tenant;
12 | private List profiles;
13 | private List openingHours;
14 |
15 | public String getTypeToken(){
16 | return this.type + " " + this.token;
17 | }
18 |
19 | public String getToken() {
20 | return token;
21 | }
22 |
23 | public String getType() {
24 | return type;
25 | }
26 |
27 | public Long getTenant() {
28 | return tenant;
29 | }
30 |
31 | public List getProfiles() {
32 | return profiles;
33 | }
34 |
35 | public void setToken(String token) {
36 | this.token = token;
37 | }
38 |
39 | public void setType(String type) {
40 | this.type = type;
41 | }
42 |
43 | public void setTenant(Long tenant) {
44 | this.tenant = tenant;
45 | }
46 |
47 | public void setProfiles(List profiles) {
48 | this.profiles = profiles;
49 | }
50 |
51 | public List getOpeningHours() {
52 | return openingHours;
53 | }
54 |
55 | public void setOpeningHours(List openingHours) {
56 | this.openingHours = openingHours;
57 | }
58 |
59 | public String getProfile() {
60 | if(!profiles.isEmpty()){
61 | return profiles.get(0);
62 | }
63 | return "";
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/model/form/EventForm.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.model.form;
2 |
3 | import java.util.List;
4 | import java.util.Set;
5 | import java.util.stream.Collectors;
6 |
7 | import br.com.beautystyle.model.entity.Event;
8 | import br.com.beautystyle.model.entity.Job;
9 |
10 | class JobForm {
11 | private Long apiId;
12 |
13 | public JobForm() {
14 | }
15 |
16 | public JobForm(Job job) {
17 | this.apiId = job.getApiId();
18 | }
19 |
20 | public Long getApiId() {
21 | return apiId;
22 | }
23 |
24 | public void setApiId(Long apiId) {
25 | this.apiId = apiId;
26 | }
27 | }
28 |
29 | public class EventForm {
30 |
31 | private Event event;
32 | private Long customerId;
33 | private Set jobs;
34 |
35 | public EventForm() {
36 | }
37 |
38 | public EventForm(Event event, Long customerId, List jobs) {
39 | this.event = event;
40 | this.customerId = customerId;
41 | this.jobs = jobs.stream().map(JobForm::new).collect(Collectors.toSet());
42 | }
43 |
44 | public Event getEvent() {
45 | return event;
46 | }
47 |
48 | public void setEvent(Event event) {
49 | this.event = event;
50 | }
51 |
52 | public Long getCustomerId() {
53 | return customerId;
54 | }
55 |
56 | public void setCustomerId(Long customerId) {
57 | this.customerId = customerId;
58 | }
59 |
60 | public Set getJobs() {
61 | return jobs;
62 | }
63 |
64 | public void setJobs(Set jobs) {
65 | this.jobs = jobs;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/fragment/ConstantFragment.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.fragment;
2 |
3 | public interface ConstantFragment {
4 | String KEY_UPDATE_EVENT = "updateEvent";
5 | String KEY_INSERT_EVENT = "newEvent";
6 | String KEY_UPDATE_EXPENSE = "updateExpense";
7 | String KEY_RESULT_EXPENSE = "resultExpense";
8 | String KEY_CLIENT = "client";
9 | String TAG_INSERT_CLIENT = "tagInsertClient";
10 | String TAG_UPDATE_CLIENT = "tagUpdateClient";
11 | String KEY_UPDATE_CLIENT = "updateClient";
12 | String KEY_INSERT_CLIENT = "insertClient";
13 | String KEY_JOB = "service";
14 | String TAG_UPDATE_JOB = "tagUpdateService";
15 | String KEY_UPDATE_JOB = "updateService";
16 | String KEY_INSERT_JOB = "insertService";
17 | String TAG_INSERT_JOB = "tagInsertService";
18 | String KEY_REPORT = "report";
19 | String KEY_DAILY_REPORT = "daily";
20 | String KEY_POSITION = "position";
21 | String KEY_START_DATE = "startDate";
22 | String KEY_END_DATE = "endDate";
23 | String KEY_RESULT_CATEGORY = "category";
24 | String KEY_NAME_CATEGORY = "newCategory";
25 | String KEY_UPDATE_CATEGORY = "updateCategory";
26 | String TAG_CALENDAR_VIEW = "calendarView";
27 | String TAG_START_TIME = "startTime";
28 | String TAG_END_TIME = "endTime";
29 | String KEY_BLOCK_TIME = "blockTime";
30 | String KEY_INSERT_BLOCK_TIME = "insertBlockTime";
31 | String TAG_INSERT_BLOCK_TIME = "tagInsertBlockTime";
32 | String TAG_UPDATE_BLOCK_TIME = "tagUpdateBlockTime";
33 | String KEY_UPDATE_BLOCK_TIME = "keyUpdateBlockTime";
34 | String KEY_START_TIME = "keyStartTime";
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/ExpenseViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.ViewModel;
5 |
6 | import java.util.List;
7 |
8 | import br.com.beautystyle.model.util.Report;
9 | import br.com.beautystyle.model.entity.Expense;
10 | import br.com.beautystyle.repository.ExpenseRepository;
11 | import br.com.beautystyle.repository.Resource;
12 | import br.com.beautystyle.util.CreateListsUtil;
13 |
14 | public class ExpenseViewModel extends ViewModel {
15 |
16 | private final ExpenseRepository repository;
17 |
18 | public ExpenseViewModel(ExpenseRepository repository) {
19 | this.repository = repository;
20 | }
21 |
22 | public LiveData>> getByPeriodLiveData() {
23 | return repository.getByPeriodLiveData();
24 | }
25 |
26 | public LiveData> insert(Expense expense) {
27 | return repository.insert(expense);
28 | }
29 |
30 | public LiveData> update(Expense expense) {
31 | return repository.update(expense);
32 | }
33 |
34 | public LiveData> delete(Expense expense) {
35 | return repository.delete(expense);
36 | }
37 |
38 | public LiveData>> getYearsListLiveData() {
39 | return repository.getYearsListLiveData();
40 | }
41 |
42 | public LiveData> getMonthsOfTheYearList() {
43 | return CreateListsUtil.createMonthsList();
44 | }
45 |
46 | public LiveData>> getReportByPeriod() {
47 | return repository.getReportByPeriod();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/fragment/TimePickerFragment.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.fragment;
2 |
3 | import android.app.Dialog;
4 | import android.app.TimePickerDialog;
5 | import android.os.Bundle;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.DialogFragment;
10 |
11 | import java.time.LocalTime;
12 |
13 | public class TimePickerFragment extends DialogFragment {
14 |
15 | private TimePickerDialog.OnTimeSetListener onTimeSetListener;
16 |
17 | private static int hour;
18 | private static int minute;
19 |
20 | public static TimePickerFragment newInstance(TimePickerDialog.OnTimeSetListener timePickerDialog) {
21 | final TimePickerFragment listener = new TimePickerFragment();
22 | listener.setOnTimeSetListener(timePickerDialog);
23 | hour = 1;
24 | minute = 0;
25 | return listener;
26 | }
27 |
28 | public static TimePickerFragment newInstance(TimePickerDialog.OnTimeSetListener timePickerDialog,
29 | LocalTime startTime) {
30 | final TimePickerFragment listener = new TimePickerFragment();
31 | listener.setOnTimeSetListener(timePickerDialog);
32 | hour = startTime.getHour();
33 | minute = startTime.getMinute();
34 | return listener;
35 | }
36 |
37 | public void setOnTimeSetListener(TimePickerDialog.OnTimeSetListener onTimeSetListener) {
38 | this.onTimeSetListener = onTimeSetListener;
39 | }
40 |
41 | @NonNull
42 | @Override
43 | public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
44 | return new TimePickerDialog(requireActivity(), onTimeSetListener, hour, minute, true);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/BlockTimeRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import javax.inject.Inject;
7 |
8 | import br.com.beautystyle.database.BeautyStyleDatabase;
9 | import br.com.beautystyle.database.dao.RoomBlockTimeDao;
10 | import br.com.beautystyle.model.entity.BlockTime;
11 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
12 | import io.reactivex.rxjava3.core.Completable;
13 | import io.reactivex.rxjava3.core.Single;
14 | import io.reactivex.rxjava3.schedulers.Schedulers;
15 |
16 | public class BlockTimeRxJava {
17 |
18 | private final RoomBlockTimeDao dao;
19 |
20 | @Inject
21 | public BlockTimeRxJava(BeautyStyleDatabase database) {
22 | dao = database.getRoomBlockTimeDao();
23 | }
24 |
25 | public Single> getByDate(LocalDate date, Long tenant) {
26 | return dao.getAll(tenant, date)
27 | .observeOn(AndroidSchedulers.mainThread())
28 | .subscribeOn(Schedulers.io());
29 | }
30 |
31 | public Single> insertAll(List blockTimes) {
32 | return dao.insertAll(blockTimes)
33 | .observeOn(AndroidSchedulers.mainThread())
34 | .subscribeOn(Schedulers.io());
35 | }
36 |
37 | public Completable delete(BlockTime blockTime) {
38 | return dao.delete(blockTime)
39 | .observeOn(AndroidSchedulers.mainThread())
40 | .subscribeOn(Schedulers.io());
41 | }
42 |
43 | public Completable update(BlockTime blockTime){
44 | return dao.update(blockTime)
45 | .observeOn(AndroidSchedulers.mainThread())
46 | .subscribeOn(Schedulers.io());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/NetworkConnectionInterceptor.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.Network;
6 | import android.net.NetworkCapabilities;
7 |
8 | import androidx.annotation.NonNull;
9 |
10 | import java.io.IOException;
11 |
12 | import okhttp3.Interceptor;
13 | import okhttp3.Request;
14 | import okhttp3.Response;
15 |
16 | public class NetworkConnectionInterceptor implements Interceptor {
17 |
18 | private final Context mContext;
19 |
20 | public NetworkConnectionInterceptor(Context context) {
21 | mContext = context;
22 | }
23 |
24 | @NonNull
25 | @Override
26 | public Response intercept(@NonNull Chain chain) throws IOException {
27 | if (!isConnected()) {
28 | throw new NoConnectivityException();
29 | }
30 |
31 | Request.Builder builder = chain.request().newBuilder();
32 | return chain.proceed(builder.build());
33 | }
34 |
35 | public boolean isConnected() {
36 | ConnectivityManager connectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
37 | Network nw = connectivityManager.getActiveNetwork();
38 | if (nw == null) return false;
39 | NetworkCapabilities actNw = connectivityManager.getNetworkCapabilities(nw);
40 | return checkNetworkConnection(actNw);
41 | }
42 |
43 | private boolean checkNetworkConnection(NetworkCapabilities actNw) {
44 | return actNw != null && (actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) ||
45 | actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
46 | actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) ||
47 | actNw.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH));
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/Category.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import androidx.room.Entity;
4 | import androidx.room.Ignore;
5 | import androidx.room.PrimaryKey;
6 |
7 | import java.io.Serializable;
8 | import java.util.List;
9 |
10 | @Entity
11 | public class Category implements Serializable {
12 |
13 | @PrimaryKey(autoGenerate = true)
14 | private Long id;
15 | private String name;
16 | private Long apiId;
17 | private Long tenant;
18 |
19 | @Ignore
20 | public Category(String name) {
21 | this.name = name;
22 | }
23 |
24 | public Category() {
25 | }
26 |
27 | public Long getApiId() {
28 | return apiId;
29 | }
30 |
31 | public void setApiId(Long apiId) {
32 | this.apiId = apiId;
33 | }
34 |
35 | public Long getId() {
36 | return id;
37 | }
38 |
39 | public void setId(Long id) {
40 | this.id = id;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public Long getTenant() {
52 | return tenant;
53 | }
54 |
55 | public void setTenant(Long tenant) {
56 | this.tenant = tenant;
57 | }
58 |
59 | public boolean isApiIdEquals(Category categoryFromApi) {
60 | if(this.apiId != null){
61 | return this.apiId.equals(categoryFromApi.getApiId());
62 | }
63 | return false;
64 | }
65 |
66 | public boolean isNotExistOnApi(List categoriesFromApi) {
67 | if(this.apiId != null){
68 | for (Category categoryFromApi : categoriesFromApi) {
69 | if (this.apiId.equals(categoryFromApi.getApiId())) {
70 | return false;
71 | }
72 | }
73 | }
74 | return true;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/fragment/CalendarViewFragment.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.fragment;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Dialog;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.widget.CalendarView;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 | import androidx.appcompat.app.AlertDialog;
13 | import androidx.fragment.app.DialogFragment;
14 |
15 | import com.example.beautystyle.R;
16 |
17 | public class CalendarViewFragment extends DialogFragment {
18 |
19 | private CalendarView.OnDateChangeListener listener;
20 |
21 | public void setOnCalendarClickListener (CalendarView.OnDateChangeListener listener){
22 | this.listener = listener;
23 | }
24 |
25 | @NonNull
26 | @Override
27 | public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
28 | @SuppressLint("InflateParams")
29 | View inflatedCalendar = LayoutInflater.from(requireActivity())
30 | .inflate(R.layout.dialog_calendar, null);
31 | AlertDialog dialogBuilderCalendar = createDialogBuilderCalendar(inflatedCalendar);
32 | setOnDateChangeListener(inflatedCalendar);
33 | return dialogBuilderCalendar;
34 | }
35 |
36 |
37 | private AlertDialog createDialogBuilderCalendar(View inflatedCalendar) {
38 | AlertDialog.Builder dialogCalendar = new AlertDialog.Builder(requireActivity());
39 | dialogCalendar.setView(inflatedCalendar);
40 | AlertDialog dialog = dialogCalendar.create();
41 | dialog.show();
42 | return dialog;
43 | }
44 |
45 | private void setOnDateChangeListener(View inflatedCalendar) {
46 | CalendarView calendar = inflatedCalendar.findViewById(R.id.dialog_calendar_view);
47 | calendar.setOnDateChangeListener(listener);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/OpeningHours.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import androidx.room.Entity;
4 | import androidx.room.PrimaryKey;
5 |
6 | import java.time.LocalTime;
7 |
8 | @Entity
9 | public class OpeningHours implements Comparable {
10 |
11 | @PrimaryKey(autoGenerate = true)
12 | private Long id;
13 | private LocalTime startTime;
14 | private LocalTime endTime;
15 | private int dayOfWeek;
16 | private Long tenant;
17 | private Long apiId;
18 |
19 | public OpeningHours() {
20 | }
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public void setId(Long id) {
27 | this.id = id;
28 | }
29 |
30 | public LocalTime getStartTime() {
31 | return startTime;
32 | }
33 |
34 | public void setStartTime(LocalTime startTime) {
35 | this.startTime = startTime;
36 | }
37 |
38 | public LocalTime getEndTime() {
39 | return endTime;
40 | }
41 |
42 | public void setEndTime(LocalTime endTime) {
43 | this.endTime = endTime;
44 | }
45 |
46 | public int getDayOfWeek() {
47 | return dayOfWeek;
48 | }
49 |
50 | public void setDayOfWeek(int dayOfWeek) {
51 | this.dayOfWeek = dayOfWeek;
52 | }
53 |
54 | public Long getTenant() {
55 | return tenant;
56 | }
57 |
58 | public void setTenant(Long tenant) {
59 | this.tenant = tenant;
60 | }
61 |
62 | public Long getApiId() {
63 | return apiId;
64 | }
65 |
66 | public void setApiId(Long apiId) {
67 | this.apiId = apiId;
68 | }
69 |
70 | public boolean isApiIdEquals(OpeningHours fromApi) {
71 | return this.apiId.equals(fromApi.getApiId());
72 | }
73 |
74 | @Override
75 | public int compareTo(OpeningHours o) {
76 | if (startTime.equals(o.getStartTime())) return 0;
77 | if (startTime.isAfter(o.getStartTime())) return 1;
78 | return -1;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/util/Report.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.util;
2 |
3 | import java.math.BigDecimal;
4 | import java.time.LocalDate;
5 |
6 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
7 | import br.com.beautystyle.model.entity.Expense;
8 |
9 | public class Report {
10 |
11 | private String clientName;
12 | private LocalDate date;
13 | private BigDecimal eventValue;
14 | private String expenseCategory;
15 | private BigDecimal expenseValue;
16 |
17 | public Report(EventWithClientAndJobs event) {
18 | clientName = event.getCustomer().getName();
19 | date = event.getEvent().getEventDate();
20 | eventValue = event.getEvent().getValue();
21 | }
22 |
23 | public Report(Expense expense) {
24 | date = expense.getExpenseDate();
25 | expenseCategory = expense.getCategory();
26 | expenseValue = expense.getValue();
27 | }
28 |
29 | public Report() {
30 | }
31 |
32 | public String getClientName() {
33 | return clientName;
34 | }
35 |
36 | public void setClientName(String clientName) {
37 | this.clientName = clientName;
38 | }
39 |
40 | public LocalDate getDate() {
41 | return date;
42 | }
43 |
44 | public void setDate(LocalDate date) {
45 | this.date = date;
46 | }
47 |
48 | public BigDecimal getEventValue() {
49 | return eventValue;
50 | }
51 |
52 | public void setEventValue(BigDecimal eventValue) {
53 | this.eventValue = eventValue;
54 | }
55 |
56 | public String getExpenseCategory() {
57 | return expenseCategory;
58 | }
59 |
60 | public void setExpenseCategory(String expenseCategory) {
61 | this.expenseCategory = expenseCategory;
62 | }
63 |
64 | public BigDecimal getExpenseValue() {
65 | return expenseValue;
66 | }
67 |
68 | public void setExpenseValue(BigDecimal expenseValue) {
69 | this.expenseValue = expenseValue;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/fragment/ProfileFragment.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.fragment;
2 |
3 | import static android.content.Context.MODE_PRIVATE;
4 | import static br.com.beautystyle.repository.ConstantsRepository.IS_LOGGED_SHARED_PREFERENCES;
5 | import static br.com.beautystyle.repository.ConstantsRepository.USER_SHARED_PREFERENCES;
6 |
7 | import android.content.Intent;
8 | import android.content.SharedPreferences;
9 | import android.os.Bundle;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.Button;
14 |
15 | import androidx.fragment.app.Fragment;
16 |
17 | import com.example.beautystyle.R;
18 |
19 | import br.com.beautystyle.ui.activity.LoginActivity;
20 |
21 | public class ProfileFragment extends Fragment {
22 |
23 | private SharedPreferences preferences;
24 |
25 | @Override
26 | public void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | preferences = requireActivity().getSharedPreferences(USER_SHARED_PREFERENCES, MODE_PRIVATE);
29 | }
30 |
31 | @Override
32 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
33 | Bundle savedInstanceState) {
34 | View inflate = inflater.inflate(R.layout.fragment_profile, container, false);
35 |
36 | Button logoutBtn = inflate.findViewById(R.id.fragment_profile_btn_logout);
37 | logoutBtn.setOnClickListener(v->{
38 | Intent intent = new Intent(requireActivity(), LoginActivity.class);
39 | // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK);
40 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
41 | startActivity(intent);
42 | SharedPreferences.Editor editor = preferences.edit();
43 | editor.putBoolean(IS_LOGGED_SHARED_PREFERENCES, false);
44 | editor.apply();
45 | });
46 |
47 | return inflate;
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
25 |
26 |
27 |
28 |
29 |
30 |
33 |
36 |
37 |
38 |
41 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ApplicationComponent.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle;
2 |
3 | import android.content.Context;
4 |
5 | import javax.inject.Singleton;
6 |
7 | import br.com.beautystyle.retrofit.NetworkModule;
8 | import br.com.beautystyle.database.DatabaseModule;
9 | import br.com.beautystyle.ui.activity.LoginActivity;
10 | import br.com.beautystyle.ui.activity.NavigationActivity;
11 | import br.com.beautystyle.ui.activity.NewEventActivity;
12 | import br.com.beautystyle.ui.activity.SplashActivity;
13 | import br.com.beautystyle.ui.fragment.client.ClientListFragment;
14 | import br.com.beautystyle.ui.fragment.event.EventListFragment;
15 | import br.com.beautystyle.ui.fragment.expense.CategoryListFragment;
16 | import br.com.beautystyle.ui.fragment.expense.ExpenseListFragment;
17 | import br.com.beautystyle.ui.fragment.job.JobListFragment;
18 | import br.com.beautystyle.ui.fragment.report.MonthlyReportFragment;
19 | import br.com.beautystyle.ui.fragment.report.ReportFragment;
20 | import dagger.BindsInstance;
21 | import dagger.Component;
22 |
23 | @Singleton
24 | @Component(modules = {DatabaseModule.class, NetworkModule.class, BeautyStyleModule.class})
25 | public interface ApplicationComponent {
26 |
27 | void injectEventFrag(EventListFragment fragment);
28 |
29 | void injectNewEventAct(NewEventActivity activity);
30 |
31 | void injectClientListFrag(ClientListFragment fragment);
32 |
33 | void injectJobListFrag(JobListFragment fragment);
34 |
35 | void injectExpenseListFrag(ExpenseListFragment fragment);
36 |
37 | void injectMonthlyReportFrag(MonthlyReportFragment fragment);
38 |
39 | void injectNavigationAct(NavigationActivity activity);
40 |
41 | void injectLoginAct(LoginActivity activity);
42 |
43 | void injectSplashAct(SplashActivity activity);
44 |
45 | void injectCategoryFrag(CategoryListFragment fragment);
46 |
47 | void injectReportFrag(ReportFragment reportFragment);
48 |
49 | @Component.Factory
50 | interface Factory{
51 | ApplicationComponent create(@BindsInstance Context context);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/BlockTime.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import androidx.room.Entity;
4 | import androidx.room.PrimaryKey;
5 |
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalDate;
10 | import java.time.LocalTime;
11 |
12 | @Entity
13 | public class BlockTime implements Serializable {
14 |
15 | @PrimaryKey(autoGenerate = true)
16 | private Long id;
17 | private LocalTime startTime;
18 | private LocalTime endTime;
19 | private LocalDate date;
20 | private String reason;
21 | private Long tenant;
22 | @SerializedName("id")
23 | private Long apiId;
24 |
25 | public BlockTime() {
26 | }
27 |
28 | public Long getId() {
29 | return id;
30 | }
31 |
32 | public void setId(Long id) {
33 | this.id = id;
34 | }
35 |
36 | public LocalTime getStartTime() {
37 | return startTime;
38 | }
39 |
40 | public void setStartTime(LocalTime startTime) {
41 | this.startTime = startTime;
42 | }
43 |
44 | public LocalTime getEndTime() {
45 | return endTime;
46 | }
47 |
48 | public void setEndTime(LocalTime endTime) {
49 | this.endTime = endTime;
50 | }
51 |
52 | public LocalDate getDate() {
53 | return date;
54 | }
55 |
56 | public void setDate(LocalDate date) {
57 | this.date = date;
58 | }
59 |
60 | public String getReason() {
61 | return reason;
62 | }
63 |
64 | public void setReason(String reason) {
65 | this.reason = reason;
66 | }
67 |
68 | public Long getTenant() {
69 | return tenant;
70 | }
71 |
72 | public void setTenant(Long tenant) {
73 | this.tenant = tenant;
74 | }
75 |
76 | public Long getApiId() {
77 | return apiId;
78 | }
79 |
80 | public void setApiId(Long apiId) {
81 | this.apiId = apiId;
82 | }
83 |
84 | public boolean isApiIdEquals(Long apiId) {
85 | return this.apiId.equals(apiId);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/callback/CallBackReturn.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.callback;
2 |
3 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.MESSAGE_SERVER_ERROR;
4 | import static br.com.beautystyle.retrofit.callback.CallbackMessages.NO_INTERNET_CONNECTION;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import java.io.IOException;
9 |
10 | import br.com.beautystyle.retrofit.NoConnectivityException;
11 | import okhttp3.ResponseBody;
12 | import retrofit2.Call;
13 | import retrofit2.Callback;
14 | import retrofit2.Response;
15 | import retrofit2.internal.EverythingIsNonNull;
16 |
17 | public class CallBackReturn implements Callback {
18 |
19 | private final CallBackResponse callBack;
20 |
21 | public CallBackReturn(CallBackResponse callBack) {
22 | this.callBack = callBack;
23 | }
24 |
25 | @Override
26 | @EverythingIsNonNull
27 | public void onResponse(Call call, Response response) {
28 | T result = response.body();
29 | if (response.isSuccessful()) {
30 | if (result != null) {
31 | callBack.onSuccess(result);
32 | }
33 | } else {
34 | ResponseBody responseBody = response.errorBody();
35 | if (responseBody != null) {
36 | try {
37 | callBack.onError(responseBody.string());
38 | } catch (IOException e) {
39 | e.printStackTrace();
40 | }
41 | } else {
42 | callBack.onError(response.message());
43 | }
44 | }
45 | }
46 |
47 | @Override
48 | public void onFailure(@NonNull Call call, @NonNull Throwable t) {
49 | if (t instanceof NoConnectivityException) {
50 | callBack.onError(NO_INTERNET_CONNECTION);
51 | } else {
52 | callBack.onError(MESSAGE_SERVER_ERROR + " " + t.getMessage());
53 | }
54 | }
55 |
56 | public interface CallBackResponse {
57 | void onSuccess(T response);
58 | void onError(String error);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/service/ExpenseService.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.service;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import br.com.beautystyle.model.util.Report;
7 | import br.com.beautystyle.model.entity.Expense;
8 | import retrofit2.Call;
9 | import retrofit2.http.Body;
10 | import retrofit2.http.DELETE;
11 | import retrofit2.http.GET;
12 | import retrofit2.http.Header;
13 | import retrofit2.http.POST;
14 | import retrofit2.http.PUT;
15 | import retrofit2.http.Path;
16 |
17 | public interface ExpenseService {
18 |
19 | @GET("expense")
20 | Call> getAll();
21 |
22 | @POST("expense")
23 | Call insert(@Body Expense expense,@Header("Authorization") String token);
24 |
25 | @PUT("expense")
26 | Call update(@Body Expense expense,@Header("Authorization") String token);
27 |
28 | @DELETE("expense/{id}")
29 | Call delete(@Path("id") long id,@Header("Authorization") String token);
30 |
31 | @GET("expense/{companyId}")
32 | Call> getYearsList(@Path("companyId") Long tenant,
33 | @Header("Authorization") String token);
34 |
35 | @GET("expense/{id}/{startDate}/{endDate}")
36 | Call> getByPeriod(@Path("startDate") LocalDate startDate,
37 | @Path("endDate") LocalDate endDate,
38 | @Path("id") Long tenant,
39 | @Header("Authorization") String token);
40 |
41 | @GET("expense/report/{id}/{startDate}/{endDate}")
42 | Call> getReportByPeriod(@Path("startDate") LocalDate startDate,
43 | @Path("endDate") LocalDate endDate,
44 | @Path("id") Long tenant,
45 | @Header("Authorization") String token);
46 | @GET("expense/report/{id}/{date}")
47 | Call> getReportByDate(@Path("date") LocalDate date,
48 | @Path("id") Long tenant,
49 | @Header("Authorization") String token);
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_report_period.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
27 |
28 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ViewModel/EventViewModel.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ViewModel;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 | import androidx.lifecycle.ViewModel;
6 |
7 | import java.util.List;
8 |
9 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
10 | import br.com.beautystyle.model.entity.Customer;
11 | import br.com.beautystyle.model.entity.Event;
12 | import br.com.beautystyle.model.entity.Job;
13 | import br.com.beautystyle.repository.EventRepository;
14 | import br.com.beautystyle.repository.Resource;
15 | import br.com.beautystyle.retrofit.model.dto.EventWithClientAndJobsDto;
16 |
17 | public class EventViewModel extends ViewModel {
18 |
19 | private MutableLiveData clientLiveData;
20 | private MutableLiveData> jobsLiveData;
21 | private final EventRepository repository;
22 |
23 | public EventViewModel(EventRepository repository) {
24 | this.repository = repository;
25 | }
26 |
27 | public LiveData> getJobsLiveData() {
28 | if (jobsLiveData == null) {
29 | jobsLiveData = new MutableLiveData<>();
30 | }
31 | return jobsLiveData;
32 | }
33 |
34 | public void add(List serviceList) {
35 |
36 | this.jobsLiveData.setValue(serviceList);
37 | }
38 |
39 | public LiveData getClientLiveData() {
40 | if (clientLiveData == null) {
41 | clientLiveData = new MutableLiveData<>();
42 | }
43 | return clientLiveData;
44 | }
45 |
46 | public void add(Customer customer) {
47 | clientLiveData.setValue(customer);
48 | }
49 |
50 | public LiveData> getByDateLiveData() {
51 | return repository.getByDateLiveData();
52 | }
53 |
54 | public LiveData> insert(EventWithClientAndJobs event) {
55 | return repository.insert(event);
56 | }
57 |
58 | public LiveData> update(EventWithClientAndJobs event) {
59 | return repository.update(event);
60 | }
61 |
62 | public LiveData> delete(Event event) {
63 | return repository.delete(event);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/CategoryRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.util.List;
4 |
5 | import javax.inject.Inject;
6 |
7 | import br.com.beautystyle.database.BeautyStyleDatabase;
8 | import br.com.beautystyle.database.dao.RoomCategoryDao;
9 | import br.com.beautystyle.model.entity.Category;
10 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
11 | import io.reactivex.rxjava3.core.Completable;
12 | import io.reactivex.rxjava3.core.Observable;
13 | import io.reactivex.rxjava3.core.Single;
14 | import io.reactivex.rxjava3.schedulers.Schedulers;
15 |
16 | public class CategoryRxJava {
17 |
18 | private final RoomCategoryDao dao;
19 |
20 | @Inject
21 | public CategoryRxJava(BeautyStyleDatabase database) {
22 | dao = database.getRoomCategoryDao();
23 | }
24 |
25 | public Observable> getAllObservable(Long tenant) {
26 | return dao.getAllObservable(tenant)
27 | .observeOn(AndroidSchedulers.mainThread())
28 | .subscribeOn(Schedulers.io());
29 | }
30 |
31 | public Completable insert(Category category) {
32 | return dao.insert(category)
33 | .observeOn(AndroidSchedulers.mainThread())
34 | .subscribeOn(Schedulers.io());
35 | }
36 |
37 | public Completable delete(Category category) {
38 | return dao.delete(category)
39 | .observeOn(AndroidSchedulers.mainThread())
40 | .subscribeOn(Schedulers.io());
41 | }
42 |
43 | public Completable update(Category category) {
44 | return dao.update(category)
45 | .observeOn(AndroidSchedulers.mainThread())
46 | .subscribeOn(Schedulers.io());
47 | }
48 |
49 | public Single> insertAll(List categories) {
50 | return dao.insertAll(categories)
51 | .observeOn(AndroidSchedulers.mainThread())
52 | .subscribeOn(Schedulers.io());
53 | }
54 |
55 | public Single> getAllSingle(Long tenant) {
56 | return dao.getAllSingle(tenant)
57 | .observeOn(AndroidSchedulers.mainThread())
58 | .subscribeOn(Schedulers.io());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_report_monthly.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
17 |
18 |
24 |
25 |
26 |
27 |
36 |
37 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_new_expense.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
24 |
35 |
36 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_new_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
34 |
35 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/JobRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 |
4 | import java.util.List;
5 |
6 | import javax.inject.Inject;
7 |
8 | import br.com.beautystyle.database.BeautyStyleDatabase;
9 | import br.com.beautystyle.database.dao.RoomJobDao;
10 | import br.com.beautystyle.model.entity.Job;
11 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
12 | import io.reactivex.rxjava3.core.Completable;
13 | import io.reactivex.rxjava3.core.Observable;
14 | import io.reactivex.rxjava3.core.Single;
15 | import io.reactivex.rxjava3.schedulers.Schedulers;
16 |
17 | public class JobRxJava {
18 |
19 | private final RoomJobDao dao;
20 |
21 | @Inject
22 | public JobRxJava(BeautyStyleDatabase database) {
23 | dao = database.getRoomJobDao();
24 | }
25 |
26 | public Observable> getAllLiveData(Long tenant) {
27 | return dao.getAllLiveData(tenant)
28 | .observeOn(AndroidSchedulers.mainThread())
29 | .subscribeOn(Schedulers.io());
30 | }
31 |
32 | public Completable insert(Job job) {
33 | return dao.insert(job)
34 | .observeOn(AndroidSchedulers.mainThread())
35 | .subscribeOn(Schedulers.io());
36 | }
37 |
38 | public Completable update(Job job) {
39 | return dao.update(job)
40 | .observeOn(AndroidSchedulers.mainThread())
41 | .subscribeOn(Schedulers.io());
42 | }
43 |
44 | public Completable updateAll(List jobs) {
45 | return dao.updateAll(jobs)
46 | .observeOn(AndroidSchedulers.mainThread())
47 | .subscribeOn(Schedulers.io());
48 | }
49 |
50 | public Completable delete(Job job) {
51 | return dao.delete(job)
52 | .observeOn(AndroidSchedulers.mainThread())
53 | .subscribeOn(Schedulers.io());
54 | }
55 |
56 | public Single> getAll(Long tenant) {
57 | return dao.getAll(tenant)
58 | .observeOn(AndroidSchedulers.mainThread())
59 | .subscribeOn(Schedulers.io());
60 | }
61 |
62 | public Single> insertAll(List jobs) {
63 | return dao.insertAll(jobs)
64 | .observeOn(AndroidSchedulers.mainThread())
65 | .subscribeOn(Schedulers.io());
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.repository;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 |
6 | import javax.inject.Inject;
7 |
8 | import br.com.beautystyle.database.BeautyStyleDatabase;
9 | import br.com.beautystyle.database.dao.RoomUserDao;
10 | import br.com.beautystyle.retrofit.model.form.UserLoginForm;
11 | import br.com.beautystyle.retrofit.model.dto.UserDto;
12 | import br.com.beautystyle.model.entity.User;
13 | import br.com.beautystyle.retrofit.webclient.UserWebClient;
14 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
15 | import io.reactivex.rxjava3.core.Completable;
16 | import io.reactivex.rxjava3.schedulers.Schedulers;
17 |
18 | public class UserRepository {
19 |
20 | @Inject
21 | UserWebClient webClient;
22 | private final RoomUserDao dao;
23 |
24 | @Inject
25 | public UserRepository(BeautyStyleDatabase localDatabase) {
26 | dao = localDatabase.getRoomUserDao();
27 | }
28 |
29 | public LiveData> authUser(UserLoginForm login) {
30 | MutableLiveData> liveData = new MutableLiveData<>();
31 | webClient.authUser(login, new ResultsCallBack() {
32 | @Override
33 | public void onSuccess(UserDto result) {
34 | liveData.setValue(new Resource<>(result, null));
35 | }
36 |
37 | @Override
38 | public void onError(String error) {
39 | liveData.setValue(new Resource<>(null, error));
40 | }
41 | });
42 | return liveData;
43 | }
44 |
45 | public Completable insertOnRoom(User user) {
46 | return dao.insert(user)
47 | .subscribeOn(Schedulers.io())
48 | .observeOn(AndroidSchedulers.mainThread());
49 | }
50 |
51 | public LiveData> getByEmail(String email) {
52 | MutableLiveData> liveData = new MutableLiveData<>();
53 | dao.getByEmail(email)
54 | .subscribeOn(Schedulers.io())
55 | .observeOn(AndroidSchedulers.mainThread())
56 | .doOnSuccess(user -> liveData.setValue(new Resource<>(user, null)))
57 | .doOnError(error -> liveData.setValue(new Resource<>(null, error.getMessage())))
58 | .subscribe();
59 | return liveData;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/BeautyStyleDatabase.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database;
2 |
3 | import androidx.room.Database;
4 | import androidx.room.RoomDatabase;
5 | import androidx.room.TypeConverters;
6 |
7 | import br.com.beautystyle.database.converters.BigDecimalConverter;
8 | import br.com.beautystyle.database.converters.LocalDateConverter;
9 | import br.com.beautystyle.database.converters.LocalTimeConverter;
10 | import br.com.beautystyle.database.dao.RoomBlockTimeDao;
11 | import br.com.beautystyle.database.dao.RoomOpeningHoursDao;
12 | import br.com.beautystyle.database.dao.RoomCategoryDao;
13 | import br.com.beautystyle.database.dao.RoomCustomerDao;
14 | import br.com.beautystyle.database.dao.RoomEventDao;
15 | import br.com.beautystyle.database.dao.RoomEventWithJobsDao;
16 | import br.com.beautystyle.database.dao.RoomExpenseDao;
17 | import br.com.beautystyle.database.dao.RoomJobDao;
18 | import br.com.beautystyle.database.dao.RoomUserDao;
19 | import br.com.beautystyle.model.entity.BlockTime;
20 | import br.com.beautystyle.model.entity.Category;
21 | import br.com.beautystyle.model.entity.Customer;
22 | import br.com.beautystyle.model.entity.Event;
23 | import br.com.beautystyle.model.entity.EventJobCrossRef;
24 | import br.com.beautystyle.model.entity.Expense;
25 | import br.com.beautystyle.model.entity.Job;
26 | import br.com.beautystyle.model.entity.OpeningHours;
27 | import br.com.beautystyle.model.entity.User;
28 |
29 |
30 | @Database(entities = {Customer.class, Event.class, Expense.class, Job.class, EventJobCrossRef.class,
31 | User.class, Category.class, OpeningHours.class, BlockTime.class},
32 | version = 8, exportSchema = false)
33 | @TypeConverters({LocalDateConverter.class, LocalTimeConverter.class, BigDecimalConverter.class})
34 | public abstract class BeautyStyleDatabase extends RoomDatabase {
35 |
36 | public abstract RoomCustomerDao getRoomClientDao();
37 |
38 | public abstract RoomEventDao getRoomEventDao();
39 |
40 | public abstract RoomExpenseDao getRoomExpenseDao();
41 |
42 | public abstract RoomJobDao getRoomJobDao();
43 |
44 | public abstract RoomEventWithJobsDao getRoomEventWithJobDao();
45 |
46 | public abstract RoomUserDao getRoomUserDao();
47 |
48 | public abstract RoomCategoryDao getRoomCategoryDao();
49 |
50 | public abstract RoomOpeningHoursDao getRoomOpeningHoursDao();
51 |
52 | public abstract RoomBlockTimeDao getRoomBlockTimeDao();
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/ui/fragment/report/DailyReportFragment.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.ui.fragment.report;
2 |
3 | import static br.com.beautystyle.ui.fragment.ConstantFragment.TAG_CALENDAR_VIEW;
4 |
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.EditText;
10 |
11 | import androidx.annotation.Nullable;
12 | import androidx.fragment.app.Fragment;
13 | import androidx.lifecycle.ViewModelProvider;
14 |
15 | import com.example.beautystyle.R;
16 |
17 | import java.time.LocalDate;
18 |
19 | import br.com.beautystyle.ViewModel.ReportViewModel;
20 | import br.com.beautystyle.ui.fragment.CalendarViewFragment;
21 | import br.com.beautystyle.util.CalendarUtil;
22 |
23 |
24 | public class DailyReportFragment extends Fragment {
25 |
26 | private EditText dayOfReport;
27 | private final CalendarViewFragment calendarViewFragment = new CalendarViewFragment();
28 | private ReportViewModel viewModel;
29 |
30 | @Override
31 | public void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | viewModel = new ViewModelProvider(requireParentFragment()).get(ReportViewModel.class);
34 | }
35 |
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
38 | Bundle savedInstanceState) {
39 | View inflatedView = inflater.inflate(R.layout.fragment_report_daily, container, false);
40 |
41 | setDailyReportListener(inflatedView);
42 | onCalendarClickListener();
43 |
44 | return inflatedView;
45 | }
46 |
47 | private void setDailyReportListener(View inflatedView) {
48 | dayOfReport = inflatedView.findViewById(R.id.et_fragment_report_daily_date);
49 | dayOfReport.setOnClickListener(v ->
50 | calendarViewFragment.show(getParentFragmentManager(), TAG_CALENDAR_VIEW)
51 | );
52 | }
53 |
54 | private void onCalendarClickListener() {
55 | calendarViewFragment.setOnCalendarClickListener((view, year, month, dayOfMonth) -> {
56 | CalendarUtil.selectedDate = LocalDate.of(year, month + 1, dayOfMonth);
57 | String dateFormatted = CalendarUtil.formatDateLong();
58 | dayOfReport.setText(dateFormatted);
59 | viewModel.addReportByDate();
60 | calendarViewFragment.dismiss();
61 | });
62 | }
63 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/CostumerRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.util.List;
4 |
5 | import javax.inject.Inject;
6 |
7 | import br.com.beautystyle.database.BeautyStyleDatabase;
8 | import br.com.beautystyle.database.dao.RoomCustomerDao;
9 | import br.com.beautystyle.model.entity.Customer;
10 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
11 | import io.reactivex.rxjava3.core.Completable;
12 | import io.reactivex.rxjava3.core.Observable;
13 | import io.reactivex.rxjava3.core.Single;
14 | import io.reactivex.rxjava3.schedulers.Schedulers;
15 |
16 | public class CostumerRxJava {
17 |
18 | private final RoomCustomerDao dao;
19 |
20 | @Inject
21 | public CostumerRxJava(BeautyStyleDatabase database) {
22 | dao = database.getRoomClientDao();
23 | }
24 |
25 | public Observable> getAllObservable(Long tenant) {
26 | return dao.getAllObservable(tenant)
27 | .observeOn(AndroidSchedulers.mainThread())
28 | .subscribeOn(Schedulers.io());
29 | }
30 |
31 | public Single> getAll(Long tenant) {
32 | return dao.getAll(tenant)
33 | .observeOn(AndroidSchedulers.mainThread())
34 | .subscribeOn(Schedulers.io());
35 | }
36 |
37 | public Completable insert(Customer customer) {
38 | return dao.insert(customer)
39 | .observeOn(AndroidSchedulers.mainThread())
40 | .subscribeOn(Schedulers.io());
41 | }
42 |
43 | public Completable update(Customer customer) {
44 | return dao.update(customer)
45 | .observeOn(AndroidSchedulers.mainThread())
46 | .subscribeOn(Schedulers.io());
47 | }
48 |
49 | public Single> insertAll(List response) {
50 | return dao.insertAll(response)
51 | .observeOn(AndroidSchedulers.mainThread())
52 | .subscribeOn(Schedulers.io());
53 | }
54 |
55 | public Completable delete(Customer customer) {
56 | return dao.delete(customer)
57 | .subscribeOn(Schedulers.io())
58 | .observeOn(AndroidSchedulers.mainThread());
59 | }
60 |
61 | public Completable updateAll(List updatedCustomerList) {
62 | return dao.updateAll(updatedCustomerList)
63 | .subscribeOn(Schedulers.io())
64 | .observeOn(AndroidSchedulers.mainThread());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/MoneyTextWatcher.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.widget.EditText;
6 |
7 | import java.lang.ref.WeakReference;
8 | import java.math.BigDecimal;
9 | import java.math.RoundingMode;
10 | import java.text.NumberFormat;
11 | import java.util.Locale;
12 | import java.util.Objects;
13 |
14 | public class MoneyTextWatcher implements TextWatcher {
15 |
16 | private final WeakReference editTextWeakReference;
17 | private final Locale locale = Locale.getDefault();
18 |
19 | public MoneyTextWatcher(EditText editText) {
20 | this.editTextWeakReference = new WeakReference<>(editText);
21 | }
22 |
23 | @Override
24 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
25 |
26 | }
27 |
28 | @Override
29 | public void onTextChanged(CharSequence s, int start, int before, int count) {
30 |
31 | }
32 |
33 | @Override
34 | public void afterTextChanged(Editable editable) {
35 | EditText editText = editTextWeakReference.get();
36 | if (editText == null) return;
37 | editText.removeTextChangedListener(this);
38 |
39 | BigDecimal parsed = parseToBigDecimal(editable.toString());
40 | String formatted = NumberFormat.getCurrencyInstance(locale).format(parsed);
41 | //Remove o símbolo da moeda e espaçamento pra evitar bug
42 | String replaceable = String.format("[%s\\s]", getCurrencySymbol());
43 | String cleanString = formatted.replaceAll(replaceable, "");
44 |
45 | editText.setText(cleanString);
46 | editText.setSelection(cleanString.length());
47 | editText.addTextChangedListener(this);
48 | }
49 |
50 | private BigDecimal parseToBigDecimal(String value) {
51 | String replaceable = String.format("[%s,.\\s]", getCurrencySymbol());
52 | String cleanString = value.replaceAll(replaceable, "");
53 | try {
54 | return new BigDecimal(cleanString).setScale(
55 | 2, RoundingMode.FLOOR).divide(new BigDecimal(100), RoundingMode.FLOOR);
56 | } catch (NumberFormatException e) {
57 | //ao apagar todos valores de uma só vez dava erro
58 | //Com a exception o valor retornado é 0.00
59 | return new BigDecimal(0);
60 | }
61 | }
62 |
63 | public static String getCurrencySymbol() {
64 | return Objects.requireNonNull(NumberFormat.getCurrencyInstance(Locale.getDefault())
65 | .getCurrency()).getSymbol();
66 | }
67 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_job_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
30 |
31 |
42 |
43 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/ExpenseRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import javax.inject.Inject;
7 |
8 | import br.com.beautystyle.database.BeautyStyleDatabase;
9 | import br.com.beautystyle.database.dao.RoomExpenseDao;
10 | import br.com.beautystyle.model.entity.Expense;
11 | import br.com.beautystyle.util.CalendarUtil;
12 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
13 | import io.reactivex.rxjava3.core.Completable;
14 | import io.reactivex.rxjava3.core.Single;
15 | import io.reactivex.rxjava3.schedulers.Schedulers;
16 |
17 | public class ExpenseRxJava {
18 |
19 | private final RoomExpenseDao dao;
20 |
21 | @Inject
22 | public ExpenseRxJava(BeautyStyleDatabase database) {
23 | dao = database.getRoomExpenseDao();
24 | }
25 |
26 | public Single insert(Expense expense) {
27 | return dao.insert(expense)
28 | .subscribeOn(Schedulers.io())
29 | .observeOn(AndroidSchedulers.mainThread());
30 | }
31 |
32 | public Completable update(Expense expense) {
33 | return dao.update(expense)
34 | .subscribeOn(Schedulers.io())
35 | .observeOn(AndroidSchedulers.mainThread());
36 |
37 | }
38 |
39 | public Completable delete(Expense expense) {
40 | return dao.delete(expense)
41 | .subscribeOn(Schedulers.io())
42 | .observeOn(AndroidSchedulers.mainThread());
43 | }
44 |
45 | public Single> insertAll(List response) {
46 | return dao.insertAll(response)
47 | .subscribeOn(Schedulers.io())
48 | .observeOn(AndroidSchedulers.mainThread());
49 | }
50 |
51 | public Single> getByPeriod(LocalDate startDate,
52 | LocalDate endDate,
53 | Long tenant) {
54 | return dao.getByPeriod(startDate, endDate, tenant)
55 | .subscribeOn(Schedulers.io())
56 | .observeOn(AndroidSchedulers.mainThread());
57 | }
58 |
59 | public Single> getYearsList(Long tenant) {
60 | return dao.getYearsList(tenant)
61 | .subscribeOn(Schedulers.io())
62 | .observeOn(AndroidSchedulers.mainThread());
63 | }
64 |
65 | public Single> getByDate(Long tenant) {
66 | return dao.getByDate(CalendarUtil.selectedDate,tenant)
67 | .subscribeOn(Schedulers.io())
68 | .observeOn(AndroidSchedulers.mainThread());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/webclient/BlockTimeWebClient.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.webclient;
2 |
3 | import static br.com.beautystyle.repository.ConstantsRepository.TOKEN_SHARED_PREFERENCES;
4 |
5 | import android.content.SharedPreferences;
6 |
7 | import javax.inject.Inject;
8 |
9 | import br.com.beautystyle.model.entity.BlockTime;
10 | import br.com.beautystyle.repository.ResultsCallBack;
11 | import br.com.beautystyle.retrofit.callback.CallBackReturn;
12 | import br.com.beautystyle.retrofit.callback.CallBackWithoutReturn;
13 | import br.com.beautystyle.retrofit.service.BlockTimeService;
14 | import retrofit2.Call;
15 |
16 | public class BlockTimeWebClient {
17 |
18 | @Inject
19 | BlockTimeService service;
20 | private final String token;
21 |
22 | @Inject
23 | public BlockTimeWebClient(SharedPreferences preferences) {
24 | token = preferences.getString(TOKEN_SHARED_PREFERENCES, "");
25 | }
26 |
27 | public void insert(BlockTime blockTime, ResultsCallBack callBack) {
28 | Call insert = service.insert(blockTime, token);
29 | insert.enqueue(new CallBackReturn<>(new CallBackReturn.CallBackResponse() {
30 | @Override
31 | public void onSuccess(BlockTime response) {
32 | callBack.onSuccess(response);
33 | }
34 |
35 | @Override
36 | public void onError(String error) {
37 | callBack.onError(error);
38 | }
39 | }));
40 | }
41 |
42 | public void delete(Long apiId, ResultsCallBack callBack) {
43 | Call callDelete = service.delete(apiId, token);
44 | callDelete.enqueue(new CallBackWithoutReturn(new CallBackWithoutReturn.CallBackResponse() {
45 | @Override
46 | public void onSuccess() {
47 | callBack.onSuccess(null);
48 | }
49 |
50 | @Override
51 | public void onError(String erro) {
52 | callBack.onError(erro);
53 | }
54 | }));
55 | }
56 |
57 | public void update(BlockTime blockTime, ResultsCallBack callBack) {
58 | Call callUpdate = service.update(blockTime.getApiId(), blockTime, token);
59 | callUpdate.enqueue(new CallBackWithoutReturn(new CallBackWithoutReturn.CallBackResponse() {
60 | @Override
61 | public void onSuccess() {
62 | callBack.onSuccess(null);
63 | }
64 |
65 | @Override
66 | public void onError(String erro) {
67 | callBack.onError(erro);
68 | }
69 | }));
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/Expense.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import androidx.room.Entity;
4 | import androidx.room.PrimaryKey;
5 |
6 | import java.io.Serializable;
7 | import java.math.BigDecimal;
8 | import java.time.LocalDate;
9 | import java.util.List;
10 |
11 | @Entity
12 | public class Expense implements Serializable {
13 |
14 | @PrimaryKey(autoGenerate = true)
15 | private Long id;
16 | private String description;
17 | private BigDecimal value;
18 | private LocalDate expenseDate;
19 | private String category;
20 | private boolean repeat;
21 | private Long tenant;
22 | private Long apiId;
23 |
24 | public Long getApiId() {
25 | return apiId;
26 | }
27 |
28 | public void setApiId(Long apiId) {
29 | this.apiId = apiId;
30 | }
31 |
32 | public Long getTenant() {
33 | return tenant;
34 | }
35 |
36 | public void setTenant(Long tenant) {
37 | this.tenant = tenant;
38 | }
39 |
40 | public Long getId() {
41 | return id;
42 | }
43 |
44 | public void setId(Long id) {
45 | this.id = id;
46 | }
47 |
48 | public String getCategory() {
49 | return category;
50 | }
51 |
52 | public void setCategory(String category) {
53 | this.category = category;
54 | }
55 |
56 | public String getDescription() {
57 | return description;
58 | }
59 |
60 | public void setDescription(String description) {
61 | this.description = description;
62 | }
63 |
64 | public BigDecimal getValue() {
65 | return value;
66 | }
67 |
68 | public void setValue(BigDecimal value) {
69 | this.value = value;
70 | }
71 |
72 | public LocalDate getExpenseDate() {
73 | return expenseDate;
74 | }
75 |
76 | public void setExpenseDate(LocalDate expenseDate) {
77 | this.expenseDate = expenseDate;
78 | }
79 |
80 | public boolean isRepeat() {
81 | return repeat;
82 | }
83 |
84 | public void setRepeat(boolean repeat) {
85 | this.repeat = repeat;
86 | }
87 |
88 | public boolean isNotExistOnApi(List expensesFromApi) {
89 | if(this.apiId == null) return true;
90 |
91 | for (Expense fromApi : expensesFromApi) {
92 | if (this.apiId.equals(fromApi.getApiId())) {
93 | return false;
94 | }
95 | }
96 | return true;
97 | }
98 |
99 | public boolean isApiIdEquals(Expense expenseFromApi) {
100 | return apiId != null && apiId.equals(expenseFromApi.getApiId());
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_loading_buttom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
34 |
35 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_list_event.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
21 |
22 |
31 |
44 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/rxjava/EventRxJava.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.rxjava;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import javax.inject.Inject;
7 |
8 | import br.com.beautystyle.database.BeautyStyleDatabase;
9 | import br.com.beautystyle.database.dao.RoomEventDao;
10 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
11 | import br.com.beautystyle.model.entity.Event;
12 | import br.com.beautystyle.util.CalendarUtil;
13 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
14 | import io.reactivex.rxjava3.core.Completable;
15 | import io.reactivex.rxjava3.core.Single;
16 | import io.reactivex.rxjava3.schedulers.Schedulers;
17 |
18 | public class EventRxJava {
19 | private final RoomEventDao dao;
20 |
21 | @Inject
22 | public EventRxJava(BeautyStyleDatabase database) {
23 | dao = database.getRoomEventDao();
24 | }
25 |
26 | public Single> getByDate(Long tenant) {
27 | return dao.getByDate(CalendarUtil.selectedDate, tenant)
28 | .observeOn(AndroidSchedulers.mainThread())
29 | .subscribeOn(Schedulers.io());
30 | }
31 |
32 | public Single insert(Event event) {
33 | return dao.insert(event)
34 | .observeOn(AndroidSchedulers.mainThread())
35 | .subscribeOn(Schedulers.io());
36 | }
37 |
38 | public Completable update(Event event) {
39 | return dao.update(event)
40 | .observeOn(AndroidSchedulers.mainThread())
41 | .subscribeOn(Schedulers.io());
42 | }
43 |
44 | public Single> insertAll(List events) {
45 | return dao.insertAll(events)
46 | .observeOn(AndroidSchedulers.mainThread())
47 | .subscribeOn(Schedulers.io());
48 | }
49 |
50 | public Completable delete(Event event) {
51 | return dao.delete(event)
52 | .subscribeOn(Schedulers.io())
53 | .observeOn(AndroidSchedulers.mainThread());
54 | }
55 |
56 | public Completable updateAll(List events) {
57 | return dao.updateAll(events)
58 | .subscribeOn(Schedulers.io())
59 | .observeOn(AndroidSchedulers.mainThread());
60 | }
61 |
62 | public Single> getByPeriod(LocalDate startDate,
63 | LocalDate endDate,
64 | Long tenant) {
65 | return dao.getByPeriod(startDate, endDate, tenant)
66 | .subscribeOn(Schedulers.io())
67 | .observeOn(AndroidSchedulers.mainThread());
68 | }
69 |
70 | public Single> getYearsList(Long tenant) {
71 | return dao.getYearsList(tenant)
72 | .subscribeOn(Schedulers.io())
73 | .observeOn(AndroidSchedulers.mainThread());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdk 31
7 |
8 | defaultConfig {
9 | applicationId "com.example.beautystyle"
10 | minSdk 26
11 | targetSdk 31
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | compileOptions {
24 | sourceCompatibility 1.8
25 | targetCompatibility 1.8
26 | }
27 | buildFeatures {
28 | viewBinding true
29 | }
30 | compileSdkVersion 31
31 | }
32 |
33 | dependencies {
34 |
35 | def room_version = "2.4.3"
36 | def view_model_version = "2.5.0"
37 |
38 | //room
39 | implementation "androidx.room:room-runtime:$room_version"
40 | annotationProcessor "androidx.room:room-compiler:$room_version"
41 | implementation "androidx.room:room-rxjava3:$room_version"
42 | implementation "androidx.room:room-common:$room_version"
43 |
44 | implementation 'com.android.support.constraint:constraint-layout:2.0.4'
45 | implementation 'androidx.appcompat:appcompat:1.4.2'
46 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
47 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
48 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
49 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$view_model_version"
50 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$view_model_version"
51 | implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$view_model_version"
52 | implementation "androidx.work:work-runtime:2.7.1"
53 | implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
54 | implementation 'com.google.android.material:material:1.6.0'
55 | implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
56 | implementation 'com.google.code.gson:gson:2.9.0'
57 | implementation 'com.google.android.gms:play-services-auth:20.2.0'
58 |
59 | implementation 'com.google.dagger:dagger:2.42'
60 | annotationProcessor 'com.google.dagger:dagger-compiler:2.42'
61 |
62 | testImplementation 'junit:junit:'
63 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
64 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
65 |
66 | implementation 'com.squareup.retrofit2:retrofit:2.9.0'
67 | implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
68 | implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"
69 |
70 | implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
71 | // implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2'
72 | implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'
73 |
74 | // implementation 'androidx.security:security-crypto:1.0.0-alpha03'
75 |
76 | }
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/database/references/EventWithClientAndJobs.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.database.references;
2 |
3 | import androidx.room.Embedded;
4 | import androidx.room.Ignore;
5 | import androidx.room.Junction;
6 | import androidx.room.Relation;
7 |
8 | import java.io.Serializable;
9 | import java.time.LocalTime;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import br.com.beautystyle.model.entity.BlockTime;
14 | import br.com.beautystyle.model.entity.Customer;
15 | import br.com.beautystyle.model.entity.Event;
16 | import br.com.beautystyle.model.entity.EventJobCrossRef;
17 | import br.com.beautystyle.model.entity.Job;
18 | import br.com.beautystyle.retrofit.model.form.EventForm;
19 |
20 | public class EventWithClientAndJobs implements Serializable {
21 |
22 | @Embedded
23 | public Event event = new Event();
24 |
25 | @Relation(
26 | parentColumn = "customerCreatorId",
27 | entityColumn = "id"
28 | )
29 | private Customer customer = new Customer();
30 |
31 | @Relation(
32 | parentColumn = "eventId",
33 | entityColumn = "jobId",
34 | associateBy = @Junction(EventJobCrossRef.class)
35 | )
36 | public List jobs = new ArrayList<>();
37 |
38 | @Ignore
39 | private BlockTime blockTime;
40 |
41 | public EventWithClientAndJobs() {
42 | }
43 |
44 | @Ignore
45 | public EventWithClientAndJobs(LocalTime startTime) {
46 | this.event = new Event(startTime);
47 | }
48 |
49 | @Ignore
50 | public EventWithClientAndJobs(EventForm eventForm) {
51 | this.event = getEvent();
52 | }
53 |
54 | public Customer getCustomer() {
55 | return customer;
56 | }
57 |
58 | public void setCustomer(Customer customer) {
59 | this.customer = customer;
60 | }
61 |
62 | public Event getEvent() {
63 | return event;
64 | }
65 |
66 | public List getJobs() {
67 | return jobs;
68 | }
69 |
70 | public void setJobs(List jobs) {
71 | this.jobs = jobs;
72 | }
73 |
74 | public void setEvent(Event event) {
75 | this.event = event;
76 | }
77 |
78 | public boolean isEventNotNull() {
79 | return event.isEventIdNotNull();
80 | }
81 |
82 | public boolean isApiIdEquals(EventWithClientAndJobs eventFromApi) {
83 | return event.isApiIdEquals(eventFromApi.getEvent().getApiId());
84 | }
85 |
86 | public boolean isNotOver() {
87 | return event.isNotOver();
88 | }
89 |
90 | public boolean isUserCustomer() {
91 | return customer.isUser();
92 | }
93 |
94 | public BlockTime getBlockTime() {
95 | return blockTime;
96 | }
97 |
98 | public void setBlockTime(BlockTime blockTime) {
99 | this.blockTime = blockTime;
100 | }
101 |
102 | public boolean isBlockTimeNotNull() {
103 | return blockTime!=null;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_report.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
20 |
23 |
24 |
35 |
36 |
47 |
48 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_list_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
28 |
29 |
40 |
41 |
51 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/model/entity/Job.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.model.entity;
2 |
3 | import androidx.room.ColumnInfo;
4 | import androidx.room.Entity;
5 | import androidx.room.Ignore;
6 | import androidx.room.PrimaryKey;
7 |
8 | import java.io.Serializable;
9 | import java.math.BigDecimal;
10 | import java.time.LocalTime;
11 | import java.util.List;
12 | import java.util.Objects;
13 |
14 | @Entity
15 | public class Job implements Serializable {
16 |
17 | @PrimaryKey(autoGenerate = true)
18 | @ColumnInfo(name = "jobId")
19 | private Long id;
20 | private String name;
21 | private BigDecimal price;
22 | private LocalTime durationTime;
23 | private Long tenant;
24 | private Long apiId;
25 |
26 | @Ignore
27 | public Job(String name, BigDecimal valueOfJob, LocalTime durationTime) {
28 | this.name = name;
29 | this.price = valueOfJob;
30 | this.durationTime = durationTime;
31 | }
32 |
33 | public Job() {
34 | }
35 |
36 |
37 | public Long getApiId() {
38 | return apiId;
39 | }
40 |
41 | public void setApiId(Long apiId) {
42 | this.apiId = apiId;
43 | }
44 |
45 | public Long getTenant() {
46 | return tenant;
47 | }
48 |
49 | public void setTenant(Long tenant) {
50 | this.tenant = tenant;
51 | }
52 |
53 | public Long getId() {
54 | return id;
55 | }
56 |
57 | public void setId(Long id) {
58 | this.id = id;
59 | }
60 |
61 | public String getName() {
62 | return name;
63 | }
64 |
65 | public BigDecimal getPrice() {
66 | return price;
67 | }
68 |
69 | public LocalTime getDurationTime() {
70 | return durationTime;
71 | }
72 |
73 | public void setName(String name) {
74 | this.name = name;
75 | }
76 |
77 | public void setPrice(BigDecimal price) {
78 | this.price = price;
79 | }
80 |
81 | public void setDurationTime(LocalTime durationTime) {
82 | this.durationTime = durationTime;
83 | }
84 |
85 | public boolean isIdNotNull() {
86 | return id != null;
87 | }
88 |
89 | @Override
90 | public boolean equals(Object o) {
91 | if (this == o) return true;
92 | if (o == null || getClass() != o.getClass()) return false;
93 | Job job = (Job) o;
94 | return Objects.equals(id, job.id) && Objects.equals(name, job.name) && Objects.equals(price, job.price) && Objects.equals(durationTime, job.durationTime) && Objects.equals(tenant, job.tenant) && Objects.equals(apiId, job.apiId);
95 | }
96 |
97 | @Override
98 | public int hashCode() {
99 | return Objects.hash(id, name, price, durationTime, tenant, apiId);
100 | }
101 |
102 | public boolean isNotExistOnApi(List jobsFromApi) {
103 | for (Job jobFromApi : jobsFromApi) {
104 | if (this.apiId.equals(jobFromApi.getApiId())) {
105 | return false;
106 | }
107 | }
108 | return true;
109 | }
110 |
111 | public boolean isApiIdEquals(Job jobApi) {
112 | return apiId != null && apiId.equals(jobApi.getApiId());
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/util/CreateListsUtil.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.util;
2 |
3 | import androidx.lifecycle.LiveData;
4 | import androidx.lifecycle.MutableLiveData;
5 |
6 | import java.time.LocalTime;
7 | import java.time.Month;
8 | import java.time.format.TextStyle;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Locale;
12 |
13 | import br.com.beautystyle.database.references.EventWithClientAndJobs;
14 |
15 | public class CreateListsUtil {
16 |
17 | public static List events;
18 | private static LocalTime startTime;
19 | private static LocalTime endTime;
20 |
21 | public static void createEventList(List eventWithJobs) {
22 | createEmptyEventList();
23 | if (eventWithJobs.size() >= 1) {
24 | updateEventList(eventWithJobs);
25 | }
26 | }
27 |
28 | private static void createEmptyEventList() {
29 | setFirstAnLastTimeDefault();
30 | events = new ArrayList<>();
31 | do {
32 | EventWithClientAndJobs event = new EventWithClientAndJobs(startTime);
33 | events.add(event);
34 | startTime = startTime.plusMinutes(30);
35 | } while (!startTime.equals(endTime));
36 | }
37 |
38 | private static void updateEventList(List eventWithJobsByDate) {
39 | for (EventWithClientAndJobs foundEvent : eventWithJobsByDate) {
40 | boolean matched = false;
41 | for (int i = 0; i < events.size(); i++) {
42 | if (foundEvent.getEvent().getStartTime()
43 | .equals(events.get(i).getEvent().getStartTime())) {
44 | events.set(i, foundEvent);
45 | events.removeIf(ev -> ev.getEvent().getStartTime().isAfter(foundEvent.getEvent().getStartTime())
46 | & ev.getEvent().getStartTime().isBefore(foundEvent.getEvent().getEndTime()));
47 | matched = true;
48 | }
49 |
50 | }
51 | if (!matched) {
52 | events.add(foundEvent);
53 | events.removeIf(ev -> ev.getEvent().getStartTime().isAfter(foundEvent.getEvent().getStartTime())
54 | & ev.getEvent().getStartTime().isBefore(foundEvent.getEvent().getEndTime()));
55 | }
56 | }
57 | events.sort(new SortByEventStartTime());
58 | }
59 |
60 | private static void setFirstAnLastTimeDefault() {
61 | startTime = LocalTime.of(7, 30);
62 | endTime = LocalTime.of(20, 0);
63 | }
64 |
65 | public static LiveData> createMonthsList() {
66 | MutableLiveData> liveData = new MutableLiveData<>();
67 | List months = getMonths();
68 | liveData.setValue(months);
69 | return liveData;
70 | }
71 |
72 | public static List getMonths(){
73 | List months = new ArrayList<>();
74 | for (int monthValue = 1; monthValue <= 12; monthValue++) {
75 | String month =
76 | Month.of(monthValue).getDisplayName(TextStyle.FULL,new Locale("pt","br"));
77 | months.add(month);
78 | }
79 | return months;
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/java/br/com/beautystyle/retrofit/webclient/ReportWebClient.java:
--------------------------------------------------------------------------------
1 | package br.com.beautystyle.retrofit.webclient;
2 |
3 | import static br.com.beautystyle.repository.ConstantsRepository.TENANT_SHARED_PREFERENCES;
4 | import static br.com.beautystyle.repository.ConstantsRepository.TOKEN_SHARED_PREFERENCES;
5 |
6 | import android.content.SharedPreferences;
7 |
8 | import java.time.LocalDate;
9 | import java.util.List;
10 |
11 | import javax.inject.Inject;
12 |
13 | import br.com.beautystyle.model.util.Report;
14 | import br.com.beautystyle.repository.ResultsCallBack;
15 | import br.com.beautystyle.retrofit.callback.CallBackReturn;
16 | import br.com.beautystyle.retrofit.service.ReportService;
17 | import retrofit2.Call;
18 |
19 | public class ReportWebClient {
20 | @Inject
21 | ReportService service;
22 | private final String token;
23 | private final Long tenant;
24 |
25 | @Inject
26 | public ReportWebClient(SharedPreferences preferences) {
27 | token = preferences.getString(TOKEN_SHARED_PREFERENCES, "");
28 | tenant = preferences.getLong(TENANT_SHARED_PREFERENCES, 0);
29 | }
30 |
31 | public void getReportByPeriod(LocalDate startDate, LocalDate endDate,
32 | ResultsCallBack> callBack) {
33 | Call> callReportByPeriod =
34 | service.getReportByPeriod(startDate, endDate, tenant, token);
35 | callReportByPeriod.enqueue(new CallBackReturn<>(
36 | new CallBackReturn.CallBackResponse>() {
37 | @Override
38 | public void onSuccess(List response) {
39 | callBack.onSuccess(response);
40 | }
41 |
42 | @Override
43 | public void onError(String error) {
44 | callBack.onError(error);
45 | }
46 | }));
47 | }
48 |
49 | public void getYearsList(ResultsCallBack> callBack) {
50 | Call> callYearsList = service.getYearsList(tenant, token);
51 | callYearsList.enqueue(new CallBackReturn<>(new CallBackReturn.CallBackResponse>() {
52 | @Override
53 | public void onSuccess(List response) {
54 | callBack.onSuccess(response);
55 | }
56 |
57 | @Override
58 | public void onError(String error) {
59 | callBack.onError(error);
60 | }
61 | }));
62 | }
63 |
64 | public void getReportByDate( LocalDate date, ResultsCallBack> callBack) {
65 | Call> callReportByPeriod =
66 | service.getReportByDate(date, tenant, token);
67 | callReportByPeriod.enqueue(new CallBackReturn<>(
68 | new CallBackReturn.CallBackResponse>() {
69 | @Override
70 | public void onSuccess(List response) {
71 | callBack.onSuccess(response);
72 | }
73 |
74 | @Override
75 | public void onError(String error) {
76 | callBack.onError(error);
77 | }
78 | }));
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_new_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
28 |
29 |
39 |
40 |
54 |
55 |
68 |
69 |
--------------------------------------------------------------------------------