diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..21eddff --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,163 @@ + + + + + + \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..04f69db Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_activity_activity_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_activity_activity_1_1_0_aar.xml new file mode 100644 index 0000000..7d98d7a --- /dev/null +++ b/.idea/libraries/Gradle__androidx_activity_activity_1_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml new file mode 100644 index 0000000..5b17db6 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml new file mode 100644 index 0000000..d7142d4 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml new file mode 100644 index 0000000..95e53cf --- /dev/null +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0_jar.xml b/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0_jar.xml new file mode 100644 index 0000000..a7f501b --- /dev/null +++ b/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml new file mode 100644 index 0000000..b449ea7 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml new file mode 100644 index 0000000..489fa02 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_browser_browser_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_browser_browser_1_2_0_aar.xml new file mode 100644 index 0000000..67edf8e --- /dev/null +++ b/.idea/libraries/Gradle__androidx_browser_browser_1_2_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml new file mode 100644 index 0000000..3a44276 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_collection_collection_1_1_0_jar.xml b/.idea/libraries/Gradle__androidx_collection_collection_1_1_0_jar.xml new file mode 100644 index 0000000..ecb16c3 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_collection_collection_1_1_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_0_beta4_aar.xml b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_0_beta4_aar.xml new file mode 100644 index 0000000..67cd1f7 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_0_beta4_aar.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_0_beta4_jar.xml b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_0_beta4_jar.xml new file mode 100644 index 0000000..472f3c3 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_0_beta4_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml new file mode 100644 index 0000000..96f6e75 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_core_core_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_core_core_1_2_0_aar.xml new file mode 100644 index 0000000..a277822 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_core_core_1_2_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_aar.xml new file mode 100644 index 0000000..80b0abf --- /dev/null +++ b/.idea/libraries/Gradle__androidx_core_core_ktx_1_2_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml new file mode 100644 index 0000000..904db18 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml new file mode 100644 index 0000000..cd62c9b --- /dev/null +++ b/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml new file mode 100644 index 0000000..29be843 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml new file mode 100644 index 0000000..a585b95 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_fragment_fragment_1_2_4_aar.xml b/.idea/libraries/Gradle__androidx_fragment_fragment_1_2_4_aar.xml new file mode 100644 index 0000000..a944c2c --- /dev/null +++ b/.idea/libraries/Gradle__androidx_fragment_fragment_1_2_4_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml new file mode 100644 index 0000000..0e1a6a3 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml new file mode 100644 index 0000000..445c8f7 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml new file mode 100644 index 0000000..006b2cf --- /dev/null +++ b/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml new file mode 100644 index 0000000..32e6a15 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_2_0_jar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_2_0_jar.xml new file mode 100644 index 0000000..26073f8 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_2_0_jar.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml new file mode 100644 index 0000000..e6905c3 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_2_0_aar.xml new file mode 100644 index 0000000..86186e4 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_2_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_2_0_aar.xml new file mode 100644 index 0000000..e249ef8 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_2_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_2_0_aar.xml new file mode 100644 index 0000000..bbd78f0 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_2_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_2_0_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_2_0_aar.xml new file mode 100644 index 0000000..4401e09 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_2_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml new file mode 100644 index 0000000..3e562d5 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml new file mode 100644 index 0000000..cf42a46 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml new file mode 100644 index 0000000..f8aef71 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_preference_preference_1_1_1_aar.xml b/.idea/libraries/Gradle__androidx_preference_preference_1_1_1_aar.xml new file mode 100644 index 0000000..0852ec6 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_preference_preference_1_1_1_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml new file mode 100644 index 0000000..bac076a --- /dev/null +++ b/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml new file mode 100644 index 0000000..d32b781 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml new file mode 100644 index 0000000..1384ea1 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml new file mode 100644 index 0000000..d651c99 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml new file mode 100644 index 0000000..54b865e --- /dev/null +++ b/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml new file mode 100644 index 0000000..8e40783 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_core_1_2_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml new file mode 100644 index 0000000..02afff6 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_2_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml new file mode 100644 index 0000000..b0c6b31 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_2_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml new file mode 100644 index 0000000..998e8d6 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_1_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml new file mode 100644 index 0000000..eaaac21 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_monitor_1_2_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml new file mode 100644 index 0000000..3fb0123 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_test_runner_1_2_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml b/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml new file mode 100644 index 0000000..e01728f --- /dev/null +++ b/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml new file mode 100644 index 0000000..8185de8 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml new file mode 100644 index 0000000..1358957 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml new file mode 100644 index 0000000..9f85bb4 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml new file mode 100644 index 0000000..10958b2 --- /dev/null +++ b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml new file mode 100644 index 0000000..fa491eb --- /dev/null +++ b/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_afollestad_material_dialogs_commons_0_9_6_0_aar.xml b/.idea/libraries/Gradle__com_afollestad_material_dialogs_commons_0_9_6_0_aar.xml new file mode 100644 index 0000000..284a0d8 --- /dev/null +++ b/.idea/libraries/Gradle__com_afollestad_material_dialogs_commons_0_9_6_0_aar.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_afollestad_material_dialogs_core_0_9_6_0_aar.xml b/.idea/libraries/Gradle__com_afollestad_material_dialogs_core_0_9_6_0_aar.xml new file mode 100644 index 0000000..d0b6b27 --- /dev/null +++ b/.idea/libraries/Gradle__com_afollestad_material_dialogs_core_0_9_6_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_IamIsPra_Sheriff_1_0_0_aar.xml b/.idea/libraries/Gradle__com_github_IamIsPra_Sheriff_1_0_0_aar.xml new file mode 100644 index 0000000..4b9a338 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_IamIsPra_Sheriff_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_Pradyuman7_ChocoBar_V1_0_aar.xml b/.idea/libraries/Gradle__com_github_Pradyuman7_ChocoBar_V1_0_aar.xml new file mode 100644 index 0000000..a97424a --- /dev/null +++ b/.idea/libraries/Gradle__com_github_Pradyuman7_ChocoBar_V1_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_a1d628430b_jar.xml b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_a1d628430b_jar.xml new file mode 100644 index 0000000..58dc077 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_a1d628430b_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_base_a1d628430b_aar.xml b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_base_a1d628430b_aar.xml new file mode 100644 index 0000000..78ca798 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_base_a1d628430b_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_imagepicker_a1d628430b_aar.xml b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_imagepicker_a1d628430b_aar.xml new file mode 100644 index 0000000..f7e1523 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_ColorPickerDialog_imagepicker_a1d628430b_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_SQLite2XL_88883cf56d_aar.xml b/.idea/libraries/Gradle__com_github_asdoi_SQLite2XL_88883cf56d_aar.xml new file mode 100644 index 0000000..8f14fd1 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_SQLite2XL_88883cf56d_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_TimetableUI_2d9340ce8c_aar.xml b/.idea/libraries/Gradle__com_github_asdoi_TimetableUI_2d9340ce8c_aar.xml new file mode 100644 index 0000000..a0559c4 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_TimetableUI_2d9340ce8c_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_asdoi_TimetableView_master_SNAPSHOT_aar.xml b/.idea/libraries/Gradle__com_github_asdoi_TimetableView_master_SNAPSHOT_aar.xml new file mode 100644 index 0000000..d788562 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_asdoi_TimetableView_master_SNAPSHOT_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_github_stephenvinouze_shapetextdrawable_1_0_0_aar.xml b/.idea/libraries/Gradle__com_github_stephenvinouze_shapetextdrawable_1_0_0_aar.xml new file mode 100644 index 0000000..fc892b7 --- /dev/null +++ b/.idea/libraries/Gradle__com_github_stephenvinouze_shapetextdrawable_1_0_0_aar.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml b/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml new file mode 100644 index 0000000..829f9c0 --- /dev/null +++ b/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml new file mode 100644 index 0000000..947e251 --- /dev/null +++ b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_google_guava_listenablefuture_1_0_jar.xml b/.idea/libraries/Gradle__com_google_guava_listenablefuture_1_0_jar.xml new file mode 100644 index 0000000..ff7f767 --- /dev/null +++ b/.idea/libraries/Gradle__com_google_guava_listenablefuture_1_0_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_8_1_2_aar.xml b/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_8_1_2_aar.xml new file mode 100644 index 0000000..14c02cf --- /dev/null +++ b/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_8_1_2_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_core_8_1_2_aar.xml b/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_core_8_1_2_aar.xml new file mode 100644 index 0000000..ce9416f --- /dev/null +++ b/.idea/libraries/Gradle__com_mikepenz_aboutlibraries_core_8_1_2_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_mikepenz_fastadapter_5_0_0_aar.xml b/.idea/libraries/Gradle__com_mikepenz_fastadapter_5_0_0_aar.xml new file mode 100644 index 0000000..0a179f9 --- /dev/null +++ b/.idea/libraries/Gradle__com_mikepenz_fastadapter_5_0_0_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml new file mode 100644 index 0000000..f97c138 --- /dev/null +++ b/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__commons_codec_commons_codec_1_10_jar.xml b/.idea/libraries/Gradle__commons_codec_commons_codec_1_10_jar.xml new file mode 100644 index 0000000..7a00e0b --- /dev/null +++ b/.idea/libraries/Gradle__commons_codec_commons_codec_1_10_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml b/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml new file mode 100644 index 0000000..5ac7d7b --- /dev/null +++ b/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__junit_junit_4_12_jar.xml b/.idea/libraries/Gradle__junit_junit_4_12_jar.xml new file mode 100644 index 0000000..24e5b72 --- /dev/null +++ b/.idea/libraries/Gradle__junit_junit_4_12_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__junit_junit_4_13_jar.xml b/.idea/libraries/Gradle__junit_junit_4_13_jar.xml new file mode 100644 index 0000000..bf50f62 --- /dev/null +++ b/.idea/libraries/Gradle__junit_junit_4_13_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__me_zhanghai_android_materialprogressbar_library_1_4_2_aar.xml b/.idea/libraries/Gradle__me_zhanghai_android_materialprogressbar_library_1_4_2_aar.xml new file mode 100644 index 0000000..b68b106 --- /dev/null +++ b/.idea/libraries/Gradle__me_zhanghai_android_materialprogressbar_library_1_4_2_aar.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml b/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml new file mode 100644 index 0000000..ddd2635 --- /dev/null +++ b/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_apache_commons_commons_collections4_4_1_jar.xml b/.idea/libraries/Gradle__org_apache_commons_commons_collections4_4_1_jar.xml new file mode 100644 index 0000000..791be33 --- /dev/null +++ b/.idea/libraries/Gradle__org_apache_commons_commons_collections4_4_1_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_apache_poi_poi_3_16_jar.xml b/.idea/libraries/Gradle__org_apache_poi_poi_3_16_jar.xml new file mode 100644 index 0000000..e16f021 --- /dev/null +++ b/.idea/libraries/Gradle__org_apache_poi_poi_3_16_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml new file mode 100644 index 0000000..6b1e2e7 --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml new file mode 100644 index 0000000..a8015c9 --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml new file mode 100644 index 0000000..00bb125 --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml b/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml new file mode 100644 index 0000000..56b3542 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_72_jar.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_72_jar.xml new file mode 100644 index 0000000..b6434f5 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_72_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72_jar.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72_jar.xml new file mode 100644 index 0000000..4510358 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72_jar.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72_jar.xml new file mode 100644 index 0000000..fb60678 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71_jar.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71_jar.xml new file mode 100644 index 0000000..bb20ad0 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_71_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_3_71_jar.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_3_71_jar.xml new file mode 100644 index 0000000..dea7dd2 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_3_71_jar.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__saschpe_android_customtabs_3_0_2_aar.xml b/.idea/libraries/Gradle__saschpe_android_customtabs_3_0_2_aar.xml new file mode 100644 index 0000000..d3ca9e7 --- /dev/null +++ b/.idea/libraries/Gradle__saschpe_android_customtabs_3_0_2_aar.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c792505 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460d --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 0faca9a..90dc594 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Timetable is an Android Application, which allows you to save timetable, homewor You are welcome to contribute with issues, pull requests and ideas. And to contribute to this project, please fork the project and submit a pull request. ### Screenshots -1 screenshot      1 screenshot      1 screenshot +1 screenshot      1 screenshot      1 screenshot ### Licence diff --git a/TimeTable.iml b/TimeTable.iml new file mode 100644 index 0000000..faeac42 --- /dev/null +++ b/TimeTable.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..ef5c122 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e97410d..6b4194c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,35 +1,65 @@ apply plugin: 'com.android.application' +apply plugin: 'com.mikepenz.aboutlibraries.plugin' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 27 + compileSdkVersion 29 defaultConfig { applicationId "com.ulan.timetable" - minSdkVersion 21 - targetSdkVersion 27 - versionCode 1 + minSdkVersion 19 + targetSdkVersion 29 + versionCode 10 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } buildTypes { release { - minifyEnabled false + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + + //To Avoid MultiDex + debug { + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } } +def acraVersion = '5.5.0' dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:support-v4:27.1.1' - implementation 'com.android.support:design:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation 'com.android.support:customtabs:27.1.1' - implementation 'com.android.support:preference-v7:27.1.1' - implementation 'com.android.support:cardview-v7:27.1.1' - implementation 'petrov.kristiyan:colorpicker-library:1.1.8' - implementation 'org.xdty.preference:color-picker:0.0.5' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.google.android.material:material:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.browser:browser:1.2.0' + implementation 'androidx.preference:preference:1.1.1' + implementation 'androidx.cardview:cardview:1.0.0' + implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0" + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + implementation 'com.github.asdoi:ColorPickerDialog:a1d628430b' + implementation 'com.github.asdoi:SQLite2XL:88883cf56d' + implementation 'saschpe.android:customtabs:3.0.2' + implementation "com.mikepenz:aboutlibraries:8.1.2" + //noinspection NewerVersionAvailable,GradleDependency + implementation 'org.apache.poi:poi:3.16' + implementation 'com.github.stephenvinouze:shapetextdrawable:1.0.0' + implementation 'com.github.Pradyuman7:ChocoBar:V1.0' + //noinspection GradleDependency + implementation 'com.afollestad.material-dialogs:core:0.9.6' + implementation 'com.afollestad.material-dialogs:commons:0.9.6.0' + implementation 'com.github.IamIsPra:Sheriff:1.0.0' + implementation 'com.github.asdoi:TimetableUI:2d9340ce8c' + implementation 'com.github.asdoi:TimetableView:master-SNAPSHOT' } diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..493aad2 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "436077303281", + "firebase_url": "https://timetable-e6129.firebaseio.com", + "project_id": "timetable-e6129", + "storage_bucket": "timetable-e6129.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:436077303281:android:844b815f9a9784aa586050", + "android_client_info": { + "package_name": "com.ulan.timetable" + } + }, + "oauth_client": [ + { + "client_id": "436077303281-eomhiu4gr9oi0iqtgcf7ft8eus6lqgsf.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyChbM3TDXNtRL5YaoRtgzd5Ps1PFnh24zw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "436077303281-eomhiu4gr9oi0iqtgcf7ft8eus6lqgsf.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b4245..54e58c8 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -14,8 +14,15 @@ # Uncomment this to preserve the line number information for # debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +-keep class .R +-keep public class org.apache.poi.hssf.** {*;} +-keep public class org.apache.poi.ss.** {*;} +-keep public class me.jfenn.colorpickerdialog.** {*;} +-dontobfuscate +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable \ No newline at end of file diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..2dbb35b Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json new file mode 100644 index 0000000..fff3838 --- /dev/null +++ b/app/release/output.json @@ -0,0 +1,20 @@ +[ + { + "outputType": { + "type": "APK" + }, + "apkData": { + "type": "MAIN", + "splits": [], + "versionCode": 10, + "versionName": "1.0", + "enabled": true, + "outputFile": "app-release.apk", + "fullName": "release", + "baseName": "release", + "dirName": "" + }, + "path": "app-release.apk", + "properties": {} + } +] \ No newline at end of file diff --git a/app/src/androidTest/java/com/ulan/timetable/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/ulan/timetable/ExampleInstrumentedTest.java deleted file mode 100644 index 3715cca..0000000 --- a/app/src/androidTest/java/com/ulan/timetable/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ulan.timetable; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.ulan.timetable", appContext.getPackageName()); - } -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2b85e58..7b535e3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,57 +1,55 @@ + xmlns:dist="http://schemas.android.com/apk/distribution" + package="com.ulan.timetable"> + + - + + + + + + + android:theme="@style/SplashTheme"> + android:configChanges="orientation|screenSize|keyboardHidden" + android:label="@string/app_name"> - - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..63a04b6 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/ulan/timetable/activities/ExamsActivity.java b/app/src/main/java/com/ulan/timetable/activities/ExamsActivity.java index c3af4be..652edc7 100644 --- a/app/src/main/java/com/ulan/timetable/activities/ExamsActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/ExamsActivity.java @@ -1,7 +1,5 @@ package com.ulan.timetable.activities; -import android.content.Context; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.SparseBooleanArray; import android.view.ActionMode; @@ -12,23 +10,29 @@ import android.widget.AbsListView; import android.widget.ListView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; import com.ulan.timetable.adapters.ExamsAdapter; import com.ulan.timetable.model.Exam; -import com.ulan.timetable.R; import com.ulan.timetable.utils.AlertDialogsHelper; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; public class ExamsActivity extends AppCompatActivity { - private Context context = this; + @NonNull + private final AppCompatActivity context = this; private ListView listView; private ExamsAdapter adapter; private DbHelper db; @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_exams); initAll(); @@ -51,14 +55,14 @@ private void setupListViewMultiSelect() { listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { + public void onItemCheckedStateChanged(@NonNull ActionMode mode, int position, long id, boolean checked) { final int checkedCount = listView.getCheckedItemCount(); mode.setTitle(checkedCount + " " + getResources().getString(R.string.selected)); - if(checkedCount == 0) mode.finish(); + if (checkedCount == 0) mode.finish(); } @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode mode, Menu menu) { MenuInflater menuInflater = mode.getMenuInflater(); menuInflater.inflate(R.menu.toolbar_action_mode, menu); return true; @@ -70,28 +74,26 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { } @Override - public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.action_delete: - ArrayList removelist = new ArrayList<>(); - SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); - for (int i = 0; i < checkedItems.size(); i++) { - int key = checkedItems.keyAt(i); - if (checkedItems.get(key)) { - db.deleteExamById(adapter.getItem(key)); - removelist.add(adapter.getExamList().get(key)); - } + public boolean onActionItemClicked(@NonNull final ActionMode mode, @NonNull MenuItem item) { + if (item.getItemId() == R.id.action_delete) { + ArrayList removelist = new ArrayList<>(); + SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); + for (int i = 0; i < checkedItems.size(); i++) { + int key = checkedItems.keyAt(i); + if (checkedItems.get(key)) { + db.deleteExamById(adapter.getItem(key)); + removelist.add(adapter.getExamList().get(key)); } - adapter.getExamList().removeAll(removelist); - db.updateExam(adapter.getExam()); - adapter.notifyDataSetChanged(); - mode.finish(); - return true; - - default: - return false; + } + adapter.getExamList().removeAll(removelist); + db.updateExam(adapter.getExam()); + adapter.notifyDataSetChanged(); + mode.finish(); + return true; } + return false; } + @Override public void onDestroyActionMode(ActionMode mode) { } diff --git a/app/src/main/java/com/ulan/timetable/activities/HomeworksActivity.java b/app/src/main/java/com/ulan/timetable/activities/HomeworksActivity.java index 10f607e..a9a517c 100644 --- a/app/src/main/java/com/ulan/timetable/activities/HomeworksActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/HomeworksActivity.java @@ -1,8 +1,6 @@ package com.ulan.timetable.activities; -import android.content.Context; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; import android.util.SparseBooleanArray; import android.view.ActionMode; import android.view.Menu; @@ -12,18 +10,24 @@ import android.widget.AbsListView; import android.widget.ListView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; import com.ulan.timetable.adapters.HomeworksAdapter; import com.ulan.timetable.model.Homework; -import com.ulan.timetable.R; import com.ulan.timetable.utils.AlertDialogsHelper; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; public class HomeworksActivity extends AppCompatActivity { + public static final String ACTION_ADD_HOMEWORK = "addHomework"; - private Context context = this; + @NonNull + private final AppCompatActivity context = this; private ListView listView; private HomeworksAdapter adapter; private DbHelper db; @@ -31,9 +35,13 @@ public class HomeworksActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_homeworks); initAll(); + if (ACTION_ADD_HOMEWORK.equalsIgnoreCase(getIntent().getAction())) { + findViewById(R.id.fab).performClick(); + } } private void initAll() { @@ -53,15 +61,15 @@ private void setupListViewMultiSelect() { listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { + public void onItemCheckedStateChanged(@NonNull ActionMode mode, int position, long id, boolean checked) { listposition = position; final int checkedCount = listView.getCheckedItemCount(); mode.setTitle(checkedCount + " " + getResources().getString(R.string.selected)); - if(checkedCount == 0) mode.finish(); + if (checkedCount == 0) mode.finish(); } @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode mode, Menu menu) { MenuInflater menuInflater = mode.getMenuInflater(); menuInflater.inflate(R.menu.toolbar_action_mode, menu); return true; @@ -73,28 +81,26 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { } @Override - public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.action_delete: - ArrayList removelist = new ArrayList<>(); - SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); - for (int i = 0; i < checkedItems.size(); i++) { - int key = checkedItems.keyAt(i); - if (checkedItems.get(key)) { - db.deleteHomeworkById(adapter.getItem(key)); - removelist.add(adapter.getHomeworkList().get(key)); - } + public boolean onActionItemClicked(@NonNull final ActionMode mode, @NonNull MenuItem item) { + if (item.getItemId() == R.id.action_delete) { + ArrayList removelist = new ArrayList<>(); + SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); + for (int i = 0; i < checkedItems.size(); i++) { + int key = checkedItems.keyAt(i); + if (checkedItems.get(key)) { + db.deleteHomeworkById(adapter.getItem(key)); + removelist.add(adapter.getHomeworkList().get(key)); } - adapter.getHomeworkList().removeAll(removelist); - db.updateHomework(adapter.getHomework()); - adapter.notifyDataSetChanged(); - mode.finish(); - return true; - - default: - return false; + } + adapter.getHomeworkList().removeAll(removelist); + db.updateHomework(adapter.getHomework()); + adapter.notifyDataSetChanged(); + mode.finish(); + return true; } + return false; } + @Override public void onDestroyActionMode(ActionMode mode) { } diff --git a/app/src/main/java/com/ulan/timetable/activities/MainActivity.java b/app/src/main/java/com/ulan/timetable/activities/MainActivity.java index 20882ad..6b8f201 100644 --- a/app/src/main/java/com/ulan/timetable/activities/MainActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/MainActivity.java @@ -1,42 +1,56 @@ package com.ulan.timetable.activities; -import android.app.AlarmManager; -import android.app.PendingIntent; +import android.Manifest; +import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.design.widget.Snackbar; -import android.support.design.widget.TabLayout; -import android.support.v4.view.ViewPager; -import android.support.v7.preference.PreferenceManager; +import android.os.Environment; +import android.provider.Settings; import android.text.TextUtils; -import android.view.View; -import android.support.design.widget.NavigationView; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.View; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.browser.customtabs.CustomTabsIntent; +import androidx.core.content.ContextCompat; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.preference.PreferenceManager; +import androidx.viewpager.widget.ViewPager; -import com.ulan.timetable.adapters.FragmentsTabAdapter; -import com.ulan.timetable.fragments.FridayFragment; -import com.ulan.timetable.fragments.MondayFragment; -import com.ulan.timetable.fragments.SaturdayFragment; -import com.ulan.timetable.fragments.SundayFragment; -import com.ulan.timetable.fragments.ThursdayFragment; -import com.ulan.timetable.fragments.TuesdayFragment; -import com.ulan.timetable.fragments.WednesdayFragment; +import com.afollestad.materialdialogs.MaterialDialog; +import com.ajts.androidmads.library.ExcelToSQLite; +import com.ajts.androidmads.library.SQLiteToExcel; +import com.google.android.material.navigation.NavigationView; +import com.google.android.material.tabs.TabLayout; +import com.mikepenz.aboutlibraries.LibsBuilder; +import com.pd.chocobar.ChocoBar; import com.ulan.timetable.R; +import com.ulan.timetable.adapters.FragmentsTabAdapter; +import com.ulan.timetable.fragments.WeekdayFragment; import com.ulan.timetable.utils.AlertDialogsHelper; -import com.ulan.timetable.utils.DailyReceiver; +import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.NotificationUtil; +import com.ulan.timetable.utils.PreferenceUtil; +import com.ulan.timetable.utils.ShortcutUtils; +import java.io.File; +import java.util.ArrayList; import java.util.Calendar; -import static com.ulan.timetable.utils.BrowserUtil.openUrlInChromeCustomTab; +import info.isuru.sheriff.enums.SheriffPermission; +import info.isuru.sheriff.helper.Sheriff; +import info.isuru.sheriff.interfaces.PermissionListener; +import saschpe.android.customtabs.CustomTabsHelper; +import saschpe.android.customtabs.WebViewFallback; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @@ -47,14 +61,41 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralThemeNoActionBar(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + if (Build.VERSION.SDK_INT >= 25) { + ShortcutUtils.Companion.createShortcuts(this); + } + if (!PreferenceUtil.hasStartActivityBeenShown(this)) { + new MaterialDialog.Builder(this) + .content(R.string.first_start_setup) + .positiveText(R.string.ok) + .onPositive((v, w) -> startActivity(new Intent(this, TimeSettingsActivity.class))) + .show(); + } + + NotificationUtil.sendNotificationCurrentLesson(this, false); initAll(); } + @Override + public void onStart() { + super.onStart(); + PreferenceUtil.setDoNotDisturb(this, PreferenceUtil.doNotDisturbDontAskAgain(this)); + } + private void initAll() { NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); + View headerview = navigationView.getHeaderView(0); + headerview.findViewById(R.id.nav_header_main_settings).setOnClickListener((View v) -> startActivity(new Intent(this, SettingsActivity.class))); + TextView title = headerview.findViewById(R.id.nav_header_main_title); + title.setText(R.string.activity_title); + + TextView desc = headerview.findViewById(R.id.nav_header_main_desc); + desc.setText(R.string.nav_drawer_description); + PreferenceManager.setDefaultValues(this, R.xml.settings, false); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -65,84 +106,83 @@ private void initAll() { drawer.addDrawerListener(toggle); toggle.syncState(); + setupSevenDaysPref(); setupFragments(); setupCustomDialog(); - setupSevenDaysPref(); - - if(switchSevenDays) changeFragments(true); - setDailyAlarm(); + if (switchSevenDays) changeFragments(true); } private void setupFragments() { adapter = new FragmentsTabAdapter(getSupportFragmentManager()); viewPager = findViewById(R.id.viewPager); TabLayout tabLayout = findViewById(R.id.tabLayout); - Calendar calendar = Calendar.getInstance(); - int day = calendar.get(Calendar.DAY_OF_WEEK); - adapter.addFragment(new MondayFragment(), getResources().getString(R.string.monday)); - adapter.addFragment(new TuesdayFragment(), getResources().getString(R.string.tuesday)); - adapter.addFragment(new WednesdayFragment(), getResources().getString(R.string.wednesday)); - adapter.addFragment(new ThursdayFragment(), getResources().getString(R.string.thursday)); - adapter.addFragment(new FridayFragment(), getResources().getString(R.string.friday)); + + WeekdayFragment mondayFragment = new WeekdayFragment(WeekdayFragment.KEY_MONDAY_FRAGMENT); + WeekdayFragment tuesdayFragment = new WeekdayFragment(WeekdayFragment.KEY_TUESDAY_FRAGMENT); + WeekdayFragment wednesdayFragment = new WeekdayFragment(WeekdayFragment.KEY_WEDNESDAY_FRAGMENT); + WeekdayFragment thursdayFragment = new WeekdayFragment(WeekdayFragment.KEY_THURSDAY_FRAGMENT); + WeekdayFragment fridayFragment = new WeekdayFragment(WeekdayFragment.KEY_FRIDAY_FRAGMENT); + + adapter.addFragment(mondayFragment, getResources().getString(R.string.monday)); + adapter.addFragment(tuesdayFragment, getResources().getString(R.string.tuesday)); + adapter.addFragment(wednesdayFragment, getResources().getString(R.string.wednesday)); + adapter.addFragment(thursdayFragment, getResources().getString(R.string.thursday)); + adapter.addFragment(fridayFragment, getResources().getString(R.string.friday)); + viewPager.setAdapter(adapter); - viewPager.setCurrentItem(day == 1 ? 6 : day-2, true); + + int day = getFragmentChoosingDay(); + viewPager.setCurrentItem(day == 1 ? 6 : day - 2, true); + tabLayout.setupWithViewPager(viewPager); } private void changeFragments(boolean isChecked) { - if(isChecked) { + if (isChecked) { TabLayout tabLayout = findViewById(R.id.tabLayout); - Calendar calendar = Calendar.getInstance(); - int day = calendar.get(Calendar.DAY_OF_WEEK); - adapter.addFragment(new SaturdayFragment(), getResources().getString(R.string.saturday)); - adapter.addFragment(new SundayFragment(), getResources().getString(R.string.sunday)); + int day = getFragmentChoosingDay(); + adapter.addFragment(new WeekdayFragment(WeekdayFragment.KEY_SATURDAY_FRAGMENT), getResources().getString(R.string.saturday)); + adapter.addFragment(new WeekdayFragment(WeekdayFragment.KEY_SUNDAY_FRAGMENT), getResources().getString(R.string.sunday)); viewPager.setAdapter(adapter); - viewPager.setCurrentItem(day == 1 ? 6 : day-2, true); + viewPager.setCurrentItem(day == 1 ? 6 : day - 2, true); tabLayout.setupWithViewPager(viewPager); } else { - if(adapter.getFragmentList().size() > 5) { - adapter.removeFragment(new SaturdayFragment(), 5); - adapter.removeFragment(new SundayFragment(), 5); + if (adapter.getFragmentList().size() > 5) { + adapter.removeFragment(new WeekdayFragment(WeekdayFragment.KEY_SATURDAY_FRAGMENT), 5); + adapter.removeFragment(new WeekdayFragment(WeekdayFragment.KEY_SUNDAY_FRAGMENT), 5); } } adapter.notifyDataSetChanged(); } - + + private int getFragmentChoosingDay() { + Calendar calendar = Calendar.getInstance(); + int day = calendar.get(Calendar.DAY_OF_WEEK); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + //If its after 18 o'clock, show the next day + if (hour >= 18) { + day++; + } + if (day > 7) { //Calender.Saturday + day = day - 7; //1 = Calendar.Sunday, 2 = Calendar.Monday etc. + } + //If Saturday/Sunday are hidden, switch to Monday + if (!switchSevenDays && (day == Calendar.SUNDAY || day == Calendar.SATURDAY)) { + day = Calendar.MONDAY; + } + return day; + } + private void setupCustomDialog() { final View alertLayout = getLayoutInflater().inflate(R.layout.dialog_add_subject, null); AlertDialogsHelper.getAddSubjectDialog(MainActivity.this, alertLayout, adapter, viewPager); } private void setupSevenDaysPref() { - SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - switchSevenDays = sharedPref.getBoolean(SettingsActivity.KEY_SEVEN_DAYS_SETTING, false); + switchSevenDays = PreferenceUtil.isSevenDays(this); } - private void setDailyAlarm() { - Calendar calendar = Calendar.getInstance(); - - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - - Calendar cur = Calendar.getInstance(); - - if (cur.after(calendar)) { - calendar.add(Calendar.DATE, 1); - } - - Intent myIntent = new Intent(this, DailyReceiver.class); - int ALARM1_ID = 10000; - PendingIntent pendingIntent = PendingIntent.getBroadcast( - this, ALARM1_ID, myIntent, PendingIntent.FLAG_UPDATE_CURRENT); - AlarmManager alarmManager = (AlarmManager) this.getSystemService(ALARM_SERVICE); - if (alarmManager != null) { - alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); - } - - } @Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); @@ -154,59 +194,295 @@ public void onBackPressed() { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.action_settings: - Intent settings = new Intent(MainActivity.this, SettingsActivity.class); - startActivity(settings); - return true; - default: - return super.onOptionsItemSelected(item); + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + if (item.getItemId() == R.id.action_settings) { + Intent settings = new Intent(MainActivity.this, SettingsActivity.class); + startActivity(settings); + } else if (item.getItemId() == R.id.action_backup) { + backup(); + } else if (item.getItemId() == R.id.action_restore) { + restore(); + } else if (item.getItemId() == R.id.action_remove_all) { + deleteAll(); + } else if (item.getItemId() == R.id.action_about_libs) { + new LibsBuilder() + .withActivityTitle(getString(R.string.about_libs_title)) + .withAboutIconShown(true) + .withFields(R.string.class.getFields()) + .withLicenseShown(true) + .withAboutDescription(getString(R.string.nav_drawer_description)) + .withAboutAppName(getString(R.string.app_name)) + .start(this); } + return super.onOptionsItemSelected(item); } @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { - final NavigationView navigationView = findViewById(R.id.nav_view); - switch (item.getItemId()) { - case R.id.schoolwebsitemenu: - String schoolWebsite = PreferenceManager.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_SCHOOL_WEBSITE_SETTING, null); - if(!TextUtils.isEmpty(schoolWebsite)) { - openUrlInChromeCustomTab(getApplicationContext(), schoolWebsite); - } else { - Snackbar.make(navigationView, R.string.school_website_snackbar, Snackbar.LENGTH_SHORT).show(); - } - return true; - case R.id.exams: - Intent exams = new Intent(MainActivity.this, ExamsActivity.class); - startActivity(exams); - return true; - case R.id.teachers: - Intent teacher = new Intent(MainActivity.this, TeachersActivity.class); - startActivity(teacher); - return true; - case R.id.homework: - Intent homework = new Intent(MainActivity.this, HomeworksActivity.class); - startActivity(homework); - return true; - case R.id.notes: - Intent note = new Intent(MainActivity.this, NotesActivity.class); - startActivity(note); - return true; - case R.id.settings: - Intent settings = new Intent(MainActivity.this, SettingsActivity.class); - startActivity(settings); - return true; - default: - DrawerLayout drawer = findViewById(R.id.drawer_layout); - drawer.closeDrawer(GravityCompat.START); - return true; + int itemId = item.getItemId(); + if (itemId == R.id.exams) { + Intent exams = new Intent(MainActivity.this, ExamsActivity.class); + startActivity(exams); + } else if (itemId == R.id.homework) { + Intent homework = new Intent(MainActivity.this, HomeworksActivity.class); + startActivity(homework); + } else if (itemId == R.id.notes) { + Intent note = new Intent(MainActivity.this, NotesActivity.class); + startActivity(note); + } else if (itemId == R.id.settings) { + Intent settings = new Intent(MainActivity.this, SettingsActivity.class); + startActivity(settings); + } else if (itemId == R.id.schoolwebsitemenu) { + String schoolWebsite = PreferenceManager.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_SCHOOL_WEBSITE_SETTING, null); + if (!TextUtils.isEmpty(schoolWebsite)) { + openUrlInChromeCustomTab(schoolWebsite); + } else { + ChocoBar.builder().setActivity(this) + .setText(getString(R.string.school_website_snackbar)) + .setDuration(ChocoBar.LENGTH_LONG) + .red() + .show(); + } + } else if (itemId == R.id.teachers) { + Intent teacher = new Intent(MainActivity.this, TeachersActivity.class); + startActivity(teacher); + } else if (itemId == R.id.summary) { + Intent teacher = new Intent(MainActivity.this, SummaryActivity.class); + startActivity(teacher); + } + DrawerLayout drawer = findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; + } + + private static final String filename = "Timetable_Backup.xls"; + + @SuppressWarnings("deprecation") + public void backup() { + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED + && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + + requestPermission(this::backup, SheriffPermission.STORAGE); + return; } + + String path = Environment.getExternalStoragePublicDirectory(Build.VERSION.SDK_INT >= 19 ? Environment.DIRECTORY_DOCUMENTS : Environment.DIRECTORY_DOWNLOADS).toString(); +// SimpleDateFormat timeStampFormat = new SimpleDateFormat("yyyyMMdd"); +// Date myDate = new Date(); +// String filename = timeStampFormat.format(myDate); + + AppCompatActivity activity = this; + + SQLiteToExcel sqliteToExcel = new SQLiteToExcel(this, DbHelper.DB_NAME, path); + sqliteToExcel.exportAllTables(filename, new SQLiteToExcel.ExportListener() { + @Override + public void onStart() { + + } + + @Override + public void onCompleted(String filePath) { + runOnUiThread(() -> ChocoBar.builder().setActivity(activity) + .setText(getString(R.string.backup_successful, Build.VERSION.SDK_INT >= 19 ? getString(R.string.Documents) : getString(R.string.Downloads))) + .setDuration(ChocoBar.LENGTH_LONG) + .green() + .show()); + } + + @Override + public void onError(Exception e) { + runOnUiThread(() -> ChocoBar.builder().setActivity(activity) + .setText(getString(R.string.backup_failed)) + .setDuration(ChocoBar.LENGTH_LONG) + .red() + .show()); + } + }); + } + + @SuppressWarnings("deprecation") + public void restore() { + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED + && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + + requestPermission(this::restore, SheriffPermission.STORAGE); + return; + } + + String path = Environment.getExternalStoragePublicDirectory(Build.VERSION.SDK_INT >= 19 ? Environment.DIRECTORY_DOCUMENTS : Environment.DIRECTORY_DOWNLOADS).toString() + File.separator + filename; + File file = new File(path); + if (!file.exists()) { + ChocoBar.builder().setActivity(this) + .setText(getString(R.string.no_backup_found_in_downloads, Build.VERSION.SDK_INT >= 19 ? getString(R.string.Documents) : getString(R.string.Downloads))) + .setDuration(ChocoBar.LENGTH_LONG) + .red() + .show(); + return; + } + + AppCompatActivity activity = this; + DbHelper dbHelper = new DbHelper(this); + dbHelper.deleteAll(); + + ExcelToSQLite excelToSQLite = new ExcelToSQLite(getApplicationContext(), DbHelper.DB_NAME, false); + excelToSQLite.importFromFile(path, new ExcelToSQLite.ImportListener() { + @Override + public void onStart() { + + } + + @Override + public void onCompleted(String filePath) { + runOnUiThread(() -> ChocoBar.builder().setActivity(activity) + .setText(getString(R.string.import_successful)) + .setDuration(ChocoBar.LENGTH_LONG) + .green() + .show()); + MainActivity.this.onStart(); + } + + @Override + public void onError(Exception e) { + runOnUiThread(() -> ChocoBar.builder().setActivity(activity) + .setText(getString(R.string.import_failed)) + .setDuration(ChocoBar.LENGTH_LONG) + .red() + .show()); + } + }); + } + + public void deleteAll() { + new MaterialDialog.Builder(this) + .title(getString(R.string.remove_all_subjects)) + .content(getString(R.string.remove_all_subjects_content)) + .positiveText(getString(R.string.yes)) + .onPositive((dialog, which) -> { + try { + DbHelper dbHelper = new DbHelper(this); + dbHelper.deleteAll(); + ChocoBar.builder().setActivity(this) + .setText(getString(R.string.remove_all_successful)) + .setDuration(ChocoBar.LENGTH_LONG) + .green() + .show(); + MainActivity.this.onStart(); + } catch (Exception e) { + ChocoBar.builder().setActivity(this) + .setText(getString(R.string.remove_all_failed)) + .setDuration(ChocoBar.LENGTH_LONG) + .red() + .show(); + } + }) + .onNegative((dialog, which) -> dialog.dismiss()) + .negativeText(getString(R.string.no)) + .onNeutral((dialog, which) -> { + backup(); + dialog.dismiss(); + }) + .neutralText(R.string.menu_backup) + .show(); + } + + private void openUrlInChromeCustomTab(String url) { + Context context = this; + try { + CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() + .addDefaultShareMenuItem() + .setToolbarColor(PreferenceUtil.getPrimaryColor(this)) + .setShowTitle(true) + .build(); + + // This is optional but recommended + CustomTabsHelper.Companion.addKeepAliveExtra(context, customTabsIntent.intent); + + // This is where the magic happens... + CustomTabsHelper.Companion.openCustomTab(context, customTabsIntent, + Uri.parse(url), + new WebViewFallback()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //Permissions + private Sheriff sheriffPermission; + private static final int REQUEST_MULTIPLE_PERMISSION = 101; + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + sheriffPermission.onRequestPermissionsResult(requestCode, permissions, grantResults); + } + + protected void requestPermission(Runnable runAfter, SheriffPermission... permissions) { + PermissionListener pl = new MyPermissionListener(runAfter); + + sheriffPermission = Sheriff.Builder() + .with(this) + .requestCode(REQUEST_MULTIPLE_PERMISSION) + .setPermissionResultCallback(pl) + .askFor(permissions) + .rationalMessage(getString(R.string.sheriff_permission_rational)) + .build(); + + sheriffPermission.requestPermissions(); + } + + private class MyPermissionListener implements PermissionListener { + final Runnable runAfter; + + MyPermissionListener(Runnable r) { + runAfter = r; + } + + @Override + public void onPermissionsGranted(int requestCode, ArrayList acceptedPermissionList) { + if (runAfter == null) + return; + try { + runAfter.run(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onPermissionsDenied(int requestCode, ArrayList deniedPermissionList) { + // setup the alert builder + MaterialDialog.Builder builder = new MaterialDialog.Builder(MainActivity.this); + builder.title(getString(R.string.permission_required)); + builder.content(getString(R.string.permission_required_description)); + + // add the buttons + builder.onPositive((dialog, which) -> { + openAppPermissionSettings(); + dialog.dismiss(); + }); + builder.positiveText(getString(R.string.permission_ok_button)); + + builder.negativeText(getString(R.string.permission_cancel_button)); + builder.onNegative((dialog, which) -> dialog.dismiss()); + + // create and show the alert dialog + MaterialDialog dialog = builder.build(); + dialog.show(); + } + } + + private void openAppPermissionSettings() { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null); + intent.setData(uri); + startActivity(intent); } } diff --git a/app/src/main/java/com/ulan/timetable/activities/NoteInfoActivity.java b/app/src/main/java/com/ulan/timetable/activities/NoteInfoActivity.java index cc2091c..fd6b65a 100644 --- a/app/src/main/java/com/ulan/timetable/activities/NoteInfoActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/NoteInfoActivity.java @@ -1,23 +1,29 @@ package com.ulan.timetable.activities; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MenuItem; import android.widget.EditText; import android.widget.Toast; -import com.ulan.timetable.model.Note; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.ulan.timetable.R; +import com.ulan.timetable.model.Note; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; public class NoteInfoActivity extends AppCompatActivity { private DbHelper db; + @Nullable private Note note; private EditText text; @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_note_info); setupIntent(); @@ -27,7 +33,7 @@ private void setupIntent() { db = new DbHelper(NoteInfoActivity.this); note = (Note) getIntent().getSerializableExtra(NotesActivity.KEY_NOTE); text = findViewById(R.id.edittextNote); - if(note.getText() != null) { + if (note.getText() != null) { text.setText(note.getText()); } } @@ -41,7 +47,7 @@ public void onBackPressed() { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: note.setText(text.getText().toString()); diff --git a/app/src/main/java/com/ulan/timetable/activities/NotesActivity.java b/app/src/main/java/com/ulan/timetable/activities/NotesActivity.java index 2f015a1..35c9c0f 100644 --- a/app/src/main/java/com/ulan/timetable/activities/NotesActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/NotesActivity.java @@ -1,8 +1,6 @@ package com.ulan.timetable.activities; -import android.content.Context; import android.content.Intent; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.SparseBooleanArray; import android.view.ActionMode; @@ -11,27 +9,33 @@ import android.view.MenuItem; import android.view.View; import android.widget.AbsListView; -import android.widget.AdapterView; import android.widget.ListView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; import com.ulan.timetable.adapters.NotesAdapter; import com.ulan.timetable.model.Note; -import com.ulan.timetable.R; import com.ulan.timetable.utils.AlertDialogsHelper; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; public class NotesActivity extends AppCompatActivity { - public static String KEY_NOTE = "note"; - private Context context = this; + @NonNull + public static final String KEY_NOTE = "note"; + @NonNull + private final AppCompatActivity context = this; private ListView listView; private DbHelper db; private NotesAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_notes); initAll(); @@ -48,13 +52,10 @@ private void setupAdapter() { listView = findViewById(R.id.notelist); adapter = new NotesAdapter(NotesActivity.this, listView, R.layout.listview_notes_adapter, db.getNote()); listView.setAdapter(adapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - Intent intent = new Intent(context, NoteInfoActivity.class); - intent.putExtra(KEY_NOTE, adapter.getNoteList().get(position)); - startActivity(intent); - } + listView.setOnItemClickListener((parent, view, position, id) -> { + Intent intent = new Intent(context, NoteInfoActivity.class); + intent.putExtra(KEY_NOTE, adapter.getNoteList().get(position)); + startActivity(intent); }); } @@ -62,14 +63,14 @@ private void setupListViewMultiSelect() { listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { + public void onItemCheckedStateChanged(@NonNull ActionMode mode, int position, long id, boolean checked) { final int checkedCount = listView.getCheckedItemCount(); mode.setTitle(checkedCount + " " + getResources().getString(R.string.selected)); - if(checkedCount == 0) mode.finish(); + if (checkedCount == 0) mode.finish(); } @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode mode, Menu menu) { MenuInflater menuInflater = mode.getMenuInflater(); menuInflater.inflate(R.menu.toolbar_action_mode, menu); return true; @@ -81,30 +82,29 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { } @Override - public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.action_delete: - ArrayList removelist = new ArrayList<>(); - SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); - for (int i = 0; i < checkedItems.size(); i++) { - int key = checkedItems.keyAt(i); - if (checkedItems.get(key)) { - db.deleteNoteById(adapter.getItem(key)); - removelist.add(adapter.getNoteList().get(key)); - } + public boolean onActionItemClicked(@NonNull final ActionMode mode, @NonNull MenuItem item) { + if (item.getItemId() == R.id.action_delete) { + ArrayList removelist = new ArrayList<>(); + SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); + for (int i = 0; i < checkedItems.size(); i++) { + int key = checkedItems.keyAt(i); + if (checkedItems.get(key)) { + db.deleteNoteById(adapter.getItem(key)); + removelist.add(adapter.getNoteList().get(key)); } - adapter.getNoteList().removeAll(removelist); - db.updateNote(adapter.getNote()); - adapter.notifyDataSetChanged(); - mode.finish(); - return true; - - default: - return false; + } + adapter.getNoteList().removeAll(removelist); + db.updateNote(adapter.getNote()); + adapter.notifyDataSetChanged(); + mode.finish(); + return true; } + return false; } + @Override - public void onDestroyActionMode(ActionMode mode) { } + public void onDestroyActionMode(ActionMode mode) { + } }); } diff --git a/app/src/main/java/com/ulan/timetable/activities/SettingsActivity.java b/app/src/main/java/com/ulan/timetable/activities/SettingsActivity.java index 4311a65..3f4d4ea 100644 --- a/app/src/main/java/com/ulan/timetable/activities/SettingsActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/SettingsActivity.java @@ -1,21 +1,25 @@ package com.ulan.timetable.activities; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import com.ulan.timetable.fragments.SettingsFragment; +import androidx.appcompat.app.AppCompatActivity; + import com.ulan.timetable.R; +import com.ulan.timetable.fragments.SettingsFragment; +import com.ulan.timetable.utils.PreferenceUtil; public class SettingsActivity extends AppCompatActivity { - public static final String - KEY_SEVEN_DAYS_SETTING = "sevendays"; + public static final String KEY_SEVEN_DAYS_SETTING = "sevendays"; public static final String KEY_SCHOOL_WEBSITE_SETTING = "schoolwebsite"; + @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); + getSupportFragmentManager().beginTransaction() - .replace(android.R.id.content, new SettingsFragment()) + .replace(R.id.settings, new SettingsFragment()) .commit(); } } diff --git a/app/src/main/java/com/ulan/timetable/activities/SummaryActivity.java b/app/src/main/java/com/ulan/timetable/activities/SummaryActivity.java new file mode 100644 index 0000000..ed81d29 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/activities/SummaryActivity.java @@ -0,0 +1,290 @@ +package com.ulan.timetable.activities; + +import android.content.Intent; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; + +import com.github.tlaabs.timetableview.Schedule; +import com.github.tlaabs.timetableview.Time; +import com.github.tlaabs.timetableview.TimetableView; +import com.ulan.timetable.R; +import com.ulan.timetable.fragments.WeekdayFragment; +import com.ulan.timetable.model.Week; +import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; +import com.ulan.timetable.utils.WeekUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import me.yaoandy107.ntut_timetable.CourseTableLayout; +import me.yaoandy107.ntut_timetable.model.CourseInfo; +import me.yaoandy107.ntut_timetable.model.StudentCourse; + +public class SummaryActivity extends AppCompatActivity { + private int lessonDuration; + private String schoolStart; + + @Override + protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_summary); + + lessonDuration = PreferenceUtil.getPeriodLength(this); + int[] oldTimes = PreferenceUtil.getStartTime(this); + schoolStart = oldTimes[0] + ":" + oldTimes[1]; + + findViewById(R.id.courseTable).setVisibility(View.GONE); + + if (PreferenceUtil.isSummaryLibrary1(this)) + setupCourseTableLibrary1(); + else + setupTimetableLibrary2(); + } + + @Override + public boolean onCreateOptionsMenu(@NonNull Menu menu) { + getMenuInflater().inflate(R.menu.summary, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + if (item.getItemId() == R.id.action_changeSummary) { + PreferenceUtil.setSummaryLibrary(this, !PreferenceUtil.isSummaryLibrary1(this)); + recreate(); + } else if (item.getItemId() == R.id.action_settings) { + startActivity(new Intent(this, TimeSettingsActivity.class)); + finish(); + } + return super.onOptionsItemSelected(item); + } + + + /** + * Setup the course Table with Library: https://github.com/asdoi/TimetableUI + */ + private void setupCourseTableLibrary1() { + DbHelper dbHelper = new DbHelper(this); + + CourseTableLayout courseTable = findViewById(R.id.courseTable); + courseTable.setVisibility(View.VISIBLE); + courseTable.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + StudentCourse studentCourse = new StudentCourse(); + ArrayList courseInfoList = new ArrayList<>(); + + List> weeks = new ArrayList<>(); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_MONDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_TUESDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_WEDNESDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_THURSDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_FRIDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_SATURDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_SUNDAY_FRAGMENT)); + + List> durationStrings = new ArrayList<>(); + for (int i = 0; i < 7; i++) { + durationStrings.add(new ArrayList<>()); + } + + for (int j = 0; j < weeks.size(); j++) { + for (int i = 0; i < weeks.get(j).size(); i++) { + Week w = weeks.get(j).get(i); + int start = WeekUtils.getMatchingScheduleBegin(w.getFromTime(), PreferenceUtil.getStartTime(this), PreferenceUtil.getPeriodLength(this)); + int end = WeekUtils.getMatchingScheduleEnd(w.getToTime(), PreferenceUtil.getStartTime(this), PreferenceUtil.getPeriodLength(this)); + durationStrings.get(j).add(i, generateLessonsString(end - start + 1, start - 1)); + } + } + + for (int j = 0; j < weeks.size(); j++) { + for (int i = 0; i < weeks.get(j).size(); i++) { + Week w = weeks.get(j).get(i); + + String[] courseTimes = new String[7]; + Arrays.fill(courseTimes, ""); + courseTimes[j] = "" + durationStrings.get(j).get(i); + + CustomCourseInfo courseInfo = new CustomCourseInfo(w); + courseInfo.setCourseTime(courseTimes); + courseInfoList.add(courseInfo); + } + } + + // Set timetable + studentCourse.setCourseList(courseInfoList); + + courseTable.setHeader(getResources().getStringArray(R.array.timetable_header)); + courseTable.setTextSize(14); + courseTable.setStudentCourse(studentCourse); + + courseTable.setOnCourseClickListener(view -> { + CustomCourseInfo item = (CustomCourseInfo) view.getTag(); + final View alertLayout = getLayoutInflater().inflate(R.layout.dialog_add_subject, null); + AlertDialogsHelper.getEditSubjectDialog(this, alertLayout, this::recreate, item.getWeek()); + }); + } + + private int getDurationOfWeek(Week w) { + return WeekUtils.getDurationOfWeek(w, false, lessonDuration); + } + + private static String generateLessonsString(int duration, int hoursBefore) { + StringBuilder durationString = new StringBuilder(); + for (int i = 1; i <= duration; i++) { + durationString.append(i + hoursBefore).append(" "); + } + + return durationString.toString(); + } + + private static class CustomCourseInfo extends CourseInfo { + private Week week; + + public CustomCourseInfo(Week w) { + super(); + week = w; + + StringBuilder name = new StringBuilder(w.getSubject()); + if (w.getTeacher() != null && !w.getTeacher().trim().isEmpty()) + name.append("\n").append(w.getTeacher()); + if (w.getRoom() != null && !w.getTeacher().trim().isEmpty()) + name.append("\n").append(w.getRoom()); + + setName(name.toString()); + + setColor(w.getColor()); + } + + public Week getWeek() { + return week; + } + } + + + /** + * Setup the course Table with Library: https://github.com/asdoi/TimetableView + */ + private void setupTimetableLibrary2() { + List> weeks = new ArrayList<>(); + DbHelper dbHelper = new DbHelper(this); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_MONDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_TUESDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_WEDNESDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_THURSDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_FRIDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_SATURDAY_FRAGMENT)); + weeks.add(dbHelper.getWeek(WeekdayFragment.KEY_SUNDAY_FRAGMENT)); + + List done = new ArrayList<>(); + ArrayList colors = new ArrayList<>(); + List> timetableContent = new ArrayList<>(); + + int rows = 0; + + for (int j = 0; j < weeks.size(); j++) { + for (int i = 0; i < weeks.get(j).size(); i++) { + ArrayList schedules = new ArrayList<>(); + Week w = weeks.get(j).get(i); + String subject = w.getSubject(); + + if (done.contains(subject)) + continue; + + int i1 = i + 1; + for (int j1 = j; j1 < weeks.size(); j1++) { + for (; i1 < weeks.get(j1).size(); i1++) { + if (weeks.get(j1).get(i1).getSubject().equalsIgnoreCase(subject)) { + CustomSchedule schedule = new CustomSchedule(weeks.get(j1).get(i1), j1); + schedules.add(schedule); + if (schedule.getStartTime().getHour() > rows) + rows = schedule.getStartTime().getHour(); + } + } + i1 = 0; + } + + CustomSchedule schedule = new CustomSchedule(w, j); + schedules.add(schedule); + if (w.getColor() != -1) + colors.add(String.format("#%06X", (0xFFFFFF & w.getColor()))); + else + colors.add(String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(this, R.color.grey)))); + + if (schedule.getStartTime().getHour() > rows) + rows = schedule.getStartTime().getHour(); + + done.add(subject); + timetableContent.add(schedules); + } + } + + int startHour = Integer.parseInt(schoolStart.substring(0, schoolStart.indexOf(":"))); + + String[] header = new String[8]; + String[] resource = getResources().getStringArray(R.array.timetable_header); + for (int i = 1; i < header.length; i++) { + header[i] = resource[i - 1]; + } + + TimetableView timetable = new TimetableView.Builder(this) + .setColumnCount(6 + (PreferenceUtil.isSevenDays(this) ? 2 : 0)) + .setRowCount(10) + .setStartTime(startHour) + .setHeaderTitle(header) + .setStickerColors(colors.toArray(new String[]{})) + .build(); + timetable.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + for (ArrayList schedules : timetableContent) { + timetable.add(schedules); + } + + ((LinearLayout) findViewById(R.id.summary_linear)).addView(timetable); + +/* timetable.setOnStickerSelectEventListener((idx, schedules1) -> { + CustomSchedule schedule = (CustomSchedule) schedules1.get(idx); + Week week = schedule.getWeek(); + final View alertLayout = this.getLayoutInflater().inflate(R.layout.dialog_add_subject, null); + AlertDialogsHelper.getEditSubjectDialog(this, alertLayout, () -> setupTimetableLibrary2(), week); + });*/ + + } + + private static class CustomSchedule extends Schedule { + private Week week; + + CustomSchedule(Week w, int day) { + super(); + this.week = w; + + int startHour = Integer.parseInt(w.getFromTime().substring(0, w.getFromTime().indexOf(":"))); + int startMinute = Integer.parseInt(w.getFromTime().substring(w.getFromTime().indexOf(":") + 1)); + + int endHour = Integer.parseInt(w.getToTime().substring(0, w.getToTime().indexOf(":"))); + int endMinute = Integer.parseInt(w.getToTime().substring(w.getToTime().indexOf(":") + 1)); + + setClassTitle(w.getSubject()); // sets subject + setClassPlace(w.getRoom() + "\n" + w.getTeacher()); // sets place + setProfessorName(""); // sets professor + setStartTime(new Time(startHour, startMinute)); // sets the beginning of class time (hour,minute) + setEndTime(new Time(endHour, endMinute)); // sets the end of class time (hour,minute) + setDay(day); + } + + public Week getWeek() { + return week; + } + } +} diff --git a/app/src/main/java/com/ulan/timetable/activities/TeachersActivity.java b/app/src/main/java/com/ulan/timetable/activities/TeachersActivity.java index 00fe339..fec932d 100644 --- a/app/src/main/java/com/ulan/timetable/activities/TeachersActivity.java +++ b/app/src/main/java/com/ulan/timetable/activities/TeachersActivity.java @@ -1,8 +1,6 @@ package com.ulan.timetable.activities; import android.content.Context; -import android.support.design.widget.CoordinatorLayout; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.SparseBooleanArray; import android.view.ActionMode; @@ -13,16 +11,19 @@ import android.widget.AbsListView; import android.widget.ListView; +import androidx.appcompat.app.AppCompatActivity; +import androidx.coordinatorlayout.widget.CoordinatorLayout; + +import com.ulan.timetable.R; import com.ulan.timetable.adapters.TeachersAdapter; import com.ulan.timetable.model.Teacher; -import com.ulan.timetable.R; import com.ulan.timetable.utils.AlertDialogsHelper; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; - public class TeachersActivity extends AppCompatActivity { private Context context = this; @@ -32,6 +33,7 @@ public class TeachersActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_teachers); initAll(); @@ -58,7 +60,7 @@ private void setupListViewMultiSelect() { public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { final int checkedCount = listView.getCheckedItemCount(); mode.setTitle(checkedCount + " " + getResources().getString(R.string.selected)); - if(checkedCount == 0) mode.finish(); + if (checkedCount == 0) mode.finish(); } @Override @@ -79,7 +81,7 @@ public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { case R.id.action_delete: ArrayList removelist = new ArrayList<>(); SparseBooleanArray checkedItems = listView.getCheckedItemPositions(); - for(int i = 0; i < checkedItems.size(); i++) { + for (int i = 0; i < checkedItems.size(); i++) { int key = checkedItems.keyAt(i); if (checkedItems.get(key)) { db.deleteTeacherById(adapter.getItem(key)); @@ -96,6 +98,7 @@ public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { return false; } } + @Override public void onDestroyActionMode(ActionMode mode) { } diff --git a/app/src/main/java/com/ulan/timetable/activities/TimeSettingsActivity.java b/app/src/main/java/com/ulan/timetable/activities/TimeSettingsActivity.java new file mode 100644 index 0000000..72bffa2 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/activities/TimeSettingsActivity.java @@ -0,0 +1,36 @@ +package com.ulan.timetable.activities; + +import android.os.Bundle; + +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; +import com.ulan.timetable.fragments.TimeSettingsFragment; +import com.ulan.timetable.utils.PreferenceUtil; + +public class TimeSettingsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings_time); + + getSupportFragmentManager().beginTransaction() + .replace(R.id.settings, new TimeSettingsFragment()) + .commit(); + } + + @Override + public void onBackPressed() { +// startActivity(new Intent(this, SummaryActivity.class)); + PreferenceUtil.setStartActivityShown(this, true); + super.onBackPressed(); + } + + @Override + public boolean onSupportNavigateUp() { + onBackPressed(); + return super.onSupportNavigateUp(); + } +} diff --git a/app/src/main/java/com/ulan/timetable/adapters/ExamsAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/ExamsAdapter.java index 5377fe8..68484df 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/ExamsAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/ExamsAdapter.java @@ -1,10 +1,11 @@ package com.ulan.timetable.adapters; -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.v7.widget.CardView; -import android.support.v7.widget.PopupMenu; +import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.util.SparseBooleanArray; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -14,10 +15,21 @@ import android.widget.ListView; import android.widget.TextView; -import com.ulan.timetable.model.Exam; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; +import androidx.core.widget.ImageViewCompat; + import com.ulan.timetable.R; +import com.ulan.timetable.activities.TeachersActivity; +import com.ulan.timetable.model.Exam; import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.ColorPalette; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; +import com.ulan.timetable.utils.WeekUtils; import java.util.ArrayList; import java.util.Objects; @@ -27,11 +39,12 @@ */ public class ExamsAdapter extends ArrayAdapter { - private Activity mActivity; - private int mResource; - private ArrayList examlist; + @NonNull + private final AppCompatActivity mActivity; + @NonNull + private final ArrayList examlist; private Exam exam; - private ListView mListView; + private final ListView mListView; private static class ViewHolder { TextView subject; @@ -43,17 +56,16 @@ private static class ViewHolder { ImageView popup; } - public ExamsAdapter(Activity activity, ListView listView, int resource, ArrayList objects) { + public ExamsAdapter(@NonNull AppCompatActivity activity, ListView listView, int resource, @NonNull ArrayList objects) { super(activity, resource, objects); mActivity = activity; mListView = listView; - mResource = resource; examlist = objects; } @NonNull @Override - public View getView(final int position, View convertView, @NonNull ViewGroup parent) { + public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { String subject = Objects.requireNonNull(getItem(position)).getSubject(); String teacher = Objects.requireNonNull(getItem(position)).getTeacher(); String room = Objects.requireNonNull(getItem(position)).getRoom(); @@ -61,12 +73,12 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par String time = Objects.requireNonNull(getItem(position)).getTime(); int color = Objects.requireNonNull(getItem(position)).getColor(); - exam = new Exam(subject, teacher, date, time, room, color); + exam = new Exam(subject, teacher, time, date, room, color); final ViewHolder holder; if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(mActivity); - convertView = inflater.inflate(mResource, parent, false); + convertView = inflater.inflate(R.layout.listview_exams_adapter, parent, false); holder = new ViewHolder(); holder.subject = convertView.findViewById(R.id.subjectexams); holder.teacher = convertView.findViewById(R.id.teacherexams); @@ -79,40 +91,66 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par } else { holder = (ViewHolder) convertView.getTag(); } + + //Setup colors based on Background + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK); + holder.subject.setTextColor(textColor); + holder.teacher.setTextColor(textColor); + holder.room.setTextColor(textColor); + holder.date.setTextColor(textColor); + holder.time.setTextColor(textColor); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.roomimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.teacherimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.teacherimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.timeimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.popupbtn), ColorStateList.valueOf(textColor)); + convertView.findViewById(R.id.line).setBackgroundColor(textColor); + + holder.subject.setText(exam.getSubject()); holder.teacher.setText(exam.getTeacher()); + holder.teacher.setOnClickListener((View v) -> { + mActivity.startActivity(new Intent(mActivity, TeachersActivity.class)); + }); + TypedValue outValue = new TypedValue(); + getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); + holder.teacher.setBackgroundResource(outValue.resourceId); + holder.room.setText(exam.getRoom()); + holder.date.setText(exam.getDate()); - holder.time.setText(exam.getTime()); + if (PreferenceUtil.showTimes(getContext())) + holder.time.setText(exam.getTime()); + else if (!exam.getTime().trim().isEmpty()) + holder.time.setText("" + WeekUtils.getMatchingScheduleBegin(exam.getTime(), PreferenceUtil.getStartTime(getContext()), PreferenceUtil.getPeriodLength(getContext()))); + holder.cardView.setCardBackgroundColor(exam.getColor()); - holder.popup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final PopupMenu popup = new PopupMenu(mActivity, holder.popup); - final DbHelper db = new DbHelper(mActivity); - popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.delete_popup: - db.deleteExamById(getItem(position)); - db.updateExam(getItem(position)); - examlist.remove(position); - notifyDataSetChanged(); - return true; - - case R.id.edit_popup: - final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_exam, null); - AlertDialogsHelper.getEditExamDialog(mActivity, alertLayout, examlist, mListView, position); - notifyDataSetChanged(); - return true; - default: - return onMenuItemClick(item); - } + holder.popup.setOnClickListener(v -> { + ContextThemeWrapper theme = new ContextThemeWrapper(mActivity, PreferenceUtil.isDark(getContext()) ? R.style.Widget_AppCompat_PopupMenu : R.style.Widget_AppCompat_Light_PopupMenu); + final PopupMenu popup = new PopupMenu(theme, holder.popup); + final DbHelper db = new DbHelper(mActivity); + popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(@NonNull MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.id.delete_popup) { + AlertDialogsHelper.getDeleteDialog(getContext(), () -> { + db.deleteExamById(getItem(position)); + db.updateExam(getItem(position)); + examlist.remove(position); + notifyDataSetChanged(); + }, getContext().getString(R.string.delete_exam, exam.getSubject())); + return true; + } else if (itemId == R.id.edit_popup) { + final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_exam, null); + AlertDialogsHelper.getEditExamDialog(mActivity, alertLayout, examlist, mListView, position); + notifyDataSetChanged(); + return true; } - }); - popup.show(); - } + return onMenuItemClick(item); + } + }); + popup.show(); }); hidePopUpMenu(holder); @@ -125,6 +163,7 @@ public long getItemId(int position) { return super.getItemId(position); } + @NonNull public ArrayList getExamList() { return examlist; } @@ -133,7 +172,7 @@ public Exam getExam() { return exam; } - private void hidePopUpMenu(ViewHolder holder) { + private void hidePopUpMenu(@NonNull ViewHolder holder) { SparseBooleanArray checkedItems = mListView.getCheckedItemPositions(); if (checkedItems.size() > 0) { for (int i = 0; i < checkedItems.size(); i++) { diff --git a/app/src/main/java/com/ulan/timetable/adapters/FragmentsTabAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/FragmentsTabAdapter.java index b6c9cb1..f241d90 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/FragmentsTabAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/FragmentsTabAdapter.java @@ -1,10 +1,10 @@ package com.ulan.timetable.adapters; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentStatePagerAdapter; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; import java.util.ArrayList; import java.util.List; @@ -12,14 +12,16 @@ /** * Created by Ulan on 05.09.2018. */ -public class FragmentsTabAdapter extends FragmentStatePagerAdapter { +public class FragmentsTabAdapter extends FragmentStatePagerAdapter { private final List mFragmentList = new ArrayList<>(); private final List mFragmentTitleList = new ArrayList<>(); - public FragmentsTabAdapter(FragmentManager fm) { - super(fm); + public FragmentsTabAdapter(@NonNull FragmentManager fm) { + super(fm, FragmentsTabAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } + + @NonNull @Override public Fragment getItem(int position) { return mFragmentList.get(position); @@ -29,11 +31,13 @@ public void addFragment(Fragment fragment, String title) { mFragmentList.add(fragment); mFragmentTitleList.add(title); } + @Nullable @Override public CharSequence getPageTitle(int position) { return mFragmentTitleList.get(position); } + @Override public int getCount() { return mFragmentList.size(); @@ -44,6 +48,7 @@ public int getItemPosition(@NonNull Object object) { return POSITION_NONE; } + @NonNull public List getFragmentList() { return mFragmentList; } diff --git a/app/src/main/java/com/ulan/timetable/adapters/HomeworksAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/HomeworksAdapter.java index ed87530..b55fc0d 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/HomeworksAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/HomeworksAdapter.java @@ -1,10 +1,9 @@ package com.ulan.timetable.adapters; -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.v7.widget.CardView; -import android.support.v7.widget.PopupMenu; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.util.SparseBooleanArray; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -14,10 +13,19 @@ import android.widget.ListView; import android.widget.TextView; -import com.ulan.timetable.model.Homework; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; +import androidx.core.widget.ImageViewCompat; + import com.ulan.timetable.R; +import com.ulan.timetable.model.Homework; import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.ColorPalette; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; import java.util.Objects; @@ -27,11 +35,12 @@ */ public class HomeworksAdapter extends ArrayAdapter { - private Activity mActivity; - private int mResource; - private ArrayList homeworklist; + @NonNull + private final AppCompatActivity mActivity; + @NonNull + private final ArrayList homeworklist; private Homework homework; - private ListView mListView; + private final ListView mListView; private static class ViewHolder { TextView subject; @@ -41,17 +50,16 @@ private static class ViewHolder { ImageView popup; } - public HomeworksAdapter(Activity activity, ListView listView, int resource, ArrayList objects) { + public HomeworksAdapter(@NonNull AppCompatActivity activity, ListView listView, int resource, @NonNull ArrayList objects) { super(activity, resource, objects); mActivity = activity; mListView = listView; - mResource = resource; homeworklist = objects; } @NonNull @Override - public View getView(final int position, View convertView, @NonNull ViewGroup parent) { + public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { String subject = Objects.requireNonNull(getItem(position)).getSubject(); String description = Objects.requireNonNull(getItem(position)).getDescription(); String date = Objects.requireNonNull(getItem(position)).getDate(); @@ -60,9 +68,9 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par homework = new Homework(subject, description, date, color); final ViewHolder holder; - if(convertView == null){ + if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(mActivity); - convertView = inflater.inflate(mResource, parent, false); + convertView = inflater.inflate(R.layout.listview_homeworks_adapter, parent, false); holder = new ViewHolder(); holder.subject = convertView.findViewById(R.id.subjecthomework); holder.description = convertView.findViewById(R.id.descriptionhomework); @@ -70,42 +78,48 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par holder.cardView = convertView.findViewById(R.id.homeworks_cardview); holder.popup = convertView.findViewById(R.id.popupbtn); convertView.setTag(holder); - } - else{ + } else { holder = (ViewHolder) convertView.getTag(); } + + //Setup colors based on Background + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK); + holder.subject.setTextColor(textColor); + holder.description.setTextColor(textColor); + holder.date.setTextColor(textColor); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.timeimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.popupbtn), ColorStateList.valueOf(textColor)); + convertView.findViewById(R.id.line).setBackgroundColor(textColor); + + holder.subject.setText(homework.getSubject()); holder.description.setText(homework.getDescription()); holder.date.setText(homework.getDate()); holder.cardView.setCardBackgroundColor(homework.getColor()); - holder.popup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final PopupMenu popup = new PopupMenu(mActivity, holder.popup); - final DbHelper db = new DbHelper(mActivity); - popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.delete_popup: - db.deleteHomeworkById(getItem(position)); - db.updateHomework(getItem(position)); - homeworklist.remove(position); - notifyDataSetChanged(); - return true; - - case R.id.edit_popup: - final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_homework, null); - AlertDialogsHelper.getEditHomeworkDialog(mActivity, alertLayout, homeworklist, mListView, position); - notifyDataSetChanged(); - return true; - default: - return onMenuItemClick(item); - } + holder.popup.setOnClickListener(v -> { + ContextThemeWrapper theme = new ContextThemeWrapper(mActivity, PreferenceUtil.isDark(getContext()) ? R.style.Widget_AppCompat_PopupMenu : R.style.Widget_AppCompat_Light_PopupMenu); + final PopupMenu popup = new PopupMenu(theme, holder.popup); + final DbHelper db = new DbHelper(mActivity); + popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(@NonNull MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.id.delete_popup) { + db.deleteHomeworkById(getItem(position)); + db.updateHomework(getItem(position)); + homeworklist.remove(position); + notifyDataSetChanged(); + return true; + } else if (itemId == R.id.edit_popup) { + final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_homework, null); + AlertDialogsHelper.getEditHomeworkDialog(mActivity, alertLayout, homeworklist, mListView, position); + notifyDataSetChanged(); + return true; } - }); - popup.show(); - } + return onMenuItemClick(item); + } + }); + popup.show(); }); hidePopUpMenu(holder); @@ -118,6 +132,7 @@ public long getItemId(int position) { return super.getItemId(position); } + @NonNull public ArrayList getHomeworkList() { return homeworklist; } @@ -126,7 +141,7 @@ public Homework getHomework() { return homework; } - private void hidePopUpMenu(ViewHolder holder) { + private void hidePopUpMenu(@NonNull ViewHolder holder) { SparseBooleanArray checkedItems = mListView.getCheckedItemPositions(); if (checkedItems.size() > 0) { for (int i = 0; i < checkedItems.size(); i++) { diff --git a/app/src/main/java/com/ulan/timetable/adapters/NotesAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/NotesAdapter.java index b773b59..1f918c3 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/NotesAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/NotesAdapter.java @@ -1,11 +1,9 @@ package com.ulan.timetable.adapters; -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.widget.CardView; -import android.support.v7.widget.PopupMenu; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.util.SparseBooleanArray; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -15,10 +13,19 @@ import android.widget.ListView; import android.widget.TextView; -import com.ulan.timetable.model.Note; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; +import androidx.core.widget.ImageViewCompat; + import com.ulan.timetable.R; +import com.ulan.timetable.model.Note; import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.ColorPalette; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; import java.util.Objects; @@ -29,11 +36,12 @@ */ public class NotesAdapter extends ArrayAdapter { - private Activity mActivity; - private int mResource; - private ArrayList notelist; + @NonNull + private final AppCompatActivity mActivity; + @NonNull + private final ArrayList notelist; private Note note; - private ListView mListView; + private final ListView mListView; private static class ViewHolder { TextView title; @@ -41,11 +49,10 @@ private static class ViewHolder { CardView cardView; } - public NotesAdapter(Activity activity, ListView listView, int resource, ArrayList objects) { + public NotesAdapter(@NonNull AppCompatActivity activity, ListView listView, int resource, @NonNull ArrayList objects) { super(activity, resource, objects); mActivity = activity; mListView = listView; - mResource = resource; notelist = objects; } @@ -59,9 +66,9 @@ public View getView(final int position, @Nullable View convertView, @NonNull Vie note = new Note(title, text, color); final ViewHolder holder; - if(convertView == null) { + if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(mActivity); - convertView = inflater.inflate(mResource, parent, false); + convertView = inflater.inflate(R.layout.listview_notes_adapter, parent, false); holder = new ViewHolder(); holder.title = convertView.findViewById(R.id.titlenote); holder.popup = convertView.findViewById(R.id.popupbtn); @@ -70,36 +77,43 @@ public View getView(final int position, @Nullable View convertView, @NonNull Vie } else { holder = (ViewHolder) convertView.getTag(); } + + //Setup colors based on Background + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK); + holder.title.setTextColor(textColor); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.popupbtn), ColorStateList.valueOf(textColor)); + + holder.title.setText(note.getTitle()); holder.cardView.setCardBackgroundColor(note.getColor()); - holder.popup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final PopupMenu popup = new PopupMenu(mActivity, holder.popup); - final DbHelper db = new DbHelper(mActivity); - popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.delete_popup: - db.deleteNoteById(getItem(position)); - db.updateNote(getItem(position)); - notelist.remove(position); - notifyDataSetChanged(); - return true; - - case R.id.edit_popup: - final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_note, null); - AlertDialogsHelper.getEditNoteDialog(mActivity, alertLayout, notelist, mListView, position); - notifyDataSetChanged(); - return true; - default: - return onMenuItemClick(item); - } + holder.popup.setOnClickListener(v -> { + ContextThemeWrapper theme = new ContextThemeWrapper(mActivity, PreferenceUtil.isDark(getContext()) ? R.style.Widget_AppCompat_PopupMenu : R.style.Widget_AppCompat_Light_PopupMenu); + final PopupMenu popup = new PopupMenu(theme, holder.popup); + final DbHelper db = new DbHelper(mActivity); + popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(@NonNull MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.id.delete_popup) { + AlertDialogsHelper.getDeleteDialog(getContext(), () -> { + db.deleteNoteById(getItem(position)); + db.updateNote(getItem(position)); + notelist.remove(position); + notifyDataSetChanged(); + }, getContext().getString(R.string.delete_note, note.getTitle())); + return true; + } else if (itemId == R.id.edit_popup) { + final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_note, null); + AlertDialogsHelper.getEditNoteDialog(mActivity, alertLayout, notelist, mListView, position); + notifyDataSetChanged(); + return true; } - }); - popup.show(); - } + return + + onMenuItemClick(item); + } + }); + popup.show(); }); hidePopUpMenu(holder); @@ -112,6 +126,7 @@ public long getItemId(int position) { return super.getItemId(position); } + @NonNull public ArrayList getNoteList() { return notelist; } @@ -120,14 +135,14 @@ public Note getNote() { return note; } - private void hidePopUpMenu(ViewHolder holder) { + private void hidePopUpMenu(@NonNull ViewHolder holder) { SparseBooleanArray checkedItems = mListView.getCheckedItemPositions(); if (checkedItems.size() > 0) { for (int i = 0; i < checkedItems.size(); i++) { int key = checkedItems.keyAt(i); if (checkedItems.get(key)) { holder.popup.setVisibility(View.INVISIBLE); - } + } } } else { holder.popup.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/ulan/timetable/adapters/TeachersAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/TeachersAdapter.java index d2df716..b6b045a 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/TeachersAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/TeachersAdapter.java @@ -1,10 +1,13 @@ package com.ulan.timetable.adapters; -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.v7.widget.CardView; -import android.support.v7.widget.PopupMenu; +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; +import android.net.Uri; import android.util.SparseBooleanArray; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -14,10 +17,19 @@ import android.widget.ListView; import android.widget.TextView; -import com.ulan.timetable.model.Teacher; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; +import androidx.core.widget.ImageViewCompat; + +import com.pd.chocobar.ChocoBar; import com.ulan.timetable.R; +import com.ulan.timetable.model.Teacher; import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.ColorPalette; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; import java.util.ArrayList; import java.util.Objects; @@ -27,7 +39,7 @@ */ public class TeachersAdapter extends ArrayAdapter { - private Activity mActivity; + private AppCompatActivity mActivity; private int mResource; private ArrayList teacherlist; private Teacher teacher; @@ -42,7 +54,7 @@ private static class ViewHolder { ImageView popup; } - public TeachersAdapter(Activity activity, ListView listView, int resource, ArrayList objects) { + public TeachersAdapter(AppCompatActivity activity, ListView listView, int resource, ArrayList objects) { super(activity, resource, objects); mActivity = activity; mListView = listView; @@ -62,10 +74,10 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par teacher = new Teacher(name, post, phonenumber, email, color); final ViewHolder holder; - if(convertView == null){ + if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(mActivity); convertView = inflater.inflate(mResource, parent, false); - holder= new ViewHolder(); + holder = new ViewHolder(); holder.name = convertView.findViewById(R.id.nameteacher); holder.post = convertView.findViewById(R.id.postteacher); holder.phonenumber = convertView.findViewById(R.id.numberteacher); @@ -73,21 +85,81 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par holder.cardView = convertView.findViewById(R.id.teacher_cardview); holder.popup = convertView.findViewById(R.id.popupbtn); convertView.setTag(holder); - } - else{ + } else { holder = (ViewHolder) convertView.getTag(); } + + //Setup colors based on Background + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK); + holder.name.setTextColor(textColor); + holder.post.setTextColor(textColor); + holder.phonenumber.setTextColor(textColor); + holder.email.setTextColor(textColor); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.personimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.imageView4), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.imageView5), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.popupbtn), ColorStateList.valueOf(textColor)); + convertView.findViewById(R.id.line).setBackgroundColor(textColor); + + + TypedValue outValue = new TypedValue(); + getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); + holder.name.setText(teacher.getName()); + holder.post.setText(teacher.getPost()); + if (teacher.getPost() != null && !teacher.getPost().trim().isEmpty()) { + holder.post.setBackgroundResource(outValue.resourceId); + holder.post.setOnClickListener((View v) -> { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("geo:0,0?q=" + teacher.getPost())); + if (intent.resolveActivity(mActivity.getPackageManager()) != null) { + try { + mActivity.startActivity(intent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(mActivity).setText(mActivity.getString(R.string.no_navigation_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } + } + }); + } + holder.phonenumber.setText(teacher.getPhonenumber()); + if (phonenumber != null && !phonenumber.trim().isEmpty()) { + holder.phonenumber.setBackgroundResource(outValue.resourceId); + holder.phonenumber.setOnClickListener((View v) -> { + Intent intent = new Intent(Intent.ACTION_DIAL); + intent.setData(Uri.parse("tel:" + phonenumber)); + mActivity.startActivity(intent); + }); + } + + holder.email.setText(teacher.getEmail()); + if (teacher.getEmail() != null && !teacher.getEmail().trim().isEmpty()) { + holder.email.setBackgroundResource(outValue.resourceId); + holder.email.setOnClickListener((View v) -> { + Intent emailIntent = new Intent(Intent.ACTION_SENDTO); + emailIntent.setData(Uri.parse("mailto:" + teacher.getEmail())); + try { + mActivity.startActivity(emailIntent); + } catch (Exception e) { + try { + emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + getContext().startActivity(emailIntent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(mActivity).setText(mActivity.getString(R.string.no_email_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } + } + }); + } + holder.cardView.setCardBackgroundColor(teacher.getColor()); holder.popup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - final PopupMenu popup = new PopupMenu(mActivity, holder.popup); final DbHelper db = new DbHelper(mActivity); - popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); + ContextThemeWrapper theme = new ContextThemeWrapper(mActivity, PreferenceUtil.isDark(getContext()) ? R.style.Widget_AppCompat_PopupMenu : R.style.Widget_AppCompat_Light_PopupMenu); + final PopupMenu popup = new PopupMenu(theme, holder.popup); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { @@ -125,14 +197,14 @@ public Teacher getTeacher() { return teacher; } - private void hidePopUpMenu(ViewHolder holder) { + private void hidePopUpMenu(ViewHolder holder) { SparseBooleanArray checkedItems = mListView.getCheckedItemPositions(); if (checkedItems.size() > 0) { for (int i = 0; i < checkedItems.size(); i++) { int key = checkedItems.keyAt(i); if (checkedItems.get(key)) { holder.popup.setVisibility(View.INVISIBLE); - } + } } } else { holder.popup.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/ulan/timetable/adapters/WeekAdapter.java b/app/src/main/java/com/ulan/timetable/adapters/WeekAdapter.java index 172d99b..376e598 100644 --- a/app/src/main/java/com/ulan/timetable/adapters/WeekAdapter.java +++ b/app/src/main/java/com/ulan/timetable/adapters/WeekAdapter.java @@ -1,11 +1,12 @@ package com.ulan.timetable.adapters; import android.annotation.SuppressLint; -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.v7.widget.CardView; -import android.support.v7.widget.PopupMenu; +import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.util.SparseBooleanArray; +import android.util.TypedValue; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -15,10 +16,21 @@ import android.widget.ListView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; +import androidx.core.widget.ImageViewCompat; + import com.ulan.timetable.R; +import com.ulan.timetable.activities.TeachersActivity; import com.ulan.timetable.model.Week; import com.ulan.timetable.utils.AlertDialogsHelper; +import com.ulan.timetable.utils.ColorPalette; import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; +import com.ulan.timetable.utils.WeekUtils; import java.util.ArrayList; import java.util.Objects; @@ -29,11 +41,12 @@ */ public class WeekAdapter extends ArrayAdapter { - private Activity mActivity; - private int mResource; - private ArrayList weeklist; + @NonNull + private final AppCompatActivity mActivity; + @NonNull + private final ArrayList weeklist; private Week week; - private ListView mListView; + private final ListView mListView; private static class ViewHolder { TextView subject; @@ -44,10 +57,9 @@ private static class ViewHolder { CardView cardView; } - public WeekAdapter(Activity activity, ListView listView, int resource, ArrayList objects) { + public WeekAdapter(@NonNull AppCompatActivity activity, ListView listView, int resource, @NonNull ArrayList objects) { super(activity, resource, objects); mActivity = activity; - mResource = resource; weeklist = objects; mListView = listView; } @@ -55,21 +67,21 @@ public WeekAdapter(Activity activity, ListView listView, int resource, ArrayList @SuppressLint("SetTextI18n") @NonNull @Override - public View getView(final int position, View convertView, @NonNull ViewGroup parent) { + public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { String subject = Objects.requireNonNull(getItem(position)).getSubject(); String teacher = Objects.requireNonNull(getItem(position)).getTeacher(); String time_from = Objects.requireNonNull(getItem(position)).getFromTime(); String time_to = Objects.requireNonNull(getItem(position)).getToTime(); String room = Objects.requireNonNull(getItem(position)).getRoom(); - int color = getItem(position).getColor(); + int color = Objects.requireNonNull(getItem(position)).getColor(); week = new Week(subject, teacher, room, time_from, time_to, color); final ViewHolder holder; - if(convertView == null){ + if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(mActivity); - convertView = inflater.inflate(mResource, parent, false); - holder= new ViewHolder(); + convertView = inflater.inflate(R.layout.listview_week_adapter, parent, false); + holder = new ViewHolder(); holder.subject = convertView.findViewById(R.id.subject); holder.teacher = convertView.findViewById(R.id.teacher); holder.time = convertView.findViewById(R.id.time); @@ -77,51 +89,83 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par holder.popup = convertView.findViewById(R.id.popupbtn); holder.cardView = convertView.findViewById(R.id.week_cardview); convertView.setTag(holder); - } - else{ + } else { holder = (ViewHolder) convertView.getTag(); } + //Setup colors based on Background + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK); + holder.subject.setTextColor(textColor); + holder.teacher.setTextColor(textColor); + holder.time.setTextColor(textColor); + holder.room.setTextColor(textColor); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.roomimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.teacherimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.timeimage), ColorStateList.valueOf(textColor)); + ImageViewCompat.setImageTintList(convertView.findViewById(R.id.popupbtn), ColorStateList.valueOf(textColor)); + convertView.findViewById(R.id.line).setBackgroundColor(textColor); + + holder.subject.setText(week.getSubject()); holder.teacher.setText(week.getTeacher()); + TypedValue outValue = new TypedValue(); + getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); + holder.teacher.setBackgroundResource(outValue.resourceId); + holder.teacher.setOnClickListener((View v) -> { + mActivity.startActivity(new Intent(mActivity, TeachersActivity.class)); + }); + holder.room.setText(week.getRoom()); - holder.time.setText(week.getFromTime() + " - " + week.getToTime()); + holder.room.setOnClickListener(null); + + if (PreferenceUtil.showTimes(getContext())) + holder.time.setText(week.getFromTime() + " - " + week.getToTime()); + else { + int start = WeekUtils.getMatchingScheduleBegin(week.getFromTime(), PreferenceUtil.getStartTime(getContext()), PreferenceUtil.getPeriodLength(getContext())); + int end = WeekUtils.getMatchingScheduleEnd(week.getToTime(), PreferenceUtil.getStartTime(getContext()), PreferenceUtil.getPeriodLength(getContext())); + if (start == end) { + holder.time.setText(start + ". " + getContext().getString(R.string.lesson)); + } else { + holder.time.setText(start + ".-" + end + ". " + getContext().getString(R.string.lesson)); + } + } + holder.cardView.setCardBackgroundColor(week.getColor()); - holder.popup.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final PopupMenu popup = new PopupMenu(mActivity, holder.popup); - final DbHelper db = new DbHelper(mActivity); - popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - switch (item.getItemId()) { - case R.id.delete_popup: - db.deleteWeekById(getItem(position)); - db.updateWeek(getItem(position)); - weeklist.remove(position); - notifyDataSetChanged(); - return true; - - case R.id.edit_popup: - final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_subject, null); - AlertDialogsHelper.getEditSubjectDialog(mActivity, alertLayout, weeklist, mListView, position); - notifyDataSetChanged(); - return true; - default: - return onMenuItemClick(item); - } + holder.popup.setOnClickListener(v -> { + ContextThemeWrapper theme = new ContextThemeWrapper(mActivity, PreferenceUtil.isDark(getContext()) ? R.style.Widget_AppCompat_PopupMenu : R.style.Widget_AppCompat_Light_PopupMenu); + final PopupMenu popup = new PopupMenu(theme, holder.popup); + final DbHelper db = new DbHelper(mActivity); + popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu()); + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + public boolean onMenuItemClick(@NonNull MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.id.delete_popup) { + AlertDialogsHelper.getDeleteDialog(getContext(), () -> { + db.deleteWeekById(getItem(position)); + db.updateWeek(getItem(position)); + weeklist.remove(position); + notifyDataSetChanged(); + }, getContext().getString(R.string.delete_week, week.getSubject())); + return true; + } else if (itemId == R.id.edit_popup) { + final View alertLayout = mActivity.getLayoutInflater().inflate(R.layout.dialog_add_subject, null); + AlertDialogsHelper.getEditSubjectDialog(mActivity, alertLayout, () -> notifyDataSetChanged(), weeklist.get(position)); + notifyDataSetChanged(); + return true; } - }); - popup.show(); - } + return onMenuItemClick(item); + } + }); + popup.show(); }); hidePopUpMenu(holder); + return convertView; } + @NonNull public ArrayList getWeekList() { return weeklist; } @@ -130,17 +174,18 @@ public Week getWeek() { return week; } - private void hidePopUpMenu(ViewHolder holder) { + private void hidePopUpMenu(@NonNull ViewHolder holder) { SparseBooleanArray checkedItems = mListView.getCheckedItemPositions(); if (checkedItems.size() > 0) { for (int i = 0; i < checkedItems.size(); i++) { int key = checkedItems.keyAt(i); if (checkedItems.get(key)) { holder.popup.setVisibility(View.INVISIBLE); - } + } } } else { holder.popup.setVisibility(View.VISIBLE); } } + } diff --git a/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConfigureActivity.java b/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConfigureActivity.java new file mode 100644 index 0000000..2e45d25 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConfigureActivity.java @@ -0,0 +1,181 @@ +package com.ulan.timetable.appwidget; + +import android.app.Activity; +import android.appwidget.AppWidgetManager; +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.RadioGroup; +import android.widget.SeekBar; +import android.widget.TextView; + +import com.ulan.timetable.R; +import com.ulan.timetable.appwidget.Dao.AppWidgetDao; +import com.ulan.timetable.utils.PreferenceUtil; + +import java.util.Map; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +public class AppWidgetConfigureActivity extends Activity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener, RadioGroup.OnCheckedChangeListener { + + private int mAppWidgetId; + private RadioGroup mRgBgColor; + private RadioGroup mRgTimeStyle; + private SeekBar mSbIntensity; + private TextView mTvIntensity; + private TextView mTvTimeStyle; + + @Override + public void onCreate(Bundle savedInstanceState) { + setTheme(PreferenceUtil.getGeneralTheme(this)); + super.onCreate(savedInstanceState); + setResult(RESULT_CANCELED); + + Bundle extras = getIntent().getExtras(); + if (extras == null) { + finish(); + return; + } + + mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { + finish(); + return; + } + + setContentView(R.layout.activity_appwidget_configure); + + initView(); + setListener(); + + Map configMap = AppWidgetDao.getAppWidgetConfig(mAppWidgetId, getApplicationContext()); + if (configMap != null) { + setConfig(configMap); + } + } + + private void initView() { + mRgBgColor = findViewById(R.id.rg_bg_color); + mTvIntensity = findViewById(R.id.tv_intensity); + mSbIntensity = findViewById(R.id.sb_intensity); + mRgTimeStyle = findViewById(R.id.rg_time_style); + mTvTimeStyle = findViewById(R.id.tv_time_style); + } + + private void setListener() { + findViewById(R.id.btn_confirm).setOnClickListener(this); + findViewById(R.id.btn_cancel).setOnClickListener(this); + mSbIntensity.setOnSeekBarChangeListener(this); + mRgTimeStyle.setOnCheckedChangeListener(this); + } + + private void setConfig(Map configMap) { + Integer backgroundColor = configMap.get("backgroundColor"); + if (backgroundColor != null && backgroundColor != -1) { + int r = (int) (((backgroundColor >> 16) & 0xff) / 255.0f * 100); + if (r == 0) { + + mRgBgColor.check(R.id.rb_black); + } else { + mRgBgColor.check(R.id.rb_white); + } + + int a = Math.round(((backgroundColor >> 24) & 0xff) / 255.0f * 100); + mSbIntensity.setProgress(a); + } + + Integer timeStyle = configMap.get("timeStyle"); + if (timeStyle != null && timeStyle != -1) { + switch (timeStyle) { + case AppWidgetConstants.TIME_STYLE_SECOND: + mRgTimeStyle.check(R.id.rb_time_style_2); + break; + case AppWidgetConstants.TIME_STYLE_THIRD: + mRgTimeStyle.check(R.id.rb_time_style_3); + break; + case AppWidgetConstants.TIME_STYLE_FIRST: + mRgTimeStyle.check(R.id.rb_time_style_1); + default: + break; + } + } + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.btn_cancel: + finish(); + break; + case R.id.btn_confirm: + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext()); + DayAppWidgetProvider.updateAppWidgetConfig(appWidgetManager, mAppWidgetId, getSettingColor(), getTimeStyle(), this); + Intent resultValue = new Intent(); + resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); + setResult(RESULT_OK, resultValue); + finish(); + break; + } + } + + public int getSettingColor() { + int progress = mSbIntensity.getProgress(); + int alpha = progress * 255 / 100; + + if (mRgBgColor.getCheckedRadioButtonId() == R.id.rb_black) { + return Color.argb(alpha, 0, 0, 0); + } else { + return Color.argb(alpha, 255, 255, 255); + } + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (seekBar.getId() == R.id.sb_intensity) { + mTvIntensity.setText(getString(R.string.app_widget_configure_intensity, progress)); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + switch (checkedId) { + case R.id.rb_time_style_1: + mTvTimeStyle.setText(getString(R.string.app_widget_configure_time_style, "Morning section")); + break; + case R.id.rb_time_style_2: + mTvTimeStyle.setText(getString(R.string.app_widget_configure_time_style, "Previous")); + break; + case R.id.rb_time_style_3: + mTvTimeStyle.setText(getString(R.string.app_widget_configure_time_style, "Upper 1")); + break; + } + } + + public int getTimeStyle() { + switch (mRgTimeStyle.getCheckedRadioButtonId()) { + case R.id.rb_time_style_2: + return AppWidgetConstants.TIME_STYLE_SECOND; + case R.id.rb_time_style_3: + return AppWidgetConstants.TIME_STYLE_THIRD; + case R.id.rb_time_style_1: + default: + return AppWidgetConstants.TIME_STYLE_FIRST; + } + } + + @Override + public void onBackPressed() { + finish(); + } +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConstants.java b/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConstants.java new file mode 100644 index 0000000..15e030c --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/AppWidgetConstants.java @@ -0,0 +1,11 @@ +package com.ulan.timetable.appwidget; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +final class AppWidgetConstants { + + static final int TIME_STYLE_FIRST = 0; + static final int TIME_STYLE_SECOND = 1; + static final int TIME_STYLE_THIRD = 2; +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/Dao/AppWidgetDao.java b/app/src/main/java/com/ulan/timetable/appwidget/Dao/AppWidgetDao.java new file mode 100644 index 0000000..c7baa12 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/Dao/AppWidgetDao.java @@ -0,0 +1,181 @@ +package com.ulan.timetable.appwidget.Dao; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + +import java.util.HashMap; +import java.util.Map; + + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +public class AppWidgetDao extends BaseDao { + + private static final String TABLE_NAME = "app_widget"; + + public static void saveAppWidgetConfig(int appWidgetId, int backgroundColor, int timeStyle, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + + ContentValues values = new ContentValues(4); + values.put("backgroundColor", backgroundColor); + values.put("timeStyle", timeStyle); + + String whereClause = "appWidgetId = ?"; + String[] whereArgs = {String.valueOf(appWidgetId)}; + + int number = update(db, TABLE_NAME, values, whereClause, whereArgs); + + if (number == 0) { + + values.put("appWidgetId", appWidgetId); + insert(db, TABLE_NAME, values); + } + + DBManager.close(db); + } + + public static Map getAppWidgetConfig(int appWidgetId, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + String selection = "appWidgetId = ?"; + String[] selectionArgs = {String.valueOf(appWidgetId)}; + String[] columns = {"backgroundColor", "timeStyle", "weekStyle"}; + Cursor cursor = queryComplex(db, TABLE_NAME, columns, selection, selectionArgs, null, null, null, null); + int count = cursor.getCount(); + + if (count == 0) { + cursor.close(); + return null; + } + + Map configMap = null; + + if (cursor.moveToNext()) {// id只存在一个,所以不用while + configMap = new HashMap<>(); + configMap.put("backgroundColor", cursor.getInt(cursor.getColumnIndex("backgroundColor"))); + configMap.put("timeStyle", cursor.getInt(cursor.getColumnIndex("timeStyle"))); + configMap.put("weekStyle", cursor.getInt(cursor.getColumnIndex("weekStyle"))); + } + + cursor.close(); + + return configMap; + } + + public static int getAppWidgetBackgroundColor(int appWidgetId, int defaultColor, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + String selection = "appWidgetId = ?"; + String[] selectionArgs = {String.valueOf(appWidgetId)}; + String[] columns = {"backgroundColor"}; + Cursor cursor = queryComplex(db, TABLE_NAME, columns, selection, selectionArgs, null, null, null, null); + int count = cursor.getCount(); + + if (count == 0) { + cursor.close(); + return defaultColor; + } + + int backgroundColorIndex = cursor.getColumnIndex("backgroundColor"); + int backgroundColor; + + if (cursor.moveToNext()) {// id只存在一个,所以不用while + backgroundColor = cursor.getInt(backgroundColorIndex); + } else { + backgroundColor = defaultColor; + } + + cursor.close(); + + return backgroundColor; + } + + public static int getAppWidgetTimeStyle(int appWidgetId, int defaultTimeStyle, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + String selection = "appWidgetId = ?"; + String[] selectionArgs = {String.valueOf(appWidgetId)}; + String[] columns = {"timeStyle"}; + Cursor cursor = queryComplex(db, TABLE_NAME, columns, selection, selectionArgs, null, null, null, null); + int count = cursor.getCount(); + + if (count == 0) { + cursor.close(); + return defaultTimeStyle; + } + + int timeStyleIndex = cursor.getColumnIndex("timeStyle"); + int timeStyle; + + if (cursor.moveToNext()) {// id只存在一个,所以不用while + timeStyle = cursor.getInt(timeStyleIndex); + } else { + timeStyle = defaultTimeStyle; + } + + cursor.close(); + + return timeStyle; + } + + public static void saveAppWidgetCurrentTime(int appWidgetId, long currentTime, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + + ContentValues values = new ContentValues(2); + values.put("currentTime", currentTime); + + String whereClause = "appWidgetId = ?"; + String[] whereArgs = {String.valueOf(appWidgetId)}; + + int number = update(db, TABLE_NAME, values, whereClause, whereArgs); + + if (number == 0) { + // 使用insertOrReplace会重置其他列的数据 + values.put("appWidgetId", appWidgetId); + insert(db, TABLE_NAME, values); + } + + DBManager.close(db); + } + + public static long getAppWidgetCurrentTime(int appWidgetId, long defaultTime, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + String selection = "appWidgetId = ?"; + String[] selectionArgs = {String.valueOf(appWidgetId)}; + String[] columns = {"currentTime"}; + Cursor cursor = queryComplex(db, TABLE_NAME, columns, selection, selectionArgs, null, null, null, null); + int count = cursor.getCount(); + + if (count == 0) { + cursor.close(); + return defaultTime; + } + + int currentTimeIndex = cursor.getColumnIndex("currentTime"); + long currentTime = 0; + + if (cursor.moveToNext()) {// id只存在一个,所以不用while + currentTime = cursor.getLong(currentTimeIndex); + } + + if (currentTime == 0) { + currentTime = defaultTime; + } + + cursor.close(); + + return currentTime; + } + + public static void deleteAppWidget(int appWidgetId, Context context) { + SQLiteDatabase db = DBManager.getDb(context); + delete(db, TABLE_NAME, "appWidgetId = ?", new String[]{String.valueOf(appWidgetId)}); + DBManager.close(db); + } + + public static void clear(Context context) { + SQLiteDatabase db = DBManager.getDb(context); + delete(db, TABLE_NAME, null, null); + DBManager.close(db); + } +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/Dao/BaseDao.java b/app/src/main/java/com/ulan/timetable/appwidget/Dao/BaseDao.java new file mode 100644 index 0000000..bee5365 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/Dao/BaseDao.java @@ -0,0 +1,96 @@ +package com.ulan.timetable.appwidget.Dao; + +import android.content.ContentValues; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +class BaseDao { + + /** + * 插入 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param contentValues 表中个字段的键值对(键的名字要和表中字段名一致,区分大小写) + */ + static void insert(SQLiteDatabase db, String tableName, ContentValues contentValues) { + db.insert(tableName, null, contentValues); + } + + /** + * 插入或替换 + * 约束值不存在,进行插入 + * 约束值存在,新数据替换掉旧数据 + * 约束值:建表时UNIQUE规定的字段 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param contentValues 表中个字段的键值对(键的名字要和表中字段名一致,区分大小写) + */ + static void insertOrReplace(SQLiteDatabase db, String tableName, ContentValues contentValues) { + db.insertWithOnConflict(tableName, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE); + } + + /** + * 插入或替换 + * 约束值不存在,进行插入 + * 约束值存在,则忽略 + * 约束值:建表时UNIQUE规定的字段 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param contentValues 表中个字段的键值对(键的名字要和表中字段名一致,区分大小写) + */ + static void insertOrIgnore(SQLiteDatabase db, String tableName, ContentValues contentValues) { + db.insertWithOnConflict(tableName, null, contentValues, SQLiteDatabase.CONFLICT_IGNORE); + } + + /** + * 删除 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param whereClause where条件 + * @param whereArgs where条件语句中的字段值 + */ + static void delete(SQLiteDatabase db, String tableName, String whereClause, String[] whereArgs) { + db.delete(tableName, whereClause, whereArgs); + } + + static int update(SQLiteDatabase db, String tableName, ContentValues values, String whereClause, String[] whereArgs) { + return db.update(tableName, values, whereClause, whereArgs); + } + + /** + * 查询 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param selection 条件语句,where部分 + * @param selectionArgs where语句中的字段值 + */ + static Cursor query(SQLiteDatabase db, String tableName, String selection, String[] selectionArgs) { + return queryComplex(db, tableName, null, selection, selectionArgs, null, null, null, null); + } + + /** + * 复杂查询 + * + * @param db 数据库 + * @param tableName 要操作的表名 + * @param columns 要获取的字段数组 + * @param selection 条件语句,where部分 + * @param selectionArgs where语句中的字段值 + * @param groupBy 与SQL中的group by语句一样 + * @param having group bu中的having语句 + * @param orderBy SQL中的排序语句 + * @param limit 限制返回的数据与偏移量 + */ + static Cursor queryComplex(SQLiteDatabase db, String tableName, String[] columns, String selection, String[] selectionArgs, String + groupBy, String having, String orderBy, String limit) { + return db.query(tableName, columns, selection, selectionArgs, groupBy, having, orderBy, limit); + } +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/Dao/DBManager.java b/app/src/main/java/com/ulan/timetable/appwidget/Dao/DBManager.java new file mode 100644 index 0000000..446fcaf --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/Dao/DBManager.java @@ -0,0 +1,28 @@ +package com.ulan.timetable.appwidget.Dao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +class DBManager { + + private static AtomicInteger sOpenCounter = new AtomicInteger(); + + static synchronized SQLiteDatabase getDb(Context context) { + sOpenCounter.incrementAndGet(); + return new DataBaseHelper(context).getWritableDatabase(); + } + + + static synchronized void close(SQLiteDatabase database) { + if (sOpenCounter.decrementAndGet() == 0) { + if (database != null) { + database.close(); + } + } + } +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/Dao/DataBaseHelper.java b/app/src/main/java/com/ulan/timetable/appwidget/Dao/DataBaseHelper.java new file mode 100644 index 0000000..8131741 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/Dao/DataBaseHelper.java @@ -0,0 +1,103 @@ +package com.ulan.timetable.appwidget.Dao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +class DataBaseHelper extends SQLiteOpenHelper { + + private static final String DB_NAME = "class_table.db"; + private static final int DB_VERSION = 3; + + public DataBaseHelper(Context context) { + super(context, DB_NAME, null, DB_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase db) { + createTables(db); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + for (int version = oldVersion + 1; version <= newVersion; version++) { + upgradeTo(db, version); + } + } + + private void upgradeTo(SQLiteDatabase db, int version) { + switch (version) { + case 1: + createTables(db); + break; + case 2: + upgradeFrom1To2(db); + break; + case 3: + upgradeFrom2To3(db); + break; + default: + throw new IllegalStateException("Don't know how to upgrade to " + version); + } + } + + private void upgradeFrom2To3(SQLiteDatabase db) { + db.execSQL("CREATE TABLE app_widget(_id INTEGER PRIMARY KEY AUTOINCREMENT , appWidgetId INTEGER , currentTime INTEGER , backgroundColor INTEGER DEFAULT -1 , timeStyle INTEGER DEFAULT -1 , weekStyle INTEGER DEFAULT -1 , UNIQUE(appWidgetId))"); + } + + private void upgradeFrom1To2(SQLiteDatabase db) { + // table_1 表主键添加自增长 + db.execSQL("CREATE TEMPORARY TABLE table_1_backup(week INTEGER , section INTEGER , time INTEGER , startWeek INTEGER , endWeek INTEGER , doubleWeek INTEGER , course CHAR , classroom CHAR)"); + db.execSQL("INSERT INTO table_1_backup SELECT week , section , time , startWeek , endWeek , doubleWeek , course , classroom FROM table_1"); + db.execSQL("DROP TABLE table_1"); + db.execSQL("CREATE TABLE table_1(_id INTEGER PRIMARY KEY AUTOINCREMENT , week INTEGER , section INTEGER , time INTEGER , startWeek INTEGER , endWeek INTEGER ,doubleWeek INTEGER , course CHAR , classroom CHAR)"); + db.execSQL("INSERT INTO table_1 (week , section , time , startWeek , endWeek , doubleWeek , course , classroom) SELECT week , section , time , startWeek , endWeek , doubleWeek , course , classroom FROM table_1_backup"); + db.execSQL("DROP TABLE table_1_backup"); + + // 创建 course_classroom 表 + db.execSQL("CREATE TABLE course_classroom(_id INTEGER PRIMARY KEY AUTOINCREMENT , course CHAR , classroom CHAR)"); + // 初始化 course_classroom 表数据 + db.execSQL("INSERT OR IGNORE INTO course_classroom (course , classroom) SELECT course , classroom FROM table_1"); + + // 删除 table_2 表 + db.execSQL("DROP TABLE IF EXISTS table_2"); + } + + @Override + public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { + for (int version = oldVersion - 1; version >= newVersion; version--) { + downgrade(db, version); + } + } + + private void downgrade(SQLiteDatabase db, int version) { + switch (version) { + case 2: + downgradeFrom3To2(db); + break; + case 1: + downgradeFrom2To1(db); + break; + default: + throw new IllegalStateException("Don't know how to downgrade to " + version); + } + } + + private void downgradeFrom3To2(SQLiteDatabase db) { + db.execSQL("DROP TABLE IF EXISTS app_widget"); + } + + private void downgradeFrom2To1(SQLiteDatabase db) { + db.execSQL("DROP TABLE IF EXISTS course_classroom"); + db.execSQL("CREATE TABLE table_2(_id INTEGER PRIMARY KEY AUTOINCREMENT , week INTEGER , section INTEGER , time INTEGER , startWeek INTEGER , endWeek INTEGER , doubleWeek INTEGER , course CHAR , classroom CHAR)"); + } + + private void createTables(SQLiteDatabase db) { + db.execSQL("CREATE TABLE table_1(_id INTEGER PRIMARY KEY AUTOINCREMENT , week INTEGER , section INTEGER , time INTEGER , startWeek INTEGER , endWeek INTEGER , doubleWeek INTEGER , course CHAR , classroom CHAR)"); + db.execSQL("CREATE TABLE course_classroom(_id INTEGER PRIMARY KEY AUTOINCREMENT , course CHAR , classroom CHAR)"); + db.execSQL("CREATE TABLE app_widget(_id INTEGER PRIMARY KEY AUTOINCREMENT , appWidgetId INTEGER , currentTime INTEGER , backgroundColor INTEGER DEFAULT -1 , timeStyle INTEGER DEFAULT -1 , weekStyle INTEGER DEFAULT -1 , UNIQUE(appWidgetId))"); + } +} diff --git a/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetProvider.java b/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetProvider.java new file mode 100644 index 0000000..ba0bbb2 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetProvider.java @@ -0,0 +1,216 @@ +package com.ulan.timetable.appwidget; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.widget.RemoteViews; + +import com.ulan.timetable.R; +import com.ulan.timetable.activities.MainActivity; +import com.ulan.timetable.appwidget.Dao.AppWidgetDao; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Locale; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +public class DayAppWidgetProvider extends AppWidgetProvider { + + private static final String ACTION_RESTORE = "com.ulan.timetable" + ".ACTION_RESTORE"; + private static final String ACTION_YESTERDAY = "com.ulan.timetable" + ".ACTION_YESTERDAY"; + private static final String ACTION_TOMORROW = "com.ulan.timetable" + ".ACTION_TOMORROW"; + private static final String ACTION_NEW_DAY = "com.ulan.timetable" + ".ACTION_NEW_DAY"; + + private static final int ONE_DAY_MILLIS = 86400000; + + @Override + public void onEnabled(Context context) { + registerNewDayBroadcast(context); + } + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + + if (isAlarmManagerNotSet(context)) { + registerNewDayBroadcast(context); + } + + for (int appWidgetId : appWidgetIds) { + Intent intent = new Intent(context, DayAppWidgetService.class); + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); + + long currentTimeMillis = System.currentTimeMillis(); + AppWidgetDao.saveAppWidgetCurrentTime(appWidgetId, currentTimeMillis, context); + + RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.day_appwidget); + rv.setRemoteAdapter(R.id.lv_day_appwidget, intent); + rv.setEmptyView(R.id.lv_day_appwidget, R.id.empty_view); + rv.setTextViewText(R.id.tv_date, getDateText(currentTimeMillis)); + rv.setInt(R.id.fl_root, "setBackgroundColor", AppWidgetDao.getAppWidgetBackgroundColor(appWidgetId, Color.TRANSPARENT, context)); + + rv.setOnClickPendingIntent(R.id.imgBtn_restore, makePendingIntent(context, appWidgetId, ACTION_RESTORE)); + rv.setOnClickPendingIntent(R.id.imgBtn_yesterday, makePendingIntent(context, appWidgetId, ACTION_YESTERDAY)); + rv.setOnClickPendingIntent(R.id.imgBtn_tomorrow, makePendingIntent(context, appWidgetId, ACTION_TOMORROW)); + + Intent listviewClickIntent = new Intent(context, MainActivity.class); + listviewClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + listviewClickIntent.setAction(Intent.ACTION_VIEW); + PendingIntent listviewPendingIntent = PendingIntent.getActivity(context, appWidgetId, listviewClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); + rv.setPendingIntentTemplate(R.id.lv_day_appwidget, listviewPendingIntent); + + appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.lv_day_appwidget); + appWidgetManager.updateAppWidget(appWidgetId, rv); + } + } + + private static String getDateText(long currentTimeMillis) { + return new SimpleDateFormat("E d.M.", Locale.getDefault()).format(currentTimeMillis); + } + + @Override + public void onDeleted(Context context, int[] appWidgetIds) { + for (int appWidgetId : appWidgetIds) { + AppWidgetDao.deleteAppWidget(appWidgetId, context); + } + } + + @Override + public void onDisabled(Context context) { + unregisterNewDayBroadcast(context); + AppWidgetDao.clear(context); + } + + @Override + public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { + onUpdate(context, appWidgetManager, new int[]{appWidgetId}); + } + + private PendingIntent makePendingIntent(Context context, int appWidgetId, String action) { + Intent intent = new Intent(context, DayAppWidgetProvider.class); + intent.setAction(action); + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + } + + static void updateAppWidgetConfig(AppWidgetManager appWidgetManager, int appWidgetId, int backgroundColor, int timeStyle, Context context) { + AppWidgetDao.saveAppWidgetConfig(appWidgetId, backgroundColor, timeStyle, context); + + Intent intent = new Intent(context, DayAppWidgetService.class); + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); + + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.day_appwidget); + views.setRemoteAdapter(R.id.lv_day_appwidget, intent); + views.setEmptyView(R.id.lv_day_appwidget, R.id.empty_view); + views.setInt(R.id.fl_root, "setBackgroundColor", backgroundColor); + views.setTextViewText(R.id.tv_date, getDateText(System.currentTimeMillis())); + appWidgetManager.partiallyUpdateAppWidget(appWidgetId, views); + } + + @Override + public void onReceive(Context context, Intent intent) { + + String action = intent.getAction(); + + if (ACTION_NEW_DAY.equals(action)) { + notifyUpdate(context); + return; + } + + if (ACTION_RESTORE.equals(action) || ACTION_YESTERDAY.equals(action) || ACTION_TOMORROW.equals(action)) { + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); + RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.day_appwidget); + int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + + long currentTime; + long newTime; + + if (ACTION_RESTORE.equals(action)) { + rv.setViewVisibility(R.id.imgBtn_restore, View.INVISIBLE); + newTime = System.currentTimeMillis(); + } else if (ACTION_YESTERDAY.equals(action)) { + rv.setViewVisibility(R.id.imgBtn_restore, View.VISIBLE); + currentTime = AppWidgetDao.getAppWidgetCurrentTime(appWidgetId, System.currentTimeMillis(), context); + newTime = currentTime - ONE_DAY_MILLIS; + } else { //ACTION_TOMORROW + rv.setViewVisibility(R.id.imgBtn_restore, View.VISIBLE); + currentTime = AppWidgetDao.getAppWidgetCurrentTime(appWidgetId, System.currentTimeMillis(), context); + newTime = currentTime + ONE_DAY_MILLIS; + } + if (("" + newTime).substring(0, 7).equalsIgnoreCase(("" + System.currentTimeMillis()).substring(0, 7))) { + rv.setViewVisibility(R.id.imgBtn_restore, View.INVISIBLE); + } + + AppWidgetDao.saveAppWidgetCurrentTime(appWidgetId, newTime, context); + rv.setTextViewText(R.id.tv_date, getDateText(newTime)); + + appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.lv_day_appwidget); + appWidgetManager.partiallyUpdateAppWidget(appWidgetId, rv); + } + + super.onReceive(context, intent); + } + + public void notifyUpdate(Context context) { + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); + int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, + DayAppWidgetProvider.class)); + onUpdate(context, appWidgetManager, appWidgetIds); + } + + private void registerNewDayBroadcast(Context context) { + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + + if (alarmManager == null) { + return; + } + + Intent intent = new Intent(context, DayAppWidgetProvider.class); + intent.setAction(ACTION_NEW_DAY); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); + + Calendar midnight = Calendar.getInstance(Locale.getDefault()); + midnight.set(Calendar.HOUR_OF_DAY, 0); + midnight.set(Calendar.MINUTE, 0); + midnight.set(Calendar.SECOND, 1); // + midnight.set(Calendar.MILLISECOND, 0); + midnight.add(Calendar.DAY_OF_YEAR, 1); + + alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, midnight.getTimeInMillis(), ONE_DAY_MILLIS, pendingIntent); + } + + private void unregisterNewDayBroadcast(Context context) { + AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + + if (alarmManager == null) { + return; + } + + Intent intent = new Intent(context, DayAppWidgetProvider.class); + intent.setAction(ACTION_NEW_DAY); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE); + if (pendingIntent != null) { + alarmManager.cancel(pendingIntent); + pendingIntent.cancel(); + } + } + + private boolean isAlarmManagerNotSet(Context context) { + Intent intent = new Intent(context, DayAppWidgetProvider.class); + intent.setAction(ACTION_NEW_DAY); + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE) == null; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetService.java b/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetService.java new file mode 100644 index 0000000..9e785b7 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/appwidget/DayAppWidgetService.java @@ -0,0 +1,117 @@ +package com.ulan.timetable.appwidget; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.Intent; +import android.widget.RemoteViews; +import android.widget.RemoteViewsService; + +import com.ulan.timetable.R; +import com.ulan.timetable.appwidget.Dao.AppWidgetDao; +import com.ulan.timetable.model.Week; +import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.PreferenceUtil; +import com.ulan.timetable.utils.WeekUtils; + +import java.util.ArrayList; +import java.util.Calendar; + +import static com.ulan.timetable.utils.NotificationUtil.getCurrentDay; + +/** + * From https://github.com/SubhamTyagi/TimeTable + */ +public class DayAppWidgetService extends RemoteViewsService { + + @Override + public RemoteViewsFactory onGetViewFactory(Intent intent) { + return new DayAppWidgetRemoteViewsFactory(this.getApplicationContext(), intent); + } +} + +class DayAppWidgetRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { + + private final Context mContext; + private ArrayList content; + private final int mAppWidgetId; + + DayAppWidgetRemoteViewsFactory(Context context, Intent intent) { + mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + mContext = context; + } + + @Override + public void onCreate() { + long currentTime = AppWidgetDao.getAppWidgetCurrentTime(mAppWidgetId, System.currentTimeMillis(), mContext); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(currentTime); + content = new DbHelper(mContext).getWeek(getCurrentDay(calendar.get(Calendar.DAY_OF_WEEK))); + } + + @Override + public void onDataSetChanged() { + onCreate(); + } + + @Override + public void onDestroy() { + content.clear(); + } + + @Override + public int getCount() { + return content.size(); + } + + @Override + public RemoteViews getViewAt(int position) { + + RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.item_day_appwidget); + Week week = content.get(position); + +// String lessons = getLessons(content, mContext); + if (week != null) { + String time; + if (PreferenceUtil.showTimes(mContext)) + time = week.getFromTime() + " - " + week.getToTime(); + else { + int start = WeekUtils.getMatchingScheduleBegin(week.getFromTime(), PreferenceUtil.getStartTime(mContext), PreferenceUtil.getPeriodLength(mContext)); + int end = WeekUtils.getMatchingScheduleEnd(week.getToTime(), PreferenceUtil.getStartTime(mContext), PreferenceUtil.getPeriodLength(mContext)); + if (start == end) { + time = start + ". " + mContext.getString(R.string.lesson); + } else { + time = start + ".-" + end + ". " + mContext.getString(R.string.lesson); + } + } + + String text = week.getSubject() + ": " + time + ", " + week.getRoom() + " (" + week.getTeacher() + ")"; + rv.setTextViewText(R.id.widget_text, text); + } + + //Set OpenApp Button intent + Intent intent = new Intent(); + intent.putExtra("keyData", position); + rv.setOnClickFillInIntent(R.id.widget_linear, intent); + return rv; + } + + @Override + public RemoteViews getLoadingView() { + return null; + } + + @Override + public int getViewTypeCount() { + return 1; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public boolean hasStableIds() { + return true; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/FridayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/FridayFragment.java deleted file mode 100644 index 2b83982..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/FridayFragment.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - - -public class FridayFragment extends Fragment { - - public static final String KEY_FRIDAY_FRAGMENT = "Friday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_friday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.fridaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_FRIDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} diff --git a/app/src/main/java/com/ulan/timetable/fragments/MondayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/MondayFragment.java deleted file mode 100644 index 904cabc..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/MondayFragment.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - - -public class MondayFragment extends Fragment { - - public static final String KEY_MONDAY_FRAGMENT = "Monday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - private ImageView popup; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_monday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - popup = view.findViewById(R.id.popupbtn); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.mondaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_MONDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/SaturdayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/SaturdayFragment.java deleted file mode 100644 index cea5705..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/SaturdayFragment.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - -public class SaturdayFragment extends Fragment { - - public static final String KEY_SATURDAY_FRAGMENT = "Saturday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_saturday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.saturdaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_SATURDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} diff --git a/app/src/main/java/com/ulan/timetable/fragments/SettingsFragment.java b/app/src/main/java/com/ulan/timetable/fragments/SettingsFragment.java index c832a58..b6cfea5 100644 --- a/app/src/main/java/com/ulan/timetable/fragments/SettingsFragment.java +++ b/app/src/main/java/com/ulan/timetable/fragments/SettingsFragment.java @@ -1,9 +1,23 @@ package com.ulan.timetable.fragments; +import android.app.AlarmManager; +import android.app.TimePickerDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.v7.preference.PreferenceFragmentCompat; + +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.PreferenceGroup; +import androidx.preference.PreferenceManager; import com.ulan.timetable.R; +import com.ulan.timetable.activities.TimeSettingsActivity; +import com.ulan.timetable.receivers.DailyReceiver; +import com.ulan.timetable.utils.PreferenceUtil; public class SettingsFragment extends PreferenceFragmentCompat { @@ -11,5 +25,96 @@ public class SettingsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.settings, rootKey); + + tintIcons(getPreferenceScreen(), PreferenceUtil.getTextColorPrimary(getContext())); + + setNotif(); + + Preference myPref = findPreference("timetableNotif"); + myPref.setOnPreferenceClickListener((Preference preference) -> { + setNotif(); + return true; + }); + + myPref = findPreference("alarm"); + Preference finalMyPref = myPref; + myPref.setOnPreferenceClickListener((Preference p) -> { + int[] oldTimes = PreferenceUtil.getAlarmTime(getContext()); + TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), + (view, hourOfDay, minute) -> { + PreferenceUtil.setAlarmTime(getContext(), hourOfDay, minute, 0); + PreferenceUtil.setRepeatingAlarm(getContext(), DailyReceiver.class, hourOfDay, minute, 0, DailyReceiver.DailyReceiverID, AlarmManager.INTERVAL_DAY); + finalMyPref.setSummary(hourOfDay + ":" + minute); + }, oldTimes[0], oldTimes[1], true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); + return true; + }); + int[] oldTimes = PreferenceUtil.getAlarmTime(getContext()); + myPref.setSummary(oldTimes[0] + ":" + oldTimes[1]); + + setTurnOff(); + myPref = findPreference("automatic_do_not_disturb"); + myPref.setOnPreferenceClickListener((Preference p) -> { + PreferenceUtil.setDoNotDisturb(getActivity(), false); + setTurnOff(); + return true; + }); + + ListPreference mp = findPreference("theme"); + mp.setOnPreferenceChangeListener((preference, newValue) -> { + mp.setValue(newValue + ""); + getActivity().recreate(); + return false; + }); + mp.setSummary(getThemeName()); + + myPref = findPreference("time_settings"); + myPref.setOnPreferenceClickListener(p -> { + startActivity(new Intent(getActivity(), TimeSettingsActivity.class)); + return true; + }); + } + + private String getThemeName() { + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + + String selectedTheme = sharedPreferences.getString("theme", "switch"); + String[] values = getResources().getStringArray(R.array.theme_array_values); + + String[] names = getResources().getStringArray(R.array.theme_array); + + for (int i = 0; i < values.length; i++) { + if (values[i].equalsIgnoreCase(selectedTheme)) { + return names[i]; + } + } + + return ""; + } + + private void setNotif() { + boolean show = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("timetableNotif", true); + findPreference("alwaysNotification").setVisible(show); + findPreference("alarm").setVisible(show); + } + + private void setTurnOff() { + boolean show = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("automatic_do_not_disturb", true); + findPreference("do_not_disturb_turn_off").setVisible(show); + } + + private static void tintIcons(Preference preference, int color) { + if (preference instanceof PreferenceGroup) { + PreferenceGroup group = ((PreferenceGroup) preference); + for (int i = 0; i < group.getPreferenceCount(); i++) { + tintIcons(group.getPreference(i), color); + } + } else { + Drawable icon = preference.getIcon(); + if (icon != null) { + DrawableCompat.setTint(icon, color); + } + } } } diff --git a/app/src/main/java/com/ulan/timetable/fragments/SundayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/SundayFragment.java deleted file mode 100644 index ea81373..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/SundayFragment.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.support.v4.app.Fragment; -import android.os.Bundle;; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - - -/** - * Created by Ulan on 06.09.2018. - */ -public class SundayFragment extends Fragment { - - public static final String KEY_SUNDAY_FRAGMENT = "Sunday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - private int listposition = 0; - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_sunday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.sundaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_SUNDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/ThursdayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/ThursdayFragment.java deleted file mode 100644 index eac9f0f..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/ThursdayFragment.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - - -public class ThursdayFragment extends Fragment { - - public static final String KEY_THURSDAY_FRAGMENT = "Thursday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_thursday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.thursdaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_THURSDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/TimeSettingsFragment.java b/app/src/main/java/com/ulan/timetable/fragments/TimeSettingsFragment.java new file mode 100644 index 0000000..4a70183 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/fragments/TimeSettingsFragment.java @@ -0,0 +1,58 @@ +package com.ulan.timetable.fragments; + +import android.app.TimePickerDialog; +import android.os.Bundle; +import android.widget.NumberPicker; + +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; + +import com.afollestad.materialdialogs.MaterialDialog; +import com.ulan.timetable.R; +import com.ulan.timetable.utils.PreferenceUtil; + + +public class TimeSettingsFragment extends PreferenceFragmentCompat { + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.settings_time, rootKey); + + Preference myPref = findPreference("start_time"); + Preference finalMyPref = myPref; + myPref.setOnPreferenceClickListener((Preference p) -> { + int[] oldTimes = PreferenceUtil.getStartTime(getContext()); + TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), + (view, hourOfDay, minute) -> { + PreferenceUtil.setStartTime(getContext(), hourOfDay, minute, 0); + finalMyPref.setSummary(hourOfDay + ":" + minute); + }, oldTimes[0], oldTimes[1], true); + timePickerDialog.setTitle(R.string.start_of_school); + timePickerDialog.show(); + return true; + }); + int[] oldTimes = PreferenceUtil.getStartTime(getContext()); + myPref.setSummary(oldTimes[0] + ":" + oldTimes[1]); + + + myPref = findPreference("set_period_length"); + Preference finalMyPref1 = myPref; + myPref.setOnPreferenceClickListener((Preference p) -> { + NumberPicker numberPicker = new NumberPicker(getContext()); + numberPicker.setMaxValue(180); + numberPicker.setMinValue(1); + numberPicker.setValue(PreferenceUtil.getPeriodLength(getContext())); + new MaterialDialog.Builder(getContext()) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((d, w) -> { + int value = numberPicker.getValue(); + PreferenceUtil.setPeriodLength(getContext(), value); + finalMyPref1.setSummary(value + " " + getString(R.string.minutes)); + }) + .show(); + return true; + }); + myPref.setSummary(PreferenceUtil.getPeriodLength(getContext()) + " " + getString(R.string.minutes)); + } +} diff --git a/app/src/main/java/com/ulan/timetable/fragments/TuesdayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/TuesdayFragment.java deleted file mode 100644 index a2aa9a0..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/TuesdayFragment.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - -public class TuesdayFragment extends Fragment { - - public static final String KEY_TUESDAY_FRAGMENT = "Tuesday"; - private WeekAdapter adapter; - private ListView listView; - private DbHelper db; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_tuesday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.tuesdaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_TUESDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/WednesdayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/WednesdayFragment.java deleted file mode 100644 index ea084d4..0000000 --- a/app/src/main/java/com/ulan/timetable/fragments/WednesdayFragment.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.ulan.timetable.fragments; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.ulan.timetable.adapters.WeekAdapter; -import com.ulan.timetable.utils.DbHelper; -import com.ulan.timetable.R; -import com.ulan.timetable.utils.FragmentHelper; - - -public class WednesdayFragment extends Fragment { - - public static final String KEY_WEDNESDAY_FRAGMENT = "Wednesday"; - private DbHelper db; - private ListView listView; - private WeekAdapter adapter; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_wednesday, container, false); - setupAdapter(view); - setupListViewMultiSelect(); - return view; - } - - private void setupAdapter(View view) { - db = new DbHelper(getActivity()); - listView = view.findViewById(R.id.wednesdaylist); - adapter = new WeekAdapter(getActivity(), listView, R.layout.listview_week_adapter, db.getWeek(KEY_WEDNESDAY_FRAGMENT)); - listView.setAdapter(adapter); - } - - private void setupListViewMultiSelect() { - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect(getActivity(), listView, adapter, db)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/fragments/WeekdayFragment.java b/app/src/main/java/com/ulan/timetable/fragments/WeekdayFragment.java new file mode 100644 index 0000000..923e83d --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/fragments/WeekdayFragment.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; + +import com.ulan.timetable.R; +import com.ulan.timetable.adapters.WeekAdapter; +import com.ulan.timetable.model.Week; +import com.ulan.timetable.utils.DbHelper; +import com.ulan.timetable.utils.FragmentHelper; + +import java.util.ArrayList; + +public class WeekdayFragment extends Fragment { + public static final String KEY_MONDAY_FRAGMENT = "Monday"; + public static final String KEY_TUESDAY_FRAGMENT = "Tuesday"; + public static final String KEY_WEDNESDAY_FRAGMENT = "Wednesday"; + public static final String KEY_THURSDAY_FRAGMENT = "Thursday"; + public static final String KEY_FRIDAY_FRAGMENT = "Friday"; + public static final String KEY_SATURDAY_FRAGMENT = "Saturday"; + public static final String KEY_SUNDAY_FRAGMENT = "Sunday"; + + @Nullable + private DbHelper db; + private ListView listView; + @Nullable + private WeekAdapter adapter; + private View view; + + private final String key; + + public WeekdayFragment(String key) { + super(); + this.key = key; + } + + public WeekdayFragment() { + super(); + this.key = KEY_MONDAY_FRAGMENT; + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.fragment_weekday, container, false); + return view; + } + + @Override + public void onStart() { + super.onStart(); + setupAdapter(view); + setupListViewMultiSelect(); + } + + private void setupAdapter(@NonNull View view) { + db = new DbHelper(getActivity()); + listView = view.findViewById(R.id.daylist); + ArrayList weeks = db.getWeek(key); + adapter = new WeekAdapter((AppCompatActivity) getActivity(), listView, 0, weeks); + listView.setAdapter(adapter); + } + + private void setupListViewMultiSelect() { + listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); + listView.setMultiChoiceModeListener(FragmentHelper.setupListViewMultiSelect((AppCompatActivity) getActivity(), listView, adapter, db)); + } + + public String getKey() { + return key; + } +} diff --git a/app/src/main/java/com/ulan/timetable/receivers/DailyReceiver.java b/app/src/main/java/com/ulan/timetable/receivers/DailyReceiver.java new file mode 100644 index 0000000..add9dca --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/receivers/DailyReceiver.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.receivers; + +import android.app.AlarmManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import androidx.annotation.NonNull; + +import com.ulan.timetable.utils.NotificationUtil; +import com.ulan.timetable.utils.PreferenceUtil; + +/** + * Created by Ulan on 28.01.2019. + */ +public class DailyReceiver extends BroadcastReceiver { + + public static final int DailyReceiverID = 10000; + + @Override + public void onReceive(@NonNull Context context, @NonNull Intent intent) { + if (intent.getAction() != null) { + if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) { + // Set the alarm here. + if (PreferenceUtil.isAlarmOn(context)) { + int[] times = PreferenceUtil.getAlarmTime(context); + PreferenceUtil.setRepeatingAlarm(context, DailyReceiver.class, times[0], times[1], times[2], DailyReceiverID, AlarmManager.INTERVAL_DAY); + } else + PreferenceUtil.cancelAlarm(context, DailyReceiver.class, DailyReceiverID); + NotificationUtil.sendNotificationSummary(context, true); + return; + } + } + + if (!PreferenceUtil.isAlarmOn(context)) { + PreferenceUtil.cancelAlarm(context, DailyReceiver.class, DailyReceiverID); + } else { + NotificationUtil.sendNotificationSummary(context, true); + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/receivers/DoNotDisturbReceivers.kt b/app/src/main/java/com/ulan/timetable/receivers/DoNotDisturbReceivers.kt new file mode 100644 index 0000000..8b0bd13 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/receivers/DoNotDisturbReceivers.kt @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.receivers + +import android.app.NotificationManager +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.os.Build +import com.ulan.timetable.utils.DbHelper +import com.ulan.timetable.utils.NotificationUtil +import com.ulan.timetable.utils.PreferenceUtil +import java.util.* + +class TurnOnReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action != null) { + if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED, ignoreCase = true)) { + // Set the alarm here. + setDoNotDisturbReceivers(context) + NotificationUtil.sendNotificationCurrentLesson(context, false) + return + } + } + + setDoNotDisturbReceivers(context) + setDoNotDisturb(context, true) + } + + companion object { + const val TurnOn_ID = 30000 + } +} + +class TurnOffReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent?) { + setDoNotDisturbReceivers(context) + if (PreferenceUtil.isDoNotDisturbTurnOff(context)) + setDoNotDisturb(context, false) + } + + companion object { + const val TurnOff_ID = 60000 + } +} + + +fun setDoNotDisturb(context: Context, on: Boolean) { + NotificationUtil.sendNotificationCurrentLesson(context, true) + if (!PreferenceUtil.isAutomaticDoNotDisturb(context)) + return + + val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + // Check if the notification policy access has been granted for the app. + if (notificationManager.isNotificationPolicyAccessGranted) { + val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + mNotificationManager.setInterruptionFilter(if (on) NotificationManager.INTERRUPTION_FILTER_NONE else NotificationManager.INTERRUPTION_FILTER_ALL) + } + } +} + +fun setDoNotDisturbReceivers(context: Context) { + Thread(Runnable { + val dbHelper = DbHelper(context) + val calendar = Calendar.getInstance() + val currentDay = NotificationUtil.getCurrentDay(calendar.get(Calendar.DAY_OF_WEEK)) + val weeks = dbHelper.getWeek(currentDay) + + var lastCalendar = Calendar.getInstance() + lastCalendar.set(Calendar.HOUR_OF_DAY, 23) + lastCalendar.set(Calendar.MINUTE, 59) + var on: Boolean? = null + + for (week in weeks) { + val weekCalendarStart = Calendar.getInstance() + val startHour = Integer.parseInt(week.fromTime.substring(0, week.fromTime.indexOf(":"))) + weekCalendarStart.set(Calendar.HOUR_OF_DAY, startHour) + val startMinute = Integer.parseInt(week.fromTime.substring(week.fromTime.indexOf(":") + 1)) + weekCalendarStart.set(Calendar.MINUTE, startMinute) + + if (((startHour == calendar.get(Calendar.HOUR_OF_DAY) && startMinute >= calendar.get(Calendar.MINUTE)) || startHour > calendar.get(Calendar.HOUR_OF_DAY)) && ((startHour == lastCalendar.get(Calendar.HOUR_OF_DAY) && startMinute <= lastCalendar.get(Calendar.MINUTE)) || startHour < lastCalendar.get(Calendar.HOUR_OF_DAY))) { + lastCalendar = weekCalendarStart + on = true + } + + val weekCalendarEnd = Calendar.getInstance() + val endHour = Integer.parseInt(week.toTime.substring(0, week.toTime.indexOf(":"))) + weekCalendarEnd.set(Calendar.HOUR_OF_DAY, endHour) + val endMinute = Integer.parseInt(week.toTime.substring(week.toTime.indexOf(":") + 1)) + weekCalendarEnd.set(Calendar.MINUTE, endMinute) + + if (((endHour == calendar.get(Calendar.HOUR_OF_DAY) && endMinute > calendar.get(Calendar.MINUTE)) || endHour > calendar.get(Calendar.HOUR_OF_DAY)) && ((endHour == lastCalendar.get(Calendar.HOUR_OF_DAY) && endMinute < lastCalendar.get(Calendar.MINUTE)) || endHour < lastCalendar.get(Calendar.HOUR_OF_DAY))) { + lastCalendar = weekCalendarEnd + on = false + } + + if (((startHour == calendar.get(Calendar.HOUR_OF_DAY) && startMinute <= calendar.get(Calendar.MINUTE)) || startHour < calendar.get(Calendar.HOUR_OF_DAY)) && ((endHour == calendar.get(Calendar.HOUR_OF_DAY) && endMinute > calendar.get(Calendar.MINUTE)) || endHour > calendar.get(Calendar.HOUR_OF_DAY))) { + //Just in lesson + setDoNotDisturb(context, true) + } + } + + if (on != null) { + if (on) { + PreferenceUtil.setOneTimeAlarm(context, TurnOnReceiver::class.java, lastCalendar.get(Calendar.HOUR_OF_DAY), lastCalendar.get(Calendar.MINUTE), 0, TurnOnReceiver.TurnOn_ID) + } else { + PreferenceUtil.setOneTimeAlarm(context, TurnOffReceiver::class.java, lastCalendar.get(Calendar.HOUR_OF_DAY), lastCalendar.get(Calendar.MINUTE), 0, TurnOffReceiver.TurnOff_ID) + } + } + }).start() +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/receivers/NotificationDismissButtonReceiver.java b/app/src/main/java/com/ulan/timetable/receivers/NotificationDismissButtonReceiver.java new file mode 100755 index 0000000..18e1414 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/receivers/NotificationDismissButtonReceiver.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.receivers; + +import android.app.NotificationManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import androidx.annotation.NonNull; + +public class NotificationDismissButtonReceiver extends BroadcastReceiver { + public static final String EXTRA_NOTIFICATION_ID = "EXTRA_NOTIFICATION_ID"; + + @Override + public void onReceive(@NonNull Context context, @NonNull Intent intent) { + // if you want cancel notification + int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, 0); + + // if you want cancel notification + NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + manager.cancel(notificationId); + } +} diff --git a/app/src/main/java/com/ulan/timetable/utils/AlertDialogsHelper.java b/app/src/main/java/com/ulan/timetable/utils/AlertDialogsHelper.java index 240caf4..78225ec 100644 --- a/app/src/main/java/com/ulan/timetable/utils/AlertDialogsHelper.java +++ b/app/src/main/java/com/ulan/timetable/utils/AlertDialogsHelper.java @@ -1,46 +1,56 @@ package com.ulan.timetable.utils; -import android.app.Activity; import android.app.DatePickerDialog; import android.app.TimePickerDialog; +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v4.content.ContextCompat; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AlertDialog; +import android.provider.CalendarContract; import android.text.TextUtils; +import android.view.KeyEvent; import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; import android.widget.Button; -import android.widget.DatePicker; import android.widget.EditText; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.NumberPicker; import android.widget.TextView; -import android.widget.TimePicker; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.viewpager.widget.ViewPager; + +import com.afollestad.materialdialogs.DialogAction; +import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; +import com.pd.chocobar.ChocoBar; +import com.ulan.timetable.R; import com.ulan.timetable.adapters.ExamsAdapter; import com.ulan.timetable.adapters.FragmentsTabAdapter; import com.ulan.timetable.adapters.HomeworksAdapter; import com.ulan.timetable.adapters.NotesAdapter; import com.ulan.timetable.adapters.TeachersAdapter; -import com.ulan.timetable.adapters.WeekAdapter; +import com.ulan.timetable.fragments.WeekdayFragment; import com.ulan.timetable.model.Exam; import com.ulan.timetable.model.Homework; import com.ulan.timetable.model.Note; import com.ulan.timetable.model.Teacher; import com.ulan.timetable.model.Week; -import com.ulan.timetable.R; - -import org.xdty.preference.colorpicker.ColorPickerDialog; -import org.xdty.preference.colorpicker.ColorPickerSwatch; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; +import java.util.Locale; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; + +import me.jfenn.colorpickerdialog.dialogs.ColorPickerDialog; +import me.jfenn.colorpickerdialog.views.picker.RGBPickerView; /** @@ -48,91 +58,148 @@ */ public class AlertDialogsHelper { - public static void getEditSubjectDialog(final Activity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int position) { + public static void getEditSubjectDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, Runnable runOnSafe, @NonNull final Week week) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subject_dialog); editTextHashs.put(R.string.subject, subject); final EditText teacher = alertLayout.findViewById(R.id.teacher_dialog); - editTextHashs.put(R.string.teacher, teacher); +// editTextHashs.put(R.string.teacher, teacher); final EditText room = alertLayout.findViewById(R.id.room_dialog); - editTextHashs.put(R.string.room, room); +// editTextHashs.put(R.string.room, room); final TextView from_time = alertLayout.findViewById(R.id.from_time); final TextView to_time = alertLayout.findViewById(R.id.to_time); + final TextView from_hour = alertLayout.findViewById(R.id.from_hour); + final TextView to_hour = alertLayout.findViewById(R.id.to_hour); final Button select_color = alertLayout.findViewById(R.id.select_color); - final Week week = adapter.get(position); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(week.getColor(), Color.WHITE, Color.BLACK)); subject.setText(week.getSubject()); teacher.setText(week.getTeacher()); room.setText(week.getRoom()); from_time.setText(week.getFromTime()); to_time.setText(week.getToTime()); + from_hour.setText("" + WeekUtils.getMatchingScheduleBegin(week.getFromTime(), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + to_hour.setText("" + WeekUtils.getMatchingScheduleEnd(week.getToTime(), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); select_color.setBackgroundColor(week.getColor() != 0 ? week.getColor() : Color.WHITE); - from_time.setOnClickListener(new View.OnClickListener() { + from_time.setOnClickListener(v -> { + int mHour = Integer.parseInt(week.getFromTime().substring(0, week.getFromTime().indexOf(":"))); + int mMinute = Integer.parseInt(week.getFromTime().substring(week.getFromTime().indexOf(":") + 1)); + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute) -> { + from_time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + week.setFromTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + from_hour.setText("" + WeekUtils.getMatchingScheduleBegin(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, mHour, mMinute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); + }); - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int mHour = c.get(Calendar.HOUR_OF_DAY); - int mMinute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - from_time.setText(String.format("%02d:%02d", hourOfDay, minute)); - week.setFromTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, mHour, mMinute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); - } + to_time.setOnClickListener(v -> { + int mHour = Integer.parseInt(week.getToTime().substring(0, week.getToTime().indexOf(":"))); + int mMinute = Integer.parseInt(week.getToTime().substring(week.getToTime().indexOf(":") + 1)); + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute1) -> { + to_time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute1)); + week.setToTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute1)); + to_hour.setText("" + WeekUtils.getMatchingScheduleEnd(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute1), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, mHour, mMinute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); }); - to_time.setOnClickListener(new View.OnClickListener() { + from_hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + numberPicker.setValue(Integer.parseInt(from_hour.getText().toString())); + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + from_time.setText(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + week.setFromTime(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + from_hour.setText("" + value); + }) + .show(); + }); - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int hour = c.get(Calendar.HOUR_OF_DAY); - int minute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - to_time.setText(String.format("%02d:%02d", hourOfDay, minute)); - week.setToTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, hour, minute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); - } + to_hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + numberPicker.setValue(Integer.parseInt(to_hour.getText().toString())); + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + to_time.setText(WeekUtils.getMatchingTimeEnd(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + week.setToTime(WeekUtils.getMatchingTimeEnd(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + to_hour.setText("" + value); + }) + .show(); }); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } + + return true; + } + } + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + } } }); @@ -145,115 +212,202 @@ public void onColorSelected(int color) { final AlertDialog dialog = alert.create(); dialog.show(); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + subject.getText().clear(); + teacher.getText().clear(); + room.getText().clear(); + from_time.setText(R.string.select_start_time); + to_time.setText(R.string.select_end_time); + from_hour.setText(R.string.lesson); + to_hour.setText(R.string.lesson); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + from_hour.setText(R.string.lesson); + to_hour.setText(R.string.lesson); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())) { - for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { - entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - entry.getValue().requestFocus(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText()) /*|| TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())*/) { + for (Map.Entry entry : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(entry.getValue().getText())) { + entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + entry.getValue().requestFocus(); } - } else if(!from_time.getText().toString().matches(".*\\d+.*") || !to_time.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper db = new DbHelper(activity); - WeekAdapter weekAdapter = (WeekAdapter) listView.getAdapter(); // In order to get notifyDataSetChanged() method. - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - week.setSubject(subject.getText().toString()); - week.setTeacher(teacher.getText().toString()); - week.setRoom(room.getText().toString()); - week.setColor(buttonColor.getColor()); - db.updateWeek(week); - weekAdapter.notifyDataSetChanged(); - dialog.dismiss(); } + } else if (!from_time.getText().toString().matches(".*\\d+.*") || !to_time.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); + } else { + DbHelper db = new DbHelper(activity); + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + week.setSubject(subject.getText().toString()); + week.setTeacher(teacher.getText().toString()); + week.setRoom(room.getText().toString()); + week.setColor(buttonColor.getColor()); + db.updateWeek(week); + runOnSafe.run(); + dialog.dismiss(); } }); } - public static void getAddSubjectDialog(final Activity activity, final View alertLayout, final FragmentsTabAdapter adapter, final ViewPager viewPager) { + public static void getAddSubjectDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final FragmentsTabAdapter adapter, @NonNull final ViewPager viewPager) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subject_dialog); + subject.requestFocus(); editTextHashs.put(R.string.subject, subject); final EditText teacher = alertLayout.findViewById(R.id.teacher_dialog); - editTextHashs.put(R.string.teacher, teacher); +// editTextHashs.put(R.string.teacher, teacher); final EditText room = alertLayout.findViewById(R.id.room_dialog); - editTextHashs.put(R.string.room, room); +// editTextHashs.put(R.string.room, room); + final TextView from_time = alertLayout.findViewById(R.id.from_time); final TextView to_time = alertLayout.findViewById(R.id.to_time); + final TextView from_hour = alertLayout.findViewById(R.id.from_hour); + final TextView to_hour = alertLayout.findViewById(R.id.to_hour); + + from_hour.setText(R.string.select_start_time); + to_hour.setText(R.string.select_end_time); + final Button select_color = alertLayout.findViewById(R.id.select_color); +// select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(((ColorDrawable) select_color.getBackground()).getColor(), Color.WHITE, Color.BLACK)); + final Week week = new Week(); - from_time.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int mHour = c.get(Calendar.HOUR_OF_DAY); - int mMinute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - from_time.setText(String.format("%02d:%02d", hourOfDay, minute)); - week.setFromTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, mHour, mMinute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); }}); + if (PreferenceUtil.showTimes(activity)) { + from_hour.setVisibility(View.GONE); + from_time.setVisibility(View.VISIBLE); + from_time.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + + to_hour.setVisibility(View.GONE); + to_time.setVisibility(View.VISIBLE); + to_time.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + } else { + from_hour.setVisibility(View.VISIBLE); + from_time.setVisibility(View.GONE); + from_hour.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + + to_hour.setVisibility(View.VISIBLE); + to_time.setVisibility(View.GONE); + to_hour.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + } + + from_time.setOnClickListener(v -> { + final Calendar c = Calendar.getInstance(); + int mHour = c.get(Calendar.HOUR_OF_DAY); + int mMinute = c.get(Calendar.MINUTE); + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute) -> { + from_time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + week.setFromTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + from_hour.setText("" + WeekUtils.getMatchingScheduleBegin(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, mHour, mMinute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); + }); - to_time.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int hour = c.get(Calendar.HOUR_OF_DAY); - int minute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - to_time.setText(String.format("%02d:%02d", hourOfDay, minute)); - week.setToTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, hour, minute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); - } + to_time.setOnClickListener(v -> { + final Calendar c = Calendar.getInstance(); + int hour = c.get(Calendar.HOUR_OF_DAY); + int minute = c.get(Calendar.MINUTE); + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute1) -> { + to_time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute1)); + week.setToTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute1)); + to_hour.setText("" + WeekUtils.getMatchingScheduleEnd(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, hour, minute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); }); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + from_hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + from_time.setText(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + week.setFromTime(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + from_hour.setText("" + value); + }) + .show(); + }); + + to_hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + to_time.setText(WeekUtils.getMatchingTimeEnd(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + week.setToTime(WeekUtils.getMatchingTimeEnd(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + to_hour.setText("" + value); + }) + .show(); + }); + + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } + + return true; + } } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } } }); @@ -264,63 +418,77 @@ public void onColorSelected(int color) { Button submit = alertLayout.findViewById(R.id.save); alert.setView(alertLayout); final AlertDialog dialog = alert.create(); + + //Preselection FloatingActionButton fab = activity.findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dialog.show(); + fab.setOnClickListener(view -> { + ArrayList customWeeks = WeekUtils.getPreselection(activity); + + ArrayList subjects = new ArrayList<>(); + for (Week w : customWeeks) { + subjects.add(w.getSubject()); } + + new MaterialDialog.Builder(activity) + .title(R.string.pick_a_subject) + .items(subjects) + .itemsCallback((dialog1, view1, which, text) -> { + Week w = customWeeks.get(which); + subject.setText(w.getSubject()); + teacher.setText(w.getTeacher()); + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + dialog.show(); + }) + .positiveText(R.string.new_subject) + .onPositive((dialog1, which) -> dialog.show()) + .show(); }); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + subject.getText().clear(); + teacher.getText().clear(); + room.getText().clear(); + from_time.setText(R.string.select_start_time); + to_time.setText(R.string.select_end_time); + from_hour.setText(R.string.select_start_time); + to_hour.setText(R.string.select_end_time); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); }); - submit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())) { - for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { - entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - entry.getValue().requestFocus(); - } + submit.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText()) /*|| TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())*/) { + for (Map.Entry entry : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(entry.getValue().getText())) { + entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + entry.getValue().requestFocus(); } - } else if(!from_time.getText().toString().matches(".*\\d+.*") || !to_time.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper dbHelper = new DbHelper(activity); - Matcher fragment = Pattern.compile("(.*Fragment)").matcher(adapter.getItem(viewPager.getCurrentItem()).toString()); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - week.setSubject(subject.getText().toString()); - week.setFragment(fragment.find() ? fragment.group() : null); - week.setTeacher(teacher.getText().toString()); - week.setRoom(room.getText().toString()); - week.setColor(buttonColor.getColor()); - dbHelper.insertWeek(week); - adapter.notifyDataSetChanged(); - subject.getText().clear(); - teacher.getText().clear(); - room.getText().clear(); - from_time.setText(R.string.select_time); - to_time.setText(R.string.select_time); - select_color.setBackgroundColor(Color.WHITE); - subject.requestFocus(); - dialog.dismiss(); } + } else if (!from_time.getText().toString().matches(".*\\d+.*") || !to_time.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); + } else { + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + week.setSubject(subject.getText().toString()); + week.setFragment(((WeekdayFragment) adapter.getItem(viewPager.getCurrentItem())).getKey()); + week.setTeacher(teacher.getText().toString()); + week.setRoom(room.getText().toString()); + week.setColor(buttonColor.getColor()); + new DbHelper(activity).insertWeek(week); + adapter.notifyDataSetChanged(); + cancel.performClick(); } }); } - public static void getEditHomeworkDialog(final Activity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int listposition) { + public static void getEditHomeworkDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final ArrayList adapter, @NonNull final ListView listView, int listposition) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subjecthomework); editTextHashs.put(R.string.subject, subject); final EditText description = alertLayout.findViewById(R.id.descriptionhomework); - editTextHashs.put(R.string.desctiption, description); + editTextHashs.put(R.string.description, description); final TextView date = alertLayout.findViewById(R.id.datehomework); final Button select_color = alertLayout.findViewById(R.id.select_color); final Homework homework = adapter.get(listposition); @@ -329,47 +497,75 @@ public static void getEditHomeworkDialog(final Activity activity, final View ale description.setText(homework.getDescription()); date.setText(homework.getDate()); select_color.setBackgroundColor(homework.getColor() != 0 ? homework.getColor() : Color.WHITE); - - date.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar calendar = Calendar.getInstance(); - int mYear = calendar.get(Calendar.YEAR); - int mMonth = calendar.get(Calendar.MONTH); - int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); - DatePickerDialog datePickerDialog = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { - date.setText(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - homework.setDate(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - } - }, mYear, mMonth, mdayofMonth); - datePickerDialog.setTitle(R.string.choose_date); - datePickerDialog.show(); - } + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(homework.getColor(), Color.WHITE, Color.BLACK)); + + date.setOnClickListener(v -> { + final Calendar calendar = Calendar.getInstance(); + int mYear = calendar.get(Calendar.YEAR); + int mMonth = calendar.get(Calendar.MONTH); + int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); + DatePickerDialog datePickerDialog = new DatePickerDialog(activity, (view, year, month, dayOfMonth) -> { + date.setText(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + homework.setDate(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + }, mYear, mMonth, mdayofMonth); + datePickerDialog.setTitle(R.string.choose_date); + datePickerDialog.show(); }); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); +// date.setText(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); +// homework.setDate(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); + } + } + + return true; + } } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); +// date.setText(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); +// homework.setDate(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); + } + } } }); @@ -382,90 +578,143 @@ public void onColorSelected(int color) { final AlertDialog dialog = alert.create(); dialog.show(); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + subject.getText().clear(); + description.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(description.getText())) { - for (Map.Entry editText : editTextHashs.entrySet()) { - if (TextUtils.isEmpty(editText.getValue().getText())) { - editText.getValue().setError(activity.getResources().getString(editText.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - editText.getValue().requestFocus(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(description.getText())) { + for (Map.Entry editText : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(editText.getValue().getText())) { + editText.getValue().setError(activity.getResources().getString(editText.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + editText.getValue().requestFocus(); } - } else if (!date.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.deadline_snackbar, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper dbHelper = new DbHelper(activity); - HomeworksAdapter homeworksAdapter = (HomeworksAdapter) listView.getAdapter(); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - homework.setSubject(subject.getText().toString()); - homework.setDescription(description.getText().toString()); - homework.setColor(buttonColor.getColor()); - dbHelper.updateHomework(homework); - homeworksAdapter.notifyDataSetChanged(); - dialog.dismiss(); } + } /*else if (!date.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.deadline_snackbar, Snackbar.LENGTH_LONG).show(); + }*/ else { + HomeworksAdapter homeworksAdapter = (HomeworksAdapter) listView.getAdapter(); + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + homework.setSubject(subject.getText().toString()); + homework.setDescription(description.getText().toString()); + homework.setColor(buttonColor.getColor()); + new DbHelper(activity).updateHomework(homework); + homeworksAdapter.notifyDataSetChanged(); + dialog.dismiss(); + + new MaterialDialog.Builder(activity) + .content(R.string.add_to_calendar) + .positiveText(R.string.yes) + .onPositive((MaterialDialog s, DialogAction w) -> { + String year = homework.getDate().substring(0, homework.getDate().indexOf("-")); + String month = homework.getDate().substring(year.length() + 1, homework.getDate().indexOf("-") + year.length() - 1); + String day = homework.getDate().substring(year.length() + month.length() + 2); + + Calendar timeCalendar = Calendar.getInstance(); + timeCalendar.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), 0, 0); + + Intent intent = new Intent(Intent.ACTION_INSERT) + .setData(CalendarContract.Events.CONTENT_URI) + .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.Events.TITLE, subject.getText().toString()) + .putExtra(CalendarContract.Events.DESCRIPTION, description.getText().toString()); + try { + activity.startActivity(intent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(activity).setText(activity.getString(R.string.no_calendar_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } + + }) + .negativeText(R.string.no) + .show(); } - }); + }); } - public static void getAddHomeworkDialog(final Activity activity, final View alertLayout, final HomeworksAdapter adapter) { + public static void getAddHomeworkDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final HomeworksAdapter adapter) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subjecthomework); editTextHashs.put(R.string.subject, subject); + subject.requestFocus(); final EditText description = alertLayout.findViewById(R.id.descriptionhomework); - editTextHashs.put(R.string.desctiption, description); + editTextHashs.put(R.string.description, description); final TextView date = alertLayout.findViewById(R.id.datehomework); final Button select_color = alertLayout.findViewById(R.id.select_color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(((ColorDrawable) select_color.getBackground()).getColor(), Color.WHITE, Color.BLACK)); + final Homework homework = new Homework(); - date.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar calendar = Calendar.getInstance(); - int mYear = calendar.get(Calendar.YEAR); - int mMonth = calendar.get(Calendar.MONTH); - int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); - DatePickerDialog datePickerDialog = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { - date.setText(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - homework.setDate(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - } - }, mYear, mMonth, mdayofMonth); - datePickerDialog.setTitle(R.string.choose_date); - datePickerDialog.show(); - } + date.setOnClickListener(v -> { + final Calendar calendar = Calendar.getInstance(); + int mYear = calendar.get(Calendar.YEAR); + int mMonth = calendar.get(Calendar.MONTH); + int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); + DatePickerDialog datePickerDialog = new DatePickerDialog(activity, (view, year, month, dayOfMonth) -> { + date.setText(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + homework.setDate(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + }, mYear, mMonth, mdayofMonth); + datePickerDialog.setTitle(R.string.choose_date); + datePickerDialog.show(); }); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); +// date.setText(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); +// homework.setDate(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); + } + } + + return true; + } + } + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); +// date.setText(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); +// homework.setDate(DBUtil.getNextOccurenceOfSubject(dbHelper, w.getSubject())); } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + } } }); @@ -477,63 +726,86 @@ public void onColorSelected(int color) { alert.setCancelable(false); final AlertDialog dialog = alert.create(); FloatingActionButton fab = activity.findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dialog.show(); - } - }); - - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + fab.setOnClickListener(view -> dialog.show()); + + cancel.setOnClickListener(v -> { + subject.getText().clear(); + description.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(description.getText())) { - for (Map.Entry editText : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(editText.getValue().getText())) { - editText.getValue().setError(activity.getResources().getString(editText.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - editText.getValue().requestFocus(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(description.getText())) { + for (Map.Entry editText : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(editText.getValue().getText())) { + editText.getValue().setError(activity.getResources().getString(editText.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + editText.getValue().requestFocus(); } - } else if(!date.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.deadline_snackbar, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper dbHelper = new DbHelper(activity); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - homework.setSubject(subject.getText().toString()); - homework.setDescription(description.getText().toString()); - homework.setColor(buttonColor.getColor()); - dbHelper.insertHomework(homework); - - adapter.clear(); - adapter.addAll(dbHelper.getHomework()); - adapter.notifyDataSetChanged(); + } + }/* else if (!date.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.deadline_snackbar, Snackbar.LENGTH_LONG).show(); + }*/ else { + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + homework.setSubject(subject.getText().toString()); + homework.setDescription(description.getText().toString()); + homework.setColor(buttonColor.getColor()); + + DbHelper dbHelper = new DbHelper(activity); + dbHelper.insertHomework(homework); + + adapter.clear(); + adapter.addAll(dbHelper.getHomework()); + adapter.notifyDataSetChanged(); + + subject.getText().clear(); + description.getText().clear(); + date.setText(R.string.choose_date); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); - subject.getText().clear(); - description.getText().clear(); - date.setText(R.string.select_date); - select_color.setBackgroundColor(Color.WHITE); - subject.requestFocus(); - dialog.dismiss(); + if (homework.getDate() != null && !homework.getDate().trim().isEmpty()) { + new MaterialDialog.Builder(activity) + .content(R.string.add_to_calendar) + .positiveText(R.string.yes) + .onPositive((MaterialDialog s, DialogAction w) -> { + String year = homework.getDate().substring(0, homework.getDate().indexOf("-")); + String month = homework.getDate().substring(year.length() + 1, homework.getDate().indexOf("-") + year.length() - 1); + String day = homework.getDate().substring(year.length() + month.length() + 2); + + Calendar timeCalendar = Calendar.getInstance(); + timeCalendar.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), 0, 0); + + Intent intent = new Intent(Intent.ACTION_INSERT) + .setData(CalendarContract.Events.CONTENT_URI) + .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.Events.TITLE, subject.getText().toString()) + .putExtra(CalendarContract.Events.DESCRIPTION, description.getText().toString()); + try { + activity.startActivity(intent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(activity).setText(activity.getString(R.string.no_calendar_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } + + }) + .negativeText(R.string.no) + .show(); } } }); } - public static void getEditTeacherDialog(final Activity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int listposition) { + public static void getEditTeacherDialog(final AppCompatActivity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int listposition) { final HashMap editTextHashs = new HashMap<>(); final EditText name = alertLayout.findViewById(R.id.name_dialog); editTextHashs.put(R.string.name, name); final EditText post = alertLayout.findViewById(R.id.post_dialog); - editTextHashs.put(R.string.post, post); +// editTextHashs.put(R.string.post, post); final EditText phone_number = alertLayout.findViewById(R.id.phonenumber_dialog); - editTextHashs.put(R.string.phone_number, phone_number); +// editTextHashs.put(R.string.phone_number, phone_number); final EditText email = alertLayout.findViewById(R.id.email_dialog); editTextHashs.put(R.string.email, email); final Button select_color = alertLayout.findViewById(R.id.select_color); @@ -545,28 +817,23 @@ public static void getEditTeacherDialog(final Activity activity, final View aler email.setText(teacher.getEmail()); select_color.setBackgroundColor(teacher.getColor() != 0 ? teacher.getColor() : Color.WHITE); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener((View v) -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); - } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); - } + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); }); final AlertDialog.Builder alert = new AlertDialog.Builder(activity); @@ -588,9 +855,9 @@ public void onClick(View v) { save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if(TextUtils.isEmpty(name.getText()) || TextUtils.isEmpty(post.getText()) || TextUtils.isEmpty(phone_number.getText()) || TextUtils.isEmpty(email.getText())) { + if (TextUtils.isEmpty(name.getText()) /*|| TextUtils.isEmpty(post.getText()) || TextUtils.isEmpty(phone_number.getText())*/ || TextUtils.isEmpty(email.getText())) { for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { + if (TextUtils.isEmpty(entry.getValue().getText())) { entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); entry.getValue().requestFocus(); } @@ -612,41 +879,36 @@ public void onClick(View v) { }); } - public static void getAddTeacherDialog(final Activity activity, final View alertLayout, final TeachersAdapter adapter) { + public static void getAddTeacherDialog(final AppCompatActivity activity, final View alertLayout, final TeachersAdapter adapter) { final HashMap editTextHashs = new HashMap<>(); final EditText name = alertLayout.findViewById(R.id.name_dialog); editTextHashs.put(R.string.name, name); final EditText post = alertLayout.findViewById(R.id.post_dialog); - editTextHashs.put(R.string.post, post); +// editTextHashs.put(R.string.post, post); final EditText phone_number = alertLayout.findViewById(R.id.phonenumber_dialog); - editTextHashs.put(R.string.phone_number, phone_number); +// editTextHashs.put(R.string.phone_number, phone_number); final EditText email = alertLayout.findViewById(R.id.email_dialog); editTextHashs.put(R.string.email, email); final Button select_color = alertLayout.findViewById(R.id.select_color); final Teacher teacher = new Teacher(); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener((View v) -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); - } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); - } + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); }); final AlertDialog.Builder alert = new AlertDialog.Builder(activity); @@ -674,9 +936,9 @@ public void onClick(View v) { save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if(TextUtils.isEmpty(name.getText()) || TextUtils.isEmpty(post.getText()) || TextUtils.isEmpty(phone_number.getText()) || TextUtils.isEmpty(email.getText())) { + if (TextUtils.isEmpty(name.getText()) /*|| TextUtils.isEmpty(post.getText()) || TextUtils.isEmpty(phone_number.getText())*/ || TextUtils.isEmpty(email.getText())) { for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { + if (TextUtils.isEmpty(entry.getValue().getText())) { entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); entry.getValue().requestFocus(); } @@ -707,35 +969,31 @@ public void onClick(View v) { }); } - public static void getEditNoteDialog(final Activity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int listposition) { + public static void getEditNoteDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final ArrayList adapter, @NonNull final ListView listView, int listposition) { final EditText title = alertLayout.findViewById(R.id.titlenote); final Button select_color = alertLayout.findViewById(R.id.select_color); final Note note = adapter.get(listposition); title.setText(note.getTitle()); select_color.setBackgroundColor(note.getColor() != 0 ? note.getColor() : Color.WHITE); - - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(note.getColor(), Color.WHITE, Color.BLACK)); + + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); - } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); - } + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); }); AlertDialog.Builder alert = new AlertDialog.Builder(activity); @@ -747,61 +1005,54 @@ public void onColorSelected(int color) { final AlertDialog dialog = alert.create(); dialog.show(); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + title.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(title.getText())) { - title.setError(activity.getResources().getString(R.string.title_error)); - title.requestFocus(); - } else { - DbHelper dbHelper = new DbHelper(activity); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - note.setTitle(title.getText().toString()); - note.setColor(buttonColor.getColor()); - dbHelper.updateNote(note); - NotesAdapter notesAdapter = (NotesAdapter) listView.getAdapter(); - notesAdapter.notifyDataSetChanged(); + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(title.getText())) { + title.setError(activity.getResources().getString(R.string.title_error)); + title.requestFocus(); + } else { + DbHelper dbHelper = new DbHelper(activity); + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + note.setTitle(title.getText().toString()); + note.setColor(buttonColor.getColor()); + dbHelper.updateNote(note); + NotesAdapter notesAdapter = (NotesAdapter) listView.getAdapter(); + notesAdapter.notifyDataSetChanged(); - dialog.dismiss(); - } + dialog.dismiss(); } }); } - public static void getAddNoteDialog(final Activity activity, final View alertLayout, final NotesAdapter adapter) { + public static void getAddNoteDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final NotesAdapter adapter) { final EditText title = alertLayout.findViewById(R.id.titlenote); + title.requestFocus(); final Button select_color = alertLayout.findViewById(R.id.select_color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(((ColorDrawable) select_color.getBackground()).getColor(), Color.WHITE, Color.BLACK)); final Note note = new Note(); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); - } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); - } + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); }); final AlertDialog.Builder alert = new AlertDialog.Builder(activity); @@ -812,56 +1063,49 @@ public void onColorSelected(int color) { alert.setCancelable(false); final AlertDialog dialog = alert.create(); FloatingActionButton fab = activity.findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dialog.show(); - } - }); + fab.setOnClickListener(view -> dialog.show()); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + title.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(title.getText())) { - title.setError(activity.getResources().getString(R.string.title_error)); - title.requestFocus(); - } else { - DbHelper dbHelper = new DbHelper(activity); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - note.setTitle(title.getText().toString()); - note.setColor(buttonColor.getColor()); - dbHelper.insertNote(note); - - adapter.clear(); - adapter.addAll(dbHelper.getNote()); - adapter.notifyDataSetChanged(); - - title.getText().clear(); - select_color.setBackgroundColor(Color.WHITE); - dialog.dismiss(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(title.getText())) { + title.setError(activity.getResources().getString(R.string.title_error)); + title.requestFocus(); + } else { + DbHelper dbHelper = new DbHelper(activity); + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + note.setTitle(title.getText().toString()); + note.setColor(buttonColor.getColor()); + dbHelper.insertNote(note); + + adapter.clear(); + adapter.addAll(dbHelper.getNote()); + adapter.notifyDataSetChanged(); + + title.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + dialog.dismiss(); } }); } - public static void getEditExamDialog(final Activity activity, final View alertLayout, final ArrayList adapter, final ListView listView, int listposition) { + public static void getEditExamDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final ArrayList adapter, @NonNull final ListView listView, int listposition) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subjectexam_dialog); editTextHashs.put(R.string.subject, subject); final EditText teacher = alertLayout.findViewById(R.id.teacherexam_dialog); - editTextHashs.put(R.string.teacher, teacher); +// editTextHashs.put(R.string.teacher, teacher); final EditText room = alertLayout.findViewById(R.id.roomexam_dialog); - editTextHashs.put(R.string.room, room); +// editTextHashs.put(R.string.room, room); final TextView date = alertLayout.findViewById(R.id.dateexam_dialog); final TextView time = alertLayout.findViewById(R.id.timeexam_dialog); + final TextView hour = alertLayout.findViewById(R.id.hourexam_dialog); final Button select_color = alertLayout.findViewById(R.id.select_color); + final Exam exam = adapter.get(listposition); subject.setText(exam.getSubject()); @@ -869,70 +1113,127 @@ public static void getEditExamDialog(final Activity activity, final View alertLa room.setText(exam.getRoom()); date.setText(exam.getDate()); time.setText(exam.getTime()); + if (!exam.getTime().trim().isEmpty()) { + hour.setText("" + WeekUtils.getMatchingScheduleBegin(exam.getTime(), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + time.setText(exam.getTime()); + } else { + hour.setText("0"); + time.setText("0:0"); + } select_color.setBackgroundColor(exam.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(exam.getColor(), Color.WHITE, Color.BLACK)); + + date.setOnClickListener(v -> { + final Calendar calendar = Calendar.getInstance(); + int mYear = calendar.get(Calendar.YEAR); + int mMonth = calendar.get(Calendar.MONTH); + int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); + DatePickerDialog datePickerDialog = new DatePickerDialog(activity, (view, year, month, dayOfMonth) -> { + date.setText(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + exam.setDate(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + }, mYear, mMonth, mdayofMonth); + datePickerDialog.setTitle(R.string.choose_date); + datePickerDialog.show(); + }); - date.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar calendar = Calendar.getInstance(); - int mYear = calendar.get(Calendar.YEAR); - int mMonth = calendar.get(Calendar.MONTH); - int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); - DatePickerDialog datePickerDialog = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { - date.setText(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - exam.setDate(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - } - }, mYear, mMonth, mdayofMonth); - datePickerDialog.setTitle(R.string.choose_date); - datePickerDialog.show(); + time.setOnClickListener(v -> { + int mHour, mMinute; + try { + mHour = Integer.parseInt(exam.getTime().substring(0, exam.getTime().indexOf(":"))); + mMinute = Integer.parseInt(exam.getTime().substring(exam.getTime().indexOf(":") + 1)); + } catch (Exception ignore) { + mHour = 0; + mMinute = 0; } + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute) -> { + time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + exam.setTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + hour.setText("" + WeekUtils.getMatchingScheduleBegin(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, mHour, mMinute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); }); - time.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int mHour = c.get(Calendar.HOUR_OF_DAY); - int mMinute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - time.setText(String.format("%02d:%02d", hourOfDay, minute)); - exam.setTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, mHour, mMinute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); + hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + try { + numberPicker.setValue(Integer.parseInt(hour.getText().toString())); + } catch (Exception e) { + numberPicker.setValue(1); } + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + time.setText(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + exam.setTime(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + hour.setText("" + value); + }) + .show(); }); - - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } + + return true; + } } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } } }); @@ -945,121 +1246,210 @@ public void onColorSelected(int color) { final AlertDialog dialog = alert.create(); dialog.show(); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + cancel.setOnClickListener(v -> { + subject.getText().clear(); + teacher.getText().clear(); + room.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())) { - for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { - entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - entry.getValue().requestFocus(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText())/* || TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())*/) { + for (Map.Entry entry : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(entry.getValue().getText())) { + entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + entry.getValue().requestFocus(); } - } else if (!date.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.date_error, Snackbar.LENGTH_LONG).show(); - } else if (!time.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper dbHelper = new DbHelper(activity); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - exam.setSubject(subject.getText().toString()); - exam.setTeacher(teacher.getText().toString()); - exam.setRoom(room.getText().toString()); - exam.setColor(buttonColor.getColor()); + } + } else if (!date.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.date_error, Snackbar.LENGTH_LONG).show(); + } /*else if (!time.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); + }*/ else { + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + exam.setSubject(subject.getText().toString()); + exam.setTeacher(teacher.getText().toString()); + exam.setRoom(room.getText().toString()); + exam.setColor(buttonColor.getColor()); + + new DbHelper(activity).updateExam(exam); + + ExamsAdapter examsAdapter = (ExamsAdapter) listView.getAdapter(); + examsAdapter.notifyDataSetChanged(); + + dialog.dismiss(); - dbHelper.updateExam(exam); + new MaterialDialog.Builder(activity) + .content(R.string.add_to_calendar) + .positiveText(R.string.yes) + .onPositive((MaterialDialog s, DialogAction w) -> { + String year = exam.getDate().substring(0, exam.getDate().indexOf("-")); + String month = exam.getDate().substring(year.length() + 1, exam.getDate().indexOf("-") + year.length() - 1); + String day = exam.getDate().substring(year.length() + month.length() + 2); + + String hour2, minute; + if (exam.getTime() != null && !exam.getTime().trim().isEmpty()) { + hour2 = exam.getTime().substring(0, exam.getTime().indexOf(":")); + minute = exam.getTime().substring(hour2.length() + 1); + } else { + hour2 = "0"; + minute = "0"; + } - ExamsAdapter examsAdapter = (ExamsAdapter) listView.getAdapter(); - examsAdapter.notifyDataSetChanged(); + Calendar timeCalendar = Calendar.getInstance(); + timeCalendar.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), Integer.parseInt(hour2), Integer.parseInt(minute)); + + Intent intent = new Intent(Intent.ACTION_INSERT) + .setData(CalendarContract.Events.CONTENT_URI) + .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.Events.TITLE, subject.getText().toString()) + .putExtra(CalendarContract.Events.DESCRIPTION, teacher.getText().toString()) + .putExtra(CalendarContract.Events.EVENT_LOCATION, room.getText().toString()); + try { + activity.startActivity(intent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(activity).setText(activity.getString(R.string.no_calendar_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } - dialog.dismiss(); - } + }) + .negativeText(R.string.no) + .show(); } }); } - public static void getAddExamDialog(final Activity activity, final View alertLayout, final ExamsAdapter adapter) { + public static void getAddExamDialog(@NonNull final AppCompatActivity activity, @NonNull final View alertLayout, @NonNull final ExamsAdapter adapter) { final HashMap editTextHashs = new HashMap<>(); final EditText subject = alertLayout.findViewById(R.id.subjectexam_dialog); editTextHashs.put(R.string.subject, subject); + subject.requestFocus(); final EditText teacher = alertLayout.findViewById(R.id.teacherexam_dialog); - editTextHashs.put(R.string.teacher, teacher); +// editTextHashs.put(R.string.teacher, teacher); final EditText room = alertLayout.findViewById(R.id.roomexam_dialog); - editTextHashs.put(R.string.room, room); +// editTextHashs.put(R.string.room, room); final TextView date = alertLayout.findViewById(R.id.dateexam_dialog); final TextView time = alertLayout.findViewById(R.id.timeexam_dialog); + final TextView hour = alertLayout.findViewById(R.id.hourexam_dialog); final Button select_color = alertLayout.findViewById(R.id.select_color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(((ColorDrawable) select_color.getBackground()).getColor(), Color.WHITE, Color.BLACK)); + + hour.setText(R.string.select_time); + if (PreferenceUtil.showTimes(activity)) { + hour.setVisibility(View.GONE); + time.setVisibility(View.VISIBLE); + time.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + } else { + hour.setVisibility(View.VISIBLE); + time.setVisibility(View.GONE); + hour.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, .7f)); + } + final Exam exam = new Exam(); - date.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar calendar = Calendar.getInstance(); - int mYear = calendar.get(Calendar.YEAR); - int mMonth = calendar.get(Calendar.MONTH); - int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); - DatePickerDialog datePickerDialog = new DatePickerDialog(activity, new DatePickerDialog.OnDateSetListener() { - @Override - public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { - date.setText(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - exam.setDate(String.format("%02d-%02d-%02d", year, month+1, dayOfMonth)); - } - }, mYear, mMonth, mdayofMonth); - datePickerDialog.setTitle(R.string.choose_date); - datePickerDialog.show(); - } + date.setOnClickListener(v -> { + final Calendar calendar = Calendar.getInstance(); + int mYear = calendar.get(Calendar.YEAR); + int mMonth = calendar.get(Calendar.MONTH); + int mdayofMonth = calendar.get(Calendar.DAY_OF_MONTH); + DatePickerDialog datePickerDialog = new DatePickerDialog(activity, (view, year, month, dayOfMonth) -> { + date.setText(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + exam.setDate(String.format(Locale.getDefault(), "%02d-%02d-%02d", year, month + 1, dayOfMonth)); + }, mYear, mMonth, mdayofMonth); + datePickerDialog.setTitle(R.string.choose_date); + datePickerDialog.show(); }); - time.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final Calendar c = Calendar.getInstance(); - int mHour = c.get(Calendar.HOUR_OF_DAY); - int mMinute = c.get(Calendar.MINUTE); - TimePickerDialog timePickerDialog = new TimePickerDialog(activity, - new TimePickerDialog.OnTimeSetListener() { - - @Override - public void onTimeSet(TimePicker view, int hourOfDay, - int minute) { - time.setText(String.format("%02d:%02d", hourOfDay, minute)); - exam.setTime(String.format("%02d:%02d", hourOfDay, minute)); - } - }, mHour, mMinute, true); - timePickerDialog.setTitle(R.string.choose_time); - timePickerDialog.show(); - } + time.setOnClickListener(v -> { + final Calendar c = Calendar.getInstance(); + int mHour = c.get(Calendar.HOUR_OF_DAY); + int mMinute = c.get(Calendar.MINUTE); + TimePickerDialog timePickerDialog = new TimePickerDialog(activity, + (view, hourOfDay, minute) -> { + time.setText(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + exam.setTime(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute)); + hour.setText("" + WeekUtils.getMatchingScheduleBegin(String.format(Locale.getDefault(), "%02d:%02d", hourOfDay, minute), PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + }, mHour, mMinute, true); + timePickerDialog.setTitle(R.string.choose_time); + timePickerDialog.show(); }); + hour.setOnClickListener(v -> { + NumberPicker numberPicker = new NumberPicker(activity); + numberPicker.setMaxValue(15); + numberPicker.setMinValue(1); + new MaterialDialog.Builder(activity) + .customView(numberPicker, false) + .positiveText(R.string.select) + .onPositive((vi, w) -> { + int value = numberPicker.getValue(); + time.setText(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + exam.setTime(WeekUtils.getMatchingTimeBegin(value, PreferenceUtil.getStartTime(activity), PreferenceUtil.getPeriodLength(activity))); + hour.setText("" + value); + }) + .show(); + }); - select_color.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int mSelectedColor = ContextCompat.getColor(activity, R.color.white); - select_color.setBackgroundColor(mSelectedColor); - int[] mColors = activity.getResources().getIntArray(R.array.default_colors); - ColorPickerDialog dialog = ColorPickerDialog.newInstance(R.string.color_picker_default_title, - mColors, - mSelectedColor, - 5, - ColorPickerDialog.SIZE_SMALL, - true - ); - - dialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { - @Override - public void onColorSelected(int color) { + select_color.setOnClickListener(v -> { + new ColorPickerDialog() + .withColor(((ColorDrawable) select_color.getBackground()).getColor()) // the default / initial color + .withPresets(ColorPalette.PRIMARY_COLORS) + .withTitle(activity.getString(R.string.choose_color)) + .withTheme(PreferenceUtil.getGeneralTheme(activity)) + .withCornerRadius(16) + .withAlphaEnabled(false) + .withListener((dialog, color) -> { + // a color has been picked; use it select_color.setBackgroundColor(color); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(color, Color.WHITE, Color.BLACK)); + }) + .clearPickers() + .withPresets(ColorPalette.PRIMARY_COLORS) + .withPicker(RGBPickerView.class) + .show(activity.getSupportFragmentManager(), "colorPicker"); + }); + + + subject.setOnEditorActionListener( + (v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE || + event != null && + event.getAction() == KeyEvent.ACTION_DOWN && + event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + if (event == null || !event.isShiftPressed()) { + // the user is done typing. + //AutoFill other fields + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(v.getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); + } + } + + return true; + } + } + return false; + } + ); + subject.setOnFocusChangeListener((v, hasFocus) -> { + if (!hasFocus) { + for (Week w : WeekUtils.getAllWeeks(new DbHelper(activity))) { + if (w.getSubject().equalsIgnoreCase(((EditText) v).getText().toString())) { + if (teacher.getText().toString().trim().isEmpty()) + teacher.setText(w.getTeacher()); + if (room.getText().toString().trim().isEmpty()) + room.setText(w.getRoom()); + select_color.setBackgroundColor(w.getColor()); + select_color.setTextColor(ColorPalette.pickTextColorBasedOnBgColorSimple(w.getColor(), Color.WHITE, Color.BLACK)); } - }); - dialog.show(activity.getFragmentManager(), "color_dialog"); + } } }); @@ -1071,58 +1461,104 @@ public void onColorSelected(int color) { alert.setView(alertLayout); final AlertDialog dialog = alert.create(); FloatingActionButton fab = activity.findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dialog.show(); - } - }); - - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } + fab.setOnClickListener(view -> dialog.show()); + + cancel.setOnClickListener(v -> { + subject.getText().clear(); + teacher.getText().clear(); + room.getText().clear(); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); }); - save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if(TextUtils.isEmpty(subject.getText()) || TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())) { - for (Map.Entry entry : editTextHashs.entrySet()) { - if(TextUtils.isEmpty(entry.getValue().getText())) { - entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); - entry.getValue().requestFocus(); - } + save.setOnClickListener(v -> { + if (TextUtils.isEmpty(subject.getText()) /*|| TextUtils.isEmpty(teacher.getText()) || TextUtils.isEmpty(room.getText())*/) { + for (Map.Entry entry : editTextHashs.entrySet()) { + if (TextUtils.isEmpty(entry.getValue().getText())) { + entry.getValue().setError(activity.getResources().getString(entry.getKey()) + " " + activity.getResources().getString(R.string.field_error)); + entry.getValue().requestFocus(); } - } else if (!date.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.date_error, Snackbar.LENGTH_LONG).show(); - } else if (!time.getText().toString().matches(".*\\d+.*")) { - Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); - } else { - DbHelper dbHelper = new DbHelper(activity); - ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); - exam.setSubject(subject.getText().toString()); - exam.setTeacher(teacher.getText().toString()); - exam.setRoom(room.getText().toString()); - exam.setColor(buttonColor.getColor()); + } + } else if (!date.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.date_error, Snackbar.LENGTH_LONG).show(); + } /*else if (!time.getText().toString().matches(".*\\d+.*")) { + Snackbar.make(alertLayout, R.string.time_error, Snackbar.LENGTH_LONG).show(); + }*/ else { + ColorDrawable buttonColor = (ColorDrawable) select_color.getBackground(); + exam.setSubject(subject.getText().toString()); + exam.setTeacher(teacher.getText().toString()); + exam.setRoom(room.getText().toString()); + exam.setColor(buttonColor.getColor()); + + DbHelper dbHelper = new DbHelper(activity); + dbHelper.insertExam(exam); + + adapter.clear(); + adapter.addAll(dbHelper.getExam()); + adapter.notifyDataSetChanged(); + + subject.getText().clear(); + teacher.getText().clear(); + room.getText().clear(); + date.setText(R.string.choose_date); + time.setText(R.string.select_time); + hour.setText(R.string.select_time); + select_color.setBackgroundColor(Color.WHITE); + subject.requestFocus(); + dialog.dismiss(); - dbHelper.insertExam(exam); + new MaterialDialog.Builder(activity) + .content(R.string.add_to_calendar) + .positiveText(R.string.yes) + .onPositive((MaterialDialog s, DialogAction w) -> { + String year = exam.getDate().substring(0, exam.getDate().indexOf("-")); + String month = exam.getDate().substring(year.length() + 1, exam.getDate().indexOf("-") + year.length() - 1); + String day = exam.getDate().substring(year.length() + month.length() + 2); + + String hour2, minute; + if (exam.getTime() != null && !exam.getTime().trim().isEmpty()) { + hour2 = exam.getTime().substring(0, exam.getTime().indexOf(":")); + minute = exam.getTime().substring(hour2.length() + 1); + } else { + hour2 = "0"; + minute = "0"; + } - adapter.clear(); - adapter.addAll(dbHelper.getExam()); - adapter.notifyDataSetChanged(); + Calendar timeCalendar = Calendar.getInstance(); + timeCalendar.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day), Integer.parseInt(hour2), Integer.parseInt(minute)); + + Intent intent = new Intent(Intent.ACTION_INSERT) + .setData(CalendarContract.Events.CONTENT_URI) + .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, timeCalendar.getTimeInMillis()) + .putExtra(CalendarContract.Events.TITLE, subject.getText().toString()) + .putExtra(CalendarContract.Events.DESCRIPTION, teacher.getText().toString()) + .putExtra(CalendarContract.Events.EVENT_LOCATION, room.getText().toString()); + try { + activity.startActivity(intent); + } catch (ActivityNotFoundException e2) { + ChocoBar.builder().setActivity(activity).setText(activity.getString(R.string.no_calendar_app)).setDuration(ChocoBar.LENGTH_LONG).red().show(); + } - subject.getText().clear(); - teacher.getText().clear(); - room.getText().clear(); - date.setText(R.string.select_date); - time.setText(R.string.select_time); - select_color.setBackgroundColor(Color.WHITE); - subject.requestFocus(); - dialog.dismiss(); - } + }) + .negativeText(R.string.no) + .show(); } }); } + + public static void getDeleteDialog(@NonNull Context context, @NonNull Runnable runnable, String deleteSubject) { + new MaterialDialog.Builder(context) + .title(context.getString(R.string.profiles_delete_submit_heading)) + .content(context.getString(R.string.delete_content, deleteSubject)) + .positiveText(context.getString(R.string.yes)) + .onPositive((dialog, which) -> { + runnable.run(); + dialog.dismiss(); + }) + .onNegative((dialog, which) -> dialog.dismiss()) + .negativeText(context.getString(R.string.no)) + .show(); + } } diff --git a/app/src/main/java/com/ulan/timetable/utils/BrowserUtil.java b/app/src/main/java/com/ulan/timetable/utils/BrowserUtil.java deleted file mode 100644 index 75cb8f3..0000000 --- a/app/src/main/java/com/ulan/timetable/utils/BrowserUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ulan.timetable.utils; - -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.support.customtabs.CustomTabsIntent; - -/** - * Created by Ulan on 19.10.2018. - */ -public class BrowserUtil { - public static void openUrlInChromeCustomTab(Context context, String url) { - try { - CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); - CustomTabsIntent customTabsIntent = builder.build(); - customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - customTabsIntent.launchUrl(context, url.contains("http://") ? Uri.parse(url) : Uri.parse("http://" + url)); - } catch (ActivityNotFoundException e) { - // might not available. - //openUrlLinkInWebView(context, url); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/app/src/main/java/com/ulan/timetable/utils/ColorPalette.java b/app/src/main/java/com/ulan/timetable/utils/ColorPalette.java new file mode 100644 index 0000000..8d6bb2d --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/utils/ColorPalette.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.utils; + +import android.graphics.Color; + +/** + * @author Aidan Follestad (afollestad) + */ +public class ColorPalette { + + public static final int[] PRIMARY_COLORS = + new int[]{ + Color.parseColor("#F44336"), + Color.parseColor("#E91E63"), + Color.parseColor("#9C27B0"), + Color.parseColor("#673AB7"), + Color.parseColor("#3F51B5"), + Color.parseColor("#2196F3"), + Color.parseColor("#03A9F4"), + Color.parseColor("#00BCD4"), + Color.parseColor("#009688"), + Color.parseColor("#4CAF50"), + Color.parseColor("#8BC34A"), + Color.parseColor("#CDDC39"), + Color.parseColor("#FFEB3B"), + Color.parseColor("#FFC107"), + Color.parseColor("#FF9800"), + Color.parseColor("#FF5722"), + Color.parseColor("#795548"), + Color.parseColor("#9E9E9E"), + Color.parseColor("#607D8B"), + Color.parseColor("#000000"), + Color.parseColor("#FFFFFF"), + Color.parseColor("#FF0000"), + Color.parseColor("#0000FF"), + Color.parseColor("#00FF00"), + Color.parseColor("#FF00FF"), + Color.parseColor("#00FFFF"), + Color.parseColor("#FFFF00") + }; + + public static int pickTextColorBasedOnBgColorSimple(int bgColor, int lightColor, int darkColor) { + String color = String.format("#%06X", (0xFFFFFF & bgColor)); + color = color.substring(1, 7); + int r = Integer.parseInt(color.substring(0, 2), 16); // hexToR + int g = Integer.parseInt(color.substring(2, 4), 16); // hexToG + int b = Integer.parseInt(color.substring(4, 6), 16); // hexToB + return (((r * 0.299) + (g * 0.587) + (b * 0.114)) > 186) ? + darkColor : lightColor; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/utils/DailyReceiver.java b/app/src/main/java/com/ulan/timetable/utils/DailyReceiver.java deleted file mode 100644 index 8fda250..0000000 --- a/app/src/main/java/com/ulan/timetable/utils/DailyReceiver.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.ulan.timetable.utils; - -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.graphics.BitmapFactory; -import android.media.RingtoneManager; -import android.net.Uri; -import android.os.Build; -import android.support.annotation.RequiresApi; -import android.support.v4.app.NotificationCompat; - -import com.ulan.timetable.activities.MainActivity; -import com.ulan.timetable.R; - -import java.util.Calendar; - -/** - * Created by Ulan on 28.01.2019. - */ -public class DailyReceiver extends BroadcastReceiver { - - Context context; - DbHelper db; - - @RequiresApi(api = Build.VERSION_CODES.N) - @Override - public void onReceive(Context context, Intent intent) { - this.context = context; - - String message ; - - long when = System.currentTimeMillis(); - NotificationManager notificationManager = (NotificationManager) context - .getSystemService(Context.NOTIFICATION_SERVICE); - - Intent notificationIntent = new Intent(context, MainActivity.class); - notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, - notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); - - Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - - db = new DbHelper(context); - Calendar calendar = Calendar.getInstance(); - int day = calendar.get(Calendar.DAY_OF_WEEK); - - message = getLessons(day); - - NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder( - context, "").setSmallIcon(R.mipmap.ic_launcher_round) - .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) - .setContentTitle(context.getString(R.string.notification_title)) - .setContentText(message).setSound(alarmSound) - .setAutoCancel(true).setWhen(when) - .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) - .setContentIntent(pendingIntent) - .setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); - if (notificationManager != null) { - notificationManager.notify(5, mNotifyBuilder.build()); - } - } - - @RequiresApi(api = Build.VERSION_CODES.N) - private String getLessons(int day) { - StringBuilder lessons = new StringBuilder(""); - String currentDay = getCurrentDay(day); - - db.getWeek(currentDay).forEach(week -> { - if(week != null) { - lessons.append(week.getSubject()).append(" ") - .append(week.getFromTime()) - .append(" - ") - .append(week.getToTime()).append(" ") - .append(week.getRoom()) - .append("\n"); - } - }); - - return !lessons.toString().equals("") ? lessons.toString() : context.getString(R.string.do_not_have_lessons); - } - - private String getCurrentDay(int day) { - String currentDay = null; - switch (day) { - case 1: - currentDay = "Sunday"; - break; - case 2: - currentDay = "Monday"; - break; - case 3: - currentDay = "Tuesday"; - break; - case 4: - currentDay = "Wednesday"; - break; - case 5: - currentDay = "Thursday"; - break; - case 6: - currentDay = "Friday"; - break; - case 7: - currentDay = "Saturday"; - break; - } - return currentDay; - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/utils/DbHelper.java b/app/src/main/java/com/ulan/timetable/utils/DbHelper.java index 3f32081..e92d54a 100644 --- a/app/src/main/java/com/ulan/timetable/utils/DbHelper.java +++ b/app/src/main/java/com/ulan/timetable/utils/DbHelper.java @@ -20,7 +20,7 @@ public class DbHelper extends SQLiteOpenHelper{ private static final int DB_VERSION = 6; - private static final String DB_NAME = "timetabledb"; + public static final String DB_NAME = "timetabledb"; private static final String TIMETABLE = "timetable"; private static final String WEEK_ID = "id"; private static final String WEEK_SUBJECT = "subject"; @@ -399,4 +399,16 @@ public ArrayList getExam() { db.close(); return examslist; } + + + public void deleteAll() { + SQLiteDatabase db = this.getWritableDatabase(); + db.execSQL("DROP TABLE IF EXISTS " + TIMETABLE); + db.execSQL("DROP TABLE IF EXISTS " + HOMEWORKS); + db.execSQL("DROP TABLE IF EXISTS " + NOTES); + db.execSQL("DROP TABLE IF EXISTS " + TEACHERS); + db.execSQL("DROP TABLE IF EXISTS " + EXAMS); + db.close(); + onCreate(this.getWritableDatabase()); + } } diff --git a/app/src/main/java/com/ulan/timetable/utils/FragmentHelper.java b/app/src/main/java/com/ulan/timetable/utils/FragmentHelper.java index 049526e..16a5169 100644 --- a/app/src/main/java/com/ulan/timetable/utils/FragmentHelper.java +++ b/app/src/main/java/com/ulan/timetable/utils/FragmentHelper.java @@ -1,6 +1,5 @@ package com.ulan.timetable.utils; -import android.app.Activity; import android.util.SparseBooleanArray; import android.view.ActionMode; import android.view.Menu; @@ -9,9 +8,11 @@ import android.widget.AbsListView; import android.widget.ListView; +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; import com.ulan.timetable.adapters.WeekAdapter; import com.ulan.timetable.model.Week; -import com.ulan.timetable.R; import java.util.ArrayList; @@ -20,7 +21,7 @@ */ public class FragmentHelper { - public static AbsListView.MultiChoiceModeListener setupListViewMultiSelect(final Activity activity, final ListView listView, final WeekAdapter adapter, final DbHelper db) { + public static AbsListView.MultiChoiceModeListener setupListViewMultiSelect(final AppCompatActivity activity, final ListView listView, final WeekAdapter adapter, final DbHelper db) { return new AbsListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { diff --git a/app/src/main/java/com/ulan/timetable/utils/LinedEditText.java b/app/src/main/java/com/ulan/timetable/utils/LinedEditText.java index bc695e0..1601bd0 100644 --- a/app/src/main/java/com/ulan/timetable/utils/LinedEditText.java +++ b/app/src/main/java/com/ulan/timetable/utils/LinedEditText.java @@ -3,13 +3,12 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.EditText; -import com.ulan.timetable.R; - /** * Created by Ulan on 28.09.2018. */ @@ -25,7 +24,7 @@ public LinedEditText(Context context, AttributeSet attrs) { mRect = new Rect(); mPaint = new Paint(); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); - mPaint.setColor(R.color.colorPrimaryDark); + mPaint.setColor(Color.parseColor("#008577")); } @Override diff --git a/app/src/main/java/com/ulan/timetable/utils/NotificationUtil.java b/app/src/main/java/com/ulan/timetable/utils/NotificationUtil.java new file mode 100644 index 0000000..47a58b1 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/utils/NotificationUtil.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.utils; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.os.Build; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.app.NotificationCompat; +import androidx.core.app.Person; +import androidx.core.app.TaskStackBuilder; +import androidx.core.graphics.drawable.DrawableKt; +import androidx.core.graphics.drawable.IconCompat; + +import com.github.stephenvinouze.shapetextdrawable.ShapeForm; +import com.github.stephenvinouze.shapetextdrawable.ShapeTextDrawable; +import com.ulan.timetable.R; +import com.ulan.timetable.activities.MainActivity; +import com.ulan.timetable.model.Week; +import com.ulan.timetable.receivers.NotificationDismissButtonReceiver; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.UUID; + +public class NotificationUtil { + private static final int NOTIFICATION_SUMMARY_ID = 9090; + private static final int NOTIFICATION_NEXT_WEEK_ID = 3030; + private static final String CHANNEL_ID = "notification"; + + public static void sendNotificationSummary(@NonNull Context context, boolean alert) { + new Thread(() -> { + DbHelper db = new DbHelper(context); + String lessons = getLessons(db.getWeek(getCurrentDay(Calendar.getInstance().get(Calendar.DAY_OF_WEEK))), context); + if (lessons == null) + return; + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) + .setSmallIcon(R.drawable.ic_assignment_black_24dp) + .setContentTitle(context.getString(R.string.notification_summary_title)) + .setStyle(new NotificationCompat.BigTextStyle().bigText(lessons)); + + sendNotification(context, alert, builder, NOTIFICATION_SUMMARY_ID); + }).start(); + } + + public static void sendNotificationCurrentLesson(@NonNull Context context, boolean alert) { + new Thread(() -> { + DbHelper db = new DbHelper(context); + ArrayList weeks = db.getWeek(getCurrentDay(Calendar.getInstance().get(Calendar.DAY_OF_WEEK))); + Week nextWeek = WeekUtils.getNextWeek(weeks); + if (nextWeek == null) + return; + weeks = new ArrayList<>(); + weeks.add(nextWeek); + + StringBuilder lesson = new StringBuilder(); + if (PreferenceUtil.showTimes(context)) + lesson.append(context.getString(R.string.time_from).substring(0, 1).toUpperCase()) + .append(context.getString(R.string.time_from).substring(1)) + .append(" ") + .append(nextWeek.getFromTime()) + .append(" - ") + .append(nextWeek.getToTime()); + else { + int start = WeekUtils.getMatchingScheduleBegin(nextWeek.getFromTime(), PreferenceUtil.getStartTime(context), PreferenceUtil.getPeriodLength(context)); + int end = WeekUtils.getMatchingScheduleEnd(nextWeek.getToTime(), PreferenceUtil.getStartTime(context), PreferenceUtil.getPeriodLength(context)); + if (start == end) { + lesson.append(start) + .append(". ") + .append(context.getString(R.string.lesson)); + } else { + lesson.append(start) + .append(".-") + .append(end) + .append(". ") + .append(context.getString(R.string.lesson)); + } + } + lesson.append(" ") + .append(context.getString(R.string.share_msg_in_room)) + .append(" ") + .append(nextWeek.getRoom()); + + StringBuilder name = new StringBuilder() + .append(nextWeek.getSubject()) + .append(" ") + .append(context.getString(R.string.with_teacher)) + .append(" ") + .append(nextWeek.getTeacher()); + + + NotificationCompat.MessagingStyle style = new NotificationCompat.MessagingStyle(new Person.Builder().setName("me").build()); + style.setConversationTitle(context.getString(R.string.notification_next_week_title)); + int color = nextWeek.getColor(); + int textColor = ColorPalette.pickTextColorBasedOnBgColorSimple(nextWeek.getColor(), Color.WHITE, Color.BLACK); + int textSize = context.getResources().getInteger(R.integer.notification_max_text_size) - context.getResources().getInteger(R.integer.notification_text_size_factor) * nextWeek.getRoom().length(); + if (textSize < context.getResources().getInteger(R.integer.notification_min_text_size)) + textSize = context.getResources().getInteger(R.integer.notification_min_text_size); + Drawable drawable = new ShapeTextDrawable(ShapeForm.ROUND, color, 10f, nextWeek.getRoom(), textColor, true, Typeface.create("sans-serif-light", Typeface.NORMAL), textSize, Color.TRANSPARENT, 0); + Person person = new Person.Builder().setName(name).setIcon(IconCompat.createWithBitmap(DrawableKt.toBitmap(drawable, context.getResources().getInteger(R.integer.notification_bitmap_size), context.getResources().getInteger(R.integer.notification_bitmap_size), null))).build(); + style.addMessage(new NotificationCompat.MessagingStyle.Message(lesson, 0, person)); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) + .setStyle(style) + .setSmallIcon(R.drawable.ic_assignment_next_black_24dp) + .setColor(color); + + + sendNotification(context, alert, builder, NOTIFICATION_NEXT_WEEK_ID); + }).start(); + } + + private static void sendNotification(@NonNull Context context, boolean alert, @Nullable NotificationCompat.Builder notificationBuilder, int id) { + if (notificationBuilder == null || !PreferenceUtil.isNotification(context) || Build.VERSION.SDK_INT < 21) + return; + + + long when = System.currentTimeMillis(); + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + + Intent notificationIntent = new Intent(context, MainActivity.class); + TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); + stackBuilder.addNextIntentWithParentStack(notificationIntent); + PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); + + createNotificationChannel(context); + NotificationCompat.Builder mNotifyBuilder = notificationBuilder + .setChannelId(CHANNEL_ID) + .setAutoCancel(true) + .setWhen(when) + .setPriority(alert ? NotificationCompat.PRIORITY_HIGH : NotificationCompat.PRIORITY_DEFAULT) + .setOnlyAlertOnce(!alert) + .setContentIntent(pendingIntent); + + + if (PreferenceUtil.isAlwaysNotification(context)) { + //Dismiss button intent + Intent buttonIntent = new Intent(context, NotificationDismissButtonReceiver.class); + buttonIntent.setAction("com.asdoi.gymwen.receivers.NotificationDismissButtonReceiver"); + buttonIntent.putExtra(NotificationDismissButtonReceiver.EXTRA_NOTIFICATION_ID, id); + PendingIntent btPendingIntent = PendingIntent.getBroadcast(context, UUID.randomUUID().hashCode(), buttonIntent, PendingIntent.FLAG_UPDATE_CURRENT); + + mNotifyBuilder.setOngoing(true); + mNotifyBuilder.addAction(R.drawable.ic_close_black_24dp, context.getString(R.string.notif_dismiss), btPendingIntent); + } + + if (notificationManager != null) { + notificationManager.notify(id, mNotifyBuilder.build()); + } + } + + private static void createNotificationChannel(@NonNull Context context) { + // Create the NotificationChannel, but only on API 26+ because + // the NotificationChannel class is new and not in the support library + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.channel), NotificationManager.IMPORTANCE_DEFAULT); + channel.setDescription(context.getString(R.string.channel_desc)); + channel.enableLights(false); + channel.setSound(null, null); + channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); + + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + NotificationManager notificationManager = context.getSystemService(NotificationManager.class); + notificationManager.createNotificationChannel(channel); + } + } + + @Nullable + public static String getLessons(@NonNull ArrayList weeks, @NonNull Context context) { + StringBuilder lessons = new StringBuilder(); + for (Week week : weeks) { + if (week != null) { + lessons.append(week.getSubject()) + .append(" ") + .append(context.getString(R.string.time_from)) + .append(" "); + + if (PreferenceUtil.showTimes(context)) + lessons.append(week.getFromTime()) + .append(" - ") + .append(week.getToTime()); + else { + int start = WeekUtils.getMatchingScheduleBegin(week.getFromTime(), PreferenceUtil.getStartTime(context), PreferenceUtil.getPeriodLength(context)); + int end = WeekUtils.getMatchingScheduleEnd(week.getToTime(), PreferenceUtil.getStartTime(context), PreferenceUtil.getPeriodLength(context)); + if (start == end) { + lessons.append(start) + .append(". ") + .append(context.getString(R.string.lesson)); + } else { + lessons.append(start) + .append(".-") + .append(end) + .append(". ") + .append(context.getString(R.string.lesson)); + } + } + lessons.append(" ") + .append(context.getString(R.string.with_teacher)) + .append(" ") + .append(week.getTeacher()) + .append(" ") + .append(context.getString(R.string.share_msg_in_room)) + .append(" ") + .append(week.getRoom()) + .append("\n"); + } + } + + return !lessons.toString().equals("") ? lessons.toString().substring(0, lessons.toString().length() - 1) : null; + } + + @Nullable + public static String getCurrentDay(int day) { + String currentDay = null; + switch (day) { + case 1: + currentDay = "Sunday"; + break; + case 2: + currentDay = "Monday"; + break; + case 3: + currentDay = "Tuesday"; + break; + case 4: + currentDay = "Wednesday"; + break; + case 5: + currentDay = "Thursday"; + break; + case 6: + currentDay = "Friday"; + break; + case 7: + currentDay = "Saturday"; + break; + } + return currentDay; + } +} diff --git a/app/src/main/java/com/ulan/timetable/utils/PreferenceUtil.java b/app/src/main/java/com/ulan/timetable/utils/PreferenceUtil.java new file mode 100644 index 0000000..e73a165 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/utils/PreferenceUtil.java @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.utils; + +import android.app.Activity; +import android.app.AlarmManager; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.util.TypedValue; + +import androidx.annotation.NonNull; +import androidx.annotation.StyleRes; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.preference.PreferenceManager; + +import com.afollestad.materialdialogs.MaterialDialog; +import com.ulan.timetable.R; +import com.ulan.timetable.activities.SettingsActivity; +import com.ulan.timetable.receivers.DoNotDisturbReceiversKt; + +import java.util.Calendar; + +import static android.content.Context.ALARM_SERVICE; + + +public class PreferenceUtil { + + private static boolean getBooleanSettings(Context context, String key, boolean defaultValue) { + return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, defaultValue); + } + + public static boolean isNotification(Context context) { + return getBooleanSettings(context, "timetableNotif", true); + } + + public static void setAlarmTime(Context context, @NonNull int... times) { + if (times.length != 3) { + if (times.length > 0 && times[0] == 0) { + setAlarm(context, false); + } else { + System.out.println("wrong parameters"); + } + return; + } + + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = sharedPref.edit(); + setAlarm(context, true); + editor.putInt("Alarm_hour", times[0]); + editor.putInt("Alarm_minute", times[1]); + editor.putInt("Alarm_second", times[2]); + editor.commit(); + } + + @NonNull + public static int[] getAlarmTime(Context context) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + return new int[]{sharedPref.getInt("Alarm_hour", 7), sharedPref.getInt("Alarm_minute", 55), sharedPref.getInt("Alarm_second", 0)}; + } + + private static void setAlarm(@NonNull Context context, boolean value) { + SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); + editor.putBoolean("alarm", value); + editor.commit(); + } + + + public static boolean isAlarmOn(@NonNull Context context) { + return getBooleanSettings(context, "alarm", false); + } + + public static boolean doNotDisturbDontAskAgain(Context context) { + return getBooleanSettings(context, "do_not_disturb_dont_ask", false); + } + + public static void setDoNotDisturbDontAskAgain(@NonNull Context context, boolean value) { + PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("do_not_disturb_dont_ask", value).apply(); + } + + public static boolean isAutomaticDoNotDisturb(Context context) { + return getBooleanSettings(context, "automatic_do_not_disturb", true); + } + + public static void setDoNotDisturb(@NonNull Activity activity, boolean dontAskAgain) { + NotificationManager notificationManager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + // Check if the notification policy access has been granted for the app. + if (!notificationManager.isNotificationPolicyAccessGranted() && !dontAskAgain) { + Drawable drawable = ContextCompat.getDrawable(activity, R.drawable.ic_do_not_disturb_on_black_24dp); + try { + Drawable wrappedDrawable = DrawableCompat.wrap(drawable); + DrawableCompat.setTint(wrappedDrawable, PreferenceUtil.getTextColorPrimary(activity)); + } catch (Exception e) { + e.printStackTrace(); + } + + new MaterialDialog.Builder(activity) + .title(R.string.permission_required) + .content(R.string.do_not_disturb_permission_desc) + .onPositive((dialog, which) -> { + Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); + activity.startActivity(intent); + }) + .positiveText(R.string.permission_ok_button) + .negativeText(R.string.permission_cancel_button) + .onNegative(((dialog, which) -> dialog.dismiss())) + .icon(drawable) + .onNeutral(((dialog, which) -> setDoNotDisturbDontAskAgain(activity, true))) + .neutralText(R.string.dont_show_again) + .show(); + } else { + DoNotDisturbReceiversKt.setDoNotDisturbReceivers(activity); + } + } + } + + public static boolean isDoNotDisturbTurnOff(Context context) { + return getBooleanSettings(context, "do_not_disturb_turn_off", false); + } + + + public static boolean isAlwaysNotification(Context context) { + return getBooleanSettings(context, "alwaysNotification", false); + } + + + public static void setOneTimeAlarm(@NonNull Context context, @NonNull Class cls, int hour, int min, int second, int id) { + // cancel already scheduled reminders + cancelAlarm(context, cls, id); + + Calendar currentCalendar = Calendar.getInstance(); + + Calendar customCalendar = Calendar.getInstance(); + customCalendar.setTimeInMillis(System.currentTimeMillis()); + customCalendar.set(Calendar.HOUR_OF_DAY, hour); + customCalendar.set(Calendar.MINUTE, min); + customCalendar.set(Calendar.SECOND, second); + + if (customCalendar.before(currentCalendar)) + customCalendar.add(Calendar.DATE, 1); + + // Enable a receiver + ComponentName receiver = new ComponentName(context, cls); + PackageManager pm = context.getPackageManager(); + + pm.setComponentEnabledSetting(receiver, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + + Intent intent = new Intent(context, cls); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), id, intent, 0); + + AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); + if (alarmManager == null) + return; + + long startTime = customCalendar.getTimeInMillis(); + if (Build.VERSION.SDK_INT < 23) { + if (Build.VERSION.SDK_INT >= 19) { + if (System.currentTimeMillis() < startTime) + alarmManager.setExact(AlarmManager.RTC_WAKEUP, startTime, pendingIntent); + } else { + if (System.currentTimeMillis() < startTime) + alarmManager.set(AlarmManager.RTC_WAKEUP, startTime, pendingIntent); + } + } else { + if (System.currentTimeMillis() < startTime) + alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, startTime, pendingIntent); + } + } + + public static void setRepeatingAlarm(@NonNull Context context, @NonNull Class cls, int hour, int min, int second, int id, long interval) { + // cancel already scheduled reminders + cancelAlarm(context, cls, id); + + Calendar currentCalendar = Calendar.getInstance(); + + Calendar customCalendar = Calendar.getInstance(); + customCalendar.setTimeInMillis(System.currentTimeMillis()); + customCalendar.set(Calendar.HOUR_OF_DAY, hour); + customCalendar.set(Calendar.MINUTE, min); + customCalendar.set(Calendar.SECOND, second); + + if (customCalendar.before(currentCalendar)) + customCalendar.add(Calendar.DATE, 1); + + // Enable a receiver + ComponentName receiver = new ComponentName(context, cls); + PackageManager pm = context.getPackageManager(); + + pm.setComponentEnabledSetting(receiver, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + + Intent intent = new Intent(context, cls); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), id, intent, 0); + + AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); + if (alarmManager == null) + return; + + long startTime = customCalendar.getTimeInMillis(); + alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, startTime, interval, pendingIntent); + } + + public static void cancelAlarm(@NonNull Context context, @NonNull Class cls, int id) { + Intent intent = new Intent(context, cls); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT); + AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); + am.cancel(pendingIntent); + pendingIntent.cancel(); + } + + + @StyleRes + public static int getGeneralTheme(Context context) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + return getThemeResFromPrefValue(sharedPref.getString("theme", "switch"), context); + } + + @StyleRes + private static int getThemeResFromPrefValue(@NonNull String themePrefValue, Context context) { + switch (themePrefValue) { + case "dark": + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Dark; + case "black": + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Black; + case "switch": + int nightModeFlags = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + switch (nightModeFlags) { + case Configuration.UI_MODE_NIGHT_YES: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Dark; + default: + case Configuration.UI_MODE_NIGHT_NO: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + return R.style.AppTheme_Light; + } + case "light": + default: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + return R.style.AppTheme_Light; + } + } + + @StyleRes + public static int getGeneralThemeNoActionBar(Context context) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + return getThemeResFromPrefValueNoActionBar(sharedPref.getString("theme", "switch"), context); + } + + @StyleRes + private static int getThemeResFromPrefValueNoActionBar(@NonNull String themePrefValue, Context context) { + switch (themePrefValue) { + case "dark": + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Dark_NoActionBar; + case "black": + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Black_NoActionBar; + case "switch": + int nightModeFlags = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + switch (nightModeFlags) { + case Configuration.UI_MODE_NIGHT_YES: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + return R.style.AppTheme_Dark_NoActionBar; + default: + case Configuration.UI_MODE_NIGHT_NO: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + return R.style.AppTheme_Light_NoActionBar; + } + case "light": + default: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + return R.style.AppTheme_Light_NoActionBar; + } + } + + public static boolean isDark(Context context) { + int theme = getGeneralTheme(context); + switch (theme) { + case R.style.AppTheme_Dark: + case R.style.AppTheme_Black: + return true; + case R.style.AppTheme_Light: + default: + return false; + } + } + + public static int getTextColorPrimary(@NonNull Context context) { + return getThemeColor(android.R.attr.textColorPrimary, context); + } + + public static int getPrimaryColor(@NonNull Context context) { + return getThemeColor(R.attr.colorPrimary, context); + } + + + private static int getThemeColor(int themeAttributeId, @NonNull Context context) { + try { + TypedValue outValue = new TypedValue(); + Resources.Theme theme = context.getTheme(); + boolean wasResolved = theme.resolveAttribute(themeAttributeId, outValue, true); + if (wasResolved) { + return ContextCompat.getColor(context, outValue.resourceId); + } else { + // fallback colour handling + return Color.BLACK; + } + } catch (Exception e) { + return Color.BLACK; + } + } + + public static boolean isSevenDays(Context context) { + return getBooleanSettings(context, SettingsActivity.KEY_SEVEN_DAYS_SETTING, false); + } + + public static boolean isSummaryLibrary1(Context context) { + return getBooleanSettings(context, "summary_lib", true); + } + + public static void setSummaryLibrary(Context context, boolean value) { + PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("summary_lib", value).commit(); + } + + public static void setStartTime(Context context, @NonNull int... times) { + if (times.length != 3) { + return; + } + + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putInt("start_hour", times[0]); + editor.putInt("start_minute", times[1]); + editor.putInt("start_second", times[2]); + editor.commit(); + } + + @NonNull + public static int[] getStartTime(Context context) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + return new int[]{sharedPref.getInt("start_hour", 8), sharedPref.getInt("start_minute", 0), sharedPref.getInt("start_second", 0)}; + } + + public static void setPeriodLength(Context context, int length) { + PreferenceManager.getDefaultSharedPreferences(context).edit().putInt("period_length", length).apply(); + } + + public static int getPeriodLength(Context context) { + return PreferenceManager.getDefaultSharedPreferences(context).getInt("period_length", 60); + } + + public static boolean hasStartActivityBeenShown(Context context) { + return getBooleanSettings(context, "start_activity", false); + } + + public static void setStartActivityShown(Context context, boolean value) { + PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("start_activity", value).commit(); + } + + public static boolean showTimes(Context context) { + return getBooleanSettings(context, "show_times", false); + } +} diff --git a/app/src/main/java/com/ulan/timetable/utils/ShortcutUtils.kt b/app/src/main/java/com/ulan/timetable/utils/ShortcutUtils.kt new file mode 100644 index 0000000..f8a1ec6 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/utils/ShortcutUtils.kt @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.utils + +import android.content.Context +import android.content.Intent +import android.content.pm.ShortcutInfo +import android.content.pm.ShortcutManager +import android.graphics.Color +import android.graphics.drawable.Icon +import android.graphics.drawable.LayerDrawable +import android.os.Build +import androidx.annotation.RequiresApi +import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.toBitmap +import com.ulan.timetable.R +import com.ulan.timetable.activities.HomeworksActivity +import com.ulan.timetable.activities.NotesActivity +import com.ulan.timetable.activities.SummaryActivity + + +@RequiresApi(25) +class ShortcutUtils { + + companion object { + fun createShortcuts(context: Context) { + + val shortcutManager = context.getSystemService(ShortcutManager::class.java) + val shortcutList = mutableListOf() + shortcutList.add(createAddHomeworkShortcut(context)) + shortcutList.add(createNotesShortcut(context)) + shortcutList.add(createSummaryShortcut(context)) + + shortcutManager!!.dynamicShortcuts = shortcutList + } + + + private const val size = 256 + private const val padding = 65 + private fun createShortcut(context: Context, id: String, shortLabel: String, iconId: Int, intent: Intent): ShortcutInfo { + val icon = ContextCompat.getDrawable(context, iconId) + icon?.setTint(Color.WHITE) + + val background = ContextCompat.getDrawable(context, R.drawable.shortcuts_background) + val combined = LayerDrawable(arrayOf(background, icon)) + combined.setLayerInset(1, padding, padding, padding, padding) + + val combinedIcon = if (Build.VERSION.SDK_INT > 25) Icon.createWithAdaptiveBitmap(combined.toBitmap(size, size)) else Icon.createWithBitmap(combined.toBitmap(size, size)) + + return ShortcutInfo.Builder(context, id) + .setShortLabel(shortLabel) + .setIcon(combinedIcon) + .setIntent(intent) + .build() + } + + private fun createAddHomeworkShortcut(context: Context): ShortcutInfo { + return createShortcut(context, "add_homework", context.getString(R.string.add_homework), R.drawable.ic_book_black_24dp, Intent(context, HomeworksActivity::class.java).setAction(HomeworksActivity.ACTION_ADD_HOMEWORK)) + } + + private fun createNotesShortcut(context: Context): ShortcutInfo { + return createShortcut(context, "open_notes", context.getString(R.string.notes_activity_title), R.drawable.ic_event_note_black_24dp, Intent(context, NotesActivity::class.java).setAction(Intent.ACTION_VIEW)) + } + + private fun createSummaryShortcut(context: Context): ShortcutInfo { + return createShortcut(context, "summary", context.getString(R.string.summary_activity_title), R.drawable.ic_assignment_black_24dp, Intent(context, SummaryActivity::class.java).setAction(Intent.ACTION_VIEW)) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/utils/WakeUpAlarmReceiver.java b/app/src/main/java/com/ulan/timetable/utils/WakeUpAlarmReceiver.java deleted file mode 100644 index 09c7228..0000000 --- a/app/src/main/java/com/ulan/timetable/utils/WakeUpAlarmReceiver.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ulan.timetable.utils; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import java.util.Calendar; -import java.util.Objects; - -/** - * Created by Ulan on 28.01.2019. - */ -public class WakeUpAlarmReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - - if (Objects.equals(intent.getAction(), "android.intent.action.BOOT_COMPLETED")) { - - Calendar calendar = Calendar.getInstance(); - - calendar.set(Calendar.HOUR_OF_DAY, 8); - calendar.set(Calendar.MINUTE, 30); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - - Calendar cur = Calendar.getInstance(); - - if (cur.after(calendar)) { - calendar.add(Calendar.DATE, 1); - } - - Intent myIntent = new Intent(context, DailyReceiver.class); - int ALARM1_ID = 10000; - PendingIntent pendingIntent = PendingIntent.getBroadcast( - context, ALARM1_ID, myIntent, PendingIntent.FLAG_UPDATE_CURRENT); - AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - if (alarmManager != null) { - alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); - } - - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ulan/timetable/utils/WeekUtils.java b/app/src/main/java/com/ulan/timetable/utils/WeekUtils.java new file mode 100644 index 0000000..98b3987 --- /dev/null +++ b/app/src/main/java/com/ulan/timetable/utils/WeekUtils.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2020 Felix Hollederer + * This file is part of GymWenApp. + * + * GymWenApp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GymWenApp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GymWenApp. If not, see . + */ + +package com.ulan.timetable.utils; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.ulan.timetable.R; +import com.ulan.timetable.fragments.WeekdayFragment; +import com.ulan.timetable.model.Week; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Locale; + +public class WeekUtils { + @Nullable + public static Week getNextWeek(@NonNull ArrayList weeks) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 1); + String hour = "" + calendar.get(Calendar.HOUR_OF_DAY); + if (hour.length() < 2) + hour = "0" + hour; + String minutes = "" + calendar.get(Calendar.MINUTE); + if (minutes.length() < 2) + minutes = "0" + minutes; + String now = hour + ":" + minutes; + + for (int i = 0; i < weeks.size(); i++) { + Week week = weeks.get(i); + if ((now.compareToIgnoreCase(week.getFromTime()) >= 0 && now.compareToIgnoreCase(week.getToTime()) <= 0) || now.compareToIgnoreCase(week.getToTime()) <= 0) { + return week; + } + } + return null; + } + + @NonNull + public static ArrayList getAllWeeks(@NonNull DbHelper dbHelper) { + return getWeeks(dbHelper, new String[]{WeekdayFragment.KEY_MONDAY_FRAGMENT, + WeekdayFragment.KEY_TUESDAY_FRAGMENT, + WeekdayFragment.KEY_WEDNESDAY_FRAGMENT, + WeekdayFragment.KEY_THURSDAY_FRAGMENT, + WeekdayFragment.KEY_FRIDAY_FRAGMENT, + WeekdayFragment.KEY_SATURDAY_FRAGMENT, + WeekdayFragment.KEY_SUNDAY_FRAGMENT}); + } + + @NonNull + public static ArrayList getWeeks(@NonNull DbHelper dbHelper, @NonNull String[] keys) { + ArrayList weeks = new ArrayList<>(); + for (String key : keys) { + weeks.addAll(dbHelper.getWeek(key)); + } + return weeks; + } + + public static ArrayList getAllWeeksAndRemoveDuplicates(DbHelper dbHelper) { + ArrayList weeks = getAllWeeks(dbHelper); + ArrayList returnValue = new ArrayList<>(); + ArrayList returnValueSubjects = new ArrayList<>(); + for (Week w : weeks) { + if (!returnValueSubjects.contains(w.getSubject().toUpperCase())) { + returnValue.add(w); + returnValueSubjects.add(w.getSubject().toUpperCase()); + } + } + return returnValue; + } + + @NotNull + public static ArrayList getPreselection(@NonNull AppCompatActivity activity) { + DbHelper dbHelper = new DbHelper(activity); + + ArrayList customWeeks = getAllWeeksAndRemoveDuplicates(dbHelper); + ArrayList subjects = new ArrayList<>(); + for (Week w : customWeeks) { + subjects.add(w.getSubject().toUpperCase()); + } + + String[] preselected = activity.getResources().getStringArray(R.array.preselected_subjects); + int[] preselectedColors = activity.getResources().getIntArray(R.array.preselected_subjects_colors); + + for (int i = preselected.length - 1; i >= 0; i--) { + if (!subjects.contains(preselected[i].toUpperCase())) + customWeeks.add(0, new Week(preselected[i], "", "", "", "", preselectedColors[i])); + } + + Collections.sort(customWeeks, (week1, week2) -> week1.getSubject().compareToIgnoreCase(week2.getSubject())); + return customWeeks; + } + + public static int getMatchingScheduleBegin(String time, int[] startTime, int lessonDuration) { + int schedule = getDurationOfWeek(new Week("", "", "", startTime[0] + ":" + (startTime[1] - 1), time, 0), false, lessonDuration); + if (schedule == 0) + return 1; + else + return schedule; + } + + public static int getMatchingScheduleEnd(String time, int[] startTime, int lessonDuration) { + int schedule = getDurationOfWeek(new Week("", "", "", startTime[0] + ":" + startTime[1], time, 0), false, lessonDuration); + if (schedule == 0) + return 1; + else + return schedule; + } + + public static String getMatchingTimeBegin(int hour, int[] startTime, int lessonDuration) { + Calendar startOfSchool = Calendar.getInstance(); + startOfSchool.set(Calendar.HOUR_OF_DAY, startTime[0]); + startOfSchool.set(Calendar.MINUTE, startTime[1]); + startOfSchool.setTimeInMillis(startOfSchool.getTimeInMillis() + (hour - 1) * lessonDuration * 60 * 1000); + + return String.format(Locale.getDefault(), "%02d:%02d", startOfSchool.get(Calendar.HOUR_OF_DAY), startOfSchool.get(Calendar.MINUTE)); + } + + public static String getMatchingTimeEnd(int hour, int[] startTime, int lessonDuration) { + Calendar startOfSchool = Calendar.getInstance(); + startOfSchool.set(Calendar.HOUR_OF_DAY, startTime[0]); + startOfSchool.set(Calendar.MINUTE, startTime[1]); + startOfSchool.setTimeInMillis(startOfSchool.getTimeInMillis() + (hour) * lessonDuration * 60 * 1000); + + return String.format(Locale.getDefault(), "%02d:%02d", startOfSchool.get(Calendar.HOUR_OF_DAY), startOfSchool.get(Calendar.MINUTE)); + } + + public static int getDurationOfWeek(Week w, boolean countOnlyIfFitsLessonsTime, int lessonDuration) { + Calendar weekCalendarStart = Calendar.getInstance(); + int startHour = Integer.parseInt(w.getFromTime().substring(0, w.getFromTime().indexOf(":"))); + weekCalendarStart.set(Calendar.HOUR_OF_DAY, startHour); + int startMinute = Integer.parseInt(w.getFromTime().substring(w.getFromTime().indexOf(":") + 1)); + weekCalendarStart.set(Calendar.MINUTE, startMinute); + + Calendar weekCalendarEnd = Calendar.getInstance(); + int endHour = Integer.parseInt(w.getToTime().substring(0, w.getToTime().indexOf(":"))); + weekCalendarEnd.set(Calendar.HOUR_OF_DAY, endHour); + int endMinute = Integer.parseInt(w.getToTime().substring(w.getToTime().indexOf(":") + 1)); + weekCalendarEnd.set(Calendar.MINUTE, endMinute); + + long differencesInMillis = weekCalendarEnd.getTimeInMillis() - weekCalendarStart.getTimeInMillis(); + int inMinutes = (int) (differencesInMillis / 1000 / 60); + + if (inMinutes < lessonDuration && countOnlyIfFitsLessonsTime) + return 0; + + int multiplier; + if (inMinutes % lessonDuration > 0 && !countOnlyIfFitsLessonsTime) { + multiplier = inMinutes / lessonDuration + 1; + } else + multiplier = inMinutes / lessonDuration; + + return multiplier; + } +} diff --git a/app/src/main/res/drawable-hdpi/baseline_access_time_black_18.png b/app/src/main/res/drawable-hdpi/baseline_access_time_black_18.png deleted file mode 100644 index 199c9ca..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_access_time_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_access_time_black_24.png b/app/src/main/res/drawable-hdpi/baseline_access_time_black_24.png deleted file mode 100644 index 9851af6..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_access_time_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_access_time_black_36.png b/app/src/main/res/drawable-hdpi/baseline_access_time_black_36.png deleted file mode 100644 index a2e1d28..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_access_time_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_access_time_black_48.png b/app/src/main/res/drawable-hdpi/baseline_access_time_black_48.png deleted file mode 100644 index 1546cb5..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_access_time_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_add_white_18.png b/app/src/main/res/drawable-hdpi/baseline_add_white_18.png deleted file mode 100644 index 5f7e7bf..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_add_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_add_white_24.png b/app/src/main/res/drawable-hdpi/baseline_add_white_24.png deleted file mode 100644 index ea78104..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_add_white_36.png b/app/src/main/res/drawable-hdpi/baseline_add_white_36.png deleted file mode 100644 index f38a8b4..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_add_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_add_white_48.png b/app/src/main/res/drawable-hdpi/baseline_add_white_48.png deleted file mode 100644 index 0fdced8..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_add_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_book_black_18.png b/app/src/main/res/drawable-hdpi/baseline_book_black_18.png deleted file mode 100644 index fc76519..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_book_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_18.png b/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_18.png deleted file mode 100644 index 1554ba1..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_24.png b/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_24.png deleted file mode 100644 index dea2b03..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_36.png b/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_36.png deleted file mode 100644 index a9c0c6e..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_48.png b/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_48.png deleted file mode 100644 index 75e83e6..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_delete_forever_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_edit_white_18.png b/app/src/main/res/drawable-hdpi/baseline_edit_white_18.png deleted file mode 100644 index ac19803..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_edit_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_edit_white_24.png b/app/src/main/res/drawable-hdpi/baseline_edit_white_24.png deleted file mode 100644 index f178630..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_edit_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_edit_white_36.png b/app/src/main/res/drawable-hdpi/baseline_edit_white_36.png deleted file mode 100644 index d0f8e08..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_edit_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_edit_white_48.png b/app/src/main/res/drawable-hdpi/baseline_edit_white_48.png deleted file mode 100644 index 340b505..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_edit_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_email_black_24.png b/app/src/main/res/drawable-hdpi/baseline_email_black_24.png deleted file mode 100644 index b981bec..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_email_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_event_note_black_18.png b/app/src/main/res/drawable-hdpi/baseline_event_note_black_18.png deleted file mode 100644 index 34108f1..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_event_note_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_18.png b/app/src/main/res/drawable-hdpi/baseline_expand_more_black_18.png deleted file mode 100644 index fb189c6..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_24.png b/app/src/main/res/drawable-hdpi/baseline_expand_more_black_24.png deleted file mode 100644 index b5b0a05..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_36.png b/app/src/main/res/drawable-hdpi/baseline_expand_more_black_36.png deleted file mode 100644 index 991a067..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_48.png b/app/src/main/res/drawable-hdpi/baseline_expand_more_black_48.png deleted file mode 100644 index 43f5f23..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_expand_more_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_list_black_18.png b/app/src/main/res/drawable-hdpi/baseline_list_black_18.png deleted file mode 100644 index 26e40d8..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_list_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_open_in_browser_black_18.png b/app/src/main/res/drawable-hdpi/baseline_open_in_browser_black_18.png deleted file mode 100644 index 5e20eca..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_open_in_browser_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_people_black_18.png b/app/src/main/res/drawable-hdpi/baseline_people_black_18.png deleted file mode 100644 index 55a69c7..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_people_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_person_black_18.png b/app/src/main/res/drawable-hdpi/baseline_person_black_18.png deleted file mode 100644 index b8cc77c..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_person_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_person_black_24.png b/app/src/main/res/drawable-hdpi/baseline_person_black_24.png deleted file mode 100644 index c3e2442..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_person_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_person_black_36.png b/app/src/main/res/drawable-hdpi/baseline_person_black_36.png deleted file mode 100644 index f81b582..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_person_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_person_black_48.png b/app/src/main/res/drawable-hdpi/baseline_person_black_48.png deleted file mode 100644 index 269cea9..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_person_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_phone_black_24.png b/app/src/main/res/drawable-hdpi/baseline_phone_black_24.png deleted file mode 100644 index c1d1de8..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_phone_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_room_black_24.png b/app/src/main/res/drawable-hdpi/baseline_room_black_24.png deleted file mode 100644 index 1e77ace..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_room_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_school_black_18.png b/app/src/main/res/drawable-hdpi/baseline_school_black_18.png deleted file mode 100644 index 5ceef80..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_school_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_school_black_24.png b/app/src/main/res/drawable-hdpi/baseline_school_black_24.png deleted file mode 100644 index ec95a86..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_school_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_school_black_36.png b/app/src/main/res/drawable-hdpi/baseline_school_black_36.png deleted file mode 100644 index c9ece8f..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_school_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_school_black_48.png b/app/src/main/res/drawable-hdpi/baseline_school_black_48.png deleted file mode 100644 index 9bd012e..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_school_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_settings_black_18.png b/app/src/main/res/drawable-hdpi/baseline_settings_black_18.png deleted file mode 100644 index 51ef042..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_settings_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_subject_black_18.png b/app/src/main/res/drawable-hdpi/baseline_subject_black_18.png deleted file mode 100644 index b0d91ba..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_subject_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_subject_black_24.png b/app/src/main/res/drawable-hdpi/baseline_subject_black_24.png deleted file mode 100644 index a75a1d5..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_subject_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_subject_black_36.png b/app/src/main/res/drawable-hdpi/baseline_subject_black_36.png deleted file mode 100644 index a9df043..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_subject_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_subject_black_48.png b/app/src/main/res/drawable-hdpi/baseline_subject_black_48.png deleted file mode 100644 index e5e2c2b..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_subject_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_view_week_black_18.png b/app/src/main/res/drawable-hdpi/baseline_view_week_black_18.png deleted file mode 100644 index 7d83ed0..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_view_week_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_view_week_black_24.png b/app/src/main/res/drawable-hdpi/baseline_view_week_black_24.png deleted file mode 100644 index cfff041..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_view_week_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_view_week_black_36.png b/app/src/main/res/drawable-hdpi/baseline_view_week_black_36.png deleted file mode 100644 index c2cb91f..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_view_week_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/baseline_view_week_black_48.png b/app/src/main/res/drawable-hdpi/baseline_view_week_black_48.png deleted file mode 100644 index 7218498..0000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_view_week_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_access_time_black_18.png b/app/src/main/res/drawable-mdpi/baseline_access_time_black_18.png deleted file mode 100644 index 8aa5dfb..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_access_time_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_access_time_black_24.png b/app/src/main/res/drawable-mdpi/baseline_access_time_black_24.png deleted file mode 100644 index 785310d..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_access_time_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_access_time_black_36.png b/app/src/main/res/drawable-mdpi/baseline_access_time_black_36.png deleted file mode 100644 index 9851af6..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_access_time_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_access_time_black_48.png b/app/src/main/res/drawable-mdpi/baseline_access_time_black_48.png deleted file mode 100644 index 4399b1e..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_access_time_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_add_white_18.png b/app/src/main/res/drawable-mdpi/baseline_add_white_18.png deleted file mode 100644 index 5c51c5d..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_add_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_add_white_24.png b/app/src/main/res/drawable-mdpi/baseline_add_white_24.png deleted file mode 100644 index eeba9f6..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_add_white_36.png b/app/src/main/res/drawable-mdpi/baseline_add_white_36.png deleted file mode 100644 index ea78104..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_add_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_add_white_48.png b/app/src/main/res/drawable-mdpi/baseline_add_white_48.png deleted file mode 100644 index 67bb598..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_add_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_book_black_18.png b/app/src/main/res/drawable-mdpi/baseline_book_black_18.png deleted file mode 100644 index 73942a6..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_book_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_18.png b/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_18.png deleted file mode 100644 index 07d2ff5..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_24.png b/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_24.png deleted file mode 100644 index cc41c80..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_36.png b/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_36.png deleted file mode 100644 index dea2b03..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_48.png b/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_48.png deleted file mode 100644 index b70443b..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_delete_forever_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_edit_white_18.png b/app/src/main/res/drawable-mdpi/baseline_edit_white_18.png deleted file mode 100644 index 73680ec..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_edit_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_edit_white_24.png b/app/src/main/res/drawable-mdpi/baseline_edit_white_24.png deleted file mode 100644 index 654d7a9..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_edit_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_edit_white_36.png b/app/src/main/res/drawable-mdpi/baseline_edit_white_36.png deleted file mode 100644 index f178630..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_edit_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_edit_white_48.png b/app/src/main/res/drawable-mdpi/baseline_edit_white_48.png deleted file mode 100644 index 9589768..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_edit_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_email_black_24.png b/app/src/main/res/drawable-mdpi/baseline_email_black_24.png deleted file mode 100644 index fb57102..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_email_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_event_note_black_18.png b/app/src/main/res/drawable-mdpi/baseline_event_note_black_18.png deleted file mode 100644 index ff31790..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_event_note_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_18.png b/app/src/main/res/drawable-mdpi/baseline_expand_more_black_18.png deleted file mode 100644 index 6535430..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_24.png b/app/src/main/res/drawable-mdpi/baseline_expand_more_black_24.png deleted file mode 100644 index 2a6f560..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_36.png b/app/src/main/res/drawable-mdpi/baseline_expand_more_black_36.png deleted file mode 100644 index b5b0a05..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_48.png b/app/src/main/res/drawable-mdpi/baseline_expand_more_black_48.png deleted file mode 100644 index 4c76133..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_expand_more_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_list_black_18.png b/app/src/main/res/drawable-mdpi/baseline_list_black_18.png deleted file mode 100644 index a16143b..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_list_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_open_in_browser_black_18.png b/app/src/main/res/drawable-mdpi/baseline_open_in_browser_black_18.png deleted file mode 100644 index 406f909..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_open_in_browser_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_people_black_18.png b/app/src/main/res/drawable-mdpi/baseline_people_black_18.png deleted file mode 100644 index 7d9d79e..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_people_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_person_black_18.png b/app/src/main/res/drawable-mdpi/baseline_person_black_18.png deleted file mode 100644 index 52e9810..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_person_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_person_black_24.png b/app/src/main/res/drawable-mdpi/baseline_person_black_24.png deleted file mode 100644 index 48667ba..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_person_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_person_black_36.png b/app/src/main/res/drawable-mdpi/baseline_person_black_36.png deleted file mode 100644 index c3e2442..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_person_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_person_black_48.png b/app/src/main/res/drawable-mdpi/baseline_person_black_48.png deleted file mode 100644 index f4949d5..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_person_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_phone_black_24.png b/app/src/main/res/drawable-mdpi/baseline_phone_black_24.png deleted file mode 100644 index 6e6d3be..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_phone_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_room_black_24.png b/app/src/main/res/drawable-mdpi/baseline_room_black_24.png deleted file mode 100644 index 934ccf2..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_room_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_school_black_18.png b/app/src/main/res/drawable-mdpi/baseline_school_black_18.png deleted file mode 100644 index 6e049f7..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_school_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_school_black_24.png b/app/src/main/res/drawable-mdpi/baseline_school_black_24.png deleted file mode 100644 index 9da3211..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_school_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_school_black_36.png b/app/src/main/res/drawable-mdpi/baseline_school_black_36.png deleted file mode 100644 index ec95a86..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_school_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_school_black_48.png b/app/src/main/res/drawable-mdpi/baseline_school_black_48.png deleted file mode 100644 index a80a30d..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_school_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_settings_black_18.png b/app/src/main/res/drawable-mdpi/baseline_settings_black_18.png deleted file mode 100644 index 39c472f..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_settings_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_subject_black_18.png b/app/src/main/res/drawable-mdpi/baseline_subject_black_18.png deleted file mode 100644 index 1b690fc..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_subject_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_subject_black_24.png b/app/src/main/res/drawable-mdpi/baseline_subject_black_24.png deleted file mode 100644 index 9c61e11..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_subject_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_subject_black_36.png b/app/src/main/res/drawable-mdpi/baseline_subject_black_36.png deleted file mode 100644 index a75a1d5..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_subject_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_subject_black_48.png b/app/src/main/res/drawable-mdpi/baseline_subject_black_48.png deleted file mode 100644 index 6e693da..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_subject_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_view_week_black_18.png b/app/src/main/res/drawable-mdpi/baseline_view_week_black_18.png deleted file mode 100644 index 62aa531..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_view_week_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_view_week_black_24.png b/app/src/main/res/drawable-mdpi/baseline_view_week_black_24.png deleted file mode 100644 index a60ad42..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_view_week_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_view_week_black_36.png b/app/src/main/res/drawable-mdpi/baseline_view_week_black_36.png deleted file mode 100644 index cfff041..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_view_week_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_view_week_black_48.png b/app/src/main/res/drawable-mdpi/baseline_view_week_black_48.png deleted file mode 100644 index c87df74..0000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_view_week_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index c7bd21d..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_access_time_black_18.png deleted file mode 100644 index 9851af6..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_access_time_black_24.png deleted file mode 100644 index 4399b1e..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_access_time_black_36.png deleted file mode 100644 index 1546cb5..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_access_time_black_48.png deleted file mode 100644 index 088adfe..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_access_time_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_add_white_18.png b/app/src/main/res/drawable-xhdpi/baseline_add_white_18.png deleted file mode 100644 index ea78104..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_add_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png deleted file mode 100644 index 67bb598..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_add_white_36.png b/app/src/main/res/drawable-xhdpi/baseline_add_white_36.png deleted file mode 100644 index 0fdced8..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_add_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_add_white_48.png b/app/src/main/res/drawable-xhdpi/baseline_add_white_48.png deleted file mode 100644 index d64c22e..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_add_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_book_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_book_black_18.png deleted file mode 100644 index ea19628..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_book_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_18.png b/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_18.png deleted file mode 100644 index dea2b03..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_24.png b/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_24.png deleted file mode 100644 index b70443b..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_36.png b/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_36.png deleted file mode 100644 index 75e83e6..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_48.png b/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_48.png deleted file mode 100644 index c56573e..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_delete_forever_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_edit_white_18.png b/app/src/main/res/drawable-xhdpi/baseline_edit_white_18.png deleted file mode 100644 index f178630..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_edit_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_edit_white_24.png b/app/src/main/res/drawable-xhdpi/baseline_edit_white_24.png deleted file mode 100644 index 9589768..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_edit_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_edit_white_36.png b/app/src/main/res/drawable-xhdpi/baseline_edit_white_36.png deleted file mode 100644 index 340b505..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_edit_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_edit_white_48.png b/app/src/main/res/drawable-xhdpi/baseline_edit_white_48.png deleted file mode 100644 index c2124f1..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_edit_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_email_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_email_black_24.png deleted file mode 100644 index 9fd561f..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_email_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_event_note_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_event_note_black_18.png deleted file mode 100644 index 1c3594e..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_event_note_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_18.png deleted file mode 100644 index b5b0a05..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_24.png deleted file mode 100644 index 4c76133..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_36.png deleted file mode 100644 index 43f5f23..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_48.png deleted file mode 100644 index 04eacc2..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_expand_more_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_list_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_list_black_18.png deleted file mode 100644 index 094529c..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_list_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_open_in_browser_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_open_in_browser_black_18.png deleted file mode 100644 index 1f339e2..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_open_in_browser_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_people_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_people_black_18.png deleted file mode 100644 index b00625c..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_people_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_person_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_person_black_18.png deleted file mode 100644 index c3e2442..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_person_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_person_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_person_black_24.png deleted file mode 100644 index f4949d5..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_person_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_person_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_person_black_36.png deleted file mode 100644 index 269cea9..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_person_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_person_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_person_black_48.png deleted file mode 100644 index f29d942..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_person_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_phone_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_phone_black_24.png deleted file mode 100644 index 7ec228b..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_phone_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_room_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_room_black_24.png deleted file mode 100644 index 326608a..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_room_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_school_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_school_black_18.png deleted file mode 100644 index ec95a86..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_school_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_school_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_school_black_24.png deleted file mode 100644 index a80a30d..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_school_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_school_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_school_black_36.png deleted file mode 100644 index 9bd012e..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_school_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_school_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_school_black_48.png deleted file mode 100644 index d5b2a95..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_school_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_settings_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_settings_black_18.png deleted file mode 100644 index f2d6980..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_settings_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_subject_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_subject_black_18.png deleted file mode 100644 index a75a1d5..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_subject_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_subject_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_subject_black_24.png deleted file mode 100644 index 6e693da..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_subject_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_subject_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_subject_black_36.png deleted file mode 100644 index e5e2c2b..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_subject_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_subject_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_subject_black_48.png deleted file mode 100644 index 4be06b0..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_subject_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_18.png b/app/src/main/res/drawable-xhdpi/baseline_view_week_black_18.png deleted file mode 100644 index cfff041..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_24.png b/app/src/main/res/drawable-xhdpi/baseline_view_week_black_24.png deleted file mode 100644 index c87df74..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_36.png b/app/src/main/res/drawable-xhdpi/baseline_view_week_black_36.png deleted file mode 100644 index 7218498..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_view_week_black_48.png deleted file mode 100644 index eff8aa6..0000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_view_week_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_18.png deleted file mode 100644 index a2e1d28..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_24.png deleted file mode 100644 index 1546cb5..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_36.png deleted file mode 100644 index 391b1a5..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_48.png deleted file mode 100644 index 0617c31..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_access_time_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_add_white_18.png b/app/src/main/res/drawable-xxhdpi/baseline_add_white_18.png deleted file mode 100644 index f38a8b4..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_add_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png deleted file mode 100644 index 0fdced8..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_add_white_36.png b/app/src/main/res/drawable-xxhdpi/baseline_add_white_36.png deleted file mode 100644 index 2f479f2..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_add_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_add_white_48.png b/app/src/main/res/drawable-xxhdpi/baseline_add_white_48.png deleted file mode 100644 index 7e69913..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_add_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_book_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_book_black_18.png deleted file mode 100644 index 1d4cfd4..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_book_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_18.png b/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_18.png deleted file mode 100644 index a9c0c6e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_24.png b/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_24.png deleted file mode 100644 index 75e83e6..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_36.png b/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_36.png deleted file mode 100644 index 923631c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_48.png b/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_48.png deleted file mode 100644 index c77ce81..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_delete_forever_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_18.png b/app/src/main/res/drawable-xxhdpi/baseline_edit_white_18.png deleted file mode 100644 index d0f8e08..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_24.png b/app/src/main/res/drawable-xxhdpi/baseline_edit_white_24.png deleted file mode 100644 index 340b505..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_36.png b/app/src/main/res/drawable-xxhdpi/baseline_edit_white_36.png deleted file mode 100644 index 675e379..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_48.png b/app/src/main/res/drawable-xxhdpi/baseline_edit_white_48.png deleted file mode 100644 index 7925f39..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_edit_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_email_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_email_black_24.png deleted file mode 100644 index c652f99..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_email_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_event_note_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_event_note_black_18.png deleted file mode 100644 index 31c7191..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_event_note_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_18.png deleted file mode 100644 index 991a067..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_24.png deleted file mode 100644 index 43f5f23..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_36.png deleted file mode 100644 index 397d7c0..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_48.png deleted file mode 100644 index ed90518..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_expand_more_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_list_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_list_black_18.png deleted file mode 100644 index eb748fd..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_list_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_open_in_browser_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_open_in_browser_black_18.png deleted file mode 100644 index 6b2393c..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_open_in_browser_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_people_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_people_black_18.png deleted file mode 100644 index 3bf8fe3..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_people_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_person_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_person_black_18.png deleted file mode 100644 index f81b582..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_person_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_person_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_person_black_24.png deleted file mode 100644 index 269cea9..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_person_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_person_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_person_black_36.png deleted file mode 100644 index 37150de..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_person_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_person_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_person_black_48.png deleted file mode 100644 index e36321d..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_person_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_phone_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_phone_black_24.png deleted file mode 100644 index 8cdd437..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_phone_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_room_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_room_black_24.png deleted file mode 100644 index b5ccffa..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_room_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_school_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_school_black_18.png deleted file mode 100644 index c9ece8f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_school_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_school_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_school_black_24.png deleted file mode 100644 index 9bd012e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_school_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_school_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_school_black_36.png deleted file mode 100644 index 3992c65..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_school_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_school_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_school_black_48.png deleted file mode 100644 index 88cad78..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_school_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_settings_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_settings_black_18.png deleted file mode 100644 index 058533e..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_settings_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_subject_black_18.png deleted file mode 100644 index a9df043..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_subject_black_24.png deleted file mode 100644 index e5e2c2b..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_subject_black_36.png deleted file mode 100644 index 61fd8a2..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_subject_black_48.png deleted file mode 100644 index 8f85dce..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_subject_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_18.png b/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_18.png deleted file mode 100644 index c2cb91f..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_24.png b/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_24.png deleted file mode 100644 index 7218498..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_36.png b/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_36.png deleted file mode 100644 index 5fbdc03..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_48.png deleted file mode 100644 index f9cefbf..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_view_week_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/shortcuts_background.xml b/app/src/main/res/drawable-xxhdpi/shortcuts_background.xml new file mode 100644 index 0000000..6366645 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/shortcuts_background.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_18.png deleted file mode 100644 index 1546cb5..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_24.png deleted file mode 100644 index 088adfe..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_36.png deleted file mode 100644 index 0617c31..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_48.png deleted file mode 100644 index 73e8166..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_access_time_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_add_white_18.png deleted file mode 100644 index 0fdced8..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png deleted file mode 100644 index d64c22e..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_add_white_36.png deleted file mode 100644 index 7e69913..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_add_white_48.png deleted file mode 100644 index 8d2dc1a..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_book_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_book_black_18.png deleted file mode 100644 index 1cc4dce..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_book_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_18.png deleted file mode 100644 index 75e83e6..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_24.png deleted file mode 100644 index c56573e..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_36.png deleted file mode 100644 index c77ce81..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_48.png deleted file mode 100644 index df5239e..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_delete_forever_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_18.png deleted file mode 100644 index 340b505..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_24.png deleted file mode 100644 index c2124f1..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_36.png deleted file mode 100644 index 7925f39..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_48.png deleted file mode 100644 index 89cabae..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_edit_white_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_email_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_email_black_24.png deleted file mode 100644 index e2d1d37..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_email_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_event_note_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_event_note_black_18.png deleted file mode 100644 index 0ddf9f5..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_event_note_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_18.png deleted file mode 100644 index 43f5f23..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_24.png deleted file mode 100644 index 04eacc2..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_36.png deleted file mode 100644 index ed90518..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_48.png deleted file mode 100644 index d0b4e0e..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_expand_more_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_list_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_list_black_18.png deleted file mode 100644 index d94b45a..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_list_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_open_in_browser_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_open_in_browser_black_18.png deleted file mode 100644 index 1e6133b..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_open_in_browser_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_people_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_people_black_18.png deleted file mode 100644 index b8e313f..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_people_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_person_black_18.png deleted file mode 100644 index 269cea9..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_person_black_24.png deleted file mode 100644 index f29d942..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_person_black_36.png deleted file mode 100644 index e36321d..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_person_black_48.png deleted file mode 100644 index fffa9e6..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_person_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_phone_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_phone_black_24.png deleted file mode 100644 index 96efa2d..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_phone_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_room_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_room_black_24.png deleted file mode 100644 index 0e19b62..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_room_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_school_black_18.png deleted file mode 100644 index 9bd012e..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_school_black_24.png deleted file mode 100644 index d5b2a95..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_school_black_36.png deleted file mode 100644 index 88cad78..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_school_black_48.png deleted file mode 100644 index 6148e03..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_school_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_settings_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_settings_black_18.png deleted file mode 100644 index 4d85280..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_settings_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_18.png deleted file mode 100644 index e5e2c2b..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_24.png deleted file mode 100644 index 4be06b0..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_36.png deleted file mode 100644 index 8f85dce..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_48.png deleted file mode 100644 index 2897dce..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_subject_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_18.png b/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_18.png deleted file mode 100644 index 7218498..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_18.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_24.png deleted file mode 100644 index eff8aa6..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_36.png b/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_36.png deleted file mode 100644 index f9cefbf..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_36.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_48.png deleted file mode 100644 index 439b35b..0000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_view_week_black_48.png and /dev/null differ diff --git a/app/src/main/res/drawable/baseline_access_time_24.xml b/app/src/main/res/drawable/baseline_access_time_24.xml deleted file mode 100644 index 2760be7..0000000 --- a/app/src/main/res/drawable/baseline_access_time_24.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/baseline_add_24.xml b/app/src/main/res/drawable/baseline_add_24.xml deleted file mode 100644 index e24557e..0000000 --- a/app/src/main/res/drawable/baseline_add_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_book_24.xml b/app/src/main/res/drawable/baseline_book_24.xml deleted file mode 100644 index 048022e..0000000 --- a/app/src/main/res/drawable/baseline_book_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_delete_forever_24.xml b/app/src/main/res/drawable/baseline_delete_forever_24.xml deleted file mode 100644 index d4d63c2..0000000 --- a/app/src/main/res/drawable/baseline_delete_forever_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_edit_24.xml b/app/src/main/res/drawable/baseline_edit_24.xml deleted file mode 100644 index 250655a..0000000 --- a/app/src/main/res/drawable/baseline_edit_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_event_note_24.xml b/app/src/main/res/drawable/baseline_event_note_24.xml deleted file mode 100644 index 16ce375..0000000 --- a/app/src/main/res/drawable/baseline_event_note_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_expand_more_24.xml b/app/src/main/res/drawable/baseline_expand_more_24.xml deleted file mode 100644 index d6d7c3c..0000000 --- a/app/src/main/res/drawable/baseline_expand_more_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_list_24.xml b/app/src/main/res/drawable/baseline_list_24.xml deleted file mode 100644 index 555080b..0000000 --- a/app/src/main/res/drawable/baseline_list_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_note_24.xml b/app/src/main/res/drawable/baseline_note_24.xml deleted file mode 100644 index 6958e16..0000000 --- a/app/src/main/res/drawable/baseline_note_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_open_in_browser_24.xml b/app/src/main/res/drawable/baseline_open_in_browser_24.xml deleted file mode 100644 index 3582977..0000000 --- a/app/src/main/res/drawable/baseline_open_in_browser_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_person_24.xml b/app/src/main/res/drawable/baseline_person_24.xml deleted file mode 100644 index eaacb65..0000000 --- a/app/src/main/res/drawable/baseline_person_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_room_24.xml b/app/src/main/res/drawable/baseline_room_24.xml deleted file mode 100644 index e008503..0000000 --- a/app/src/main/res/drawable/baseline_room_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_school_24.xml b/app/src/main/res/drawable/baseline_school_24.xml deleted file mode 100644 index d19e7bc..0000000 --- a/app/src/main/res/drawable/baseline_school_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_subject_24.xml b/app/src/main/res/drawable/baseline_subject_24.xml deleted file mode 100644 index b8baa90..0000000 --- a/app/src/main/res/drawable/baseline_subject_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/baseline_view_week_24.xml b/app/src/main/res/drawable/baseline_view_week_24.xml deleted file mode 100644 index 9897262..0000000 --- a/app/src/main/res/drawable/baseline_view_week_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/card_state_pressed.xml b/app/src/main/res/drawable/card_state_pressed.xml index c0b1f8e..f832cd0 100644 --- a/app/src/main/res/drawable/card_state_pressed.xml +++ b/app/src/main/res/drawable/card_state_pressed.xml @@ -2,14 +2,14 @@ - + - + diff --git a/app/src/main/res/drawable/home_widget.webp b/app/src/main/res/drawable/home_widget.webp new file mode 100644 index 0000000..c92dde1 Binary files /dev/null and b/app/src/main/res/drawable/home_widget.webp differ diff --git a/app/src/main/res/drawable/ic_access_time_black_24dp.xml b/app/src/main/res/drawable/ic_access_time_black_24dp.xml new file mode 100644 index 0000000..d182045 --- /dev/null +++ b/app/src/main/res/drawable/ic_access_time_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_add_black_24dp.xml b/app/src/main/res/drawable/ic_add_black_24dp.xml new file mode 100644 index 0000000..e50678e --- /dev/null +++ b/app/src/main/res/drawable/ic_add_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_assignment_black_24dp.xml b/app/src/main/res/drawable/ic_assignment_black_24dp.xml new file mode 100644 index 0000000..1681cc0 --- /dev/null +++ b/app/src/main/res/drawable/ic_assignment_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_assignment_next_black_24dp.xml b/app/src/main/res/drawable/ic_assignment_next_black_24dp.xml new file mode 100644 index 0000000..b943bab --- /dev/null +++ b/app/src/main/res/drawable/ic_assignment_next_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_book_black_24dp.xml b/app/src/main/res/drawable/ic_book_black_24dp.xml new file mode 100644 index 0000000..fea8004 --- /dev/null +++ b/app/src/main/res/drawable/ic_book_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_clear_black_24dp.xml b/app/src/main/res/drawable/ic_clear_black_24dp.xml new file mode 100644 index 0000000..bd0b6f6 --- /dev/null +++ b/app/src/main/res/drawable/ic_clear_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_close_black_24dp.xml b/app/src/main/res/drawable/ic_close_black_24dp.xml new file mode 100755 index 0000000..276de88 --- /dev/null +++ b/app/src/main/res/drawable/ic_close_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_delete_forever_black_24dp.xml b/app/src/main/res/drawable/ic_delete_forever_black_24dp.xml new file mode 100644 index 0000000..4cb68d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_delete_forever_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_do_not_disturb_on_black_24dp.xml b/app/src/main/res/drawable/ic_do_not_disturb_on_black_24dp.xml new file mode 100644 index 0000000..80cd999 --- /dev/null +++ b/app/src/main/res/drawable/ic_do_not_disturb_on_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_edit_black_24dp.xml b/app/src/main/res/drawable/ic_edit_black_24dp.xml new file mode 100644 index 0000000..dfb651e --- /dev/null +++ b/app/src/main/res/drawable/ic_edit_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_email_24.xml b/app/src/main/res/drawable/ic_email_black_24dp.xml similarity index 71% rename from app/src/main/res/drawable/baseline_email_24.xml rename to app/src/main/res/drawable/ic_email_black_24dp.xml index ee249cc..6012945 100644 --- a/app/src/main/res/drawable/baseline_email_24.xml +++ b/app/src/main/res/drawable/ic_email_black_24dp.xml @@ -2,9 +2,8 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24.0" - android:viewportHeight="24.0" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24.0"> diff --git a/app/src/main/res/drawable/ic_event_note_black_24dp.xml b/app/src/main/res/drawable/ic_event_note_black_24dp.xml new file mode 100644 index 0000000..4d4c080 --- /dev/null +++ b/app/src/main/res/drawable/ic_event_note_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_expand_more_black_24dp.xml b/app/src/main/res/drawable/ic_expand_more_black_24dp.xml new file mode 100644 index 0000000..9b6ec13 --- /dev/null +++ b/app/src/main/res/drawable/ic_expand_more_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_go.xml b/app/src/main/res/drawable/ic_go.xml new file mode 100644 index 0000000..307e41c --- /dev/null +++ b/app/src/main/res/drawable/ic_go.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_camera.xml b/app/src/main/res/drawable/ic_menu_camera.xml deleted file mode 100644 index 0d9ea10..0000000 --- a/app/src/main/res/drawable/ic_menu_camera.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_menu_gallery.xml b/app/src/main/res/drawable/ic_menu_gallery.xml deleted file mode 100644 index f6872c4..0000000 --- a/app/src/main/res/drawable/ic_menu_gallery.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_menu_manage.xml b/app/src/main/res/drawable/ic_menu_manage.xml deleted file mode 100644 index c1be60b..0000000 --- a/app/src/main/res/drawable/ic_menu_manage.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_send.xml b/app/src/main/res/drawable/ic_menu_send.xml deleted file mode 100644 index 00c668c..0000000 --- a/app/src/main/res/drawable/ic_menu_send.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_menu_share.xml b/app/src/main/res/drawable/ic_menu_share.xml deleted file mode 100644 index a28fb9e..0000000 --- a/app/src/main/res/drawable/ic_menu_share.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_menu_slideshow.xml b/app/src/main/res/drawable/ic_menu_slideshow.xml deleted file mode 100644 index 209aa64..0000000 --- a/app/src/main/res/drawable/ic_menu_slideshow.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_open_in_browser_white_24dp.xml b/app/src/main/res/drawable/ic_open_in_browser_white_24dp.xml new file mode 100644 index 0000000..7df7b75 --- /dev/null +++ b/app/src/main/res/drawable/ic_open_in_browser_white_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_palette_black_24dp.xml b/app/src/main/res/drawable/ic_palette_black_24dp.xml new file mode 100644 index 0000000..71c37dd --- /dev/null +++ b/app/src/main/res/drawable/ic_palette_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/baseline_people_24.xml b/app/src/main/res/drawable/ic_people_black_24dp.xml similarity index 79% rename from app/src/main/res/drawable/baseline_people_24.xml rename to app/src/main/res/drawable/ic_people_black_24dp.xml index 1845bbf..e02ce7c 100644 --- a/app/src/main/res/drawable/baseline_people_24.xml +++ b/app/src/main/res/drawable/ic_people_black_24dp.xml @@ -2,9 +2,8 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24.0" - android:viewportHeight="24.0" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24.0"> diff --git a/app/src/main/res/drawable/ic_person_black_24dp.xml b/app/src/main/res/drawable/ic_person_black_24dp.xml new file mode 100644 index 0000000..894c1fa --- /dev/null +++ b/app/src/main/res/drawable/ic_person_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/baseline_phone_24.xml b/app/src/main/res/drawable/ic_phone_black_24dp.xml similarity index 78% rename from app/src/main/res/drawable/baseline_phone_24.xml rename to app/src/main/res/drawable/ic_phone_black_24dp.xml index 1fbafeb..4081729 100644 --- a/app/src/main/res/drawable/baseline_phone_24.xml +++ b/app/src/main/res/drawable/ic_phone_black_24dp.xml @@ -2,9 +2,8 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24.0" - android:viewportHeight="24.0" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24.0"> diff --git a/app/src/main/res/drawable/ic_restore.xml b/app/src/main/res/drawable/ic_restore.xml new file mode 100644 index 0000000..db82485 --- /dev/null +++ b/app/src/main/res/drawable/ic_restore.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_room_black_24dp.xml b/app/src/main/res/drawable/ic_room_black_24dp.xml new file mode 100644 index 0000000..94dc681 --- /dev/null +++ b/app/src/main/res/drawable/ic_room_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_school_black_24dp.xml b/app/src/main/res/drawable/ic_school_black_24dp.xml new file mode 100644 index 0000000..516ca55 --- /dev/null +++ b/app/src/main/res/drawable/ic_school_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_settings_black_24dp.xml b/app/src/main/res/drawable/ic_settings_black_24dp.xml new file mode 100755 index 0000000..1217a7c --- /dev/null +++ b/app/src/main/res/drawable/ic_settings_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_slideshow_black_24dp.xml b/app/src/main/res/drawable/ic_slideshow_black_24dp.xml new file mode 100644 index 0000000..e5237de --- /dev/null +++ b/app/src/main/res/drawable/ic_slideshow_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_view_week_black_24dp.xml b/app/src/main/res/drawable/ic_view_week_black_24dp.xml new file mode 100644 index 0000000..039b7ef --- /dev/null +++ b/app/src/main/res/drawable/ic_view_week_black_24dp.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/drawable/launch_screen.xml b/app/src/main/res/drawable/launch_screen.xml new file mode 100644 index 0000000..dcc73bf --- /dev/null +++ b/app/src/main/res/drawable/launch_screen.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml old mode 100644 new mode 100755 index 6d81870..5230c2e --- a/app/src/main/res/drawable/side_nav_bar.xml +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -1,9 +1,34 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tab_background.xml b/app/src/main/res/drawable/tab_background.xml deleted file mode 100644 index d5a47b3..0000000 --- a/app/src/main/res/drawable/tab_background.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_appwidget_configure.xml b/app/src/main/res/layout/activity_appwidget_configure.xml new file mode 100644 index 0000000..c71af02 --- /dev/null +++ b/app/src/main/res/layout/activity_appwidget_configure.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +