Skip to content

Commit

Permalink
Alarms manager issue #35 (#54)
Browse files Browse the repository at this point in the history
* Prepare code for add alarms to realm from other tabs (#29)

* Add initial EventBus setup

* Refactor Alarm classess, remove add item to alarm option for now

* Add more dependencies to .gitignore

* Resolve 2 issues (#31)

* Add feature: double back press to exit, Issue #17

* Apply style for TimePicker in dark mode, Issue #8

* Change ic_access_alarm foreground color, Issue #2 (#36)

* Fix bug with navigation bar, solve issue #32 (#37)

* Add informative toast, issue #16 (#39)

* Set screen orientation to portrait only in all activities, issue #38 (#40)

* Issue/#42 (#44)

* Change TAGs to match theirs class names

* Refactor ItemBuilder classes to make them consistent and cleaner

* Refactor count down function in MainContract to make it functionality easier to understand

* Change names of items builder classes

* Fix issue #42

*  Refactor ItemBuilders, Add save state of list feature, Fix unit tests, a
dd more unit test

* Clean a code

* Add temporary solution for showTheClosestAlarmToDefinedHour()

* Fix issue #42

* Add Issue #45 feature, make WakeUpAt's layout dynamic (#47)

* Remove redundant layout file

* Add basic animation implementation

* Change list layout from static to dynamic

* Update layout (#49)

* Fix wake up at layout

* Remove image

* Replace constraint layout in cardListView to Linear

* Replace ImageView with FrameLayout

* Add emptyListPlaceholderStyle

* Add empty list image to alarms, make the recyclerView layout dynamic

* Center toolbarTitle textView horizontally to match overflow menu

* Add padding to sleep now list

* WakeUpAt code rearrangement (#51)

* Refactor onActivityCreated function in WakeUpAtPresenter

* Rearange code contract for WakeUpAt view and presenter

* Clean view from business logic and move everything business-like to the presenter

* Remove redundant function

* Items builder improvement (#52)

* Implement strategy pattern for ItemsBuilder, Add tests

* Add more tests that covers all opportunities

* Add info about method of naming convention

* Add more tests in getSummaryTests

* Change code structure of Alarms to dual Contract MVP

* Add AlarmManager, refactor AlarmsPresenter

* Create simple subscriber to set alarm event

* Implement show and hide UI elements system at Alarms tab

* Improve realm connections over app, add onRealmChangeListener to Alarms tab

* Add WakeUpAt subscriber to connect with alarm manager

* Create MyViewManager to avoid repeating myself

* Refactor methods to hide/show at WakeUpAtFragment, move MyViewManager to the utility directory
  • Loading branch information
letelete committed Sep 22, 2018
1 parent a6f8bce commit eadcf48
Show file tree
Hide file tree
Showing 64 changed files with 1,918 additions and 768 deletions.
67 changes: 67 additions & 0 deletions SleepCycleAlarm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,70 @@
/build
/captures
.externalNativeBuild

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

105 changes: 0 additions & 105 deletions SleepCycleAlarm/.idea/assetWizardSettings.xml

This file was deleted.

Binary file removed SleepCycleAlarm/.idea/caches/build_file_checksums.ser
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.gmail.brunokawka.poland.sleepcyclealarm;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

public class TestsHelper {
public static DateTime getDateTimeFromString(String executionHour) {
return DateTimeFormat.forPattern("dd/MM/yyyy HH:mm").parseDateTime(executionHour);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.gmail.brunokawka.poland.sleepcyclealarm.utils.ItemContentBuilderTests;

import com.gmail.brunokawka.poland.sleepcyclealarm.TestsHelper;
import com.gmail.brunokawka.poland.sleepcyclealarm.data.ItemsBuilderData;
import com.gmail.brunokawka.poland.sleepcyclealarm.utils.ItemContentBuilder;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

// This class uses the following naming convention:
// Should_ExpectedBehavior_When_StateUnderTest

@RunWith(MockitoJUnitRunner.class)
public class getSummaryTest {

private static final String CURRENT_DATE_STRING = "01/01/1111 22:20";

private static final List<String> SUMMARY_VARIABLES_FOR_CURRENT_DATE_EQUALS_2220 = Arrays.asList(
"02/01/1111 00:05", "1h 30min", "Unhealthy",
"02/01/1111 01:35", "3h", "Unhealthy",
"02/01/1111 03:05", "4h 30min", "Optimal",
"02/01/1111 04:35", "6h", "Optimal",
"02/01/1111 06:05", "7h 30min", "Healthy",
"02/01/1111 07:35", "9h", "Healthy",
"02/01/1111 09:05", "10h 30min", "Not recommended",
"02/01/1111 10:35", "12h", "Not recommended"
);

@Test
public void testIfCanReturnSummaries() {
int amountOfUsedItemsOnOneLoopRun = 3;
int maxIndex = SUMMARY_VARIABLES_FOR_CURRENT_DATE_EQUALS_2220.size() - 1;

for (int index = 0; index < maxIndex; index += amountOfUsedItemsOnOneLoopRun) {
String executionDateString = SUMMARY_VARIABLES_FOR_CURRENT_DATE_EQUALS_2220.get(index);
String sleepDurationString = SUMMARY_VARIABLES_FOR_CURRENT_DATE_EQUALS_2220.get(index+1);
String sleepQuality = SUMMARY_VARIABLES_FOR_CURRENT_DATE_EQUALS_2220.get(index+2);

String expected = String.format("%1$s of sleep, %2$s", sleepDurationString, sleepQuality);
assertEquals(expected, ItemContentBuilder.getSummary(
TestsHelper.getDateTimeFromString(CURRENT_DATE_STRING),
TestsHelper.getDateTimeFromString(executionDateString).minusMinutes(ItemsBuilderData.getTimeForFallAsleepInMinutes())));
}
}
}

0 comments on commit eadcf48

Please sign in to comment.