forked from github/szkolny
Compare commits
518 Commits
feature/gd
...
develop
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cefb0deba8 | ||
![]() |
90a151c129 | ||
![]() |
9fd9721ae7 | ||
![]() |
ceca75ef4b | ||
![]() |
21c00bbe53 | ||
![]() |
db00566ebf | ||
![]() |
07ab1b984f | ||
![]() |
8177d4aa2d | ||
![]() |
beff1b6460 | ||
![]() |
31b569b02e | ||
![]() |
8bf77817d2 | ||
![]() |
27b61adf1d | ||
![]() |
a0244841ad | ||
![]() |
12c0c6f2ec | ||
![]() |
aaa3b8626e | ||
![]() |
48c9e2dfe3 | ||
![]() |
81d4801d27 | ||
![]() |
5f8016061d | ||
![]() |
5007587192 | ||
![]() |
dfd1083e41 | ||
![]() |
678baf46e5 | ||
![]() |
4077fe448d | ||
![]() |
f085e17ef7 | ||
![]() |
7fd2cad46b | ||
![]() |
93dc2ac9ab | ||
![]() |
ac53e267fc | ||
![]() |
86eb1a0f42 | ||
![]() |
710d82da27 | ||
![]() |
0123f50810 | ||
![]() |
6d3eb65445 | ||
![]() |
a9a0630226 | ||
![]() |
ec7577f999 | ||
![]() |
05c7c0012c | ||
![]() |
d65c6db954 | ||
![]() |
771dc437e6 | ||
![]() |
3d5d3847cc | ||
![]() |
18cc60a80b | ||
![]() |
fedde9f739 | ||
![]() |
9fde97bef0 | ||
![]() |
742bd03e9e | ||
![]() |
62ffc652ab | ||
![]() |
bfd2e9883a | ||
![]() |
00e077d01f | ||
![]() |
c21d89cf60 | ||
![]() |
f52cc1b197 | ||
![]() |
c90ad97f55 | ||
![]() |
845e09d875 | ||
![]() |
158b69a8d3 | ||
![]() |
9535f53563 | ||
![]() |
eeb3fc4621 | ||
![]() |
41693a9fc8 | ||
![]() |
d3599b8c89 | ||
![]() |
ffd81f8b82 | ||
![]() |
2c34924052 | ||
![]() |
26ad6373e6 | ||
![]() |
cac8f94407 | ||
![]() |
6628b97faf | ||
![]() |
8424414317 | ||
![]() |
d8bb927703 | ||
![]() |
c8e8c172a2 | ||
![]() |
0d4dee765a | ||
![]() |
fd407b2b03 | ||
![]() |
40ed5a221f | ||
![]() |
5150467372 | ||
![]() |
63c5720f63 | ||
![]() |
6c93cd4217 | ||
![]() |
649d4f619a | ||
![]() |
ba10d10a10 | ||
![]() |
1450d63fcb | ||
![]() |
2ec06bc39a | ||
![]() |
6f12227c2e | ||
![]() |
3a91f87ccd | ||
![]() |
52a53334ca | ||
![]() |
3ab9602865 | ||
![]() |
dc19043f73 | ||
![]() |
cf25507850 | ||
![]() |
044cedff99 | ||
![]() |
4de066bf5f | ||
![]() |
8d174bda01 | ||
![]() |
e2fd714070 | ||
![]() |
8097e8d06d | ||
![]() |
93ccdbdeb7 | ||
![]() |
7ded400a30 | ||
![]() |
2ff784066e | ||
![]() |
6c96875c83 | ||
![]() |
9f3aaf6e86 | ||
![]() |
55369eaa8b | ||
![]() |
c983c16907 | ||
![]() |
c7362bce12 | ||
![]() |
7935d0f097 | ||
![]() |
4b64277948 | ||
![]() |
132729bbd9 | ||
![]() |
6d36ab27d1 | ||
![]() |
11fabb231f | ||
![]() |
6fd999f88c | ||
![]() |
7711413b30 | ||
![]() |
cdc0c9d458 | ||
![]() |
8e5f750a80 | ||
![]() |
f4e7e8978c | ||
![]() |
96c542d6d2 | ||
![]() |
77d22b87aa | ||
![]() |
37c68443bd | ||
![]() |
9dbb5d70e9 | ||
![]() |
99afa77a63 | ||
![]() |
a5d0f4212d | ||
![]() |
a85f935eb4 | ||
![]() |
bb44fa066c | ||
![]() |
54a61c6254 | ||
![]() |
ac10874bf1 | ||
![]() |
fa55b4901a | ||
![]() |
0f90430387 | ||
![]() |
745523c620 | ||
![]() |
8911ce2bc1 | ||
![]() |
2990fc5479 | ||
![]() |
48b7adb564 | ||
![]() |
f8ac9e793a | ||
![]() |
148597e578 | ||
![]() |
6c50a80b42 | ||
![]() |
1bf0679e92 | ||
![]() |
5b5dc5cade | ||
![]() |
98a89b1ca1 | ||
![]() |
6d1e18cce2 | ||
![]() |
8fe0f88be4 | ||
![]() |
aeed735521 | ||
![]() |
e314fafaff | ||
![]() |
2ab0dd7546 | ||
![]() |
aa06868a4e | ||
![]() |
2b104e6463 | ||
![]() |
afb1863827 | ||
![]() |
d8228748e4 | ||
![]() |
b0608c47c4 | ||
![]() |
dda0d88f19 | ||
![]() |
a1b5560977 | ||
![]() |
86f5811bda | ||
![]() |
3f11e75985 | ||
![]() |
c39b5442c9 | ||
![]() |
3b80adf355 | ||
![]() |
cae41d17b6 | ||
![]() |
519d75d9d9 | ||
![]() |
cb953ea8a8 | ||
![]() |
52968cafad | ||
![]() |
b7755dae96 | ||
![]() |
113ecc0ef1 | ||
![]() |
23bd9b8e05 | ||
![]() |
decfd2068a | ||
![]() |
a88cfb8ae3 | ||
![]() |
50cb0acc7d | ||
![]() |
27413a9745 | ||
![]() |
49a093201b | ||
![]() |
7c925cb88a | ||
![]() |
8745d7d526 | ||
![]() |
e02246f97d | ||
![]() |
e629e03b33 | ||
![]() |
e2ad3758e0 | ||
![]() |
f3e2d21b89 | ||
![]() |
fd62653d79 | ||
![]() |
ca3e6f7fc9 | ||
![]() |
d8abac1917 | ||
![]() |
2807659da3 | ||
![]() |
7884bf4077 | ||
![]() |
59f80c049c | ||
![]() |
f1e58db151 | ||
![]() |
74b766f18a | ||
![]() |
7e0f69d95d | ||
![]() |
fa318d4509 | ||
![]() |
63b74a9fda | ||
![]() |
1a543814f4 | ||
![]() |
50ae767fcd | ||
![]() |
44263ac95f | ||
![]() |
a6aca42c8c | ||
![]() |
83daae46b8 | ||
![]() |
6611fc5843 | ||
![]() |
fe82c86c93 | ||
![]() |
692555732d | ||
![]() |
d59286bb05 | ||
![]() |
91cfa7e945 | ||
![]() |
2d277e80cc | ||
![]() |
3cdca5eb33 | ||
![]() |
591abb4bb8 | ||
![]() |
0b4421c7a7 | ||
![]() |
325efd8b14 | ||
![]() |
959168771b | ||
![]() |
18c306b9ea | ||
![]() |
c6be1a7954 | ||
![]() |
e8e9f04050 | ||
![]() |
3700a71c39 | ||
![]() |
60f0628f5e | ||
![]() |
80dcd9aa69 | ||
![]() |
91b685576b | ||
![]() |
2e3e3dcf3c | ||
![]() |
118f5e1794 | ||
![]() |
e902352a4b | ||
![]() |
2f7fcb6dc3 | ||
![]() |
21ddb9d706 | ||
![]() |
efa63452e7 | ||
![]() |
83f84de019 | ||
![]() |
b9aca981e5 | ||
![]() |
5913707519 | ||
![]() |
dd6a2c0979 | ||
![]() |
9fdee6e0c7 | ||
![]() |
b31bf5c1ab | ||
![]() |
cf4906f2f4 | ||
![]() |
680a5dfea3 | ||
![]() |
c1062cd7ed | ||
![]() |
8edc581f0b | ||
![]() |
ea9d801d08 | ||
![]() |
8f72e11d0c | ||
![]() |
452271e8c0 | ||
![]() |
7b4effe889 | ||
![]() |
e2bf48d1b6 | ||
![]() |
c88056ddb9 | ||
![]() |
96dbb0a057 | ||
![]() |
288c80ea26 | ||
![]() |
5a217aca01 | ||
![]() |
4bed62aa6f | ||
![]() |
a4d604e146 | ||
![]() |
ae4405ef78 | ||
![]() |
71ca51e813 | ||
![]() |
1bf07d736f | ||
![]() |
909899612e | ||
![]() |
4184fbb2cd | ||
![]() |
75010c0771 | ||
![]() |
5562498e84 | ||
![]() |
c2d0940a80 | ||
![]() |
baa98f25c5 | ||
![]() |
26645ee83c | ||
![]() |
85d74bec1c | ||
![]() |
fd0fc652a3 | ||
![]() |
c85dac2e4d | ||
![]() |
c855f08f9c | ||
![]() |
a31c68e87a | ||
![]() |
99021f6b3a | ||
![]() |
e2b47db3fd | ||
![]() |
8609956ae7 | ||
![]() |
e25ca930e0 | ||
![]() |
47ec1899a1 | ||
![]() |
1e8fb6a9ae | ||
![]() |
02eb5b7ee4 | ||
![]() |
776806caef | ||
![]() |
755b846b50 | ||
![]() |
73f3ba17de | ||
![]() |
07fb1e0e12 | ||
![]() |
297867cbf3 | ||
![]() |
db598af28a | ||
![]() |
ec765c9070 | ||
![]() |
5eaa754401 | ||
![]() |
b48b5589f4 | ||
![]() |
634ef16bc5 | ||
![]() |
ccf0bdaf05 | ||
![]() |
4647da7803 | ||
![]() |
613f271c4e | ||
![]() |
8b1529f240 | ||
![]() |
3eb09033bf | ||
![]() |
12619f6bde | ||
![]() |
f5ceaa9afe | ||
![]() |
777ae945e0 | ||
![]() |
3eae8fb58b | ||
![]() |
b14ef5cd78 | ||
![]() |
98bf4f3bdc | ||
![]() |
2d6cf50ca7 | ||
![]() |
95baf9fb9c | ||
![]() |
dd0972b528 | ||
![]() |
d17f6297d3 | ||
![]() |
3ae785a45c | ||
![]() |
dd254d4bec | ||
![]() |
e04bd75f1f | ||
![]() |
929ccb53db | ||
![]() |
72319a4613 | ||
![]() |
e389e6c073 | ||
![]() |
cd6951dcbb | ||
![]() |
02d60754b6 | ||
![]() |
6884251646 | ||
![]() |
582e2059d8 | ||
![]() |
ea2974bfae | ||
![]() |
b8ff649c96 | ||
![]() |
8661ecdafb | ||
![]() |
fe8cbc061d | ||
![]() |
b4459e1fd4 | ||
![]() |
fd6553871f | ||
![]() |
a4ca44e1ce | ||
![]() |
e124c429d1 | ||
![]() |
e9a2dae1e4 | ||
![]() |
8b0f3490e3 | ||
![]() |
131606a6cf | ||
![]() |
cacafa205e | ||
![]() |
9c620de1e7 | ||
![]() |
3e98fb967b | ||
![]() |
8db81478f3 | ||
![]() |
8f9861bac6 | ||
![]() |
5b35e3500e | ||
![]() |
fc4c297bef | ||
![]() |
e7cb699bcf | ||
![]() |
5301b4efad | ||
![]() |
bf595dd09c | ||
![]() |
cb4b168b2a | ||
![]() |
b2fcbb8289 | ||
![]() |
df7982d11b | ||
![]() |
7ed9bac0db | ||
![]() |
e6c42ccb87 | ||
![]() |
73378571a2 | ||
![]() |
1cb18b554b | ||
![]() |
b9e7e80e11 | ||
![]() |
114d855c81 | ||
![]() |
1108f2eb71 | ||
![]() |
2a3b1422ef | ||
![]() |
5690a136f1 | ||
![]() |
4bea803220 | ||
![]() |
5ac1f94302 | ||
![]() |
62fdfe754e | ||
![]() |
9ba1bf130f | ||
![]() |
37c0ff2ac7 | ||
![]() |
6287f694f4 | ||
![]() |
4469323fe0 | ||
![]() |
ebbb9e4904 | ||
![]() |
7e38445c98 | ||
![]() |
bf03601e83 | ||
![]() |
e6dec4c6c0 | ||
![]() |
891be2f9dd | ||
![]() |
1f6da2babe | ||
![]() |
cce47ed472 | ||
![]() |
2808c66840 | ||
![]() |
17351066d1 | ||
![]() |
b5d5685b4c | ||
![]() |
3093850a4a | ||
![]() |
93233f6afa | ||
![]() |
76838fcc41 | ||
![]() |
34e44a7a36 | ||
![]() |
5242d15ebd | ||
![]() |
fe90fc6442 | ||
![]() |
dc08abac53 | ||
![]() |
f72f8228f0 | ||
![]() |
5c87ae2711 | ||
![]() |
abcd6916b3 | ||
![]() |
6824960731 | ||
![]() |
726a37d5d6 | ||
![]() |
704a55d789 | ||
![]() |
bf5fb5f623 | ||
![]() |
1af65de548 | ||
![]() |
06407ee439 | ||
![]() |
db265fa12b | ||
![]() |
e721261e84 | ||
![]() |
c5eb67271e | ||
![]() |
a5f5c740c9 | ||
![]() |
1b271bd20e | ||
![]() |
d191982da6 | ||
![]() |
6e9a0b217d | ||
![]() |
df4b6ec3e5 | ||
![]() |
d9b91d6de8 | ||
![]() |
dd6e536f88 | ||
![]() |
a5cbee2b45 | ||
![]() |
7a43ef4dee | ||
![]() |
549a542879 | ||
![]() |
0f84732f80 | ||
![]() |
4045da7fc5 | ||
![]() |
ae6af77aef | ||
![]() |
fdad2d9e1a | ||
![]() |
2d01a8c4d4 | ||
![]() |
6c4a1b54ba | ||
![]() |
37879ca07e | ||
![]() |
2834ab1050 | ||
![]() |
9ef37c46ef | ||
![]() |
1364691a46 | ||
![]() |
2933e214c6 | ||
![]() |
a58a557fd0 | ||
![]() |
43d71c082b | ||
![]() |
3eb99a4bf5 | ||
![]() |
ea7b4438e8 | ||
![]() |
208d097986 | ||
![]() |
07561c6484 | ||
![]() |
930ad12f5b | ||
![]() |
b4595446a3 | ||
![]() |
efcd2d80da | ||
![]() |
da953c9b1c | ||
![]() |
177ffd92f7 | ||
![]() |
85379b0beb | ||
![]() |
cf4aa552e7 | ||
![]() |
b6d625a1fc | ||
![]() |
78333e0077 | ||
![]() |
ea3598bb6d | ||
![]() |
e91d99652c | ||
![]() |
d78dad5090 | ||
![]() |
0615593d94 | ||
![]() |
15f9db5ca6 | ||
![]() |
75b3485ab4 | ||
![]() |
50e7bf14d4 | ||
![]() |
147f4c39e5 | ||
![]() |
9e95d05182 | ||
![]() |
9ccb6e0a24 | ||
![]() |
92d7a46314 | ||
![]() |
7aaefa977b | ||
![]() |
530034d7da | ||
![]() |
44647946e0 | ||
![]() |
efd63797e4 | ||
![]() |
74820fe67d | ||
![]() |
e825af0ff0 | ||
![]() |
256f6c8732 | ||
![]() |
22abad35cc | ||
![]() |
6a33088352 | ||
![]() |
01c41645ab | ||
![]() |
54f74d2a3c | ||
![]() |
e0688fe79b | ||
![]() |
36c7bb1127 | ||
![]() |
045205754e | ||
![]() |
e34e4d6906 | ||
![]() |
481af64137 | ||
![]() |
2b3a7f6b41 | ||
![]() |
e3fe03c5fc | ||
![]() |
9740e0b7bf | ||
![]() |
58a26cc0c6 | ||
![]() |
d201c0c448 | ||
![]() |
359432d24d | ||
![]() |
edf8ec20f0 | ||
![]() |
3ad9e5da1f | ||
![]() |
459bbf78b2 | ||
![]() |
d0baf02750 | ||
![]() |
a5bb7d9c6e | ||
![]() |
a939d95ea3 | ||
![]() |
4c081c970e | ||
![]() |
b75ab76c2a | ||
![]() |
9da6dbccb3 | ||
![]() |
66444ae35b | ||
![]() |
3e8b3de2b7 | ||
![]() |
85ac5769a1 | ||
![]() |
93e3d5994a | ||
![]() |
0cf24c527b | ||
![]() |
97c5acd6ba | ||
![]() |
30aeb70647 | ||
![]() |
b599d679c4 | ||
![]() |
1eecd24d91 | ||
![]() |
c698dfdb73 | ||
![]() |
c7a44f5ced | ||
![]() |
c8ee6ff1e7 | ||
![]() |
552acd4043 | ||
![]() |
ede101ea20 | ||
![]() |
13c2640ed5 | ||
![]() |
dd0739fd4b | ||
![]() |
9023f13932 | ||
![]() |
f8456fb087 | ||
![]() |
9b48041cd9 | ||
![]() |
46cecf3474 | ||
![]() |
c27254bcad | ||
![]() |
80333cdea4 | ||
![]() |
6aee3ea420 | ||
![]() |
a11a44b768 | ||
![]() |
e869107101 | ||
![]() |
5903bbe59d | ||
![]() |
6c0ddd3e6d | ||
![]() |
621a7ac642 | ||
![]() |
e86b47fb1b | ||
![]() |
98fb7ac8c9 | ||
![]() |
f49e39e858 | ||
![]() |
8fc57cd3f5 | ||
![]() |
a9eda087e0 | ||
![]() |
3f36a284ee | ||
![]() |
1814fd67e1 | ||
![]() |
54e49af943 | ||
![]() |
d6a67a0da6 | ||
![]() |
28725c6400 | ||
![]() |
4fc965d970 | ||
![]() |
2aaf713d58 | ||
![]() |
c7d2ac4e3e | ||
![]() |
ae20c30c88 | ||
![]() |
aef3f66654 | ||
![]() |
c7abde8f11 | ||
![]() |
2fcff33bd6 | ||
![]() |
b08e4c2d3d | ||
![]() |
73ff09052c | ||
![]() |
9649afd43f | ||
![]() |
ed3a245b51 | ||
![]() |
477730708f | ||
![]() |
f39d0c595d | ||
![]() |
46407f9647 | ||
![]() |
6ecb97b87e | ||
![]() |
ecdaaeae65 | ||
![]() |
a0c302b663 | ||
![]() |
b31039ecd9 | ||
![]() |
5c84086f42 | ||
![]() |
752cdfa8d6 | ||
![]() |
8e3d404352 | ||
![]() |
810cfd8092 | ||
![]() |
bd2a9524c6 | ||
![]() |
d780d5118d | ||
![]() |
f1570b8eb9 | ||
![]() |
de0f29a09e | ||
![]() |
c0d11c91e3 | ||
![]() |
22c540a3d4 | ||
![]() |
b7e35d0322 | ||
![]() |
7bcd6bf038 | ||
![]() |
ea4591144b | ||
![]() |
7627d184a2 | ||
![]() |
076b485fda | ||
![]() |
09cb97e367 | ||
![]() |
4e1f2ed41a | ||
![]() |
281b6a95ef | ||
![]() |
e40871c0d0 | ||
![]() |
b74eeed994 | ||
![]() |
ccde482364 | ||
![]() |
a02033d0f3 | ||
![]() |
6c6bc89f57 | ||
![]() |
1e3da45340 | ||
![]() |
0d366adddb | ||
![]() |
2c24eba46d | ||
![]() |
7c6dbca986 | ||
![]() |
33a8fa2a1e | ||
![]() |
300e2c4bc2 | ||
![]() |
f883318bd2 | ||
![]() |
5460c1e2a0 | ||
![]() |
137c975e81 | ||
![]() |
001de4a88c | ||
![]() |
5dcb3fd580 | ||
![]() |
f13995aa5c | ||
![]() |
e23deb5ca6 | ||
![]() |
d688b379a2 | ||
![]() |
d6a796e25e | ||
![]() |
e02d3e571d | ||
![]() |
907b75b22d | ||
![]() |
c3660b5f80 | ||
![]() |
7ff10df70c |
BIN
.github/apk-badge.png
vendored
Normal file
BIN
.github/apk-badge.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
.github/google-play-badge.png
vendored
Normal file
BIN
.github/google-play-badge.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
.github/readme-banner.png
vendored
Normal file
BIN
.github/readme-banner.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
2
.github/utils/.gitignore
vendored
Normal file
2
.github/utils/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.env
|
||||
__pycache__/
|
57
.github/utils/_get_password.py
vendored
Normal file
57
.github/utils/_get_password.py
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
import base64
|
||||
import secrets
|
||||
from hashlib import sha256
|
||||
from typing import Tuple
|
||||
|
||||
import mysql.connector as mysql
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
|
||||
def get_password(
|
||||
version_name: str,
|
||||
version_code: int,
|
||||
db_host: str,
|
||||
db_user: str,
|
||||
db_pass: str,
|
||||
db_name: str,
|
||||
) -> Tuple[str, bytes]:
|
||||
db = mysql.connect(
|
||||
host=db_host,
|
||||
user=db_user,
|
||||
password=db_pass,
|
||||
database=db_name,
|
||||
auth_plugin="mysql_native_password",
|
||||
)
|
||||
|
||||
print(f"Generating passwords for version {version_name} ({version_code})")
|
||||
|
||||
password = base64.b64encode(secrets.token_bytes(16)).decode()
|
||||
iv = secrets.token_bytes(16)
|
||||
|
||||
key = f"{version_name}.{password}.{version_code}"
|
||||
key = sha256(key.encode()).digest()
|
||||
data = "ThisIsOurHardWorkPleaseDoNotCopyOrSteal(c)2019.KubaSz"
|
||||
data = sha256(data.encode()).digest()
|
||||
data = data + (chr(16) * 16).encode()
|
||||
|
||||
aes = AES.new(key=key, mode=AES.MODE_CBC, iv=iv)
|
||||
|
||||
app_password = base64.b64encode(aes.encrypt(data)).decode()
|
||||
|
||||
c = db.cursor()
|
||||
c.execute(
|
||||
"INSERT IGNORE INTO _appPasswords (versionCode, appPassword, password, iv) VALUES (%s, %s, %s, %s);",
|
||||
(version_code, app_password, password, iv),
|
||||
)
|
||||
db.commit()
|
||||
|
||||
c = db.cursor()
|
||||
c.execute(
|
||||
"SELECT password, iv FROM _appPasswords WHERE versionCode = %s;",
|
||||
(version_code,),
|
||||
)
|
||||
row = c.fetchone()
|
||||
|
||||
db.close()
|
||||
|
||||
return (row[0], row[1])
|
142
.github/utils/_utils.py
vendored
Normal file
142
.github/utils/_utils.py
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Tuple
|
||||
|
||||
VERSION_NAME_REGEX = r'versionName: "(.+?)"'
|
||||
VERSION_CODE_REGEX = r"versionCode: ([0-9]+)"
|
||||
VERSION_NAME_FORMAT = 'versionName: "{}"'
|
||||
VERSION_CODE_FORMAT = "versionCode: {}"
|
||||
|
||||
|
||||
def get_project_dir() -> str:
|
||||
project_dir = sys.argv[1]
|
||||
if project_dir[-1:] == "/" or project_dir[-1:] == "\\":
|
||||
project_dir = project_dir[:-1]
|
||||
return project_dir
|
||||
|
||||
|
||||
def read_gradle_version(project_dir: str) -> Tuple[int, str]:
|
||||
GRADLE_PATH = f"{project_dir}/build.gradle"
|
||||
|
||||
with open(GRADLE_PATH, "r") as f:
|
||||
gradle = f.read()
|
||||
|
||||
version_name = re.search(VERSION_NAME_REGEX, gradle).group(1)
|
||||
version_code = int(re.search(VERSION_CODE_REGEX, gradle).group(1))
|
||||
|
||||
return (version_code, version_name)
|
||||
|
||||
|
||||
def write_gradle_version(project_dir: str, version_code: int, version_name: str):
|
||||
GRADLE_PATH = f"{project_dir}/build.gradle"
|
||||
|
||||
with open(GRADLE_PATH, "r") as f:
|
||||
gradle = f.read()
|
||||
|
||||
gradle = re.sub(
|
||||
VERSION_NAME_REGEX, VERSION_NAME_FORMAT.format(version_name), gradle
|
||||
)
|
||||
gradle = re.sub(
|
||||
VERSION_CODE_REGEX, VERSION_CODE_FORMAT.format(version_code), gradle
|
||||
)
|
||||
|
||||
with open(GRADLE_PATH, "w") as f:
|
||||
f.write(gradle)
|
||||
|
||||
|
||||
def build_version_code(version_name: str) -> int:
|
||||
version = version_name.split("+")[0].split("-")
|
||||
version_base = version[0]
|
||||
version_suffix = version[1] if len(version) == 2 else ""
|
||||
|
||||
base_parts = version_base.split(".")
|
||||
major = int(base_parts[0]) or 0
|
||||
minor = int(base_parts[1]) if len(base_parts) > 1 else 0
|
||||
patch = int(base_parts[2]) if len(base_parts) > 2 else 0
|
||||
|
||||
beta = 9
|
||||
rc = 9
|
||||
if "dev" in version_suffix:
|
||||
beta = 0
|
||||
rc = 0
|
||||
elif "beta." in version_suffix:
|
||||
beta = int(version_suffix.split(".")[1])
|
||||
rc = 0
|
||||
elif "rc." in version_suffix:
|
||||
beta = 0
|
||||
rc = int(version_suffix.split(".")[1])
|
||||
|
||||
version_code = beta + rc * 10 + patch * 100 + minor * 10000 + major * 1000000
|
||||
return version_code
|
||||
|
||||
|
||||
def get_changelog(project_dir: str, format: str) -> Tuple[str, str]:
|
||||
with open(
|
||||
f"{project_dir}/app/src/main/assets/pl-changelog.html", "r", encoding="utf-8"
|
||||
) as f:
|
||||
changelog = f.read()
|
||||
|
||||
title = re.search(r"<h3>(.+?)</h3>", changelog).group(1)
|
||||
content = re.search(r"(?s)<ul>(.+)</ul>", changelog).group(1).strip()
|
||||
content = "\n".join(line.strip() for line in content.split("\n"))
|
||||
|
||||
if format != "html":
|
||||
content = content.replace("<li>", "- ")
|
||||
content = content.replace("<br>", "\n")
|
||||
if format == "markdown":
|
||||
content = re.sub(r"<u>(.+?)</u>", "__\\1__", content)
|
||||
content = re.sub(r"<i>(.+?)</i>", "*\\1*", content)
|
||||
content = re.sub(r"<b>(.+?)</b>", "**\\1**", content)
|
||||
content = re.sub(r"</?.+?>", "", content)
|
||||
|
||||
return (title, content)
|
||||
|
||||
|
||||
def get_commit_log(project_dir: str, format: str, max_lines: int = None) -> str:
|
||||
last_tag = (
|
||||
subprocess.check_output("git describe --tags --abbrev=0".split(" "))
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
|
||||
log = subprocess.run(
|
||||
args=f"git log {last_tag}..HEAD --format=%an%x00%at%x00%h%x00%s%x00%D".split(" "),
|
||||
cwd=project_dir,
|
||||
stdout=subprocess.PIPE,
|
||||
)
|
||||
log = log.stdout.strip().decode()
|
||||
|
||||
commits = [line.split("\x00") for line in log.split("\n")]
|
||||
if max_lines:
|
||||
commits = commits[:max_lines]
|
||||
|
||||
output = []
|
||||
valid = False
|
||||
|
||||
for commit in commits:
|
||||
if not commit[0]:
|
||||
continue
|
||||
if "origin/" in commit[4]:
|
||||
valid = True
|
||||
if not valid:
|
||||
continue
|
||||
date = datetime.fromtimestamp(float(commit[1]))
|
||||
date = date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
if format == "html":
|
||||
output.append(f"<li>{commit[3]} <i> - {commit[0]}</i></li>")
|
||||
elif format == "markdown":
|
||||
output.append(f"[{date}] {commit[0]}\n {commit[3]}")
|
||||
elif format == "markdown_full":
|
||||
output.append(
|
||||
f"_[{date}] {commit[0]}_\n` `__`{commit[2]}`__ **{commit[3]}**"
|
||||
)
|
||||
elif format == "plain":
|
||||
output.append(f"- {commit[3]}")
|
||||
|
||||
if format == "markdown":
|
||||
output.insert(0, "```")
|
||||
output.append("```")
|
||||
|
||||
return "\n".join(output)
|
69
.github/utils/bump_nightly.py
vendored
Normal file
69
.github/utils/bump_nightly.py
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import requests
|
||||
|
||||
from _utils import (
|
||||
get_commit_log,
|
||||
get_project_dir,
|
||||
read_gradle_version,
|
||||
write_gradle_version,
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: bump_nightly.py <project dir>")
|
||||
exit(-1)
|
||||
|
||||
repo = os.getenv("GITHUB_REPOSITORY")
|
||||
sha = os.getenv("GITHUB_SHA")
|
||||
|
||||
if not repo or not sha:
|
||||
print("Missing GitHub environment variables.")
|
||||
exit(-1)
|
||||
|
||||
with requests.get(
|
||||
f"https://api.github.com/repos/{repo}/actions/runs?per_page=5&status=success"
|
||||
) as r:
|
||||
data = json.loads(r.text)
|
||||
runs = [run for run in data["workflow_runs"] if run["head_sha"] == sha]
|
||||
if runs:
|
||||
print("::set-output name=hasNewChanges::false")
|
||||
exit(0)
|
||||
|
||||
print("::set-output name=hasNewChanges::true")
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
(version_code, version_name) = read_gradle_version(project_dir)
|
||||
version_name = version_name.split("+")[0]
|
||||
|
||||
date = datetime.now()
|
||||
if date.hour > 6:
|
||||
version_name += "+daily." + date.strftime("%Y%m%d-%H%M")
|
||||
else:
|
||||
date -= timedelta(days=1)
|
||||
version_name += "+nightly." + date.strftime("%Y%m%d")
|
||||
|
||||
print("::set-output name=appVersionName::" + version_name)
|
||||
print("::set-output name=appVersionCode::" + str(version_code))
|
||||
|
||||
write_gradle_version(project_dir, version_code, version_name)
|
||||
|
||||
commit_log = get_commit_log(project_dir, format="html", max_lines=10)
|
||||
|
||||
with open(
|
||||
f"{project_dir}/app/src/main/assets/pl-changelog.html", "r", encoding="utf-8"
|
||||
) as f:
|
||||
changelog = f.read()
|
||||
|
||||
changelog = re.sub(r"<h3>(.+?)</h3>", f"<h3>{version_name}</h3>", changelog)
|
||||
changelog = re.sub(r"(?s)<ul>(.+)</ul>", f"<ul>\n{commit_log}\n</ul>", changelog)
|
||||
|
||||
with open(
|
||||
f"{project_dir}/app/src/main/assets/pl-changelog.html", "w", encoding="utf-8"
|
||||
) as f:
|
||||
f.write(changelog)
|
41
.github/utils/bump_version.py
vendored
Normal file
41
.github/utils/bump_version.py
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from _get_password import get_password
|
||||
from _utils import build_version_code, write_gradle_version
|
||||
from sign import sign
|
||||
|
||||
if __name__ == "__main__":
|
||||
version_name = input("Enter version name: ")
|
||||
version_code = build_version_code(version_name)
|
||||
|
||||
print(f"Bumping version to {version_name} ({version_code})")
|
||||
|
||||
project_dir = "../.."
|
||||
|
||||
load_dotenv()
|
||||
DB_HOST = os.getenv("DB_HOST")
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
DB_PASS = os.getenv("DB_PASS")
|
||||
DB_NAME = os.getenv("DB_NAME")
|
||||
|
||||
write_gradle_version(project_dir, version_code, version_name)
|
||||
(password, iv) = get_password(
|
||||
version_name, version_code, DB_HOST, DB_USER, DB_PASS, DB_NAME
|
||||
)
|
||||
|
||||
sign(project_dir, version_name, version_code, password, iv, commit=False)
|
||||
|
||||
print("Writing mock passwords")
|
||||
os.chdir(project_dir)
|
||||
os.system(
|
||||
"sed -i -E 's/\/\*([0-9a-f]{2} ?){16}\*\//\/*secret password - removed for source code publication*\//g' app/src/main/cpp/szkolny-signing.cpp"
|
||||
)
|
||||
os.system(
|
||||
"sed -i -E 's/\\t0x.., 0x(.)., 0x.(.), 0x.(.), 0x.., 0x.., 0x.., 0x.(.), 0x.., 0x.(.), 0x(.)., 0x(.)., 0x.., 0x.., 0x.., 0x.(.)/\\t0x\\3\\6, 0x\\7\\4, 0x\\1\\8, 0x\\2\\5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff /g' app/src/main/cpp/szkolny-signing.cpp"
|
||||
)
|
||||
os.system(
|
||||
"sed -i -E 's/param1\..(.).(.).(.).(.)..(.)..(.)..(.)..(.).../param1.MTIzNDU2Nzg5MD\\5\\2\\7\\6\\1\\3\\4\8==/g' app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt"
|
||||
)
|
||||
input("Press any key to finish")
|
72
.github/utils/extract_changelogs.py
vendored
Normal file
72
.github/utils/extract_changelogs.py
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from _utils import get_changelog, get_commit_log, get_project_dir, read_gradle_version
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: extract_changelogs.py <project dir>")
|
||||
exit(-1)
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
(version_code, version_name) = read_gradle_version(project_dir)
|
||||
|
||||
print("::set-output name=appVersionName::" + version_name)
|
||||
print("::set-output name=appVersionCode::" + str(version_code))
|
||||
|
||||
dir = f"{project_dir}/app/release/whatsnew-{version_name}/"
|
||||
os.makedirs(dir, exist_ok=True)
|
||||
|
||||
print("::set-output name=changelogDir::" + dir)
|
||||
|
||||
(title, changelog) = get_changelog(project_dir, format="plain")
|
||||
|
||||
# plain text changelog - Firebase App Distribution
|
||||
with open(dir + "whatsnew_titled.txt", "w", encoding="utf-8") as f:
|
||||
f.write(title)
|
||||
f.write("\n")
|
||||
f.write(changelog)
|
||||
print("::set-output name=changelogPlainTitledFile::" + dir + "whatsnew_titled.txt")
|
||||
|
||||
print("::set-output name=changelogTitle::" + title)
|
||||
|
||||
# plain text changelog, max 500 chars - Google Play
|
||||
with open(dir + "whatsnew-pl-PL", "w", encoding="utf-8") as f:
|
||||
changelog_lines = changelog.split("\n")
|
||||
changelog = ""
|
||||
for line in changelog_lines:
|
||||
if len(changelog) + len(line) < 500:
|
||||
changelog += "\n" + line
|
||||
changelog = changelog.strip()
|
||||
f.write(changelog)
|
||||
|
||||
print("::set-output name=changelogPlainFile::" + dir + "whatsnew-pl-PL")
|
||||
|
||||
# markdown changelog - Discord webhook
|
||||
(_, changelog) = get_changelog(project_dir, format="markdown")
|
||||
with open(dir + "whatsnew.md", "w", encoding="utf-8") as f:
|
||||
f.write(changelog)
|
||||
print("::set-output name=changelogMarkdownFile::" + dir + "whatsnew.md")
|
||||
|
||||
# html changelog - version info in DB
|
||||
(_, changelog) = get_changelog(project_dir, format="html")
|
||||
with open(dir + "whatsnew.html", "w", encoding="utf-8") as f:
|
||||
f.write(changelog)
|
||||
print("::set-output name=changelogHtmlFile::" + dir + "whatsnew.html")
|
||||
|
||||
|
||||
changelog = get_commit_log(project_dir, format="plain", max_lines=10)
|
||||
with open(dir + "commit_log.txt", "w", encoding="utf-8") as f:
|
||||
f.write(changelog)
|
||||
print("::set-output name=commitLogPlainFile::" + dir + "commit_log.txt")
|
||||
|
||||
changelog = get_commit_log(project_dir, format="markdown", max_lines=10)
|
||||
with open(dir + "commit_log.md", "w", encoding="utf-8") as f:
|
||||
f.write(changelog)
|
||||
print("::set-output name=commitLogMarkdownFile::" + dir + "commit_log.md")
|
||||
|
||||
changelog = get_commit_log(project_dir, format="html", max_lines=10)
|
||||
with open(dir + "commit_log.html", "w", encoding="utf-8") as f:
|
||||
f.write(changelog)
|
||||
print("::set-output name=commitLogHtmlFile::" + dir + "commit_log.html")
|
26
.github/utils/rename_artifacts.py
vendored
Normal file
26
.github/utils/rename_artifacts.py
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
from _utils import get_project_dir
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: rename_artifacts.py <project dir>")
|
||||
exit(-1)
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
files = glob.glob(f"{project_dir}/app/release/*.*")
|
||||
for file in files:
|
||||
file_relative = file.replace(os.getenv("GITHUB_WORKSPACE") + "/", "")
|
||||
if "-aligned.apk" in file:
|
||||
os.unlink(file)
|
||||
elif "-signed.apk" in file:
|
||||
new_file = file.replace("-signed.apk", ".apk")
|
||||
if os.path.isfile(new_file):
|
||||
os.unlink(new_file)
|
||||
os.rename(file, new_file)
|
||||
elif ".apk" in file or ".aab" in file:
|
||||
print("::set-output name=signedReleaseFile::" + file)
|
||||
print("::set-output name=signedReleaseFileRelative::" + file_relative)
|
122
.github/utils/save_version.py
vendored
Normal file
122
.github/utils/save_version.py
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from time import time
|
||||
|
||||
import mysql.connector as mysql
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from _utils import get_changelog, get_commit_log, get_project_dir, read_gradle_version
|
||||
|
||||
|
||||
def save_version(
|
||||
project_dir: str,
|
||||
db_host: str,
|
||||
db_user: str,
|
||||
db_pass: str,
|
||||
db_name: str,
|
||||
apk_server_release: str,
|
||||
apk_server_nightly: str,
|
||||
):
|
||||
db = mysql.connect(
|
||||
host=db_host,
|
||||
user=db_user,
|
||||
password=db_pass,
|
||||
database=db_name,
|
||||
auth_plugin="mysql_native_password",
|
||||
)
|
||||
|
||||
(version_code, version_name) = read_gradle_version(project_dir)
|
||||
(_, changelog) = get_changelog(project_dir, format="html")
|
||||
|
||||
types = ["dev", "beta", "nightly", "daily", "rc", "release"]
|
||||
build_type = [x for x in types if x in version_name]
|
||||
build_type = build_type[0] if build_type else "release"
|
||||
|
||||
if "+nightly." in version_name or "+daily." in version_name:
|
||||
changelog = get_commit_log(project_dir, format="html")
|
||||
build_type = "nightly"
|
||||
elif "-dev" in version_name:
|
||||
build_type = "dev"
|
||||
elif "-beta." in version_name:
|
||||
build_type = "beta"
|
||||
elif "-rc." in version_name:
|
||||
build_type = "rc"
|
||||
|
||||
build_date = int(time())
|
||||
apk_name = None
|
||||
bundle_name_play = None
|
||||
|
||||
files = glob.glob(f"{project_dir}/app/release/*.*")
|
||||
output_apk = f"Edziennik_{version_name}_official.apk"
|
||||
output_aab_play = f"Edziennik_{version_name}_play.aab"
|
||||
for file in files:
|
||||
if output_apk in file:
|
||||
build_date = int(os.stat(file).st_mtime)
|
||||
apk_name = output_apk
|
||||
if output_aab_play in file:
|
||||
build_date = int(os.stat(file).st_mtime)
|
||||
bundle_name_play = output_aab_play
|
||||
|
||||
build_date = datetime.fromtimestamp(build_date).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
if build_type in ["nightly", "daily"]:
|
||||
download_url = apk_server_nightly + apk_name if apk_name else None
|
||||
else:
|
||||
download_url = apk_server_release + apk_name if apk_name else None
|
||||
|
||||
cols = [
|
||||
"versionCode",
|
||||
"versionName",
|
||||
"releaseDate",
|
||||
"releaseNotes",
|
||||
"releaseType",
|
||||
"downloadUrl",
|
||||
"apkName",
|
||||
"bundleNamePlay",
|
||||
]
|
||||
updated = {
|
||||
"versionCode": version_code,
|
||||
"downloadUrl": download_url,
|
||||
"apkName": apk_name,
|
||||
"bundleNamePlay": bundle_name_play,
|
||||
}
|
||||
|
||||
values = [
|
||||
version_code,
|
||||
version_name,
|
||||
build_date,
|
||||
changelog,
|
||||
build_type,
|
||||
download_url,
|
||||
apk_name,
|
||||
bundle_name_play,
|
||||
]
|
||||
values.extend(val for val in updated.values() if val)
|
||||
|
||||
updated = ", ".join(f"{col} = %s" for (col, val) in updated.items() if val)
|
||||
|
||||
sql = f"INSERT INTO updates ({', '.join(cols)}) VALUES ({'%s, ' * (len(cols) - 1)}%s) ON DUPLICATE KEY UPDATE {updated};"
|
||||
|
||||
c = db.cursor()
|
||||
c.execute(sql, tuple(values))
|
||||
db.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: save_version.py <project dir>")
|
||||
exit(-1)
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
load_dotenv()
|
||||
DB_HOST = os.getenv("DB_HOST")
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
DB_PASS = os.getenv("DB_PASS")
|
||||
DB_NAME = os.getenv("DB_NAME")
|
||||
APK_SERVER_RELEASE = os.getenv("APK_SERVER_RELEASE")
|
||||
APK_SERVER_NIGHTLY = os.getenv("APK_SERVER_NIGHTLY")
|
||||
|
||||
save_version(project_dir, DB_HOST, DB_USER, DB_PASS, DB_NAME, APK_SERVER_RELEASE, APK_SERVER_NIGHTLY)
|
84
.github/utils/sign.py
vendored
Normal file
84
.github/utils/sign.py
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from _get_password import get_password
|
||||
from _utils import get_project_dir, read_gradle_version
|
||||
|
||||
|
||||
def sign(
|
||||
project_dir: str,
|
||||
version_name: str,
|
||||
version_code: int,
|
||||
password: str,
|
||||
iv: bytes,
|
||||
commit: bool = False,
|
||||
):
|
||||
SIGNING_PATH = f"{project_dir}/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt"
|
||||
CPP_PATH = f"{project_dir}/app/src/main/cpp/szkolny-signing.cpp"
|
||||
|
||||
with open(SIGNING_PATH, "r") as f:
|
||||
signing = f.read()
|
||||
|
||||
with open(CPP_PATH, "r") as f:
|
||||
cpp = f.read()
|
||||
|
||||
SIGNING_REGEX = r"\$param1\..*\.\$param2"
|
||||
CPP_REGEX = r"(?s)/\*.+?toys AES_IV\[16\] = {.+?};"
|
||||
|
||||
SIGNING_FORMAT = "$param1.{}.$param2"
|
||||
CPP_FORMAT = "/*{}*/\nstatic toys AES_IV[16] = {{\n\t{} }};"
|
||||
|
||||
print(f"Writing passwords for version {version_name} ({version_code})")
|
||||
|
||||
iv_hex = " ".join(["{:02x}".format(x) for x in iv])
|
||||
iv_cpp = ", ".join(["0x{:02x}".format(x) for x in iv])
|
||||
|
||||
signing = re.sub(SIGNING_REGEX, SIGNING_FORMAT.format(password), signing)
|
||||
cpp = re.sub(CPP_REGEX, CPP_FORMAT.format(iv_hex, iv_cpp), cpp)
|
||||
|
||||
with open(SIGNING_PATH, "w") as f:
|
||||
f.write(signing)
|
||||
|
||||
with open(CPP_PATH, "w") as f:
|
||||
f.write(cpp)
|
||||
|
||||
if commit:
|
||||
os.chdir(project_dir)
|
||||
os.system("git add .")
|
||||
os.system(
|
||||
f'git commit -m "[{version_name}] Update build.gradle, signing and changelog."'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: sign.py <project dir> [commit]")
|
||||
exit(-1)
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
load_dotenv()
|
||||
DB_HOST = os.getenv("DB_HOST")
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
DB_PASS = os.getenv("DB_PASS")
|
||||
DB_NAME = os.getenv("DB_NAME")
|
||||
|
||||
(version_code, version_name) = read_gradle_version(project_dir)
|
||||
(password, iv) = get_password(
|
||||
version_name, version_code, DB_HOST, DB_USER, DB_PASS, DB_NAME
|
||||
)
|
||||
|
||||
print("::set-output name=appVersionName::" + version_name)
|
||||
print("::set-output name=appVersionCode::" + str(version_code))
|
||||
|
||||
sign(
|
||||
project_dir,
|
||||
version_name,
|
||||
version_code,
|
||||
password,
|
||||
iv,
|
||||
commit="commit" in sys.argv,
|
||||
)
|
118
.github/utils/webhook_discord.py
vendored
Normal file
118
.github/utils/webhook_discord.py
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from _utils import get_changelog, get_commit_log, get_project_dir, read_gradle_version
|
||||
|
||||
|
||||
def post_webhook(
|
||||
project_dir: str,
|
||||
apk_file: str,
|
||||
apk_server_release: str,
|
||||
apk_server_nightly: str,
|
||||
webhook_release: str,
|
||||
webhook_testing: str,
|
||||
):
|
||||
(_, version_name) = read_gradle_version(project_dir)
|
||||
|
||||
types = ["dev", "beta", "nightly", "daily", "rc", "release"]
|
||||
build_type = [x for x in types if x in version_name]
|
||||
build_type = build_type[0] if build_type else None
|
||||
|
||||
testing = ["dev", "beta", "nightly", "daily"]
|
||||
testing = build_type in testing
|
||||
|
||||
apk_name = os.path.basename(apk_file)
|
||||
if build_type in ["nightly", "daily"]:
|
||||
download_url = apk_server_nightly + apk_name
|
||||
else:
|
||||
download_url = apk_server_release + apk_name
|
||||
|
||||
if testing:
|
||||
build_date = int(os.stat(apk_file).st_mtime)
|
||||
if build_date:
|
||||
build_date = datetime.fromtimestamp(build_date).strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
# untagged release, get commit log
|
||||
if build_type in ["nightly", "daily"]:
|
||||
changelog = get_commit_log(project_dir, format="markdown", max_lines=5)
|
||||
else:
|
||||
changelog = get_changelog(project_dir, format="markdown")
|
||||
|
||||
webhook = get_webhook_testing(
|
||||
version_name, build_type, changelog, download_url, build_date
|
||||
)
|
||||
requests.post(url=webhook_testing, json=webhook)
|
||||
else:
|
||||
changelog = get_changelog(project_dir, format="markdown")
|
||||
webhook = get_webhook_release(changelog, download_url)
|
||||
requests.post(url=webhook_release, json=webhook)
|
||||
|
||||
|
||||
def get_webhook_release(changelog: str, download_url: str):
|
||||
(title, content) = changelog
|
||||
return {"content": f"__**{title}**__\n{content}\n{download_url}"}
|
||||
|
||||
|
||||
def get_webhook_testing(
|
||||
version_name: str,
|
||||
build_type: str,
|
||||
changelog: str,
|
||||
download_url: str,
|
||||
build_date: str,
|
||||
):
|
||||
return {
|
||||
"embeds": [
|
||||
{
|
||||
"title": f"Nowa wersja {build_type} aplikacji Szkolny.eu",
|
||||
"description": f"Dostępna jest nowa wersja testowa **{build_type}**.",
|
||||
"color": 2201331,
|
||||
"fields": [
|
||||
{
|
||||
"name": f"Wersja `{version_name}`",
|
||||
"value": f"[Pobierz .APK]({download_url})"
|
||||
if download_url
|
||||
else "*Pobieranie niedostępne*",
|
||||
"inline": False,
|
||||
},
|
||||
{
|
||||
"name": "Data kompilacji",
|
||||
"value": build_date or "-",
|
||||
"inline": False,
|
||||
},
|
||||
{
|
||||
"name": "Ostatnie zmiany",
|
||||
"value": changelog or "-",
|
||||
"inline": False,
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: webhook_discord.py <project dir>")
|
||||
exit(-1)
|
||||
|
||||
project_dir = get_project_dir()
|
||||
|
||||
load_dotenv()
|
||||
APK_FILE = os.getenv("APK_FILE")
|
||||
APK_SERVER_RELEASE = os.getenv("APK_SERVER_RELEASE")
|
||||
APK_SERVER_NIGHTLY = os.getenv("APK_SERVER_NIGHTLY")
|
||||
WEBHOOK_RELEASE = os.getenv("WEBHOOK_RELEASE")
|
||||
WEBHOOK_TESTING = os.getenv("WEBHOOK_TESTING")
|
||||
|
||||
post_webhook(
|
||||
project_dir,
|
||||
APK_FILE,
|
||||
APK_SERVER_RELEASE,
|
||||
APK_SERVER_NIGHTLY,
|
||||
WEBHOOK_RELEASE,
|
||||
WEBHOOK_TESTING,
|
||||
)
|
154
.github/workflows/build-nightly-apk.yml
vendored
Normal file
154
.github/workflows/build-nightly-apk.yml
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
name: Nightly build
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# 23:30 UTC, 0:30 or 1:30 CET/CEST
|
||||
- cron: "30 23 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare build environment
|
||||
runs-on: self-hosted
|
||||
outputs:
|
||||
hasNewChanges: ${{ steps.nightly.outputs.hasNewChanges }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
clean: false
|
||||
- name: Set executable permissions to gradlew
|
||||
run: chmod +x ./gradlew
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install packages
|
||||
uses: BSFishy/pip-action@v1
|
||||
with:
|
||||
packages: |
|
||||
python-dotenv
|
||||
pycryptodome
|
||||
mysql-connector-python
|
||||
requests
|
||||
- name: Bump nightly version
|
||||
id: nightly
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/bump_nightly.py $GITHUB_WORKSPACE
|
||||
- name: Write signing passwords
|
||||
if: steps.nightly.outputs.hasNewChanges
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/sign.py $GITHUB_WORKSPACE commit
|
||||
build:
|
||||
name: Build APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- prepare
|
||||
if: ${{ needs.prepare.outputs.hasNewChanges == 'true' }}
|
||||
outputs:
|
||||
androidHome: ${{ env.ANDROID_HOME }}
|
||||
androidSdkRoot: ${{ env.ANDROID_SDK_ROOT }}
|
||||
steps:
|
||||
- name: Setup JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v2
|
||||
- name: Clean build artifacts
|
||||
run: |
|
||||
rm -rf app/release/*
|
||||
rm -rf app/build/outputs/apk/*
|
||||
rm -rf app/build/outputs/bundle/*
|
||||
- name: Assemble official release with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: assembleOfficialRelease
|
||||
sign:
|
||||
name: Sign APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- build
|
||||
outputs:
|
||||
signedReleaseFile: ${{ steps.artifacts.outputs.signedReleaseFile }}
|
||||
signedReleaseFileRelative: ${{ steps.artifacts.outputs.signedReleaseFileRelative }}
|
||||
steps:
|
||||
- name: Sign build artifacts
|
||||
id: sign_app
|
||||
uses: r0adkll/sign-android-release@v1
|
||||
with:
|
||||
releaseDirectory: app/release
|
||||
signingKeyBase64: ${{ secrets.KEY_STORE }}
|
||||
alias: ${{ secrets.KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEY_ALIAS_PASSWORD }}
|
||||
env:
|
||||
ANDROID_HOME: ${{ needs.build.outputs.androidHome }}
|
||||
ANDROID_SDK_ROOT: ${{ needs.build.outputs.androidSdkRoot }}
|
||||
BUILD_TOOLS_VERSION: "30.0.2"
|
||||
- name: Rename signed artifacts
|
||||
id: artifacts
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/rename_artifacts.py $GITHUB_WORKSPACE
|
||||
publish:
|
||||
name: Publish APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- sign
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
- name: Extract changelogs
|
||||
id: changelog
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/extract_changelogs.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Upload APK to SFTP
|
||||
uses: easingthemes/ssh-deploy@v2.1.6
|
||||
env:
|
||||
REMOTE_HOST: ${{ secrets.SSH_IP }}
|
||||
REMOTE_USER: ${{ secrets.SSH_USERNAME }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
|
||||
SOURCE: ${{ needs.sign.outputs.signedReleaseFileRelative }}
|
||||
TARGET: ${{ secrets.SSH_PATH_NIGHTLY }}
|
||||
- name: Save version metadata
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
APK_SERVER_RELEASE: ${{ secrets.APK_SERVER_RELEASE }}
|
||||
APK_SERVER_NIGHTLY: ${{ secrets.APK_SERVER_NIGHTLY }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/save_version.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Distribute to App Distribution
|
||||
uses: wzieba/Firebase-Distribution-Github-Action@v1
|
||||
with:
|
||||
appId: ${{ secrets.FIREBASE_APP_ID }}
|
||||
token: ${{ secrets.FIREBASE_TOKEN }}
|
||||
groups: ${{ secrets.FIREBASE_GROUPS_NIGHTLY }}
|
||||
file: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
releaseNotesFile: ${{ steps.changelog.outputs.commitLogPlainFile }}
|
||||
|
||||
- name: Post Discord webhook
|
||||
env:
|
||||
APK_FILE: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
APK_SERVER_RELEASE: ${{ secrets.APK_SERVER_RELEASE }}
|
||||
APK_SERVER_NIGHTLY: ${{ secrets.APK_SERVER_NIGHTLY }}
|
||||
WEBHOOK_RELEASE: ${{ secrets.WEBHOOK_RELEASE }}
|
||||
WEBHOOK_TESTING: ${{ secrets.WEBHOOK_TESTING }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/webhook_discord.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
if: true
|
||||
with:
|
||||
name: ${{ steps.changelog.outputs.appVersionName }}
|
||||
path: |
|
||||
app/release/whatsnew*/
|
||||
app/release/*.apk
|
||||
app/release/*.aab
|
||||
app/release/*.json
|
||||
app/release/*.txt
|
132
.github/workflows/build-release-aab-play.yml
vendored
Normal file
132
.github/workflows/build-release-aab-play.yml
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
name: Release build - Google Play [AAB]
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare build environment
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
clean: false
|
||||
- name: Set executable permissions to gradlew
|
||||
run: chmod +x ./gradlew
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install packages
|
||||
uses: BSFishy/pip-action@v1
|
||||
with:
|
||||
packages: |
|
||||
python-dotenv
|
||||
pycryptodome
|
||||
mysql-connector-python
|
||||
requests
|
||||
- name: Write signing passwords
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/sign.py $GITHUB_WORKSPACE commit
|
||||
build:
|
||||
name: Build App Bundle
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- prepare
|
||||
outputs:
|
||||
androidHome: ${{ env.ANDROID_HOME }}
|
||||
androidSdkRoot: ${{ env.ANDROID_SDK_ROOT }}
|
||||
steps:
|
||||
- name: Setup JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v2
|
||||
- name: Clean build artifacts
|
||||
run: |
|
||||
rm -rf app/release/*
|
||||
rm -rf app/build/outputs/apk/*
|
||||
rm -rf app/build/outputs/bundle/*
|
||||
- name: Bundle play release with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: bundlePlayRelease
|
||||
sign:
|
||||
name: Sign App Bundle
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- build
|
||||
outputs:
|
||||
signedReleaseFile: ${{ steps.artifacts.outputs.signedReleaseFile }}
|
||||
signedReleaseFileRelative: ${{ steps.artifacts.outputs.signedReleaseFileRelative }}
|
||||
steps:
|
||||
- name: Sign build artifacts
|
||||
id: sign_app
|
||||
uses: r0adkll/sign-android-release@v1
|
||||
with:
|
||||
releaseDirectory: app/release
|
||||
signingKeyBase64: ${{ secrets.KEY_STORE }}
|
||||
alias: ${{ secrets.KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEY_ALIAS_PASSWORD }}
|
||||
env:
|
||||
ANDROID_HOME: ${{ needs.build.outputs.androidHome }}
|
||||
ANDROID_SDK_ROOT: ${{ needs.build.outputs.androidSdkRoot }}
|
||||
BUILD_TOOLS_VERSION: "30.0.2"
|
||||
- name: Rename signed artifacts
|
||||
id: artifacts
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/rename_artifacts.py $GITHUB_WORKSPACE
|
||||
publish:
|
||||
name: Publish App Bundle
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- sign
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
- name: Extract changelogs
|
||||
id: changelog
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/extract_changelogs.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Save version metadata
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
APK_SERVER_RELEASE: ${{ secrets.APK_SERVER_RELEASE }}
|
||||
APK_SERVER_NIGHTLY: ${{ secrets.APK_SERVER_NIGHTLY }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/save_version.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Publish AAB to Google Play
|
||||
uses: r0adkll/upload-google-play@v1
|
||||
if: ${{ endsWith(needs.sign.outputs.signedReleaseFile, '.aab') }}
|
||||
with:
|
||||
serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }}
|
||||
packageName: pl.szczodrzynski.edziennik
|
||||
releaseFiles: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
releaseName: ${{ steps.changelog.outputs.appVersionName }}
|
||||
track: ${{ secrets.PLAY_RELEASE_TRACK }}
|
||||
whatsNewDirectory: ${{ steps.changelog.outputs.changelogDir }}
|
||||
status: completed
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: ${{ steps.changelog.outputs.appVersionName }}
|
||||
path: |
|
||||
app/release/whatsnew*/
|
||||
app/release/*.apk
|
||||
app/release/*.aab
|
||||
app/release/*.json
|
||||
app/release/*.txt
|
154
.github/workflows/build-release-apk.yml
vendored
Normal file
154
.github/workflows/build-release-apk.yml
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
name: Release build - official
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare build environment
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
clean: false
|
||||
- name: Set executable permissions to gradlew
|
||||
run: chmod +x ./gradlew
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install packages
|
||||
uses: BSFishy/pip-action@v1
|
||||
with:
|
||||
packages: |
|
||||
python-dotenv
|
||||
pycryptodome
|
||||
mysql-connector-python
|
||||
requests
|
||||
- name: Write signing passwords
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/sign.py $GITHUB_WORKSPACE commit
|
||||
build:
|
||||
name: Build APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- prepare
|
||||
outputs:
|
||||
androidHome: ${{ env.ANDROID_HOME }}
|
||||
androidSdkRoot: ${{ env.ANDROID_SDK_ROOT }}
|
||||
steps:
|
||||
- name: Setup JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v2
|
||||
- name: Clean build artifacts
|
||||
run: |
|
||||
rm -rf app/release/*
|
||||
rm -rf app/build/outputs/apk/*
|
||||
rm -rf app/build/outputs/bundle/*
|
||||
- name: Assemble official release with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: assembleOfficialRelease
|
||||
sign:
|
||||
name: Sign APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- build
|
||||
outputs:
|
||||
signedReleaseFile: ${{ steps.artifacts.outputs.signedReleaseFile }}
|
||||
signedReleaseFileRelative: ${{ steps.artifacts.outputs.signedReleaseFileRelative }}
|
||||
steps:
|
||||
- name: Sign build artifacts
|
||||
id: sign_app
|
||||
uses: r0adkll/sign-android-release@v1
|
||||
with:
|
||||
releaseDirectory: app/release
|
||||
signingKeyBase64: ${{ secrets.KEY_STORE }}
|
||||
alias: ${{ secrets.KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEY_ALIAS_PASSWORD }}
|
||||
env:
|
||||
ANDROID_HOME: ${{ needs.build.outputs.androidHome }}
|
||||
ANDROID_SDK_ROOT: ${{ needs.build.outputs.androidSdkRoot }}
|
||||
BUILD_TOOLS_VERSION: "30.0.2"
|
||||
- name: Rename signed artifacts
|
||||
id: artifacts
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/rename_artifacts.py $GITHUB_WORKSPACE
|
||||
publish:
|
||||
name: Publish APK
|
||||
runs-on: self-hosted
|
||||
needs:
|
||||
- sign
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
- name: Extract changelogs
|
||||
id: changelog
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/extract_changelogs.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Upload APK to SFTP
|
||||
uses: easingthemes/ssh-deploy@v2.1.6
|
||||
env:
|
||||
REMOTE_HOST: ${{ secrets.SSH_IP }}
|
||||
REMOTE_USER: ${{ secrets.SSH_USERNAME }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
|
||||
SOURCE: ${{ needs.sign.outputs.signedReleaseFileRelative }}
|
||||
TARGET: ${{ secrets.SSH_PATH_RELEASE }}
|
||||
- name: Save version metadata
|
||||
env:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASS: ${{ secrets.DB_PASS }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
APK_SERVER_RELEASE: ${{ secrets.APK_SERVER_RELEASE }}
|
||||
APK_SERVER_NIGHTLY: ${{ secrets.APK_SERVER_NIGHTLY }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/save_version.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Distribute to App Distribution
|
||||
uses: wzieba/Firebase-Distribution-Github-Action@v1
|
||||
with:
|
||||
appId: ${{ secrets.FIREBASE_APP_ID }}
|
||||
token: ${{ secrets.FIREBASE_TOKEN }}
|
||||
groups: ${{ secrets.FIREBASE_GROUPS_RELEASE }}
|
||||
file: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
releaseNotesFile: ${{ steps.changelog.outputs.changelogPlainTitledFile }}
|
||||
- name: Release on GitHub
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: ${{ steps.changelog.outputs.changelogTitle }}
|
||||
body_path: ${{ steps.changelog.outputs.changelogMarkdownFile }}
|
||||
files: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Post Discord webhook
|
||||
env:
|
||||
APK_FILE: ${{ needs.sign.outputs.signedReleaseFile }}
|
||||
APK_SERVER_RELEASE: ${{ secrets.APK_SERVER_RELEASE }}
|
||||
APK_SERVER_NIGHTLY: ${{ secrets.APK_SERVER_NIGHTLY }}
|
||||
WEBHOOK_RELEASE: ${{ secrets.WEBHOOK_RELEASE }}
|
||||
WEBHOOK_TESTING: ${{ secrets.WEBHOOK_TESTING }}
|
||||
run: python $GITHUB_WORKSPACE/.github/utils/webhook_discord.py $GITHUB_WORKSPACE
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
if: true
|
||||
with:
|
||||
name: ${{ steps.changelog.outputs.appVersionName }}
|
||||
path: |
|
||||
app/release/whatsnew*/
|
||||
app/release/*.apk
|
||||
app/release/*.aab
|
||||
app/release/*.json
|
||||
app/release/*.txt
|
196
.gitignore
vendored
196
.gitignore
vendored
@ -1,5 +1,11 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/android,androidstudio,gradle,java,kotlin
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=android,androidstudio,gradle,java,kotlin
|
||||
|
||||
### Android ###
|
||||
# Built application files
|
||||
*.apk
|
||||
*.aar
|
||||
*.ap_
|
||||
*.aab
|
||||
|
||||
@ -23,7 +29,7 @@ build/
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
#proguard/
|
||||
# proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
@ -40,22 +46,22 @@ captures/
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
#.idea/dictionaries
|
||||
.idea/libraries
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||
.idea/navEditor.xml
|
||||
.idea/copyright/profiles_settings.xml
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||
*.jks
|
||||
*.keystore
|
||||
#*.jks
|
||||
#*.keystore
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
.cxx/
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
# google-services.json
|
||||
@ -82,9 +88,181 @@ lint/outputs/
|
||||
lint/tmp/
|
||||
# lint/reports/
|
||||
|
||||
app/schemas/
|
||||
### Android Patch ###
|
||||
gen-external-apklibs
|
||||
output-metadata.json
|
||||
|
||||
# Replacement of .externalNativeBuild directories introduced
|
||||
# with Android Studio 3.5.
|
||||
|
||||
### Java ###
|
||||
# Compiled class file
|
||||
|
||||
# Log file
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
!/*/libs/*.jar
|
||||
|
||||
### Kotlin ###
|
||||
# Compiled class file
|
||||
|
||||
# Log file
|
||||
|
||||
# BlueJ files
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
|
||||
# Package Files #
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
### AndroidStudio ###
|
||||
# Covers files to be ignored for android development using Android Studio.
|
||||
|
||||
# Built application files
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
|
||||
# Java class files
|
||||
|
||||
# Generated files
|
||||
|
||||
# Gradle files
|
||||
|
||||
# Signing files
|
||||
.signing/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
|
||||
# Log Files
|
||||
|
||||
# Android Studio
|
||||
/*/build/
|
||||
/*/local.properties
|
||||
/*/out
|
||||
/*/*/build
|
||||
/*/*/production
|
||||
*.ipr
|
||||
*~
|
||||
*.swp
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
# google-services.json
|
||||
|
||||
# Android Patch
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
|
||||
# NDK
|
||||
obj/
|
||||
|
||||
# IntelliJ IDEA
|
||||
*.iws
|
||||
/out/
|
||||
|
||||
# User-specific configurations
|
||||
.idea/caches/
|
||||
.idea/libraries/
|
||||
.idea/shelf/
|
||||
.idea/.name
|
||||
.idea/compiler.xml
|
||||
.idea/copyright/profiles_settings.xml
|
||||
.idea/encodings.xml
|
||||
.idea/misc.xml
|
||||
.idea/scopes/scope_settings.xml
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
.idea/datasources.xml
|
||||
.idea/dataSources.ids
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
.idea/jarRepositories.xml
|
||||
|
||||
# OS-specific files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Legacy Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
.cproject
|
||||
.settings/
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
|
||||
# Package Files #
|
||||
|
||||
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
### AndroidStudio Patch ###
|
||||
|
||||
!/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/android,androidstudio,gradle,java,kotlin
|
||||
|
||||
signatures/
|
||||
|
||||
app/.cxx
|
||||
/i18n/
|
||||
.idea/*.xml
|
||||
|
1
.idea/.name
generated
1
.idea/.name
generated
@ -1 +0,0 @@
|
||||
Szkolny.eu
|
16
.idea/codeStyles/Project.xml
generated
16
.idea/codeStyles/Project.xml
generated
@ -1,6 +1,19 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
||||
<option name="ALLOW_TRAILING_COMMA" value="true" />
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="SMART_TABS" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
@ -112,5 +125,8 @@
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
6
.idea/copyright/Antoni.xml
generated
Normal file
6
.idea/copyright/Antoni.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright (c) Antoni Czaplicki &#36;{today.year}-&#36;{today.month}-&#36;{today.day}. " />
|
||||
<option name="myName" value="Antoni" />
|
||||
</copyright>
|
||||
</component>
|
20
.idea/dictionaries/Kuba.xml
generated
Normal file
20
.idea/dictionaries/Kuba.xml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="Kuba">
|
||||
<words>
|
||||
<w>autoryzacji</w>
|
||||
<w>ciasteczko</w>
|
||||
<w>csrf</w>
|
||||
<w>edziennik</w>
|
||||
<w>eggfall</w>
|
||||
<w>elearning</w>
|
||||
<w>gson</w>
|
||||
<w>hebe</w>
|
||||
<w>idziennik</w>
|
||||
<w>kuba</w>
|
||||
<w>synergia</w>
|
||||
<w>szczodrzyński</w>
|
||||
<w>szkolny</w>
|
||||
<w>usos</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
9
.idea/discord.xml
generated
9
.idea/discord.xml
generated
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="true" />
|
||||
</component>
|
||||
<component name="ProjectNotificationSettings">
|
||||
<option name="askShowProject" value="false" />
|
||||
</component>
|
||||
</project>
|
4
.idea/encodings.xml
generated
4
.idea/encodings.xml
generated
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
55
.idea/jarRepositories.xml
generated
55
.idea/jarRepositories.xml
generated
@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven2" />
|
||||
<option name="name" value="maven2" />
|
||||
<option name="url" value="https://kotlin.bintray.com/kotlinx/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven3" />
|
||||
<option name="name" value="maven3" />
|
||||
<option name="url" value="https://dl.bintray.com/wulkanowy/wulkanowy" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://jitpack.io" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven4" />
|
||||
<option name="name" value="maven4" />
|
||||
<option name="url" value="https://dl.bintray.com/undervoid/Powerpermission" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven4" />
|
||||
<option name="name" value="maven4" />
|
||||
<option name="url" value="https://dl.bintray.com/undervoid/PowerPermission" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
6
.idea/kotlinc.xml
generated
6
.idea/kotlinc.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
</project>
|
60
.idea/misc.xml
generated
60
.idea/misc.xml
generated
@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeSettings">
|
||||
<configurations>
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="EntryPointsManager">
|
||||
<list size="2">
|
||||
<item index="0" class="java.lang.String" itemvalue="androidx.databinding.BindingAdapter" />
|
||||
<item index="1" class="java.lang.String" itemvalue="org.greenrobot.eventbus.Subscribe" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
|
||||
<option name="myDefaultNotNull" value="androidx.annotation.RecentlyNonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="12">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
<item index="10" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="11">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
<item index="9" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
12
.idea/runConfigurations.xml
generated
12
.idea/runConfigurations.xml
generated
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
621
LICENSE
Normal file
621
LICENSE
Normal file
@ -0,0 +1,621 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
86
README.md
86
README.md
@ -1 +1,85 @@
|
||||
Szkolny.eu
|
||||
<div align="center">
|
||||
|
||||

|
||||
|
||||
[](https://szkolny.eu/discord)
|
||||
[](https://szkolny.eu/)
|
||||
[](https://szkolny.eu/facebook)
|
||||
|
||||

|
||||
[](https://github.com/szkolny-eu/szkolny-android/releases/latest)
|
||||

|
||||
|
||||
[](https://github.com/szkolny-eu/szkolny-android/actions/workflows/build-release-apk.yml)
|
||||
[](https://github.com/szkolny-eu/szkolny-android/actions/workflows/build-release-aab-play.yml)
|
||||
[](https://github.com/szkolny-eu/szkolny-android/actions/workflows/build-nightly-apk.yml)
|
||||
|
||||
</div>
|
||||
|
||||
## Ważna informacja
|
||||
|
||||
Jak zapewne już wiecie, we wrześniu 2020 r. **firma Librus zabroniła nam** publikowania w sklepie Google Play naszej aplikacji z obsługą dziennika Librus® Synergia. Prowadziliśmy rozmowy, aby **umożliwić Wam wygodny, bezpłatny dostęp do Waszych ocen, wiadomości, zadań domowych**, jednak oczekiwania firmy Librus zdecydowanie przekroczyły wszelkie nasze możliwości finansowe. Mając na uwadze powyższe względy, zdecydowaliśmy się opublikować kod źródłowy aplikacji Szkolny.eu. Liczymy, że dzięki temu aplikacja będzie mogła dalej funkcjonować, być rozwijana, pomagając Wam w czasie zdalnego nauczania i przez kolejne lata nauki.
|
||||
|
||||
__Zachęcamy do [przeczytania całej informacji](https://szkolny.eu/informacja) na naszej stronie.__
|
||||
|
||||
*- Autorzy Szkolny.eu*
|
||||
|
||||
## O aplikacji
|
||||
|
||||
Szkolny.eu jest nieoficjalną aplikacją, umożliwiającą rodzicom i uczniom dostęp do danych z e-dziennika w każdym smartfonie. Jest to jedyna aplikacja, która posiada wsparcie dla wszystkich najpopularniejszych e-dzienników. Oznacza to, że mając kilka kont w różnych szkołach, wystarczy mieć tylko jedną aplikację.
|
||||
|
||||
### Funkcje aplikacji
|
||||
|
||||
- plan lekcji, terminarz, oceny, wiadomości, zadania domowe, uwagi, frekwencja
|
||||
- wygodne **widgety** na ekran główny
|
||||
- łatwa komunikacja z nauczycielami — **odbieranie, wyszukiwanie i wysyłanie wiadomości**
|
||||
- pobieranie **załączników wiadomości i zadań domowych**
|
||||
- **powiadomienia** o nowych informacjach na telefonie lub na komputerze
|
||||
- organizacja zadań domowych i sprawdzianów — łatwe oznaczanie jako wykonane
|
||||
- obliczanie **średniej ocen** ze wszystkich przedmiotów, oceny proponowane i końcowe
|
||||
- Symulator edycji ocen — obliczanie średniej z przedmiotu po zmianie dowolnych jego ocen
|
||||
- **dodawanie własnych wydarzeń** i zadań do terminarza
|
||||
- nowoczesny i intuicyjny interfejs użytkownika
|
||||
- **obsługa wielu profili** uczniów — jeżeli jesteś Rodzicem, możesz skonfigurować wszystkie swoje konta uczniowskie i łatwo między nimi przełączać
|
||||
- opcja **automatycznej synchronizacji** z E-dziennikiem
|
||||
- opcja Ciszy nocnej — nigdy więcej budzących Cię dźwięków z telefonu
|
||||
|
||||
[Zobacz porównanie funkcji z innymi aplikacjami](https://szkolny.eu/funkcje)
|
||||
|
||||
### Pobieranie
|
||||
|
||||
Najnowsze wersje możesz pobrać z Google Play lub bezpośrednio z naszej strony, w formacie .APK.
|
||||
|
||||
[<img src=".github/google-play-badge.png" height="100px">](https://szkolny.eu/pobierz/android)
|
||||
[<img src=".github/apk-badge.png" height="100px">](https://szkolny.eu/pobierz)
|
||||
|
||||
### Kompilacja
|
||||
|
||||
Aby uruchomić aplikację „ze źródeł” należy użyć Android Studio w wersji co najmniej 4.2 Beta 6. Wersja `debug` może wtedy zostać zainstalowana np. na emulatorze Androida.
|
||||
|
||||
Aby zbudować wersję produkcyjną, tzn. `release` należy użyć wariantu `mainRelease` oraz podpisać wyjściowy plik .APK sygnaturą w wersji V1 i V2.
|
||||
|
||||
Warianty `play` oraz `official` są zastrzeżone dla wydań oficjalnych.
|
||||
|
||||
## Współpraca
|
||||
|
||||
PRy wprowadzające nowe funkcje lub naprawiające błędy są mile widziane!
|
||||
|
||||
__Jeśli masz jakieś pytania, zapraszamy na [nasz serwer Discord](https://szkolny.eu/discord).__
|
||||
|
||||
## Licencja
|
||||
|
||||
Szkolny.eu publikowany jest na licencji [GNU GPLv3](LICENSE). W szczególności, deweloper:
|
||||
- Może modyfikować oraz usprawniać kod aplikacji
|
||||
- Może dystrybuować wersje produkcyjne
|
||||
- Musi opublikować wszelkie wprowadzone zmiany, tzn. publiczny fork tego repozytorium
|
||||
- Nie może zmieniać licencji ani copyrightu aplikacji
|
||||
|
||||
Dodatkowo:
|
||||
- Zabronione jest modyfikowanie lub usuwanie kodu odpowiedzialnego za zgodność wersji produkcyjnych z licencją.
|
||||
|
||||
- **Wersje skompilowane nie mogą być dystrybuowane za pomocą Google Play oraz żadnej platformy, na której istnieje oficjalna wersja aplikacji**.
|
||||
|
||||
**Autorzy aplikacji nie biorą odpowiedzialności za używanie aplikacji, modyfikowanie oraz dystrybuowanie.**
|
||||
|
||||
Znaki towarowe zamieszczone w aplikacji oraz tym dokumencie należą do ich prawowitych właścicieli i są używane wyłącznie w celach informacyjnych.
|
||||
|
1
agendacalendarview/.gitignore
vendored
1
agendacalendarview/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build
|
@ -1,54 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
//apply plugin: 'me.tatarka.retrolambda'
|
||||
|
||||
android {
|
||||
compileSdkVersion setup.compileSdk
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion setup.targetSdk
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debugMinify {
|
||||
debuggable = true
|
||||
minifyEnabled = true
|
||||
proguardFiles 'proguard-android.txt'
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
assets.srcDirs = ['assets']
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
// Google libraries
|
||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
||||
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
|
||||
implementation "com.google.android.material:material:${versions.material}"
|
||||
|
||||
// other libraries
|
||||
//implementation 'se.emilsjolander:stickylistheaders:2.7.0'
|
||||
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
|
||||
implementation 'io.reactivex:rxjava:1.1.1'
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.tibolte.agendacalendarview">
|
||||
</manifest>
|
@ -1,264 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.agenda.AgendaAdapter;
|
||||
import com.github.tibolte.agendacalendarview.agenda.AgendaView;
|
||||
import com.github.tibolte.agendacalendarview.calendar.CalendarView;
|
||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.DayItem;
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
||||
import com.github.tibolte.agendacalendarview.models.WeekItem;
|
||||
import com.github.tibolte.agendacalendarview.render.DefaultEventRenderer;
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer;
|
||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
||||
import com.github.tibolte.agendacalendarview.utils.ListViewScrollTracker;
|
||||
import com.github.tibolte.agendacalendarview.widgets.FloatingActionButton;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||
|
||||
/**
|
||||
* View holding the agenda and calendar view together.
|
||||
*/
|
||||
public class AgendaCalendarView extends FrameLayout implements StickyListHeadersListView.OnStickyHeaderChangedListener {
|
||||
|
||||
private static final String LOG_TAG = AgendaCalendarView.class.getSimpleName();
|
||||
|
||||
private CalendarView mCalendarView;
|
||||
private AgendaView mAgendaView;
|
||||
private FloatingActionButton mFloatingActionButton;
|
||||
|
||||
private int mAgendaCurrentDayTextColor, mCalendarHeaderColor, mCalendarHeaderTextColor, mCalendarBackgroundColor, mCalendarDayTextColor, mCalendarPastDayTextColor, mCalendarCurrentDayColor, mFabColor;
|
||||
private CalendarPickerController mCalendarPickerController;
|
||||
|
||||
public AgendaView getAgendaView() {
|
||||
return mAgendaView;
|
||||
}
|
||||
|
||||
private ListViewScrollTracker mAgendaListViewScrollTracker;
|
||||
private AbsListView.OnScrollListener mAgendaScrollListener = new AbsListView.OnScrollListener() {
|
||||
int mCurrentAngle;
|
||||
int mMaxAngle = 85;
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
int scrollY = mAgendaListViewScrollTracker.calculateScrollY(firstVisibleItem, visibleItemCount);
|
||||
if (scrollY != 0) {
|
||||
mFloatingActionButton.show();
|
||||
}
|
||||
//Log.d(LOG_TAG, String.format("Agenda listView scrollY: %d", scrollY));
|
||||
/*int toAngle = scrollY / 100;
|
||||
if (toAngle > mMaxAngle) {
|
||||
toAngle = mMaxAngle;
|
||||
} else if (toAngle < -mMaxAngle) {
|
||||
toAngle = -mMaxAngle;
|
||||
}
|
||||
RotateAnimation rotate = new RotateAnimation(mCurrentAngle, toAngle, mFloatingActionButton.getWidth() / 2, mFloatingActionButton.getHeight() / 2);
|
||||
rotate.setFillAfter(true);
|
||||
mCurrentAngle = toAngle;
|
||||
mFloatingActionButton.startAnimation(rotate);*/
|
||||
}
|
||||
};
|
||||
|
||||
// region Constructors
|
||||
|
||||
public AgendaCalendarView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AgendaCalendarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorOptionsView, 0, 0);
|
||||
mAgendaCurrentDayTextColor = a.getColor(R.styleable.ColorOptionsView_agendaCurrentDayTextColor, getResources().getColor(R.color.theme_primary));
|
||||
mCalendarHeaderColor = a.getColor(R.styleable.ColorOptionsView_calendarHeaderColor, getResources().getColor(R.color.theme_primary_dark));
|
||||
mCalendarHeaderTextColor = a.getColor(R.styleable.ColorOptionsView_calendarHeaderTextColor, getResources().getColor(R.color.theme_text_icons));
|
||||
mCalendarBackgroundColor = a.getColor(R.styleable.ColorOptionsView_calendarColor, getResources().getColor(R.color.theme_primary));
|
||||
mCalendarDayTextColor = a.getColor(R.styleable.ColorOptionsView_calendarDayTextColor, getResources().getColor(R.color.theme_text_icons));
|
||||
mCalendarCurrentDayColor = a.getColor(R.styleable.ColorOptionsView_calendarCurrentDayTextColor, getResources().getColor(R.color.calendar_text_current_day));
|
||||
mCalendarPastDayTextColor = a.getColor(R.styleable.ColorOptionsView_calendarPastDayTextColor, getResources().getColor(R.color.theme_light_primary));
|
||||
mFabColor = a.getColor(R.styleable.ColorOptionsView_fabColor, getResources().getColor(R.color.theme_accent));
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.view_agendacalendar, this, true);
|
||||
|
||||
setAlpha(0f);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Class - View
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mCalendarView = (CalendarView) findViewById(R.id.calendar_view);
|
||||
mAgendaView = (AgendaView) findViewById(R.id.agenda_view);
|
||||
mFloatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);
|
||||
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{mFabColor});
|
||||
mFloatingActionButton.setBackgroundTintList(csl);
|
||||
|
||||
LinearLayout mDayNamesHeader = mCalendarView.findViewById(R.id.cal_day_names);
|
||||
mDayNamesHeader.setBackgroundColor(mCalendarHeaderColor);
|
||||
for (int i = 0; i < mDayNamesHeader.getChildCount(); i++) {
|
||||
TextView txtDay = (TextView) mDayNamesHeader.getChildAt(i);
|
||||
txtDay.setTextColor(mCalendarHeaderTextColor);
|
||||
}
|
||||
mCalendarView.findViewById(R.id.list_week).setBackgroundColor(mCalendarBackgroundColor);
|
||||
|
||||
mAgendaView.getAgendaListView().setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
|
||||
mCalendarPickerController.onEventSelected(CalendarManager.getInstance().getEvents().get(position));
|
||||
});
|
||||
|
||||
BusProvider.getInstance().toObserverable()
|
||||
.subscribe(event -> {
|
||||
if (event instanceof Events.DayClickedEvent) {
|
||||
if (mCalendarPickerController != null)
|
||||
mCalendarPickerController.onDaySelected(((Events.DayClickedEvent) event).getDay());
|
||||
} else if (event instanceof Events.EventsFetched) {
|
||||
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), 1f).setDuration(500);
|
||||
alphaAnimation.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
long fabAnimationDelay = 500;
|
||||
// Just after setting the alpha from this view to 1, we hide the fab.
|
||||
// It will reappear as soon as the user is scrolling the Agenda view.
|
||||
new Handler().postDelayed(() -> {
|
||||
mFloatingActionButton.hide();
|
||||
mAgendaListViewScrollTracker = new ListViewScrollTracker(mAgendaView.getAgendaListView());
|
||||
mAgendaView.getAgendaListView().setOnScrollListener(mAgendaScrollListener);
|
||||
mFloatingActionButton.setOnClickListener((v) -> {
|
||||
mAgendaView.translateList(0);
|
||||
mAgendaView.getAgendaListView().smoothScrollBy(0, 0);
|
||||
//mAgendaView.getAgendaListView().getWrappedList().smoothScrollBy(0, 0);
|
||||
mAgendaView.getAgendaListView().scrollToCurrentDate(CalendarManager.getInstance().getToday());
|
||||
new Handler().postDelayed(() -> mFloatingActionButton.hide(), fabAnimationDelay);
|
||||
});
|
||||
}, fabAnimationDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
alphaAnimation.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Interface - StickyListHeadersListView.OnStickyHeaderChangedListener
|
||||
|
||||
@Override
|
||||
public void onStickyHeaderChanged(StickyListHeadersListView stickyListHeadersListView, View header, int position, long headerId) {
|
||||
//Log.d(LOG_TAG, String.format("onStickyHeaderChanged, position = %d, headerId = %d", position, headerId));
|
||||
|
||||
if (CalendarManager.getInstance().getEvents().size() > 0) {
|
||||
CalendarEvent event = CalendarManager.getInstance().getEvents().get(position);
|
||||
if (event != null) {
|
||||
mCalendarView.scrollToDate(event);
|
||||
mCalendarPickerController.onScrollToDate(event.getInstanceDay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void init(List<CalendarEvent> eventList, Calendar minDate, Calendar maxDate, Locale locale, CalendarPickerController calendarPickerController, EventRenderer<?> ... renderers) {
|
||||
mCalendarPickerController = calendarPickerController;
|
||||
|
||||
CalendarManager.getInstance(getContext()).buildCal(minDate, maxDate, locale, new DayItem(), new WeekItem());
|
||||
|
||||
// Feed our views with weeks list and events
|
||||
mCalendarView.init(CalendarManager.getInstance(getContext()), mCalendarDayTextColor, mCalendarCurrentDayColor, mCalendarPastDayTextColor, eventList);
|
||||
|
||||
// Load agenda events and scroll to current day
|
||||
AgendaAdapter agendaAdapter = new AgendaAdapter(mAgendaCurrentDayTextColor);
|
||||
mAgendaView.getAgendaListView().setAdapter(agendaAdapter);
|
||||
mAgendaView.getAgendaListView().setOnStickyHeaderChangedListener(this);
|
||||
|
||||
CalendarManager.getInstance().loadEvents(eventList, new BaseCalendarEvent());
|
||||
BusProvider.getInstance().send(new Events.EventsFetched());
|
||||
Log.d(LOG_TAG, "CalendarEventTask finished, event count "+eventList.size());
|
||||
|
||||
// add default event renderer
|
||||
addEventRenderer(new DefaultEventRenderer());
|
||||
for (EventRenderer<?> renderer: renderers) {
|
||||
addEventRenderer(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
public void init(Locale locale, List<IWeekItem> lWeeks, List<IDayItem> lDays, List<CalendarEvent> lEvents, CalendarPickerController calendarPickerController) {
|
||||
mCalendarPickerController = calendarPickerController;
|
||||
|
||||
CalendarManager.getInstance(getContext()).loadCal(locale, lWeeks, lDays, lEvents);
|
||||
|
||||
// Feed our views with weeks list and events
|
||||
mCalendarView.init(CalendarManager.getInstance(getContext()), mCalendarDayTextColor, mCalendarCurrentDayColor, mCalendarPastDayTextColor, lEvents);
|
||||
|
||||
// Load agenda events and scroll to current day
|
||||
AgendaAdapter agendaAdapter = new AgendaAdapter(mAgendaCurrentDayTextColor);
|
||||
mAgendaView.getAgendaListView().setAdapter(agendaAdapter);
|
||||
mAgendaView.getAgendaListView().setOnStickyHeaderChangedListener(this);
|
||||
|
||||
// notify that actually everything is loaded
|
||||
BusProvider.getInstance().send(new Events.EventsFetched());
|
||||
Log.d(LOG_TAG, "CalendarEventTask finished");
|
||||
|
||||
// add default event renderer
|
||||
addEventRenderer(new DefaultEventRenderer());
|
||||
}
|
||||
|
||||
public void addEventRenderer(@NonNull final EventRenderer<?> renderer) {
|
||||
AgendaAdapter adapter = (AgendaAdapter) mAgendaView.getAgendaListView().getAdapter();
|
||||
adapter.addEventRenderer(renderer);
|
||||
}
|
||||
|
||||
public void enableFloatingIndicator(boolean enable) {
|
||||
mFloatingActionButton.setVisibility(enable ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,267 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This class manages information about the calendar. (Events, weather info...)
|
||||
* Holds reference to the days list of the calendar.
|
||||
* As the app is using several views, we want to keep everything in one place.
|
||||
*/
|
||||
public class CalendarManager {
|
||||
|
||||
private static final String LOG_TAG = CalendarManager.class.getSimpleName();
|
||||
|
||||
private static CalendarManager mInstance;
|
||||
|
||||
private Context mContext;
|
||||
private Locale mLocale;
|
||||
private Calendar mToday = Calendar.getInstance();
|
||||
private SimpleDateFormat mWeekdayFormatter;
|
||||
private SimpleDateFormat mMonthHalfNameFormat;
|
||||
|
||||
/// instances of classes provided from outside
|
||||
private IDayItem mCleanDay;
|
||||
private IWeekItem mCleanWeek;
|
||||
|
||||
/**
|
||||
* List of days used by the calendar
|
||||
*/
|
||||
private List<IDayItem> mDays = new ArrayList<>();
|
||||
/**
|
||||
* List of weeks used by the calendar
|
||||
*/
|
||||
private List<IWeekItem> mWeeks = new ArrayList<>();
|
||||
/**
|
||||
* List of events instances
|
||||
*/
|
||||
private List<CalendarEvent> mEvents = new ArrayList<>();
|
||||
|
||||
// region Constructors
|
||||
|
||||
public CalendarManager(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public static CalendarManager getInstance(Context context) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new CalendarManager(context);
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public static CalendarManager getInstance() {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Getters/Setters
|
||||
|
||||
public Locale getLocale() {
|
||||
return mLocale;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public Calendar getToday() {
|
||||
return mToday;
|
||||
}
|
||||
|
||||
public void setToday(Calendar today) {
|
||||
this.mToday = today;
|
||||
}
|
||||
|
||||
public List<IWeekItem> getWeeks() {
|
||||
return mWeeks;
|
||||
}
|
||||
|
||||
public List<CalendarEvent> getEvents() {
|
||||
return mEvents;
|
||||
}
|
||||
|
||||
public List<IDayItem> getDays() {
|
||||
return mDays;
|
||||
}
|
||||
|
||||
public SimpleDateFormat getWeekdayFormatter() {
|
||||
return mWeekdayFormatter;
|
||||
}
|
||||
|
||||
public SimpleDateFormat getMonthHalfNameFormat() {
|
||||
return mMonthHalfNameFormat;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void buildCal(Calendar minDate, Calendar maxDate, Locale locale, IDayItem cleanDay, IWeekItem cleanWeek) {
|
||||
if (minDate == null || maxDate == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"minDate and maxDate must be non-null.");
|
||||
}
|
||||
if (minDate.after(maxDate)) {
|
||||
throw new IllegalArgumentException(
|
||||
"minDate must be before maxDate.");
|
||||
}
|
||||
if (locale == null) {
|
||||
throw new IllegalArgumentException("Locale is null.");
|
||||
}
|
||||
|
||||
setLocale(locale);
|
||||
|
||||
mDays.clear();
|
||||
mWeeks.clear();
|
||||
mEvents.clear();
|
||||
|
||||
mCleanDay = cleanDay;
|
||||
mCleanWeek = cleanWeek;
|
||||
|
||||
Calendar mMinCal = Calendar.getInstance(mLocale);
|
||||
Calendar mMaxCal = Calendar.getInstance(mLocale);
|
||||
Calendar mWeekCounter = Calendar.getInstance(mLocale);
|
||||
|
||||
mMinCal.setTime(minDate.getTime());
|
||||
mMaxCal.setTime(maxDate.getTime());
|
||||
|
||||
// maxDate is exclusive, here we bump back to the previous day, as maxDate if December 1st, 2020,
|
||||
// we don't include that month in our list
|
||||
mMaxCal.add(Calendar.MINUTE, -1);
|
||||
|
||||
// Now iterate we iterate between mMinCal and mMaxCal so we build our list of weeks
|
||||
mWeekCounter.setTime(mMinCal.getTime());
|
||||
int maxMonth = mMaxCal.get(Calendar.MONTH);
|
||||
int maxYear = mMaxCal.get(Calendar.YEAR);
|
||||
|
||||
int currentMonth = mWeekCounter.get(Calendar.MONTH);
|
||||
int currentYear = mWeekCounter.get(Calendar.YEAR);
|
||||
|
||||
// Loop through the weeks
|
||||
while ((currentMonth <= maxMonth // Up to, including the month.
|
||||
|| currentYear < maxYear) // Up to the year.
|
||||
&& currentYear < maxYear + 1) { // But not > next yr.
|
||||
|
||||
Date date = mWeekCounter.getTime();
|
||||
// Build our week list
|
||||
int currentWeekOfYear = mWeekCounter.get(Calendar.WEEK_OF_YEAR);
|
||||
|
||||
IWeekItem weekItem = cleanWeek.copy();
|
||||
weekItem.setWeekInYear(currentWeekOfYear);
|
||||
weekItem.setYear(currentYear);
|
||||
weekItem.setDate(date);
|
||||
weekItem.setMonth(currentMonth);
|
||||
weekItem.setLabel(mMonthHalfNameFormat.format(date));
|
||||
List<IDayItem> dayItems = getDayCells(mWeekCounter); // gather days for the built week
|
||||
weekItem.setDayItems(dayItems);
|
||||
mWeeks.add(weekItem);
|
||||
|
||||
//Log.d(LOG_TAG, String.format("Adding week: %s", weekItem));
|
||||
|
||||
mWeekCounter.add(Calendar.WEEK_OF_YEAR, 1);
|
||||
|
||||
currentMonth = mWeekCounter.get(Calendar.MONTH);
|
||||
currentYear = mWeekCounter.get(Calendar.YEAR);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadEvents(List<CalendarEvent> eventList, CalendarEvent noEvent) {
|
||||
|
||||
for (IWeekItem weekItem : getWeeks()) {
|
||||
for (IDayItem dayItem : weekItem.getDayItems()) {
|
||||
boolean isEventForDay = false;
|
||||
boolean isShowBadgeForDay = false;
|
||||
for (CalendarEvent event : eventList) {
|
||||
if (DateHelper.isBetweenInclusive(dayItem.getDate(), event.getStartTime(), event.getEndTime())) {
|
||||
CalendarEvent copy = event.copy();
|
||||
|
||||
if (copy.getShowBadge()) {
|
||||
isShowBadgeForDay = true;
|
||||
}
|
||||
|
||||
Calendar dayInstance = Calendar.getInstance();
|
||||
dayInstance.setTime(dayItem.getDate());
|
||||
copy.setInstanceDay(dayInstance);
|
||||
copy.setDayReference(dayItem);
|
||||
copy.setWeekReference(weekItem);
|
||||
// add instances in chronological order
|
||||
getEvents().add(copy);
|
||||
isEventForDay = true;
|
||||
}
|
||||
}
|
||||
if (!isEventForDay) {
|
||||
Calendar dayInstance = Calendar.getInstance();
|
||||
dayInstance.setTime(dayItem.getDate());
|
||||
CalendarEvent copy = noEvent.copy();
|
||||
|
||||
copy.setInstanceDay(dayInstance);
|
||||
copy.setDayReference(dayItem);
|
||||
copy.setWeekReference(weekItem);
|
||||
copy.setLocation("");
|
||||
copy.setTitle(getContext().getResources().getString(R.string.agenda_event_no_events));
|
||||
copy.setPlaceholder(true);
|
||||
getEvents().add(copy);
|
||||
}
|
||||
dayItem.setShowBadge(isShowBadgeForDay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCal (Locale locale, List<IWeekItem> lWeeks, List<IDayItem> lDays, List<CalendarEvent> lEvents) {
|
||||
mWeeks = lWeeks;
|
||||
mDays = lDays;
|
||||
mEvents = lEvents;
|
||||
setLocale(locale);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Private methods
|
||||
|
||||
private List<IDayItem> getDayCells(Calendar startCal) {
|
||||
Calendar cal = Calendar.getInstance(mLocale);
|
||||
cal.setTime(startCal.getTime());
|
||||
List<IDayItem> dayItems = new ArrayList<>();
|
||||
|
||||
int firstDayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
||||
int offset = cal.getFirstDayOfWeek() - firstDayOfWeek;
|
||||
if (offset > 0) {
|
||||
offset -= 7;
|
||||
}
|
||||
cal.add(Calendar.DATE, offset);
|
||||
|
||||
//Log.d(LOG_TAG, String.format("Buiding row week starting at %s", cal.getTime()));
|
||||
for (int c = 0; c < 7; c++) {
|
||||
IDayItem dayItem = mCleanDay.copy();
|
||||
dayItem.buildDayItemFromCal(cal);
|
||||
dayItems.add(dayItem);
|
||||
cal.add(Calendar.DATE, 1);
|
||||
}
|
||||
|
||||
mDays.addAll(dayItems);
|
||||
return dayItems;
|
||||
}
|
||||
|
||||
private void setLocale(Locale locale) {
|
||||
this.mLocale = locale;
|
||||
setToday(Calendar.getInstance(mLocale));
|
||||
mWeekdayFormatter = new SimpleDateFormat(getContext().getString(R.string.day_name_format), mLocale);
|
||||
mMonthHalfNameFormat = new SimpleDateFormat(getContext().getString(R.string.month_half_name_format), locale);
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public interface CalendarPickerController {
|
||||
void onDaySelected(IDayItem dayItem);
|
||||
|
||||
void onEventSelected(CalendarEvent event);
|
||||
|
||||
void onScrollToDate(Calendar calendar);
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.agenda;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.render.DefaultEventRenderer;
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||
|
||||
/**
|
||||
* Adapter for the agenda, implements StickyListHeadersAdapter.
|
||||
* Days as sections and CalendarEvents as list items.
|
||||
*/
|
||||
public class AgendaAdapter extends BaseAdapter implements StickyListHeadersAdapter {
|
||||
|
||||
private List<CalendarEvent> mEvents = new ArrayList<>();
|
||||
private List<EventRenderer<?>> mRenderers = new ArrayList<>();
|
||||
private int mCurrentDayColor;
|
||||
|
||||
// region Constructor
|
||||
|
||||
public AgendaAdapter(int currentDayTextColor) {
|
||||
this.mCurrentDayColor = currentDayTextColor;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void updateEvents(List<CalendarEvent> events) {
|
||||
this.mEvents.clear();
|
||||
this.mEvents.addAll(events);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Interface - StickyListHeadersAdapter
|
||||
|
||||
@Override
|
||||
public View getHeaderView(int position, View convertView, ViewGroup parent) {
|
||||
AgendaHeaderView agendaHeaderView = (AgendaHeaderView) convertView;
|
||||
if (agendaHeaderView == null) {
|
||||
agendaHeaderView = AgendaHeaderView.inflate(parent);
|
||||
}
|
||||
agendaHeaderView.setDay(getItem(position).getInstanceDay(), mCurrentDayColor, getItem(position).getDayReference().getShowBadge());
|
||||
return agendaHeaderView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeaderId(int position) {
|
||||
return mEvents.get(position).getInstanceDay().getTimeInMillis();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Class - BaseAdapter
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mEvents.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalendarEvent getItem(int position) {
|
||||
return mEvents.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
EventRenderer eventRenderer = new DefaultEventRenderer();
|
||||
final CalendarEvent event = getItem(position);
|
||||
|
||||
// Search for the correct event renderer
|
||||
for (EventRenderer renderer : mRenderers) {
|
||||
if(event.getClass().isAssignableFrom(renderer.getRenderType())) {
|
||||
eventRenderer = renderer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(eventRenderer.getEventLayout(), parent, false);
|
||||
eventRenderer.render(convertView, event);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public void addEventRenderer(@NonNull final EventRenderer<?> renderer) {
|
||||
mRenderers.add(renderer);
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.agenda;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* List item view for the StickyHeaderListView of the agenda view
|
||||
*/
|
||||
public class AgendaEventView extends LinearLayout {
|
||||
public static AgendaEventView inflate(ViewGroup parent) {
|
||||
return (AgendaEventView) LayoutInflater.from(parent.getContext()).inflate(R.layout.view_agenda_event, parent, false);
|
||||
}
|
||||
|
||||
// region Constructors
|
||||
|
||||
public AgendaEventView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public AgendaEventView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public AgendaEventView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setPadding(getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_left),
|
||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_top),
|
||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_right),
|
||||
getResources().getDimensionPixelSize(R.dimen.agenda_event_view_padding_bottom));
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.agenda;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Header view for the StickyHeaderListView of the agenda view
|
||||
*/
|
||||
public class AgendaHeaderView extends LinearLayout {
|
||||
|
||||
public static AgendaHeaderView inflate(ViewGroup parent) {
|
||||
return (AgendaHeaderView) LayoutInflater.from(parent.getContext()).inflate(R.layout.view_agenda_header, parent, false);
|
||||
}
|
||||
|
||||
// region Constructors
|
||||
|
||||
public AgendaHeaderView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AgendaHeaderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public AgendaHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void setDay(Calendar day, int currentDayTextColor, boolean showBadge) {
|
||||
TextView txtDayOfMonth = (TextView) findViewById(R.id.view_agenda_day_of_month);
|
||||
TextView txtDayOfWeek = (TextView) findViewById(R.id.view_agenda_day_of_week);
|
||||
TextView txtDay = (TextView) findViewById(R.id.view_agenda_day_text);
|
||||
View circleView = findViewById(R.id.view_day_circle_selected);
|
||||
|
||||
Calendar today = CalendarManager.getInstance().getToday();
|
||||
|
||||
SimpleDateFormat dayWeekFormatter = new SimpleDateFormat(getContext().getString(R.string.day_name_format), CalendarManager.getInstance().getLocale());
|
||||
SimpleDateFormat dayWeekLongFormatter = new SimpleDateFormat("EEEE", CalendarManager.getInstance().getLocale());
|
||||
|
||||
txtDayOfMonth.setTextColor(getResources().getColor(R.color.calendar_text_default));
|
||||
txtDayOfWeek.setTextColor(getResources().getColor(R.color.calendar_text_default));
|
||||
|
||||
if (DateHelper.sameDate(day, today)) {
|
||||
txtDayOfMonth.setTextColor(currentDayTextColor);
|
||||
circleView.setVisibility(VISIBLE);
|
||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), currentDayTextColor);
|
||||
} else if (showBadge) {
|
||||
circleView.setVisibility(VISIBLE);
|
||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), 0xffff0000);
|
||||
}
|
||||
else {
|
||||
circleView.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
txtDayOfMonth.setText(String.valueOf(day.get(Calendar.DAY_OF_MONTH)));
|
||||
txtDayOfWeek.setText(dayWeekFormatter.format(day.getTime()));
|
||||
//txtDay.setText(dayWeekLongFormatter.format(day.getTime()));
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.agenda;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||
|
||||
/**
|
||||
* StickyListHeadersListView to scroll chronologically through events.
|
||||
*/
|
||||
public class AgendaListView extends StickyListHeadersListView {
|
||||
|
||||
// region Constructors
|
||||
|
||||
public AgendaListView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AgendaListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public AgendaListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void scrollToCurrentDate(Calendar today) {
|
||||
List<CalendarEvent> events = CalendarManager.getInstance().getEvents();
|
||||
|
||||
int toIndex = 0;
|
||||
for (int i = 0; i < events.size(); i++) {
|
||||
if (DateHelper.sameDate(today, events.get(i).getInstanceDay())) {
|
||||
toIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final int finalToIndex = toIndex;
|
||||
post(()->setSelection(finalToIndex));
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.agenda;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
||||
|
||||
public class AgendaView extends FrameLayout {
|
||||
|
||||
private AgendaListView mAgendaListView;
|
||||
private View mShadowView;
|
||||
|
||||
// region Constructors
|
||||
|
||||
public AgendaView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AgendaView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.view_agenda, this, true);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Class - View
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
mAgendaListView = (AgendaListView) findViewById(R.id.agenda_listview);
|
||||
mShadowView = findViewById(R.id.view_shadow);
|
||||
|
||||
BusProvider.getInstance().toObserverable()
|
||||
.subscribe(event -> {
|
||||
if (event instanceof Events.DayClickedEvent) {
|
||||
Events.DayClickedEvent clickedEvent = (Events.DayClickedEvent) event;
|
||||
getAgendaListView().scrollToCurrentDate(clickedEvent.getCalendar());
|
||||
} else if (event instanceof Events.CalendarScrolledEvent) {
|
||||
int offset = (int) (3 * getResources().getDimension(R.dimen.day_cell_height));
|
||||
translateList(offset);
|
||||
} else if (event instanceof Events.EventsFetched) {
|
||||
if (getAgendaListView().getAdapter() != null)
|
||||
((AgendaAdapter) getAgendaListView().getAdapter()).updateEvents(CalendarManager.getInstance().getEvents());
|
||||
|
||||
getViewTreeObserver().addOnGlobalLayoutListener(
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (getWidth() != 0 && getHeight() != 0) {
|
||||
// display only two visible rows on the calendar view
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
||||
int height = getHeight();
|
||||
int margin = (int) (getContext().getResources().getDimension(R.dimen.calendar_header_height) + 2 * getContext().getResources().getDimension(R.dimen.day_cell_height));
|
||||
layoutParams.height = height;
|
||||
layoutParams.setMargins(0, margin, 0, 0);
|
||||
setLayoutParams(layoutParams);
|
||||
|
||||
getAgendaListView().scrollToCurrentDate(CalendarManager.getInstance().getToday());
|
||||
|
||||
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
} else if (event instanceof Events.ForecastFetched) {
|
||||
((AgendaAdapter) getAgendaListView().getAdapter()).updateEvents(CalendarManager.getInstance().getEvents());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
int eventaction = event.getAction();
|
||||
|
||||
switch (eventaction) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// if the user touches the listView, we put it back to the top
|
||||
translateList(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public AgendaListView getAgendaListView() {
|
||||
return mAgendaListView;
|
||||
}
|
||||
|
||||
public void translateList(int targetY) {
|
||||
if (targetY != getTranslationY()) {
|
||||
ObjectAnimator mover = ObjectAnimator.ofFloat(this, "translationY", targetY);
|
||||
mover.setDuration(150);
|
||||
mover.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
//mShadowView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (targetY == 0) {
|
||||
BusProvider.getInstance().send(new Events.AgendaListViewTouchedEvent());
|
||||
}
|
||||
//mShadowView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
mover.start();
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,279 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.calendar;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.calendar.weekslist.WeekListView;
|
||||
import com.github.tibolte.agendacalendarview.calendar.weekslist.WeeksAdapter;
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The calendar view is a freely scrolling view that allows the user to browse between days of the
|
||||
* year.
|
||||
*/
|
||||
public class CalendarView extends LinearLayout {
|
||||
|
||||
private static final String LOG_TAG = CalendarView.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* Top of the calendar view layout, the week days list
|
||||
*/
|
||||
private LinearLayout mDayNamesHeader;
|
||||
/**
|
||||
* Part of the calendar view layout always visible, the weeks list
|
||||
*/
|
||||
private WeekListView mListViewWeeks;
|
||||
/**
|
||||
* The adapter for the weeks list
|
||||
*/
|
||||
private WeeksAdapter mWeeksAdapter;
|
||||
/**
|
||||
* The current highlighted day in blue
|
||||
*/
|
||||
private IDayItem mSelectedDay;
|
||||
/**
|
||||
* The current row displayed at top of the list
|
||||
*/
|
||||
private int mCurrentListPosition;
|
||||
|
||||
// region Constructors
|
||||
|
||||
public CalendarView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CalendarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.view_calendar, this, true);
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
public IDayItem getSelectedDay() {
|
||||
return mSelectedDay;
|
||||
}
|
||||
|
||||
public void setSelectedDay(IDayItem mSelectedDay) {
|
||||
this.mSelectedDay = mSelectedDay;
|
||||
}
|
||||
|
||||
public WeekListView getListViewWeeks() {
|
||||
return mListViewWeeks;
|
||||
}
|
||||
|
||||
// region Class - View
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
mDayNamesHeader = (LinearLayout) findViewById(R.id.cal_day_names);
|
||||
mListViewWeeks = (WeekListView) findViewById(R.id.list_week);
|
||||
mListViewWeeks.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mListViewWeeks.setHasFixedSize(true);
|
||||
mListViewWeeks.setItemAnimator(null);
|
||||
mListViewWeeks.setSnapEnabled(true);
|
||||
|
||||
// display only two visible rows on the calendar view
|
||||
getViewTreeObserver().addOnGlobalLayoutListener(
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (getWidth() != 0 && getHeight() != 0) {
|
||||
collapseCalendarView();
|
||||
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
BusProvider.getInstance().toObserverable()
|
||||
.subscribe(event -> {
|
||||
if (event instanceof Events.CalendarScrolledEvent) {
|
||||
expandCalendarView();
|
||||
} else if (event instanceof Events.AgendaListViewTouchedEvent) {
|
||||
collapseCalendarView();
|
||||
} else if (event instanceof Events.DayClickedEvent) {
|
||||
Events.DayClickedEvent clickedEvent = (Events.DayClickedEvent) event;
|
||||
updateSelectedDay(clickedEvent.getCalendar(), clickedEvent.getDay());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void init(CalendarManager calendarManager, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> eventList) {
|
||||
Calendar today = calendarManager.getToday();
|
||||
Locale locale = calendarManager.getLocale();
|
||||
SimpleDateFormat weekDayFormatter = calendarManager.getWeekdayFormatter();
|
||||
List<IWeekItem> weeks = calendarManager.getWeeks();
|
||||
|
||||
setUpHeader(today, weekDayFormatter, locale);
|
||||
setUpAdapter(today, weeks, dayTextColor, currentDayTextColor, pastDayTextColor, eventList);
|
||||
scrollToDate(today, weeks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the Agenda list view changes section.
|
||||
*
|
||||
* @param calendarEvent The event for the selected position in the agenda listview.
|
||||
*/
|
||||
public void scrollToDate(final CalendarEvent calendarEvent) {
|
||||
mListViewWeeks.post(()->scrollToPosition(updateSelectedDay(calendarEvent.getInstanceDay(), calendarEvent.getDayReference())));
|
||||
}
|
||||
|
||||
public void scrollToDate(Calendar today, List<IWeekItem> weeks) {
|
||||
Integer currentWeekIndex = null;
|
||||
|
||||
for (int c = 0; c < weeks.size(); c++) {
|
||||
if (DateHelper.sameWeek(today, weeks.get(c))) {
|
||||
currentWeekIndex = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWeekIndex != null) {
|
||||
final Integer finalCurrentWeekIndex = currentWeekIndex;
|
||||
mListViewWeeks.post(() -> scrollToPosition(finalCurrentWeekIndex));
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int color) {
|
||||
mListViewWeeks.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Private methods
|
||||
|
||||
private void scrollToPosition(int targetPosition) {
|
||||
LinearLayoutManager layoutManager = ((LinearLayoutManager) mListViewWeeks.getLayoutManager());
|
||||
layoutManager.scrollToPosition(targetPosition);
|
||||
}
|
||||
|
||||
private void updateItemAtPosition(int position) {
|
||||
WeeksAdapter weeksAdapter = (WeeksAdapter) mListViewWeeks.getAdapter();
|
||||
weeksAdapter.notifyItemChanged(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new adapter if necessary and sets up its parameters.
|
||||
*/
|
||||
private void setUpAdapter(Calendar today, List<IWeekItem> weeks, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> events) {
|
||||
BusProvider.getInstance().toObserverable()
|
||||
.subscribe(event -> {
|
||||
if (event instanceof Events.EventsFetched) {
|
||||
//Log.d("CalendarView", "events size "+events.size());
|
||||
if (mWeeksAdapter == null) {
|
||||
//Log.d(LOG_TAG, "Setting adapter with today's calendar: " + today.toString());
|
||||
mWeeksAdapter = new WeeksAdapter(getContext(), today, dayTextColor, currentDayTextColor, pastDayTextColor, events);
|
||||
mListViewWeeks.setAdapter(mWeeksAdapter);
|
||||
}
|
||||
mWeeksAdapter.updateWeeksItems(weeks);
|
||||
}});
|
||||
|
||||
}
|
||||
|
||||
private void setUpHeader(Calendar today, SimpleDateFormat weekDayFormatter, Locale locale) {
|
||||
int daysPerWeek = 7;
|
||||
String[] dayLabels = new String[daysPerWeek];
|
||||
Calendar cal = Calendar.getInstance(CalendarManager.getInstance(getContext()).getLocale());
|
||||
cal.setTime(today.getTime());
|
||||
int firstDayOfWeek = cal.getFirstDayOfWeek();
|
||||
for (int count = 0; count < 7; count++) {
|
||||
cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek + count);
|
||||
if (locale.getLanguage().equals("en")) {
|
||||
dayLabels[count] = weekDayFormatter.format(cal.getTime()).toUpperCase(locale);
|
||||
} else {
|
||||
dayLabels[count] = weekDayFormatter.format(cal.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mDayNamesHeader.getChildCount(); i++) {
|
||||
TextView txtDay = (TextView) mDayNamesHeader.getChildAt(i);
|
||||
txtDay.setText(dayLabels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void expandCalendarView() {
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
||||
layoutParams.height = (int) (getResources().getDimension(R.dimen.calendar_header_height) + 5 * getResources().getDimension(R.dimen.day_cell_height));
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
private void collapseCalendarView() {
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
|
||||
layoutParams.height = (int) (getResources().getDimension(R.dimen.calendar_header_height) + 2 * getResources().getDimension(R.dimen.day_cell_height));
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a selected cell day item.
|
||||
*
|
||||
* @param calendar The Calendar instance of the day selected.
|
||||
* @param dayItem The DayItem information held by the cell item.
|
||||
* @return The selected row of the weeks list, to be updated.
|
||||
*/
|
||||
private int updateSelectedDay(Calendar calendar, IDayItem dayItem) {
|
||||
Integer currentWeekIndex = null;
|
||||
|
||||
// update highlighted/selected day
|
||||
if (!dayItem.equals(getSelectedDay())) {
|
||||
dayItem.setSelected(true);
|
||||
if (getSelectedDay() != null) {
|
||||
getSelectedDay().setSelected(false);
|
||||
}
|
||||
setSelectedDay(dayItem);
|
||||
}
|
||||
|
||||
for (int c = 0; c < CalendarManager.getInstance().getWeeks().size(); c++) {
|
||||
if (DateHelper.sameWeek(calendar, CalendarManager.getInstance().getWeeks().get(c))) {
|
||||
currentWeekIndex = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWeekIndex != null) {
|
||||
// highlighted day has changed, update the rows concerned
|
||||
if (currentWeekIndex != mCurrentListPosition) {
|
||||
updateItemAtPosition(mCurrentListPosition);
|
||||
}
|
||||
mCurrentListPosition = currentWeekIndex;
|
||||
updateItemAtPosition(currentWeekIndex);
|
||||
}
|
||||
|
||||
return mCurrentListPosition;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.calendar.weekslist;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class WeekListView extends RecyclerView {
|
||||
private boolean mUserScrolling = false;
|
||||
private boolean mScrolling = false;
|
||||
|
||||
// region Constructors
|
||||
|
||||
public WeekListView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WeekListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public WeekListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
/**
|
||||
* Enable snapping behaviour for this recyclerView
|
||||
*
|
||||
* @param enabled enable or disable the snapping behaviour
|
||||
*/
|
||||
public void setSnapEnabled(boolean enabled) {
|
||||
if (enabled) {
|
||||
addOnScrollListener(mScrollListener);
|
||||
} else {
|
||||
removeOnScrollListener(mScrollListener);
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Private methods
|
||||
|
||||
private OnScrollListener mScrollListener = new OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
final WeeksAdapter weeksAdapter = (WeeksAdapter) getAdapter();
|
||||
|
||||
switch (newState) {
|
||||
case SCROLL_STATE_IDLE:
|
||||
if (mUserScrolling) {
|
||||
scrollToView(getCenterView());
|
||||
postDelayed(() -> weeksAdapter.setDragging(false), 700); // Wait for recyclerView to settle
|
||||
}
|
||||
|
||||
mUserScrolling = false;
|
||||
mScrolling = false;
|
||||
break;
|
||||
// If scroll is caused by a touch (scroll touch, not any touch)
|
||||
case SCROLL_STATE_DRAGGING:
|
||||
BusProvider.getInstance().send(new Events.CalendarScrolledEvent());
|
||||
// If scroll was initiated already, this is not a user scrolling, but probably a tap, else set userScrolling
|
||||
if (!mScrolling) {
|
||||
mUserScrolling = true;
|
||||
}
|
||||
weeksAdapter.setDragging(true);
|
||||
break;
|
||||
case SCROLL_STATE_SETTLING:
|
||||
// The user's finger is not touching the list anymore, no need
|
||||
// for any alpha animation then
|
||||
weeksAdapter.setAlphaSet(true);
|
||||
mScrolling = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private View getChildClosestToPosition(int y) {
|
||||
if (getChildCount() <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int itemHeight = getChildAt(0).getMeasuredHeight();
|
||||
|
||||
int closestY = 9999;
|
||||
View closestChild = null;
|
||||
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
|
||||
int childCenterY = ((int) child.getY() + (itemHeight / 2));
|
||||
int yDistance = childCenterY - y;
|
||||
|
||||
// If child center is closer than previous closest, set it as closest
|
||||
if (Math.abs(yDistance) < Math.abs(closestY)) {
|
||||
closestY = yDistance;
|
||||
closestChild = child;
|
||||
}
|
||||
}
|
||||
|
||||
return closestChild;
|
||||
}
|
||||
|
||||
private View getCenterView() {
|
||||
return getChildClosestToPosition(getMeasuredHeight() / 2);
|
||||
}
|
||||
|
||||
private void scrollToView(View child) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
stopScroll();
|
||||
|
||||
int scrollDistance = getScrollDistance(child);
|
||||
|
||||
if (scrollDistance != 0) {
|
||||
smoothScrollBy(0, scrollDistance);
|
||||
}
|
||||
}
|
||||
|
||||
private int getScrollDistance(View child) {
|
||||
int itemHeight = getChildAt(0).getMeasuredHeight();
|
||||
int centerY = getMeasuredHeight() / 2;
|
||||
|
||||
int childCenterY = ((int) child.getY() + (itemHeight / 2));
|
||||
|
||||
return childCenterY - centerY;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,321 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.calendar.weekslist;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
||||
import com.github.tibolte.agendacalendarview.utils.BusProvider;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
import com.github.tibolte.agendacalendarview.utils.Events;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class WeeksAdapter extends RecyclerView.Adapter<WeeksAdapter.WeekViewHolder> {
|
||||
|
||||
public static final long FADE_DURATION = 250;
|
||||
|
||||
private Context mContext;
|
||||
private Calendar mToday;
|
||||
private List<IWeekItem> mWeeksList = new ArrayList<>();
|
||||
private List<CalendarEvent> mEventList = new ArrayList<>();
|
||||
private boolean mDragging;
|
||||
private boolean mAlphaSet;
|
||||
private int mDayTextColor, mPastDayTextColor, mCurrentDayColor;
|
||||
|
||||
// region Constructor
|
||||
|
||||
public WeeksAdapter(Context context, Calendar today, int dayTextColor, int currentDayTextColor, int pastDayTextColor, List<CalendarEvent> events) {
|
||||
this.mToday = today;
|
||||
this.mContext = context;
|
||||
this.mDayTextColor = dayTextColor;
|
||||
this.mCurrentDayColor = currentDayTextColor;
|
||||
this.mPastDayTextColor = pastDayTextColor;
|
||||
this.mEventList = events;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
public void updateWeeksItems(List<IWeekItem> weekItems) {
|
||||
this.mWeeksList.clear();
|
||||
this.mWeeksList.addAll(weekItems);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// region Getters/setters
|
||||
|
||||
public List<IWeekItem> getWeeksList() {
|
||||
return mWeeksList;
|
||||
}
|
||||
|
||||
public boolean isDragging() {
|
||||
return mDragging;
|
||||
}
|
||||
|
||||
public void setDragging(boolean dragging) {
|
||||
if (dragging != this.mDragging) {
|
||||
this.mDragging = dragging;
|
||||
notifyItemRangeChanged(0, mWeeksList.size());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlphaSet() {
|
||||
return mAlphaSet;
|
||||
}
|
||||
|
||||
public void setAlphaSet(boolean alphaSet) {
|
||||
mAlphaSet = alphaSet;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region RecyclerView.Adapter<WeeksAdapter.WeekViewHolder> methods
|
||||
|
||||
@Override
|
||||
public WeekViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_week, parent, false);
|
||||
return new WeekViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(WeekViewHolder weekViewHolder, int position) {
|
||||
IWeekItem weekItem = mWeeksList.get(position);
|
||||
weekViewHolder.bindWeek(weekItem, mToday);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mWeeksList.size();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Class - WeekViewHolder
|
||||
|
||||
public class WeekViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
/**
|
||||
* List of layout containers for each day
|
||||
*/
|
||||
private List<LinearLayout> mCells;
|
||||
private TextView mTxtMonth;
|
||||
private FrameLayout mMonthBackground;
|
||||
|
||||
public WeekViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTxtMonth = (TextView) itemView.findViewById(R.id.month_label);
|
||||
mMonthBackground = (FrameLayout) itemView.findViewById(R.id.month_background);
|
||||
LinearLayout daysContainer = (LinearLayout) itemView.findViewById(R.id.week_days_container);
|
||||
setUpChildren(daysContainer);
|
||||
}
|
||||
|
||||
public void bindWeek(IWeekItem weekItem, Calendar today) {
|
||||
setUpMonthOverlay();
|
||||
|
||||
List<IDayItem> dayItems = weekItem.getDayItems();
|
||||
|
||||
for (int c = 0; c < dayItems.size(); c++) {
|
||||
final IDayItem dayItem = dayItems.get(c);
|
||||
LinearLayout cellItem = mCells.get(c);
|
||||
TextView txtDay = (TextView) cellItem.findViewById(R.id.view_day_day_label);
|
||||
TextView txtMonth = (TextView) cellItem.findViewById(R.id.view_day_month_label);
|
||||
View circleView = cellItem.findViewById(R.id.view_day_circle_selected);
|
||||
View eventIndicator1 = cellItem.findViewById(R.id.view_day_event_indicator1);
|
||||
View eventIndicator2 = cellItem.findViewById(R.id.view_day_event_indicator2);
|
||||
View eventIndicator3 = cellItem.findViewById(R.id.view_day_event_indicator3);
|
||||
cellItem.setOnClickListener(v->BusProvider.getInstance().send(new Events.DayClickedEvent(dayItem)));
|
||||
|
||||
eventIndicator1.setVisibility(View.INVISIBLE);
|
||||
eventIndicator2.setVisibility(View.INVISIBLE);
|
||||
eventIndicator3.setVisibility(View.INVISIBLE);
|
||||
|
||||
Calendar dayItemCalendar = Calendar.getInstance();
|
||||
dayItemCalendar.setTime(dayItem.getDate());
|
||||
int eventCount = 0;
|
||||
for (CalendarEvent event: mEventList) {
|
||||
if (event.getStartTime().get(Calendar.YEAR) == dayItemCalendar.get(Calendar.YEAR)
|
||||
&& event.getStartTime().get(Calendar.MONTH) == dayItemCalendar.get(Calendar.MONTH)
|
||||
&& event.getStartTime().get(Calendar.DAY_OF_MONTH) == dayItemCalendar.get(Calendar.DAY_OF_MONTH)) {
|
||||
eventCount++;
|
||||
if (eventCount == 1) {
|
||||
eventIndicator1.setVisibility(View.VISIBLE);
|
||||
eventIndicator1.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
if (eventCount == 2) {
|
||||
eventIndicator2.setVisibility(View.VISIBLE);
|
||||
eventIndicator2.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
if (eventCount == 3) {
|
||||
eventIndicator3.setVisibility(View.VISIBLE);
|
||||
eventIndicator3.getBackground().setColorFilter(new PorterDuffColorFilter(event.getColor(),PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.d("CalendarView", "Event count for day "+dayItem.getValue()+" is "+eventCount);
|
||||
|
||||
txtMonth.setVisibility(View.GONE);
|
||||
txtDay.setTextColor(mDayTextColor);
|
||||
txtMonth.setTextColor(mDayTextColor);
|
||||
circleView.setVisibility(View.GONE);
|
||||
|
||||
txtDay.setTypeface(null, Typeface.NORMAL);
|
||||
txtMonth.setTypeface(null, Typeface.NORMAL);
|
||||
|
||||
// Display the day
|
||||
txtDay.setText(Integer.toString(dayItem.getValue()));
|
||||
|
||||
// Highlight first day of the month
|
||||
if (dayItem.isFirstDayOfTheMonth() && !dayItem.isSelected()) {
|
||||
txtMonth.setVisibility(View.VISIBLE);
|
||||
txtMonth.setText(dayItem.getMonth());
|
||||
txtDay.setTypeface(null, Typeface.BOLD);
|
||||
txtMonth.setTypeface(null, Typeface.BOLD);
|
||||
}
|
||||
|
||||
// Check if this day is in the past
|
||||
if (today.getTime().after(dayItem.getDate()) && !DateHelper.sameDate(today, dayItem.getDate())) {
|
||||
txtDay.setTextColor(mPastDayTextColor);
|
||||
txtMonth.setTextColor(mPastDayTextColor);
|
||||
}
|
||||
|
||||
// Highlight the cell if this day is today
|
||||
if (dayItem.isToday() && !dayItem.isSelected()) {
|
||||
txtDay.setTextColor(mCurrentDayColor);
|
||||
}
|
||||
|
||||
if (dayItem.getShowBadge()) {
|
||||
circleView.setVisibility(View.VISIBLE);
|
||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
||||
drawable.setStroke((int) (2 * Resources.getSystem().getDisplayMetrics().density), 0xffff0000);
|
||||
}
|
||||
|
||||
// Show a circle if the day is selected
|
||||
if (dayItem.isSelected()) {
|
||||
txtDay.setTextColor(mDayTextColor);
|
||||
circleView.setVisibility(View.VISIBLE);
|
||||
GradientDrawable drawable = (GradientDrawable) circleView.getBackground();
|
||||
drawable.setStroke((int) (1 * Resources.getSystem().getDisplayMetrics().density), mDayTextColor);
|
||||
}
|
||||
|
||||
// Check if the month label has to be displayed
|
||||
if (dayItem.getValue() == 15) {
|
||||
mTxtMonth.setVisibility(View.VISIBLE);
|
||||
SimpleDateFormat monthDateFormat = new SimpleDateFormat(mContext.getResources().getString(R.string.month_name_format), CalendarManager.getInstance().getLocale());
|
||||
String month = monthDateFormat.format(weekItem.getDate()).toUpperCase();
|
||||
if (today.get(Calendar.YEAR) != weekItem.getYear()) {
|
||||
month = month + String.format(" %d", weekItem.getYear());
|
||||
}
|
||||
mTxtMonth.setText(month);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpChildren(LinearLayout daysContainer) {
|
||||
mCells = new ArrayList<>();
|
||||
for (int i = 0; i < daysContainer.getChildCount(); i++) {
|
||||
mCells.add((LinearLayout) daysContainer.getChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpMonthOverlay() {
|
||||
mTxtMonth.setVisibility(View.GONE);
|
||||
|
||||
if (isDragging()) {
|
||||
AnimatorSet animatorSetFadeIn = new AnimatorSet();
|
||||
animatorSetFadeIn.setDuration(FADE_DURATION);
|
||||
ObjectAnimator animatorTxtAlphaIn = ObjectAnimator.ofFloat(mTxtMonth, "alpha", mTxtMonth.getAlpha(), 1f);
|
||||
ObjectAnimator animatorBackgroundAlphaIn = ObjectAnimator.ofFloat(mMonthBackground, "alpha", mMonthBackground.getAlpha(), 1f);
|
||||
animatorSetFadeIn.playTogether(
|
||||
animatorTxtAlphaIn
|
||||
//animatorBackgroundAlphaIn
|
||||
);
|
||||
animatorSetFadeIn.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
setAlphaSet(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
animatorSetFadeIn.start();
|
||||
} else {
|
||||
AnimatorSet animatorSetFadeOut = new AnimatorSet();
|
||||
animatorSetFadeOut.setDuration(FADE_DURATION);
|
||||
ObjectAnimator animatorTxtAlphaOut = ObjectAnimator.ofFloat(mTxtMonth, "alpha", mTxtMonth.getAlpha(), 0f);
|
||||
ObjectAnimator animatorBackgroundAlphaOut = ObjectAnimator.ofFloat(mMonthBackground, "alpha", mMonthBackground.getAlpha(), 0f);
|
||||
animatorSetFadeOut.playTogether(
|
||||
animatorTxtAlphaOut
|
||||
//animatorBackgroundAlphaOut
|
||||
);
|
||||
animatorSetFadeOut.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
setAlphaSet(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
animatorSetFadeOut.start();
|
||||
}
|
||||
|
||||
if (isAlphaSet()) {
|
||||
//mMonthBackground.setAlpha(1f);
|
||||
mTxtMonth.setAlpha(1f);
|
||||
} else {
|
||||
//mMonthBackground.setAlpha(0f);
|
||||
mTxtMonth.setAlpha(0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,345 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Event model class containing the information to be displayed on the agenda view.
|
||||
*/
|
||||
public class BaseCalendarEvent implements CalendarEvent {
|
||||
|
||||
/**
|
||||
* Id of the event.
|
||||
*/
|
||||
private long mId;
|
||||
/**
|
||||
* Color to be displayed in the agenda view.
|
||||
*/
|
||||
private int mColor;
|
||||
/**
|
||||
* Text color displayed on the background color
|
||||
*/
|
||||
private int mTextColor;
|
||||
/**
|
||||
* Title of the event.
|
||||
*/
|
||||
private String mTitle;
|
||||
/**
|
||||
* Description of the event.
|
||||
*/
|
||||
private String mDescription;
|
||||
/**
|
||||
* Where the event takes place.
|
||||
*/
|
||||
private String mLocation;
|
||||
/**
|
||||
* Calendar instance helping sorting the events per section in the agenda view.
|
||||
*/
|
||||
private Calendar mInstanceDay;
|
||||
/**
|
||||
* Start time of the event.
|
||||
*/
|
||||
private Calendar mStartTime;
|
||||
/**
|
||||
* End time of the event.
|
||||
*/
|
||||
private Calendar mEndTime;
|
||||
/**
|
||||
* Indicates if the event lasts all day.
|
||||
*/
|
||||
private boolean mAllDay;
|
||||
/**
|
||||
* Tells if this BaseCalendarEvent instance is used as a placeholder in the agenda view, if there's
|
||||
* no event for that day.
|
||||
*/
|
||||
private boolean mPlaceHolder;
|
||||
/**
|
||||
* Tells if this BaseCalendarEvent instance is used as a forecast information holder in the agenda
|
||||
* view.
|
||||
*/
|
||||
private boolean mWeather;
|
||||
/**
|
||||
* Duration of the event.
|
||||
*/
|
||||
private String mDuration;
|
||||
/**
|
||||
* References to a DayItem instance for that event, used to link interaction between the
|
||||
* calendar view and the agenda view.
|
||||
*/
|
||||
private IDayItem mDayReference;
|
||||
/**
|
||||
* References to a WeekItem instance for that event, used to link interaction between the
|
||||
* calendar view and the agenda view.
|
||||
*/
|
||||
private IWeekItem mWeekReference;
|
||||
/**
|
||||
* Weather icon string returned by the Dark Sky API.
|
||||
*/
|
||||
private String mWeatherIcon;
|
||||
/**
|
||||
* Temperature value returned by the Dark Sky API.
|
||||
*/
|
||||
private double mTemperature;
|
||||
|
||||
private boolean mShowBadge;
|
||||
|
||||
// region Constructor
|
||||
|
||||
/**
|
||||
* Initializes the event
|
||||
*
|
||||
* @param id The id of the event.
|
||||
* @param color The color of the event.
|
||||
* @param textColor The color of the event description text.
|
||||
* @param title The title of the event.
|
||||
* @param description The description of the event.
|
||||
* @param location The location of the event.
|
||||
* @param dateStart The start date of the event.
|
||||
* @param dateEnd The end date of the event.
|
||||
* @param allDay Int that can be equal to 0 or 1.
|
||||
* @param duration The duration of the event in RFC2445 format.
|
||||
*/
|
||||
public BaseCalendarEvent(long id, int color, int textColor, String title, String description, String location, long dateStart, long dateEnd, int allDay, String duration) {
|
||||
this.mId = id;
|
||||
this.mColor = color;
|
||||
this.mTextColor = textColor;
|
||||
this.mAllDay = (allDay == 1);
|
||||
this.mDuration = duration;
|
||||
this.mTitle = title;
|
||||
this.mDescription = description;
|
||||
this.mLocation = location;
|
||||
|
||||
this.mStartTime = Calendar.getInstance();
|
||||
this.mStartTime.setTimeInMillis(dateStart);
|
||||
this.mEndTime = Calendar.getInstance();
|
||||
this.mEndTime.setTimeInMillis(dateEnd);
|
||||
}
|
||||
|
||||
public BaseCalendarEvent() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the event
|
||||
* @param title The title of the event.
|
||||
* @param description The description of the event.
|
||||
* @param location The location of the event.
|
||||
* @param color The color of the event (for display in the app).
|
||||
* @param textColor The color of the event description text.
|
||||
* @param startTime The start time of the event.
|
||||
* @param endTime The end time of the event.
|
||||
* @param allDay Indicates if the event lasts the whole day.
|
||||
*/
|
||||
public BaseCalendarEvent(String title, String description, String location, int color, int textColor, Calendar startTime, Calendar endTime, boolean allDay) {
|
||||
this.mTitle = title;
|
||||
this.mDescription = description;
|
||||
this.mLocation = location;
|
||||
this.mColor = color;
|
||||
this.mTextColor = textColor;
|
||||
this.mStartTime = startTime;
|
||||
this.mEndTime = endTime;
|
||||
this.mAllDay = allDay;
|
||||
}
|
||||
|
||||
public BaseCalendarEvent(String title, String description, String location, int color, int textColor, Calendar startTime, Calendar endTime, boolean allDay, long id, boolean showBadge) {
|
||||
this.mTitle = title;
|
||||
this.mDescription = description;
|
||||
this.mLocation = location;
|
||||
this.mColor = color;
|
||||
this.mTextColor = textColor;
|
||||
this.mStartTime = startTime;
|
||||
this.mEndTime = endTime;
|
||||
this.mAllDay = allDay;
|
||||
this.mId = id;
|
||||
this.mShowBadge = showBadge;
|
||||
}
|
||||
|
||||
public BaseCalendarEvent(BaseCalendarEvent calendarEvent) {
|
||||
this.mId = calendarEvent.getId();
|
||||
this.mColor = calendarEvent.getColor();
|
||||
this.mTextColor = calendarEvent.getTextColor();
|
||||
this.mAllDay = calendarEvent.isAllDay();
|
||||
this.mDuration = calendarEvent.getDuration();
|
||||
this.mTitle = calendarEvent.getTitle();
|
||||
this.mDescription = calendarEvent.getDescription();
|
||||
this.mLocation = calendarEvent.getLocation();
|
||||
this.mStartTime = calendarEvent.getStartTime();
|
||||
this.mEndTime = calendarEvent.getEndTime();
|
||||
this.mShowBadge = calendarEvent.getShowBadge();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Getters/Setters
|
||||
|
||||
public int getColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public void setColor(int mColor) {
|
||||
this.mColor = mColor;
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return mTextColor;
|
||||
}
|
||||
|
||||
public void setTextColor(int mTextColor) {
|
||||
this.mTextColor = mTextColor;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
public boolean isAllDay() {
|
||||
return mAllDay;
|
||||
}
|
||||
|
||||
public void setAllDay(boolean allDay) {
|
||||
this.mAllDay = allDay;
|
||||
}
|
||||
|
||||
public void setDescription(String mDescription) {
|
||||
this.mDescription = mDescription;
|
||||
}
|
||||
|
||||
public Calendar getInstanceDay() {
|
||||
return mInstanceDay;
|
||||
}
|
||||
|
||||
public void setInstanceDay(Calendar mInstanceDay) {
|
||||
this.mInstanceDay = mInstanceDay;
|
||||
this.mInstanceDay.set(Calendar.HOUR, 0);
|
||||
this.mInstanceDay.set(Calendar.MINUTE, 0);
|
||||
this.mInstanceDay.set(Calendar.SECOND, 0);
|
||||
this.mInstanceDay.set(Calendar.MILLISECOND, 0);
|
||||
this.mInstanceDay.set(Calendar.AM_PM, 0);
|
||||
}
|
||||
|
||||
public Calendar getEndTime() {
|
||||
return mEndTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Calendar mEndTime) {
|
||||
this.mEndTime = mEndTime;
|
||||
}
|
||||
public void setPlaceholder(boolean placeholder) {
|
||||
mPlaceHolder = placeholder;
|
||||
}
|
||||
public boolean isPlaceholder() {
|
||||
return mPlaceHolder;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
public void setId(long mId) {
|
||||
this.mId = mId;
|
||||
}
|
||||
|
||||
public boolean getShowBadge() {
|
||||
return mShowBadge;
|
||||
}
|
||||
|
||||
public void setShowBadge(boolean mShowBadge) {
|
||||
this.mShowBadge = mShowBadge;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
public void setLocation(String mLocation) {
|
||||
this.mLocation = mLocation;
|
||||
}
|
||||
|
||||
public Calendar getStartTime() {
|
||||
return mStartTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Calendar mStartTime) {
|
||||
this.mStartTime = mStartTime;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public void setTitle(String mTitle) {
|
||||
this.mTitle = mTitle;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
public void setDuration(String duration) {
|
||||
this.mDuration = duration;
|
||||
}
|
||||
|
||||
public boolean isPlaceHolder() {
|
||||
return mPlaceHolder;
|
||||
}
|
||||
|
||||
public void setPlaceHolder(boolean mPlaceHolder) {
|
||||
this.mPlaceHolder = mPlaceHolder;
|
||||
}
|
||||
|
||||
public boolean isWeather() {
|
||||
return mWeather;
|
||||
}
|
||||
|
||||
public void setWeather(boolean mWeather) {
|
||||
this.mWeather = mWeather;
|
||||
}
|
||||
|
||||
public IDayItem getDayReference() {
|
||||
return mDayReference;
|
||||
}
|
||||
|
||||
public void setDayReference(IDayItem mDayReference) {
|
||||
this.mDayReference = mDayReference;
|
||||
}
|
||||
|
||||
public IWeekItem getWeekReference() {
|
||||
return mWeekReference;
|
||||
}
|
||||
|
||||
public void setWeekReference(IWeekItem mWeekReference) {
|
||||
this.mWeekReference = mWeekReference;
|
||||
}
|
||||
|
||||
public String getWeatherIcon() {
|
||||
return mWeatherIcon;
|
||||
}
|
||||
|
||||
public void setWeatherIcon(String mWeatherIcon) {
|
||||
this.mWeatherIcon = mWeatherIcon;
|
||||
}
|
||||
|
||||
public double getTemperature() {
|
||||
return mTemperature;
|
||||
}
|
||||
|
||||
public void setTemperature(double mTemperature) {
|
||||
this.mTemperature = mTemperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalendarEvent copy() {
|
||||
return new BaseCalendarEvent(this);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseCalendarEvent{"
|
||||
+ "title='"
|
||||
+ mTitle
|
||||
+ ", instanceDay= "
|
||||
+ mInstanceDay.getTime()
|
||||
+ "}";
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public interface CalendarEvent {
|
||||
|
||||
|
||||
void setPlaceholder(boolean placeholder);
|
||||
|
||||
boolean isPlaceholder();
|
||||
|
||||
public String getLocation();
|
||||
|
||||
public void setLocation(String mLocation);
|
||||
|
||||
long getId();
|
||||
|
||||
void setId(long mId);
|
||||
|
||||
boolean getShowBadge();
|
||||
|
||||
void setShowBadge(boolean mShowBadge);
|
||||
|
||||
int getTextColor();
|
||||
|
||||
void setTextColor(int mTextColor);
|
||||
|
||||
String getDescription();
|
||||
|
||||
void setDescription(String mDescription);
|
||||
|
||||
boolean isAllDay();
|
||||
|
||||
void setAllDay(boolean allDay);
|
||||
|
||||
Calendar getStartTime();
|
||||
|
||||
void setStartTime(Calendar mStartTime);
|
||||
|
||||
Calendar getEndTime();
|
||||
|
||||
void setEndTime(Calendar mEndTime);
|
||||
|
||||
String getTitle();
|
||||
|
||||
void setTitle(String mTitle);
|
||||
|
||||
Calendar getInstanceDay();
|
||||
|
||||
void setInstanceDay(Calendar mInstanceDay);
|
||||
|
||||
IDayItem getDayReference();
|
||||
|
||||
void setDayReference(IDayItem mDayReference);
|
||||
|
||||
IWeekItem getWeekReference();
|
||||
|
||||
void setWeekReference(IWeekItem mWeekReference);
|
||||
|
||||
CalendarEvent copy();
|
||||
|
||||
int getColor();
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.utils.DateHelper;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Day model class.
|
||||
*/
|
||||
public class DayItem implements IDayItem {
|
||||
private Date mDate;
|
||||
private int mValue;
|
||||
private int mDayOfTheWeek;
|
||||
private boolean mToday;
|
||||
private boolean mFirstDayOfTheMonth;
|
||||
private boolean mSelected;
|
||||
private String mMonth;
|
||||
private boolean mShowBadge;
|
||||
|
||||
// region Constructor
|
||||
|
||||
public DayItem(Date date, int value, boolean today, String month) {
|
||||
this.mDate = date;
|
||||
this.mValue = value;
|
||||
this.mToday = today;
|
||||
this.mMonth = month;
|
||||
}
|
||||
// only for cleanDay
|
||||
public DayItem() {
|
||||
|
||||
}
|
||||
public DayItem(DayItem original) {
|
||||
|
||||
this.mDate = original.getDate();
|
||||
this.mValue = original.getValue();
|
||||
this.mToday = original.isToday();
|
||||
this.mDayOfTheWeek = original.getDayOftheWeek();
|
||||
this.mFirstDayOfTheMonth = original.isFirstDayOfTheMonth();
|
||||
this.mSelected = original.isSelected();
|
||||
this.mMonth = original.getMonth();
|
||||
this.mShowBadge = original.mShowBadge;
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Getters/Setters
|
||||
|
||||
public Date getDate() {
|
||||
return mDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.mDate = date;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.mValue = value;
|
||||
}
|
||||
|
||||
public boolean isToday() {
|
||||
return mToday;
|
||||
}
|
||||
|
||||
public void setToday(boolean today) {
|
||||
this.mToday = today;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.mSelected = selected;
|
||||
}
|
||||
|
||||
public boolean isFirstDayOfTheMonth() {
|
||||
return mFirstDayOfTheMonth;
|
||||
}
|
||||
|
||||
public void setFirstDayOfTheMonth(boolean firstDayOfTheMonth) {
|
||||
this.mFirstDayOfTheMonth = firstDayOfTheMonth;
|
||||
}
|
||||
|
||||
public String getMonth() {
|
||||
return mMonth;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.mMonth = month;
|
||||
}
|
||||
|
||||
public int getDayOftheWeek() {
|
||||
return mDayOfTheWeek;
|
||||
}
|
||||
|
||||
public void setDayOftheWeek(int mDayOftheWeek) {
|
||||
this.mDayOfTheWeek = mDayOftheWeek;
|
||||
}
|
||||
|
||||
public void setShowBadge(boolean showBadge) {
|
||||
this.mShowBadge = showBadge;
|
||||
}
|
||||
|
||||
public boolean getShowBadge() {
|
||||
return this.mShowBadge;
|
||||
}
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void buildDayItemFromCal(Calendar calendar) {
|
||||
Date date = calendar.getTime();
|
||||
this.mDate = date;
|
||||
|
||||
this.mValue = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
this.mToday = DateHelper.sameDate(calendar, CalendarManager.getInstance().getToday());
|
||||
this.mMonth = CalendarManager.getInstance().getMonthHalfNameFormat().format(date);
|
||||
if (this.mValue == 1) {
|
||||
this.mFirstDayOfTheMonth = true;
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DayItem{"
|
||||
+ "Date='"
|
||||
+ mDate.toString()
|
||||
+ ", value="
|
||||
+ mValue
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDayItem copy() {
|
||||
return new DayItem(this);
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public interface IDayItem {
|
||||
|
||||
// region Getters/Setters
|
||||
|
||||
Date getDate();
|
||||
|
||||
void setDate(Date date);
|
||||
|
||||
int getValue();
|
||||
|
||||
void setValue(int value);
|
||||
|
||||
boolean isToday();
|
||||
|
||||
void setToday(boolean today);
|
||||
|
||||
boolean isSelected();
|
||||
|
||||
void setSelected(boolean selected);
|
||||
|
||||
boolean isFirstDayOfTheMonth();
|
||||
|
||||
void setFirstDayOfTheMonth(boolean firstDayOfTheMonth);
|
||||
|
||||
String getMonth();
|
||||
|
||||
void setMonth(String month);
|
||||
|
||||
int getDayOftheWeek();
|
||||
|
||||
void setDayOftheWeek(int mDayOftheWeek);
|
||||
|
||||
// endregion
|
||||
|
||||
void buildDayItemFromCal(Calendar calendar);
|
||||
|
||||
String toString();
|
||||
|
||||
IDayItem copy();
|
||||
|
||||
void setShowBadge(boolean showBadge);
|
||||
|
||||
boolean getShowBadge();
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface IWeekItem {
|
||||
|
||||
|
||||
int getWeekInYear();
|
||||
|
||||
void setWeekInYear(int weekInYear);
|
||||
|
||||
int getYear();
|
||||
|
||||
void setYear(int year);
|
||||
|
||||
int getMonth();
|
||||
|
||||
void setMonth(int month);
|
||||
|
||||
Date getDate();
|
||||
|
||||
void setDate(Date date);
|
||||
|
||||
String getLabel();
|
||||
|
||||
void setLabel(String label);
|
||||
|
||||
List<IDayItem> getDayItems();
|
||||
|
||||
void setDayItems(List<IDayItem> dayItems);
|
||||
|
||||
IWeekItem copy();
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.models;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Week model class.
|
||||
*/
|
||||
public class WeekItem implements IWeekItem {
|
||||
private int mWeekInYear;
|
||||
private int mYear;
|
||||
private int mMonth;
|
||||
private Date mDate;
|
||||
private String mLabel;
|
||||
private List<IDayItem> mDayItems;
|
||||
|
||||
// region Constructor
|
||||
|
||||
public WeekItem(int weekInYear, int year, Date date, String label, int month) {
|
||||
this.mWeekInYear = weekInYear;
|
||||
this.mYear = year;
|
||||
this.mDate = date;
|
||||
this.mLabel = label;
|
||||
this.mMonth = month;
|
||||
}
|
||||
public WeekItem(WeekItem original) {
|
||||
this.mWeekInYear = original.getWeekInYear();
|
||||
this.mYear = original.getYear();
|
||||
this.mMonth = original.getMonth();
|
||||
this.mDate = original.getDate();
|
||||
this.mLabel = original.getLabel();
|
||||
this.mDayItems = original.getDayItems();
|
||||
}
|
||||
|
||||
public WeekItem(){
|
||||
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Getters/Setters
|
||||
|
||||
public int getWeekInYear() {
|
||||
return mWeekInYear;
|
||||
}
|
||||
|
||||
public void setWeekInYear(int weekInYear) {
|
||||
this.mWeekInYear = weekInYear;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return mYear;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
this.mYear = year;
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
return mMonth;
|
||||
}
|
||||
|
||||
public void setMonth(int month) {
|
||||
this.mMonth = month;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return mDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.mDate = date;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.mLabel = label;
|
||||
}
|
||||
|
||||
public List<IDayItem> getDayItems() {
|
||||
return mDayItems;
|
||||
}
|
||||
|
||||
public void setDayItems(List<IDayItem> dayItems) {
|
||||
this.mDayItems = dayItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWeekItem copy() {
|
||||
return new WeekItem(this);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeekItem{"
|
||||
+ "label='"
|
||||
+ mLabel
|
||||
+ '\''
|
||||
+ ", weekInYear="
|
||||
+ mWeekInYear
|
||||
+ ", year="
|
||||
+ mYear
|
||||
+ '}';
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.render;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.models.BaseCalendarEvent;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
|
||||
/**
|
||||
* Class helping to inflate our default layout in the AgendaAdapter
|
||||
*/
|
||||
public class DefaultEventRenderer extends EventRenderer<BaseCalendarEvent> {
|
||||
|
||||
public static int themeAttributeToColor(int themeAttributeId,
|
||||
Context context,
|
||||
int fallbackColorId) {
|
||||
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 fallbackColorId;
|
||||
}
|
||||
}
|
||||
|
||||
// region class - EventRenderer
|
||||
|
||||
@Override
|
||||
public void render(@NonNull View view, @NonNull BaseCalendarEvent event) {
|
||||
CardView card = view.findViewById(R.id.view_agenda_event_card_view);
|
||||
TextView txtTitle = view.findViewById(R.id.view_agenda_event_title);
|
||||
TextView txtLocation = view.findViewById(R.id.view_agenda_event_location);
|
||||
LinearLayout descriptionContainer = view.findViewById(R.id.view_agenda_event_description_container);
|
||||
LinearLayout locationContainer = view.findViewById(R.id.view_agenda_event_location_container);
|
||||
|
||||
descriptionContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
txtTitle.setText(event.getTitle());
|
||||
txtLocation.setText(event.getLocation());
|
||||
if (event.getLocation().length() > 0) {
|
||||
locationContainer.setVisibility(View.VISIBLE);
|
||||
txtLocation.setText(event.getLocation());
|
||||
} else {
|
||||
locationContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!event.isPlaceholder()/*!event.getTitle().equals(view.getResources().getString(R.string.agenda_event_no_events))*/) {
|
||||
txtTitle.setTextColor(event.getTextColor());
|
||||
card.setCardBackgroundColor(event.getColor());
|
||||
txtLocation.setTextColor(event.getTextColor());
|
||||
}
|
||||
else {
|
||||
card.setCardBackgroundColor(Color.TRANSPARENT);
|
||||
card.setCardElevation(0);
|
||||
card.setBackgroundColor(Color.TRANSPARENT);
|
||||
card.setRadius(0);
|
||||
card.setBackgroundDrawable(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEventLayout() {
|
||||
return R.layout.view_agenda_event;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.render;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import android.view.View;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.models.CalendarEvent;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
/**
|
||||
* Base class for helping layout rendering
|
||||
*/
|
||||
public abstract class EventRenderer<T extends CalendarEvent> {
|
||||
public abstract void render(final View view, final T event);
|
||||
|
||||
@LayoutRes
|
||||
public abstract int getEventLayout();
|
||||
|
||||
public Class<T> getRenderType() {
|
||||
ParameterizedType type = (ParameterizedType) getClass().getGenericSuperclass();
|
||||
return (Class<T>) type.getActualTypeArguments()[0];
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.utils;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.subjects.PublishSubject;
|
||||
import rx.subjects.SerializedSubject;
|
||||
import rx.subjects.Subject;
|
||||
|
||||
public class BusProvider {
|
||||
|
||||
public static BusProvider mInstance;
|
||||
|
||||
private final Subject<Object, Object> mBus = new SerializedSubject<>(PublishSubject.create());
|
||||
|
||||
// region Constructors
|
||||
|
||||
public static BusProvider getInstance() {
|
||||
if (mInstance == null) {
|
||||
mInstance = new BusProvider();
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void send(Object object) {
|
||||
mBus.onNext(object);
|
||||
}
|
||||
|
||||
public Observable<Object> toObserverable() {
|
||||
return mBus;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.utils;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.CalendarManager;
|
||||
import com.github.tibolte.agendacalendarview.R;
|
||||
import com.github.tibolte.agendacalendarview.models.IWeekItem;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Class containing helper functions for dates
|
||||
*/
|
||||
public class DateHelper {
|
||||
|
||||
// region Public methods
|
||||
|
||||
/**
|
||||
* Check if two Calendar instances have the same time (by month, year and day of month)
|
||||
*
|
||||
* @param cal The first Calendar instance.
|
||||
* @param selectedDate The second Calendar instance.
|
||||
* @return True if both instances have the same time.
|
||||
*/
|
||||
public static boolean sameDate(Calendar cal, Calendar selectedDate) {
|
||||
return cal.get(Calendar.MONTH) == selectedDate.get(Calendar.MONTH)
|
||||
&& cal.get(Calendar.YEAR) == selectedDate.get(Calendar.YEAR)
|
||||
&& cal.get(Calendar.DAY_OF_MONTH) == selectedDate.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Date instance and a Calendar instance have the same time (by month, year and day
|
||||
* of month)
|
||||
*
|
||||
* @param cal The Calendar instance.
|
||||
* @param selectedDate The Date instance.
|
||||
* @return True if both have the same time.
|
||||
*/
|
||||
public static boolean sameDate(Calendar cal, Date selectedDate) {
|
||||
Calendar selectedCal = Calendar.getInstance();
|
||||
selectedCal.setTime(selectedDate);
|
||||
return cal.get(Calendar.MONTH) == selectedCal.get(Calendar.MONTH)
|
||||
&& cal.get(Calendar.YEAR) == selectedCal.get(Calendar.YEAR)
|
||||
&& cal.get(Calendar.DAY_OF_MONTH) == selectedCal.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Date instance is between two Calendar instances' dates (inclusively) in time.
|
||||
*
|
||||
* @param selectedDate The date to verify.
|
||||
* @param startCal The start time.
|
||||
* @param endCal The end time.
|
||||
* @return True if the verified date is between the two specified dates.
|
||||
*/
|
||||
public static boolean isBetweenInclusive(Date selectedDate, Calendar startCal, Calendar endCal) {
|
||||
Calendar selectedCal = Calendar.getInstance();
|
||||
selectedCal.setTime(selectedDate);
|
||||
// Check if we deal with the same day regarding startCal and endCal
|
||||
return sameDate(selectedCal, startCal) || selectedCal.after(startCal) && selectedCal.before(endCal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Calendar instance's date is in the same week, as the WeekItem instance.
|
||||
*
|
||||
* @param cal The Calendar instance to verify.
|
||||
* @param week The WeekItem instance to compare to.
|
||||
* @return True if both instances are in the same week.
|
||||
*/
|
||||
public static boolean sameWeek(Calendar cal, IWeekItem week) {
|
||||
return (cal.get(Calendar.WEEK_OF_YEAR) == week.getWeekInYear() && cal.get(Calendar.YEAR) == week.getYear());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a millisecond duration to a string format
|
||||
*
|
||||
* @param millis A duration to convert to a string form
|
||||
* @return A string of the form "Xd" or either "XhXm".
|
||||
*/
|
||||
public static String getDuration(Context context, long millis) {
|
||||
if (millis < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
}
|
||||
|
||||
long days = TimeUnit.MILLISECONDS.toDays(millis);
|
||||
millis -= TimeUnit.DAYS.toMillis(days);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(millis);
|
||||
millis -= TimeUnit.HOURS.toMillis(hours);
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
|
||||
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
if (days > 0) {
|
||||
sb.append(days);
|
||||
sb.append(context.getResources().getString(R.string.agenda_event_day_duration));
|
||||
return (sb.toString());
|
||||
} else {
|
||||
if (hours > 0) {
|
||||
sb.append(hours);
|
||||
sb.append("h");
|
||||
}
|
||||
if (minutes > 0) {
|
||||
sb.append(minutes);
|
||||
sb.append("m");
|
||||
}
|
||||
}
|
||||
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for displaying the date in any section of the agenda view.
|
||||
*
|
||||
* @param calendar The date of the section.
|
||||
* @param locale The locale used by the Sunrise calendar.
|
||||
* @return The formatted date without the year included.
|
||||
*/
|
||||
public static String getYearLessLocalizedDate(Calendar calendar, Locale locale) {
|
||||
SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.FULL, CalendarManager.getInstance().getLocale());
|
||||
String pattern = sdf.toPattern();
|
||||
|
||||
String yearLessPattern = pattern.replaceAll("\\W?[Yy]+\\W?", "");
|
||||
SimpleDateFormat yearLessSDF = new SimpleDateFormat(yearLessPattern, locale);
|
||||
String yearLessDate = yearLessSDF.format(calendar.getTime()).toUpperCase();
|
||||
if (yearLessDate.endsWith(",")) {
|
||||
yearLessDate = yearLessDate.substring(0, yearLessDate.length() - 1);
|
||||
}
|
||||
return yearLessDate;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.utils;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.models.IDayItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Events emitted by the bus provider.
|
||||
*/
|
||||
public class Events {
|
||||
|
||||
public static class DayClickedEvent {
|
||||
|
||||
public Calendar mCalendar;
|
||||
public IDayItem mDayItem;
|
||||
|
||||
public DayClickedEvent(IDayItem dayItem) {
|
||||
this.mCalendar = Calendar.getInstance();
|
||||
this.mCalendar.setTime(dayItem.getDate());
|
||||
this.mDayItem = dayItem;
|
||||
}
|
||||
|
||||
public Calendar getCalendar() {
|
||||
return mCalendar;
|
||||
}
|
||||
|
||||
public IDayItem getDay() {
|
||||
return mDayItem;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CalendarScrolledEvent {
|
||||
}
|
||||
|
||||
public static class AgendaListViewTouchedEvent {
|
||||
}
|
||||
|
||||
public static class EventsFetched {
|
||||
}
|
||||
|
||||
public static class ForecastFetched {
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.utils;
|
||||
|
||||
import com.github.tibolte.agendacalendarview.agenda.AgendaListView;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Helper class calculating the scrolling distance in the AgendaListView.
|
||||
*/
|
||||
public class ListViewScrollTracker {
|
||||
private AgendaListView mListView;
|
||||
private SparseArray<Integer> mPositions;
|
||||
private SparseArray<Integer> mListViewItemHeights = new SparseArray<>();
|
||||
private int mFirstVisiblePosition;
|
||||
private int mReferencePosition = -1; // Position of the current date in the Agenda listView
|
||||
|
||||
// region Constructor and Accessor(s)
|
||||
|
||||
public ListViewScrollTracker(AgendaListView listView) {
|
||||
mListView = listView;
|
||||
}
|
||||
|
||||
public int getReferencePosition() {
|
||||
return mReferencePosition;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
/**
|
||||
* Call from an AbsListView.OnScrollListener to calculate the incremental offset (change in
|
||||
* scroll offset
|
||||
* since the last calculation).
|
||||
*
|
||||
* @param firstVisiblePosition First visible item position in the list.
|
||||
* @param visibleItemCount Number of visible items in the list.
|
||||
* @return The incremental offset, or 0 if it wasn't possible to calculate the offset.
|
||||
*/
|
||||
public int calculateIncrementalOffset(int firstVisiblePosition, int visibleItemCount) {
|
||||
// Remember previous positions, if any
|
||||
SparseArray<Integer> previousPositions = mPositions;
|
||||
|
||||
// Store new positions
|
||||
mPositions = new SparseArray<>();
|
||||
for (int i = 0; i < visibleItemCount; i++) {
|
||||
mPositions.put(firstVisiblePosition + i, mListView.getListChildAt(i).getTop());
|
||||
}
|
||||
|
||||
if (previousPositions != null) {
|
||||
// Find position which exists in both mPositions and previousPositions, then return the difference
|
||||
// of the new and old Y values.
|
||||
for (int i = 0; i < previousPositions.size(); i++) {
|
||||
int previousPosition = previousPositions.keyAt(i);
|
||||
int previousTop = previousPositions.get(previousPosition);
|
||||
Integer newTop = mPositions.get(previousPosition);
|
||||
if (newTop != null) {
|
||||
return newTop - previousTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // No view's position was in both previousPositions and mPositions
|
||||
}
|
||||
|
||||
/**
|
||||
* Call from an AbsListView.OnScrollListener to calculate the scrollY (Here
|
||||
* we definite as the distance in pixels compared to the position representing the current
|
||||
* date).
|
||||
*
|
||||
* @param firstVisiblePosition First visible item position in the list.
|
||||
* @param visibleItemCount Number of visible items in the list.
|
||||
* @return Distance in pixels compared to current day position (negative if firstVisiblePosition less than mReferencePosition)
|
||||
*/
|
||||
public int calculateScrollY(int firstVisiblePosition, int visibleItemCount) {
|
||||
mFirstVisiblePosition = firstVisiblePosition;
|
||||
if (mReferencePosition < 0) {
|
||||
mReferencePosition = mFirstVisiblePosition;
|
||||
}
|
||||
|
||||
if (visibleItemCount > 0) {
|
||||
View c = mListView.getListChildAt(0); // this is the first visible row
|
||||
int scrollY = -c.getTop();
|
||||
mListViewItemHeights.put(firstVisiblePosition, c.getMeasuredHeight());
|
||||
|
||||
if (mFirstVisiblePosition >= mReferencePosition) {
|
||||
for (int i = mReferencePosition; i < firstVisiblePosition; ++i) {
|
||||
if (mListViewItemHeights.get(i) == null) {
|
||||
mListViewItemHeights.put(i, c.getMeasuredHeight());
|
||||
}
|
||||
scrollY += mListViewItemHeights.get(i); // add all heights of the views that are gone
|
||||
}
|
||||
return scrollY;
|
||||
} else {
|
||||
for (int i = mReferencePosition - 1; i >= firstVisiblePosition; --i) {
|
||||
if (mListViewItemHeights.get(i) == null) {
|
||||
mListViewItemHeights.put(i, c.getMeasuredHeight());
|
||||
}
|
||||
scrollY -= mListViewItemHeights.get(i);
|
||||
}
|
||||
return scrollY;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mPositions = null;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package com.github.tibolte.agendacalendarview.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
/**
|
||||
* Floating action button helping to scroll back to the current date.
|
||||
*/
|
||||
public class FloatingActionButton extends com.google.android.material.floatingactionbutton.FloatingActionButton {
|
||||
private static final int TRANSLATE_DURATION_MILLIS = 200;
|
||||
|
||||
private boolean mVisible = true;
|
||||
|
||||
private final Interpolator mInterpolator = new AccelerateDecelerateInterpolator();
|
||||
|
||||
// region Constructors
|
||||
|
||||
public FloatingActionButton(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FloatingActionButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Overrides
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
show(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
hide(true);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Public methods
|
||||
|
||||
public void show(boolean animate) {
|
||||
toggle(true, animate, false);
|
||||
}
|
||||
|
||||
public void hide(boolean animate) {
|
||||
toggle(false, animate, false);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Private methods
|
||||
|
||||
private void toggle(final boolean visible, final boolean animate, boolean force) {
|
||||
if (mVisible != visible || force) {
|
||||
mVisible = visible;
|
||||
int height = getHeight();
|
||||
if (height == 0 && !force) {
|
||||
ViewTreeObserver vto = getViewTreeObserver();
|
||||
if (vto.isAlive()) {
|
||||
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
ViewTreeObserver currentVto = getViewTreeObserver();
|
||||
if (currentVto.isAlive()) {
|
||||
currentVto.removeOnPreDrawListener(this);
|
||||
}
|
||||
toggle(visible, animate, true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
int translationY = visible ? 0 : height + getMarginBottom();
|
||||
if (animate) {
|
||||
animate().setInterpolator(mInterpolator)
|
||||
.setDuration(TRANSLATE_DURATION_MILLIS)
|
||||
.translationY(translationY);
|
||||
} else {
|
||||
setTranslationY(translationY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getMarginBottom() {
|
||||
int marginBottom = 0;
|
||||
final ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
|
||||
marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
|
||||
}
|
||||
return marginBottom;
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<stroke android:width="2dp" android:color="@color/theme_primary"/>
|
||||
|
||||
<solid android:color="@android:color/transparent" />
|
||||
|
||||
</shape>
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="#ffffff" />
|
||||
</shape>
|
@ -1,7 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#fff" android:pathData="M7,10H12V15H7M19,19H5V8H19M19,3H18V1H16V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />
|
||||
</vector>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<stroke android:width="1dp" android:color="@color/theme_text_icons"/>
|
||||
|
||||
<solid android:color="@android:color/transparent" />
|
||||
</shape>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:startColor="#88444444"
|
||||
android:endColor="#00000000" />
|
||||
</shape>
|
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/week_days_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
<include layout="@layout/view_day_cell" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/month_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/day_cell_height"
|
||||
android:alpha="0"
|
||||
android:background="@color/calendar_month_transparent_background" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/month_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:alpha="0"
|
||||
tools:alpha="1"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="MAJ" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:background="@drawable/shadow"
|
||||
android:visibility="visible"/>
|
||||
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaListView
|
||||
android:id="@+id/agenda_listview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animationCache="false"
|
||||
android:divider="@color/agenda_list_header_divider"
|
||||
android:dividerHeight="1dp"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
android:scrollingCache="false" />
|
||||
|
||||
</merge>
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaEventView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/view_agenda_event_card_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:cardBackgroundColor="@color/blue_selected"
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_agenda_event_description_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_agenda_event_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp"
|
||||
tools:text="sprawdzian - Biotechnologia" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_agenda_event_location_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_agenda_event_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/calendar_text_default"
|
||||
android:textSize="12sp"
|
||||
tools:text="9:05, biologia, Beata Pudełko, 1B3T" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</com.github.tibolte.agendacalendarview.agenda.AgendaEventView>
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaHeaderView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_agenda_day_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="18sp"
|
||||
android:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="5dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_day_circle_selected"
|
||||
android:layout_width="@dimen/circle_day_size"
|
||||
android:layout_height="@dimen/circle_day_size"
|
||||
android:background="@drawable/agenda_day_circle"
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_agenda_day_of_month"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="20sp"
|
||||
tools:text="24" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_agenda_day_of_week"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textSize="12sp"
|
||||
android:visibility="visible"
|
||||
tools:text="śr." />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</com.github.tibolte.agendacalendarview.agenda.AgendaHeaderView>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.github.tibolte.agendacalendarview.calendar.CalendarView
|
||||
android:id="@+id/calendar_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.github.tibolte.agendacalendarview.agenda.AgendaView
|
||||
android:id="@+id/agenda_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</com.github.tibolte.agendacalendarview.agenda.AgendaView>
|
||||
|
||||
<com.github.tibolte.agendacalendarview.widgets.FloatingActionButton
|
||||
android:id="@+id/floating_action_button"
|
||||
style="@style/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="center" />
|
||||
|
||||
</merge>
|
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="LinearLayout"
|
||||
tools:orientation="vertical">
|
||||
|
||||
<!-- Day names labels -->
|
||||
<LinearLayout
|
||||
android:id="@+id/cal_day_names"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/calendar_header_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
<include layout="@layout/view_day_calendar_header" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="#ff7f7f7f" />
|
||||
|
||||
<com.github.tibolte.agendacalendarview.calendar.weekslist.WeekListView
|
||||
android:id="@+id/list_week"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:divider="@color/calendar_divider_color"
|
||||
android:dividerHeight="1dp"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none" />
|
||||
|
||||
</merge>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
tools:text="pon." />
|
@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="@dimen/day_cell_height"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_day_month_label"
|
||||
style="@style/CalendarCellText"
|
||||
android:visibility="gone"
|
||||
tools:text="maj" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_day_circle_selected"
|
||||
android:layout_width="@dimen/circle_selected_size"
|
||||
android:layout_height="@dimen/circle_selected_size"
|
||||
android:background="@drawable/selected_day_color_circle"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_day_day_label"
|
||||
style="@style/CalendarCellText"
|
||||
android:layout_gravity="center"
|
||||
tools:text="1" />
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_day_event_indicator3"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:background="@drawable/event_color_circle"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_day_event_indicator2"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:background="@drawable/event_color_circle"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_day_event_indicator1"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:background="@drawable/event_color_circle"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,12 +0,0 @@
|
||||
<resources>
|
||||
<!-- Agenda -->
|
||||
<string name="today">Today</string>
|
||||
<string name="tomorrow">Tomorrow</string>
|
||||
<string name="agenda_event_day_duration">d</string>
|
||||
<string name="agenda_event_all_day">All day</string>
|
||||
<string name="agenda_event_no_events">No events</string>
|
||||
|
||||
<!-- Weather -->
|
||||
<string name="month_name_format">LLLL</string>
|
||||
<string name="month_half_name_format">MMM</string>
|
||||
</resources>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="ColorOptionsView">
|
||||
<attr name="agendaCurrentDayTextColor" format="color" />
|
||||
<attr name="calendarHeaderColor" format="color" />
|
||||
<attr name="calendarHeaderTextColor" format="color" />
|
||||
<attr name="calendarColor" format="color" />
|
||||
<attr name="calendarDayTextColor" format="color" />
|
||||
<attr name="calendarPastDayTextColor" format="color" />
|
||||
<attr name="calendarCurrentDayTextColor" format="color" />
|
||||
<attr name="fabColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Colors for Calendar view -->
|
||||
<color name="calendar_text_current_day">#000000</color>
|
||||
<color name="calendar_text_default">#9C9CA0</color>
|
||||
<color name="calendar_month_transparent_background">#CCFFFFFF</color>
|
||||
<color name="calendar_divider_color">#F3F3F3</color>
|
||||
|
||||
<!-- Colors for Agenda view -->
|
||||
<!--<color name="agenda_list_header_divider">#666666</color>-->
|
||||
<color name="agenda_list_header_divider">#00000000</color>
|
||||
|
||||
<!-- General -->
|
||||
<color name="blue_selected">#2196F3</color>
|
||||
<color name="theme_primary_dark">#1976D2</color>
|
||||
<color name="theme_primary">#2196F3</color>
|
||||
<color name="theme_light_primary">#BBDEFB</color>
|
||||
<color name="theme_accent">#4caf50</color>
|
||||
<color name="theme_text_icons">#FFFFFF</color>
|
||||
|
||||
</resources>
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Calendar values -->
|
||||
<dimen name="calendar_header_height">20dp</dimen>
|
||||
<dimen name="day_cell_height">52dp</dimen>
|
||||
<dimen name="text_day_size">14dp</dimen>
|
||||
<dimen name="circle_selected_size">32dp</dimen>
|
||||
|
||||
<!-- Agenda values -->
|
||||
<dimen name="circle_day_size">60dp</dimen>
|
||||
|
||||
<!-- Floating action button values -->
|
||||
<!--<dimen name="fab_size">56dp</dimen>-->
|
||||
|
||||
<dimen name="agenda_event_view_padding_left">70dp</dimen>
|
||||
<dimen name="agenda_event_view_padding_top">5dp</dimen>
|
||||
<dimen name="agenda_event_view_padding_right">15dp</dimen>
|
||||
<dimen name="agenda_event_view_padding_bottom">5dp</dimen>
|
||||
</resources>
|
@ -1,14 +0,0 @@
|
||||
<resources>
|
||||
<!-- Calendar -->
|
||||
<string name="month_name_format">LLLL</string>
|
||||
<string name="day_name_format" translatable="false">E</string>
|
||||
|
||||
<!-- Agenda -->
|
||||
<string name="today">Dziś</string>
|
||||
<string name="tomorrow">Jutro</string>
|
||||
<string name="agenda_event_day_duration">d</string>
|
||||
<string name="agenda_event_all_day">Cały dzień</string>
|
||||
<string name="agenda_event_no_events">Brak wydarzeń</string>
|
||||
|
||||
<string name="month_half_name_format">MMM</string>
|
||||
</resources>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Calendar styles -->
|
||||
<style name="CalendarCellText">
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:textColor">@color/calendar_text_default</item>
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textSize">@dimen/text_day_size</item>
|
||||
</style>
|
||||
|
||||
<!-- Agenda styles -->
|
||||
|
||||
<!-- FAB -->
|
||||
<style name="fab">
|
||||
<item name="android:src">@drawable/fab_arrow</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_gravity">bottom|start</item>
|
||||
<item name="android:layout_margin">16dp</item>
|
||||
<item name="elevation">8dp</item>
|
||||
<item name="fabSize">normal</item>
|
||||
<item name="pressedTranslationZ">6dp</item>
|
||||
</style>
|
||||
</resources>
|
1
annotation/.gitignore
vendored
1
annotation/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
||||
*/
|
||||
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
|
||||
sourceCompatibility = "7"
|
||||
targetCompatibility = "7"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.annotation
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
annotation class SelectiveDao(
|
||||
val db: KClass<*>
|
||||
)
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2020-3-28.
|
||||
*/
|
||||
|
||||
package pl.szczodrzynski.edziennik.annotation
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
annotation class UpdateSelective(
|
||||
val primaryKeys: Array<String>,
|
||||
val skippedColumns: Array<String> = []
|
||||
)
|
323
app/build.gradle
323
app/build.gradle
@ -1,73 +1,105 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'io.fabric'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
|
||||
apply from: 'git-info.gradle'
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
}
|
||||
compileSdkVersion setup.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'pl.szczodrzynski.edziennik'
|
||||
minSdkVersion setup.minSdk
|
||||
targetSdkVersion setup.targetSdk
|
||||
|
||||
versionCode release.versionCode
|
||||
versionName release.versionName
|
||||
multiDexEnabled true
|
||||
|
||||
buildConfigField "java.util.Map<String, String>", "GIT_INFO", gitInfoMap
|
||||
buildConfigField "String", "VERSION_BASE", "\"${release.versionName}\""
|
||||
manifestPlaceholders = [
|
||||
buildTimestamp: String.valueOf(System.currentTimeMillis())
|
||||
]
|
||||
|
||||
multiDexEnabled = true
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-std=c++11"
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all {
|
||||
if (variant.buildType.name == "release") {
|
||||
outputFileName = "Edziennik_" + defaultConfig.versionName + ".apk"
|
||||
} else if (variant.buildType.name == "debugMinify") {
|
||||
outputFileName = "Edziennik_" + defaultConfig.versionName + "_debugMinify.apk"
|
||||
} else {
|
||||
outputFileName = "Edziennik_" + defaultConfig.versionName + "_debug.apk"
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
minifyEnabled false
|
||||
getIsDefault().set(true)
|
||||
minifyEnabled = false
|
||||
manifestPlaceholders = [
|
||||
buildTimestamp: 0
|
||||
]
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt')
|
||||
minifyEnabled = true
|
||||
shrinkResources = true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
proguardFiles fileTree('proguard').asList().toArray()
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation "com.google.firebase:firebase-core:${versions.firebase}"
|
||||
flavorDimensions "platform"
|
||||
productFlavors {
|
||||
unofficial {
|
||||
getIsDefault().set(true)
|
||||
versionName "${release.versionName}-${gitInfo.versionSuffix}"
|
||||
}
|
||||
official {}
|
||||
play {}
|
||||
}
|
||||
variantFilter { variant ->
|
||||
def flavors = variant.flavors*.name
|
||||
setIgnore(variant.buildType.name == "debug" && !flavors.contains("unofficial") || flavors.contains("main"))
|
||||
}
|
||||
sourceSets {
|
||||
unofficial {
|
||||
java.srcDirs = ["src/main/java", "src/play-not/java"]
|
||||
manifest.srcFile("src/play-not/AndroidManifest.xml")
|
||||
}
|
||||
official {
|
||||
java.srcDirs = ["src/main/java", "src/play-not/java"]
|
||||
manifest.srcFile("src/play-not/AndroidManifest.xml")
|
||||
}
|
||||
play {
|
||||
java.srcDirs = ["src/main/java", "src/play/java"]
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility '1.8'
|
||||
targetCompatibility '1.8'
|
||||
}
|
||||
productFlavors {
|
||||
coreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/library-core_release.kotlin_module'
|
||||
resources {
|
||||
excludes += ['META-INF/library-core_release.kotlin_module']
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
@ -75,142 +107,125 @@ android {
|
||||
version "3.10.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*task finalizeBundleDebug(type: Copy) {
|
||||
from("debug/debug")
|
||||
include "app.aab"
|
||||
destinationDir file("debug/debug")
|
||||
rename "app.aab", "Edziennik_debug.aab"
|
||||
}
|
||||
|
||||
// it finalizes :bundleRelease
|
||||
task finalizeBundleRelease(type: Copy) {
|
||||
from("release/release")
|
||||
include "app.aab"
|
||||
destinationDir file("release/release")
|
||||
rename "app.aab", "Edziennik_${android.defaultConfig.versionCode}.aab"
|
||||
}*/
|
||||
/*
|
||||
// this adds the above two tasks
|
||||
tasks.whenTaskAdded { task ->
|
||||
if (task.name == "bundleDebug") {
|
||||
task.finalizedBy finalizeBundleDebug
|
||||
} else if (task.name == "bundleRelease") {
|
||||
task.finalizedBy finalizeBundleRelease
|
||||
lint {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
tasks.whenTaskAdded { task ->
|
||||
if (!task.name.endsWith("Release") && !task.name.endsWith("ReleaseWithR8"))
|
||||
return
|
||||
def renameTaskName = "rename${task.name.capitalize()}"
|
||||
|
||||
def flavor = ""
|
||||
if (task.name.startsWith("bundle"))
|
||||
flavor = task.name.substring("bundle".length(), task.name.indexOf("Release")).uncapitalize()
|
||||
if (task.name.startsWith("assemble"))
|
||||
flavor = task.name.substring("assemble".length(), task.name.indexOf("Release")).uncapitalize()
|
||||
if (task.name.startsWith("minify"))
|
||||
flavor = task.name.substring("minify".length(), task.name.indexOf("Release")).uncapitalize()
|
||||
|
||||
if (flavor != "") {
|
||||
tasks.create(renameTaskName, Copy) {
|
||||
from file("${projectDir}/${flavor}/release/"),
|
||||
file("${buildDir}/outputs/mapping/${flavor}Release/"),
|
||||
file("${buildDir}/outputs/apk/${flavor}/release/"),
|
||||
file("${buildDir}/outputs/bundle/${flavor}Release/")
|
||||
include "*.aab", "*.apk", "mapping.txt", "output-metadata.json"
|
||||
destinationDir file("${projectDir}/release/")
|
||||
rename ".+?\\.(.+)", "Edziennik_${android.defaultConfig.versionName}_${flavor}." + '$1'
|
||||
}
|
||||
task.finalizedBy(renameTaskName)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
|
||||
kapt "androidx.room:room-compiler:${versions.room}"
|
||||
debugImplementation "com.amitshekhar.android:debug-db:1.0.5"
|
||||
// Language cores
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||
|
||||
implementation "android.arch.navigation:navigation-fragment-ktx:${versions.navigationFragment}"
|
||||
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
|
||||
implementation "androidx.cardview:cardview:${versions.cardView}"
|
||||
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
|
||||
implementation "androidx.core:core-ktx:${versions.ktx}"
|
||||
implementation "androidx.gridlayout:gridlayout:${versions.gridLayout}"
|
||||
implementation "androidx.legacy:legacy-support-v4:${versions.legacy}"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata:${versions.lifecycle}"
|
||||
implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
|
||||
implementation "androidx.room:room-runtime:${versions.room}"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
|
||||
// Android Jetpack
|
||||
implementation "androidx.appcompat:appcompat:1.5.1"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||
implementation "androidx.core:core-ktx:1.9.0"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
|
||||
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
||||
implementation "androidx.room:room-runtime:2.4.3"
|
||||
implementation "androidx.room:room-ktx:2.4.3"
|
||||
implementation "androidx.work:work-runtime-ktx:2.7.1"
|
||||
kapt "androidx.room:room-compiler:2.4.3"
|
||||
|
||||
implementation "com.google.android.gms:play-services-wearable:${versions.play_services}"
|
||||
implementation "com.google.android.material:material:${versions.material}"
|
||||
implementation "com.google.firebase:firebase-messaging:${versions.firebasemessaging}"
|
||||
// Google design libs
|
||||
implementation "com.google.android.material:material:1.6.1"
|
||||
implementation "com.google.android.flexbox:flexbox:3.0.0"
|
||||
|
||||
//implementation "com.github.kuba2k2.MaterialDrawer:library:e603091449"
|
||||
implementation "com.mikepenz:crossfader:1.6.0" // do not update
|
||||
implementation "com.mikepenz:iconics-core:${versions.iconics}"
|
||||
implementation "com.mikepenz:iconics-views:${versions.iconics}"
|
||||
implementation "com.mikepenz:community-material-typeface:${versions.font_cmd}@aar"
|
||||
implementation "com.mikepenz:materialize:1.2.1"
|
||||
// Play Services/Firebase
|
||||
implementation "com.google.android.gms:play-services-wearable:17.1.0"
|
||||
implementation("com.google.firebase:firebase-core") { version { strictly "19.0.2" } }
|
||||
implementation "com.google.firebase:firebase-crashlytics:18.2.13"
|
||||
implementation("com.google.firebase:firebase-messaging") { version { strictly "20.1.3" } }
|
||||
|
||||
implementation "com.github.kuba2k2:NavLib:${versions.navlib}"
|
||||
// OkHttp, Retrofit, Gson, Jsoup
|
||||
implementation("com.squareup.okhttp3:okhttp") { version { strictly "3.12.13" } }
|
||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
|
||||
implementation 'com.google.code.gson:gson:2.8.8'
|
||||
implementation 'org.jsoup:jsoup:1.14.3'
|
||||
implementation "pl.droidsonroids:jspoon:1.3.2"
|
||||
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
|
||||
|
||||
implementation "com.afollestad.material-dialogs:commons:${versions.materialdialogs}"
|
||||
implementation "com.afollestad.material-dialogs:core:${versions.materialdialogs}"
|
||||
// Szkolny.eu libraries/forks
|
||||
implementation "eu.szkolny:android-snowfall:1ca9ea2da3"
|
||||
implementation "eu.szkolny:agendacalendarview:1.0.4"
|
||||
implementation "eu.szkolny:cafebar:5bf0c618de"
|
||||
implementation "eu.szkolny.fslogin:lib:2.0.0"
|
||||
implementation "eu.szkolny:material-about-library:1d5ebaf47c"
|
||||
implementation "eu.szkolny:mhttp:af4b62e6e9"
|
||||
implementation "eu.szkolny:nachos:0e5dfcaceb"
|
||||
implementation "eu.szkolny.selective-dao:annotation:27f8f3f194"
|
||||
officialImplementation "eu.szkolny:ssl-provider:1.0.0"
|
||||
unofficialImplementation "eu.szkolny:ssl-provider:1.0.0"
|
||||
implementation "pl.szczodrzynski:navlib:0.8.0"
|
||||
implementation "pl.szczodrzynski:numberslidingpicker:2921225f76"
|
||||
implementation "pl.szczodrzynski:recyclertablayout:700f980584"
|
||||
implementation "pl.szczodrzynski:tachyon:551943a6b5"
|
||||
kapt "eu.szkolny.selective-dao:codegen:27f8f3f194"
|
||||
|
||||
implementation "cat.ereza:customactivityoncrash:2.2.0"
|
||||
implementation "com.applandeo:material-calendar-view:1.5.0"
|
||||
implementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
|
||||
// Iconics & related
|
||||
implementation "com.mikepenz:iconics-core:5.3.2"
|
||||
implementation "com.mikepenz:iconics-views:5.3.2"
|
||||
implementation "com.mikepenz:community-material-typeface:5.8.55.0-kotlin@aar"
|
||||
implementation "eu.szkolny:szkolny-font:77e33acc2a"
|
||||
|
||||
// Other dependencies
|
||||
implementation "cat.ereza:customactivityoncrash:2.3.0"
|
||||
implementation "com.android.volley:volley:1.2.1"
|
||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||
implementation "com.evernote:android-job:1.2.6"
|
||||
implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2"
|
||||
implementation "com.github.bassaer:chatmessageview:2.0.1"
|
||||
implementation("com.github.ozodrukh:CircularReveal:2.0.1@aar") {transitive = true}
|
||||
implementation "com.heinrichreimersoftware:material-intro:1.5.8" // do not update
|
||||
implementation "com.jaredrummler:colorpicker:1.0.2"
|
||||
implementation("com.squareup.okhttp3:okhttp") {
|
||||
version {
|
||||
strictly "3.12.2"
|
||||
}
|
||||
}
|
||||
implementation "com.theartofdev.edmodo:android-image-cropper:2.8.0" // do not update
|
||||
implementation "com.wdullaer:materialdatetimepicker:4.1.2"
|
||||
implementation "com.yuyh.json:jsonviewer:1.0.6"
|
||||
implementation "com.github.Applandeo:Material-Calendar-View:15de569cbc" // https://github.com/Applandeo/Material-Calendar-View
|
||||
implementation "com.github.CanHub:Android-Image-Cropper:2.2.2" // https://github.com/CanHub/Android-Image-Cropper
|
||||
implementation "com.github.ChuckerTeam.Chucker:library:3.5.2" // https://github.com/ChuckerTeam/chucker
|
||||
implementation "com.github.antonKozyriatskyi:CircularProgressIndicator:1.2.2" // https://github.com/antonKozyriatskyi/CircularProgressIndicator
|
||||
implementation "com.github.bassaer:chatmessageview:2.0.1" // https://github.com/bassaer/ChatMessageView
|
||||
implementation "com.github.hypertrack:hyperlog-android:0.0.10" // https://github.com/hypertrack/hyperlog-android
|
||||
implementation "com.github.smuyyh:JsonViewer:V1.0.6" // https://github.com/smuyyh/JsonViewer
|
||||
implementation "com.github.underwindfall.PowerPermission:powerpermission-coroutines:1.4.0" // https://github.com/underwindfall/PowerPermission
|
||||
implementation "com.github.underwindfall.PowerPermission:powerpermission:1.4.0" // https://github.com/underwindfall/PowerPermission
|
||||
implementation "com.github.wulkanowy.uonet-request-signer:hebe-jvm:a99ca50a31" // https://github.com/wulkanowy/uonet-request-signer
|
||||
implementation "com.jaredrummler:colorpicker:1.1.0"
|
||||
implementation "io.coil-kt:coil:1.1.1"
|
||||
implementation "me.dm7.barcodescanner:zxing:1.9.8"
|
||||
implementation "me.grantland:autofittextview:0.2.1"
|
||||
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
|
||||
implementation "org.greenrobot:eventbus:3.1.1"
|
||||
implementation "org.jsoup:jsoup:1.10.1"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.15"
|
||||
//implementation "se.emilsjolander:stickylistheaders:2.7.0"
|
||||
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
|
||||
implementation "uk.co.samuelwall:material-tap-target-prompt:2.14.0"
|
||||
implementation "org.greenrobot:eventbus:3.2.0"
|
||||
implementation("com.heinrichreimersoftware:material-intro") { version { strictly "1.5.8" } }
|
||||
implementation("pl.droidsonroids.gif:android-gif-drawable") { version { strictly "1.2.15" } }
|
||||
|
||||
implementation project(":agendacalendarview")
|
||||
implementation project(":cafebar")
|
||||
implementation project(":material-about-library")
|
||||
implementation project(":mhttp")
|
||||
implementation project(":nachos")
|
||||
//implementation project(":Navigation")
|
||||
implementation project(":szkolny-font")
|
||||
|
||||
implementation "com.github.ChuckerTeam.Chucker:library:3.0.1"
|
||||
//releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:3.0.1"
|
||||
|
||||
//implementation 'com.github.wulkanowy:uonet-request-signer:master-SNAPSHOT'
|
||||
//implementation 'com.github.kuba2k2.uonet-request-signer:android:master-63f094b14a-1'
|
||||
|
||||
//implementation "org.redundent:kotlin-xml-builder:1.5.3"
|
||||
|
||||
implementation "io.github.wulkanowy:signer-android:0.1.1"
|
||||
|
||||
implementation "androidx.work:work-runtime-ktx:${versions.work}"
|
||||
|
||||
implementation 'com.hypertrack:hyperlog:0.0.10'
|
||||
|
||||
implementation 'com.github.kuba2k2:RecyclerTabLayout:700f980584'
|
||||
|
||||
implementation 'com.github.kuba2k2:Tachyon:551943a6b5'
|
||||
|
||||
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
|
||||
implementation "com.squareup.retrofit2:converter-gson:${versions.retrofit}"
|
||||
|
||||
implementation 'com.github.jetradarmobile:android-snowfall:1.2.0'
|
||||
|
||||
implementation "io.coil-kt:coil:0.9.2"
|
||||
|
||||
implementation 'com.github.kuba2k2:NumberSlidingPicker:2921225f76'
|
||||
|
||||
implementation project(":annotation")
|
||||
kapt project(":codegen")
|
||||
|
||||
implementation 'com.google.android:flexbox:2.0.1'
|
||||
|
||||
implementation 'com.qifan.powerpermission:powerpermission:1.0.0'
|
||||
implementation 'com.qifan.powerpermission:powerpermission-coroutines:1.0.0'
|
||||
|
||||
implementation 'com.github.kuba2k2.FSLogin:lib:master-SNAPSHOT'
|
||||
implementation 'pl.droidsonroids:jspoon:1.3.2'
|
||||
implementation "com.squareup.retrofit2:converter-scalars:2.8.1"
|
||||
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
// Debug-only dependencies
|
||||
debugImplementation "com.github.amitshekhariitbhu.Android-Debug-Database:debug-db:v1.0.6"
|
||||
}
|
||||
|
124
app/git-info.gradle
Normal file
124
app/git-info.gradle
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) Kuba Szczodrzyński 2021-3-27.
|
||||
*/
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.eclipse.jgit:org.eclipse.jgit:5.5.+"
|
||||
}
|
||||
}
|
||||
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException
|
||||
import org.eclipse.jgit.lib.Constants
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
import org.eclipse.jgit.revwalk.RevCommit
|
||||
import org.eclipse.jgit.revwalk.RevTag
|
||||
import org.eclipse.jgit.revwalk.RevWalk
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
|
||||
|
||||
private def getGit() {
|
||||
Repository repo
|
||||
try {
|
||||
repo = new FileRepositoryBuilder()
|
||||
.readEnvironment()
|
||||
.findGitDir(project.projectDir)
|
||||
.build()
|
||||
} catch (IllegalArgumentException | RepositoryNotFoundException ignore) {
|
||||
def logger = LoggerFactory.getLogger("androidGitVersion")
|
||||
logger.error("No git repository reachable from ${project.projectDir}")
|
||||
return results
|
||||
}
|
||||
return Git.wrap(repo)
|
||||
}
|
||||
|
||||
private static def getTags(Repository repo, Git git) {
|
||||
RevWalk walk = new RevWalk(repo)
|
||||
def tags = git.tagList().call().findResults { ref ->
|
||||
def obj = walk.parseAny(ref.getObjectId())
|
||||
def name = null
|
||||
if (obj instanceof RevTag) {
|
||||
name = obj.getTagName()
|
||||
} else if (obj instanceof RevCommit) {
|
||||
name = Repository.shortenRefName(ref.name)
|
||||
}
|
||||
[obj.id, name]
|
||||
}
|
||||
walk.close()
|
||||
return tags
|
||||
}
|
||||
|
||||
private static def getLastTag(Repository repo, Git git, Ref head) {
|
||||
def tags = getTags(repo, git)
|
||||
|
||||
RevWalk revs = new RevWalk(repo)
|
||||
revs.markStart(revs.parseCommit(head.getObjectId()))
|
||||
def revCount = 0
|
||||
Collection<List> commitTags = null
|
||||
for (RevCommit commit : revs) {
|
||||
def tagsHere = tags.findAll { (it[0] == commit.id) }
|
||||
if (tagsHere) {
|
||||
commitTags = tagsHere.stream().map {
|
||||
[it[0].name, it[1], revCount]
|
||||
}.toArray()
|
||||
break
|
||||
}
|
||||
revCount++
|
||||
}
|
||||
|
||||
return commitTags.last()
|
||||
}
|
||||
|
||||
private def buildGitInfo() {
|
||||
Git git = getGit()
|
||||
Repository repo = git.repository
|
||||
|
||||
def head = repo.findRef(Constants.HEAD).target
|
||||
|
||||
def remotes = git.remoteList().call()
|
||||
.stream()
|
||||
.map {
|
||||
it.name + "(" + it.URIs.stream()
|
||||
.map { it.rawPath.stripMargin('/').replace(".git", "") }
|
||||
.toArray()
|
||||
.join(", ") + ")"
|
||||
}
|
||||
.toArray()
|
||||
.join("; ")
|
||||
|
||||
def status = git.status().call()
|
||||
def dirty = status.hasUncommittedChanges()
|
||||
|
||||
def tag = getLastTag(repo, git, head)
|
||||
def tagName = tag[1]
|
||||
def tagRevCount = tag[2]
|
||||
|
||||
def result = [
|
||||
hash : head.objectId.name,
|
||||
branch : repo.branch,
|
||||
dirty : dirty,
|
||||
remotes : remotes,
|
||||
unstaged : status.uncommittedChanges.join("; "),
|
||||
tag : tagName,
|
||||
revCount : tagRevCount,
|
||||
version : """$tagName-$tagRevCount-g${head.objectId.name.substring(0, 8)}""" + (dirty ? ".dirty" : ""),
|
||||
versionSuffix : """${repo.branch.replace("/", "_")}""" + (dirty ? ".dirty" : "")
|
||||
]
|
||||
return result
|
||||
}
|
||||
|
||||
private static def getMapString(map) {
|
||||
def hashMap = "new java.util.HashMap<String, String>() { {\n"
|
||||
map.each { k, v -> hashMap += """\tput("${k}", "${v}");\n""" }
|
||||
return hashMap + "} }"
|
||||
}
|
||||
|
||||
ext {
|
||||
gitInfo = buildGitInfo()
|
||||
gitInfoMap = getMapString(gitInfo)
|
||||
}
|
18
app/proguard/app.pro → app/proguard-rules.pro
vendored
18
app/proguard/app.pro → app/proguard-rules.pro
vendored
@ -22,18 +22,24 @@
|
||||
-keep class android.support.v7.widget.** { *; }
|
||||
|
||||
-keep class pl.szczodrzynski.edziennik.utils.models.** { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.enums.* { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.entity.Event { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.full.EventFull { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.entity.FeedbackMessage { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.ui.modules.home.HomeCardModel { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.data.db.entity.Note { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.ui.home.HomeCardModel { *; }
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.ui.widgets.WidgetConfig { public *; }
|
||||
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.timetable.WidgetTimetableProvider
|
||||
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.notifications.WidgetNotificationsProvider
|
||||
-keepnames class pl.szczodrzynski.edziennik.ui.widgets.luckynumber.WidgetLuckyNumberProvider
|
||||
-keep class pl.szczodrzynski.edziennik.config.AppData { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.config.AppData$** { *; }
|
||||
-keep class pl.szczodrzynski.edziennik.utils.managers.TextStylingManager$HtmlMode { *; }
|
||||
|
||||
-keepnames class androidx.appcompat.view.menu.MenuBuilder { setHeaderTitleInt(java.lang.CharSequence); }
|
||||
-keepclassmembernames class androidx.appcompat.view.menu.StandardMenuPopup { private *; }
|
||||
-keepnames class androidx.appcompat.view.menu.MenuPopupHelper { showPopup(int, int, boolean, boolean); }
|
||||
-keepclassmembernames class androidx.appcompat.view.menu.StandardMenuPopup { private *; }
|
||||
-keepclassmembernames class androidx.appcompat.view.menu.MenuItemImpl { private *; }
|
||||
|
||||
-keepclassmembernames class com.mikepenz.materialdrawer.widget.MiniDrawerSliderView { private *; }
|
||||
|
||||
@ -64,5 +70,9 @@
|
||||
|
||||
-keep class pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing { public final byte[] pleaseStopRightNow(java.lang.String, long); }
|
||||
|
||||
-keepclassmembernames class pl.szczodrzynski.edziennik.data.api.szkolny.request.** { *; }
|
||||
-keepclassmembernames class pl.szczodrzynski.edziennik.data.api.szkolny.response.** { *; }
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.data.api.szkolny.request.** { *; }
|
||||
-keepclassmembers class pl.szczodrzynski.edziennik.data.api.szkolny.response.** { *; }
|
||||
-keepclassmembernames class pl.szczodrzynski.edziennik.ui.login.LoginInfo$Platform { *; }
|
||||
|
||||
-keepclassmembernames class pl.szczodrzynski.fslogin.realm.RealmData { *; }
|
||||
-keepclassmembernames class pl.szczodrzynski.fslogin.realm.RealmData$Type { *; }
|
@ -1,14 +0,0 @@
|
||||
-dontwarn com.evernote.android.job.gcm.**
|
||||
-dontwarn com.evernote.android.job.GcmAvailableHelper
|
||||
-dontwarn com.evernote.android.job.work.**
|
||||
-dontwarn com.evernote.android.job.WorkManagerAvailableHelper
|
||||
|
||||
-keep public class com.evernote.android.job.v21.PlatformJobService
|
||||
-keep public class com.evernote.android.job.v14.PlatformAlarmService
|
||||
-keep public class com.evernote.android.job.v14.PlatformAlarmReceiver
|
||||
-keep public class com.evernote.android.job.JobBootReceiver
|
||||
-keep public class com.evernote.android.job.JobRescheduleService
|
||||
-keep public class com.evernote.android.job.gcm.PlatformGcmService
|
||||
-keep public class com.evernote.android.job.work.PlatformWorker
|
||||
|
||||
-keep class com.evernote.android.job.** { *; }
|
@ -1 +0,0 @@
|
||||
-keep class android.support.v8.renderscript.** { *; }
|
@ -1,25 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in D:\AndroidSDK/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
|
||||
-keep class android.support.v7.graphics.** { *; }
|
||||
-dontwarn android.support.v7.graphics.**
|
||||
|
||||
-keep class android.support.design.widget.** { *; }
|
||||
-keep interface android.support.design.widget.** { *; }
|
||||
-dontwarn android.support.design.**
|
@ -1,14 +0,0 @@
|
||||
# Android iconics library - https://github.com/mikepenz/Android-Iconics
|
||||
# Warning: works ONLY with iconics > 1.0.0
|
||||
#
|
||||
# Tested on gradle config:
|
||||
#
|
||||
# compile 'com.mikepenz:iconics-core:1.7.1@aar'
|
||||
#
|
||||
|
||||
-keep class com.mikepenz.iconics.** { *; }
|
||||
-keep class com.mikepenz.community_material_typeface_library.CommunityMaterial
|
||||
-keep class com.mikepenz.fontawesome_typeface_library.FontAwesome
|
||||
-keep class com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
-keep class com.mikepenz.meteocons_typeface_library.Meteoconcs
|
||||
-keep class com.mikepenz.octicons_typeface_library.Octicons
|
@ -1,48 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/wangchao/Work/android-sdk/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
-dontwarn im.wangchao.**
|
||||
-dontwarn okio.**
|
||||
-dontwarn javax.annotation.Nullable
|
||||
-dontwarn javax.annotation.ParametersAreNonnullByDefault
|
||||
-keep class im.wangchao.** { *; }
|
||||
-keep class **_HttpBinder { *; }
|
||||
-keepclasseswithmembernames class * {
|
||||
@im.wangchao.* <fields>;
|
||||
}
|
||||
-keepclasseswithmembernames class * {
|
||||
@im.wangchao.* <methods>;
|
||||
}
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
static final long serialVersionUID;
|
||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||
!static !transient <fields>;
|
||||
private void writeObject(java.io.ObjectOutputStream);
|
||||
private void readObject(java.io.ObjectInputStream);
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
}
|
||||
# okhttp
|
||||
-dontwarn okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-dontwarn javax.annotation.**
|
||||
-dontwarn org.conscrypt.**
|
||||
# A resource is loaded with a relative path so the package of this class must be preserved.
|
||||
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
|
||||
|
||||
# If you do not use Rx:
|
||||
-dontwarn rx.**
|
@ -1 +0,0 @@
|
||||
-keep class com.mikepenz.szkolny_font_typeface_library.SzkolnyFont { *; }
|
@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
2320
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/100.json
Normal file
2320
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/100.json
Normal file
File diff suppressed because it is too large
Load Diff
2293
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/97.json
Normal file
2293
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/97.json
Normal file
File diff suppressed because it is too large
Load Diff
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/98.json
Normal file
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/98.json
Normal file
File diff suppressed because it is too large
Load Diff
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/99.json
Normal file
2314
app/schemas/pl.szczodrzynski.edziennik.data.db.AppDb/99.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="pl.szczodrzynski.edziennik">
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
@ -13,7 +12,7 @@
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<!-- PowerPermission uses minSdk 21, it's safe to override as it is used only in >= 23 -->
|
||||
<uses-sdk tools:overrideLibrary="com.qifan.powerpermission.coroutines, com.qifan.powerpermission.core" />
|
||||
|
||||
@ -29,6 +28,8 @@
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<meta-data android:name="buildTimestamp" android:value="${buildTimestamp}" />
|
||||
|
||||
<!-- __ __ _ _ _ _ _
|
||||
| \/ | (_) /\ | | (_) (_) |
|
||||
| \ / | __ _ _ _ __ / \ ___| |_ ___ ___| |_ _ _
|
||||
@ -41,6 +42,7 @@
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:exported="true"
|
||||
android:theme="@style/SplashTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@ -64,6 +66,7 @@
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:excludeFromRecents="true"
|
||||
android:noHistory="true"
|
||||
android:exported="true"
|
||||
android:theme="@style/AppTheme.Dark.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
@ -71,7 +74,8 @@
|
||||
</activity>
|
||||
<!-- TIMETABLE -->
|
||||
<receiver android:name=".ui.widgets.timetable.WidgetTimetableProvider"
|
||||
android:label="@string/widget_timetable_title">
|
||||
android:label="@string/widget_timetable_title"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
@ -86,10 +90,12 @@
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:excludeFromRecents="true"
|
||||
android:noHistory="true"
|
||||
android:exported="true"
|
||||
android:theme="@style/AppTheme.Dark.NoDisplay" />
|
||||
<!-- NOTIFICATIONS -->
|
||||
<receiver android:name=".ui.widgets.notifications.WidgetNotificationsProvider"
|
||||
android:label="@string/widget_notifications_title">
|
||||
android:label="@string/widget_notifications_title"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
@ -102,7 +108,8 @@
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS" />
|
||||
<!-- LUCKY NUMBER -->
|
||||
<receiver android:name=".ui.widgets.luckynumber.WidgetLuckyNumberProvider"
|
||||
android:label="@string/widget_lucky_number_title">
|
||||
android:label="@string/widget_lucky_number_title"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
@ -119,34 +126,47 @@
|
||||
/ ____ \ (__| |_| |\ V /| | |_| | __/\__ \
|
||||
/_/ \_\___|\__|_| \_/ |_|\__|_|\___||___/
|
||||
-->
|
||||
<activity android:name=".ui.modules.base.CrashActivity"
|
||||
<activity android:name=".ui.base.CrashActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:process=":error_activity"
|
||||
android:exported="false"
|
||||
android:theme="@style/DeadTheme" />
|
||||
<activity android:name=".ui.modules.base.CrashGtfoActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:theme="@style/DeadTheme" />
|
||||
<activity android:name=".ui.modules.intro.ChangelogIntroActivity"
|
||||
<activity android:name=".ui.intro.ChangelogIntroActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Intro" />
|
||||
<activity android:name=".ui.modules.login.LoginActivity"
|
||||
<activity android:name=".ui.login.LoginActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTop"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.Light" />
|
||||
<activity android:name=".ui.modules.home.CounterActivity"
|
||||
<activity android:name=".ui.home.CounterActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.Black" />
|
||||
<activity android:name=".ui.modules.feedback.FeedbackActivity"
|
||||
<activity android:name=".ui.feedback.FeedbackActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".ui.modules.settings.SettingsLicenseActivity"
|
||||
<activity android:name=".ui.settings.SettingsLicenseActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".ui.modules.webpush.QrScannerActivity" />
|
||||
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
|
||||
<activity android:name="com.canhub.cropper.CropImageActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/Base.Theme.AppCompat" />
|
||||
<activity android:name=".ui.login.oauth.OAuthLoginActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar" />
|
||||
<activity android:name=".ui.login.recaptcha.RecaptchaActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar" />
|
||||
<activity android:name=".ui.base.BuildInvalidActivity" android:exported="false" />
|
||||
<activity android:name=".ui.settings.contributors.ContributorsActivity" android:exported="false" />
|
||||
|
||||
<!-- _____ _
|
||||
| __ \ (_)
|
||||
@ -156,12 +176,14 @@
|
||||
|_| \_\___|\___\___|_| \_/ \___|_| |___/
|
||||
-->
|
||||
<receiver android:name=".receivers.UserPresentReceiver"
|
||||
android:enabled="true">
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.USER_PRESENT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".sync.UpdateDownloaderService$DownloadProgressReceiver">
|
||||
<receiver android:name=".sync.UpdateDownloaderService$DownloadProgressReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
|
||||
</intent-filter>
|
||||
@ -180,13 +202,6 @@
|
||||
____) | __/ | \ V /| | (_| __/\__ \
|
||||
|_____/ \___|_| \_/ |_|\___\___||___/
|
||||
-->
|
||||
<!--<service android:name=".sync.MyFirebaseMessagingService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>-->
|
||||
<service android:name=".data.api.ApiService" />
|
||||
<service android:name=".data.firebase.MyFirebaseService"
|
||||
android:exported="false">
|
||||
|
@ -1,27 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
|
||||
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
|
||||
SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
|
||||
GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
|
||||
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
|
||||
SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
|
||||
Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
|
||||
a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
|
||||
/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
|
||||
AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
|
||||
CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
|
||||
bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
|
||||
c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
|
||||
VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
|
||||
ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
|
||||
MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
|
||||
Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
|
||||
AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
|
||||
uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
|
||||
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
|
||||
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
|
||||
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
|
||||
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
|
||||
-----END CERTIFICATE-----
|
@ -1,10 +1,10 @@
|
||||
<h3>Wersja 4.1, 2020-05-09</h3>
|
||||
<h3>Wersja 4.13.6, 2023-03-24</h3>
|
||||
<ul>
|
||||
<li>Naprawiona synchronizacja Wiadomości w Librusie.</li>
|
||||
<li>Widok adresu dołączenia do lekcji online w kalendarzu (jeżeli nauczyciel wpisze adres).</li>
|
||||
<li>Nowy moduł Frekwencji, obsługujący również lekcje zdalne.</li>
|
||||
<li>Naprawiono pobieranie załączników na Androidzie 13 i nowszym.</li>
|
||||
<li>Dodano opcję odświeżenia planu lekcji na wybrany tydzień.</li>
|
||||
<li>Usunięto błędy logowania. @BxOxSxS</li>
|
||||
</ul>
|
||||
<br>
|
||||
<br>
|
||||
Dzięki za korzystanie ze Szkolnego!<br>
|
||||
<i>© Kuba Szczodrzyński, Kacper Ziubryniewicz 2020</i>
|
||||
<i>© [Kuba Szczodrzyński](@kuba2k2) 2023</i>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
/*secret password - removed for source code publication*/
|
||||
static toys AES_IV[16] = {
|
||||
0xec, 0xc0, 0x3e, 0x4e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
0x6d, 0xa5, 0x32, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat);
|
||||
|
||||
|
@ -12,6 +12,7 @@ import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.multidex.MultiDexApplication
|
||||
import androidx.work.Configuration
|
||||
@ -26,47 +27,88 @@ import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.google.gson.Gson
|
||||
import com.hypertrack.hyperlog.HyperLog
|
||||
import com.mikepenz.iconics.Iconics
|
||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
||||
import im.wangchao.mhttp.MHttp
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import me.leolin.shortcutbadger.ShortcutBadger
|
||||
import okhttp3.OkHttpClient
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.config.AppData
|
||||
import pl.szczodrzynski.edziennik.config.Config
|
||||
import pl.szczodrzynski.edziennik.data.api.events.ProfileListEmptyEvent
|
||||
import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi
|
||||
import pl.szczodrzynski.edziennik.data.api.szkolny.interceptor.Signing
|
||||
import pl.szczodrzynski.edziennik.data.db.AppDb
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||
import pl.szczodrzynski.edziennik.network.NetworkUtils
|
||||
import pl.szczodrzynski.edziennik.data.db.enums.LoginType
|
||||
import pl.szczodrzynski.edziennik.ext.DAY
|
||||
import pl.szczodrzynski.edziennik.ext.MS
|
||||
import pl.szczodrzynski.edziennik.ext.putExtras
|
||||
import pl.szczodrzynski.edziennik.ext.setLanguage
|
||||
import pl.szczodrzynski.edziennik.network.SSLProviderInstaller
|
||||
import pl.szczodrzynski.edziennik.network.cookie.DumbCookieJar
|
||||
import pl.szczodrzynski.edziennik.sync.SyncWorker
|
||||
import pl.szczodrzynski.edziennik.sync.UpdateWorker
|
||||
import pl.szczodrzynski.edziennik.ui.modules.base.CrashActivity
|
||||
import pl.szczodrzynski.edziennik.utils.*
|
||||
import pl.szczodrzynski.edziennik.utils.managers.*
|
||||
import pl.szczodrzynski.edziennik.ui.base.CrashActivity
|
||||
import pl.szczodrzynski.edziennik.ui.base.enums.NavTarget
|
||||
import pl.szczodrzynski.edziennik.utils.DebugLogFormat
|
||||
import pl.szczodrzynski.edziennik.utils.PermissionChecker
|
||||
import pl.szczodrzynski.edziennik.utils.Themes
|
||||
import pl.szczodrzynski.edziennik.utils.Utils
|
||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||
import pl.szczodrzynski.edziennik.utils.managers.AttendanceManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.AvailabilityManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.BuildManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.EventManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.GradesManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.MessageManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.NoteManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.NotificationChannelsManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.PermissionManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.TextStylingManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.TimetableManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.UpdateManager
|
||||
import pl.szczodrzynski.edziennik.utils.managers.UserActionManager
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
companion object {
|
||||
@Volatile
|
||||
lateinit var db: AppDb
|
||||
val config: Config by lazy { Config(db) }
|
||||
var profile: Profile by mutableLazy { Profile(0, 0, 0, "") }
|
||||
private set
|
||||
lateinit var config: Config
|
||||
// private set // for LabFragment
|
||||
lateinit var profile: Profile
|
||||
private set
|
||||
lateinit var data: AppData
|
||||
private set
|
||||
val profileId
|
||||
get() = profile.id
|
||||
|
||||
var devMode = false
|
||||
var enableChucker = false
|
||||
var debugMode = false
|
||||
var devMode = false
|
||||
}
|
||||
|
||||
val notificationChannelsManager by lazy { NotificationChannelsManager(this) }
|
||||
val userActionManager by lazy { UserActionManager(this) }
|
||||
val gradesManager by lazy { GradesManager(this) }
|
||||
val timetableManager by lazy { TimetableManager(this) }
|
||||
val eventManager by lazy { EventManager(this) }
|
||||
val permissionManager by lazy { PermissionManager(this) }
|
||||
val api by lazy { SzkolnyApi(this) }
|
||||
val attendanceManager by lazy { AttendanceManager(this) }
|
||||
val availabilityManager by lazy { AvailabilityManager(this) }
|
||||
val buildManager by lazy { BuildManager(this) }
|
||||
val eventManager by lazy { EventManager(this) }
|
||||
val gradesManager by lazy { GradesManager(this) }
|
||||
val messageManager by lazy { MessageManager(this) }
|
||||
val noteManager by lazy { NoteManager(this) }
|
||||
val notificationChannelsManager by lazy { NotificationChannelsManager(this) }
|
||||
val permissionManager by lazy { PermissionManager(this) }
|
||||
val textStylingManager by lazy { TextStylingManager(this) }
|
||||
val timetableManager by lazy { TimetableManager(this) }
|
||||
val updateManager by lazy { UpdateManager(this) }
|
||||
val userActionManager by lazy { UserActionManager(this) }
|
||||
|
||||
val db
|
||||
get() = App.db
|
||||
@ -76,6 +118,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
get() = App.profile
|
||||
val profileId
|
||||
get() = App.profileId
|
||||
val data
|
||||
get() = App.data
|
||||
|
||||
private val job = Job()
|
||||
override val coroutineContext: CoroutineContext
|
||||
@ -85,7 +129,6 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
.build()
|
||||
|
||||
val permissionChecker by lazy { PermissionChecker(this) }
|
||||
val networkUtils by lazy { NetworkUtils(this) }
|
||||
val gson by lazy { Gson() }
|
||||
|
||||
/* _ _ _______ _______ _____
|
||||
@ -94,34 +137,38 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
| __ | | | | | | ___/
|
||||
| | | | | | | | | |
|
||||
|_| |_| |_| |_| |*/
|
||||
val http: OkHttpClient by lazy {
|
||||
val builder = OkHttpClient.Builder()
|
||||
.cache(null)
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.retryOnConnectionFailure(true)
|
||||
.cookieJar(cookieJar)
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
builder.installHttpsSupport(this)
|
||||
lateinit var http: OkHttpClient
|
||||
lateinit var httpLazy: OkHttpClient
|
||||
|
||||
if (debugMode || BuildConfig.DEBUG) {
|
||||
HyperLog.initialize(this)
|
||||
HyperLog.setLogLevel(Log.VERBOSE)
|
||||
HyperLog.setLogFormat(DebugLogFormat(this))
|
||||
val chuckerCollector = ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR)
|
||||
val chuckerInterceptor = ChuckerInterceptor(this, chuckerCollector)
|
||||
builder.addInterceptor(chuckerInterceptor)
|
||||
private fun buildHttp() {
|
||||
val builder = OkHttpClient.Builder()
|
||||
.cache(null)
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.retryOnConnectionFailure(true)
|
||||
.cookieJar(cookieJar)
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
|
||||
SSLProviderInstaller.enableSupportedTls(builder, enableCleartext = true)
|
||||
|
||||
if (devMode) {
|
||||
if (enableChucker) {
|
||||
val chuckerCollector = ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR)
|
||||
val chuckerInterceptor = ChuckerInterceptor(this, chuckerCollector)
|
||||
builder.addInterceptor(chuckerInterceptor)
|
||||
}
|
||||
}
|
||||
|
||||
builder.build()
|
||||
}
|
||||
val httpLazy: OkHttpClient by lazy {
|
||||
http.newBuilder()
|
||||
.followRedirects(false)
|
||||
.followSslRedirects(false)
|
||||
.build()
|
||||
http = builder.build()
|
||||
|
||||
httpLazy = http.newBuilder()
|
||||
.followRedirects(false)
|
||||
.followSslRedirects(false)
|
||||
.build()
|
||||
|
||||
MHttp.instance().customOkHttpClient(http)
|
||||
}
|
||||
val cookieJar by lazy { DumbCookieJar(this) }
|
||||
|
||||
@ -158,33 +205,46 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
.errorActivity(CrashActivity::class.java)
|
||||
.apply()
|
||||
Iconics.init(applicationContext)
|
||||
Iconics.registerFont(SzkolnyFont)
|
||||
App.db = AppDb(this)
|
||||
Themes.themeInt = config.ui.theme
|
||||
debugMode = config.debugMode
|
||||
MHttp.instance().customOkHttpClient(http)
|
||||
Iconics.respectFontBoundsDefault = true
|
||||
|
||||
if (!profileLoadById(config.lastProfileId)) {
|
||||
db.profileDao().firstId?.let { profileLoadById(it) }
|
||||
// initialize companion object values
|
||||
AppData.read(this)
|
||||
App.db = AppDb(this)
|
||||
App.config = Config(App.db)
|
||||
debugMode = BuildConfig.DEBUG
|
||||
devMode = config.devMode ?: debugMode
|
||||
enableChucker = config.enableChucker ?: devMode
|
||||
|
||||
if (devMode) {
|
||||
HyperLog.initialize(this)
|
||||
HyperLog.setLogLevel(Log.VERBOSE)
|
||||
HyperLog.setLogFormat(DebugLogFormat(this))
|
||||
}
|
||||
|
||||
if (!profileLoadById(config.lastProfileId)) {
|
||||
val success = db.profileDao().firstId?.let { profileLoadById(it) }
|
||||
if (success != true)
|
||||
profileLoad(Profile(0, 0, LoginType.TEMPLATE, ""))
|
||||
}
|
||||
|
||||
buildHttp()
|
||||
|
||||
Themes.themeInt = config.ui.theme
|
||||
config.ui.language?.let {
|
||||
setLanguage(it)
|
||||
}
|
||||
|
||||
devMode = BuildConfig.DEBUG
|
||||
if (BuildConfig.DEBUG)
|
||||
debugMode = true
|
||||
|
||||
Signing.getCert(this)
|
||||
Utils.initializeStorageDir(this)
|
||||
|
||||
launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
config.migrate(this@App)
|
||||
|
||||
SSLProviderInstaller.install(applicationContext, this@App::buildHttp)
|
||||
|
||||
if (config.devModePassword != null)
|
||||
checkDevModePassword()
|
||||
debugMode = devMode || config.debugMode
|
||||
|
||||
if (config.sync.enabled)
|
||||
SyncWorker.scheduleNext(this@App, false)
|
||||
@ -203,35 +263,35 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
.setShortLabel(getString(R.string.shortcut_timetable)).setLongLabel(getString(R.string.shortcut_timetable))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_timetable))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_TIMETABLE))
|
||||
.putExtras("fragmentId" to NavTarget.TIMETABLE))
|
||||
.build()
|
||||
|
||||
val shortcutAgenda = ShortcutInfo.Builder(this@App, "item_agenda")
|
||||
.setShortLabel(getString(R.string.shortcut_agenda)).setLongLabel(getString(R.string.shortcut_agenda))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_agenda))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_AGENDA))
|
||||
.putExtras("fragmentId" to NavTarget.AGENDA))
|
||||
.build()
|
||||
|
||||
val shortcutGrades = ShortcutInfo.Builder(this@App, "item_grades")
|
||||
.setShortLabel(getString(R.string.shortcut_grades)).setLongLabel(getString(R.string.shortcut_grades))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_grades))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_GRADES))
|
||||
.putExtras("fragmentId" to NavTarget.GRADES))
|
||||
.build()
|
||||
|
||||
val shortcutHomework = ShortcutInfo.Builder(this@App, "item_homeworks")
|
||||
.setShortLabel(getString(R.string.shortcut_homework)).setLongLabel(getString(R.string.shortcut_homework))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_homework))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_HOMEWORK))
|
||||
.putExtras("fragmentId" to NavTarget.HOMEWORK))
|
||||
.build()
|
||||
|
||||
val shortcutMessages = ShortcutInfo.Builder(this@App, "item_messages")
|
||||
.setShortLabel(getString(R.string.shortcut_messages)).setLongLabel(getString(R.string.shortcut_messages))
|
||||
.setIcon(Icon.createWithResource(this@App, R.mipmap.ic_shortcut_messages))
|
||||
.setIntent(Intent(Intent.ACTION_MAIN, null, this@App, MainActivity::class.java)
|
||||
.putExtra("fragmentId", MainActivity.DRAWER_ITEM_MESSAGES))
|
||||
.putExtras("fragmentId" to NavTarget.MESSAGES))
|
||||
.build()
|
||||
|
||||
shortcutManager.dynamicShortcuts = listOf(
|
||||
@ -257,6 +317,10 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
val pushMobidziennikApp = FirebaseApp.initializeApp(
|
||||
this@App,
|
||||
FirebaseOptions.Builder()
|
||||
.setProjectId("mobidziennik")
|
||||
.setStorageBucket("mobidziennik.appspot.com")
|
||||
.setDatabaseUrl("https://mobidziennik.firebaseio.com")
|
||||
.setGcmSenderId("747285019373")
|
||||
.setApiKey("AIzaSyCi5LmsZ5BBCQnGtrdvWnp1bWLCNP8OWQE")
|
||||
.setApplicationId("1:747285019373:android:f6341bf7b158621d")
|
||||
.build(),
|
||||
@ -266,6 +330,10 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
val pushLibrusApp = FirebaseApp.initializeApp(
|
||||
this@App,
|
||||
FirebaseOptions.Builder()
|
||||
.setProjectId("synergiadru")
|
||||
.setStorageBucket("synergiadru.appspot.com")
|
||||
.setDatabaseUrl("https://synergiadru.firebaseio.com")
|
||||
.setGcmSenderId("513056078587")
|
||||
.setApiKey("AIzaSyDfTuEoYPKdv4aceEws1CO3n0-HvTndz-o")
|
||||
.setApplicationId("1:513056078587:android:1e29083b760af544")
|
||||
.build(),
|
||||
@ -275,19 +343,38 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
val pushVulcanApp = FirebaseApp.initializeApp(
|
||||
this@App,
|
||||
FirebaseOptions.Builder()
|
||||
.setProjectId("dzienniczekplus")
|
||||
.setStorageBucket("dzienniczekplus.appspot.com")
|
||||
.setDatabaseUrl("https://dzienniczekplus.firebaseio.com")
|
||||
.setGcmSenderId("987828170337")
|
||||
.setApiKey("AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA")
|
||||
.setApplicationId("1:987828170337:android:ac97431a0a4578c3")
|
||||
.build(),
|
||||
"Vulcan"
|
||||
)
|
||||
|
||||
val pushVulcanHebeApp = FirebaseApp.initializeApp(
|
||||
this@App,
|
||||
FirebaseOptions.Builder()
|
||||
.setProjectId("dzienniczekplus")
|
||||
.setStorageBucket("dzienniczekplus.appspot.com")
|
||||
.setDatabaseUrl("https://dzienniczekplus.firebaseio.com")
|
||||
.setGcmSenderId("987828170337")
|
||||
.setApiKey("AIzaSyDW8MUtanHy64_I0oCpY6cOxB3jrvJd_iA")
|
||||
.setApplicationId("1:987828170337:android:7e16404b9e5deaaa")
|
||||
.build(),
|
||||
"VulcanHebe"
|
||||
)
|
||||
|
||||
try {
|
||||
FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { instanceIdResult ->
|
||||
val token = instanceIdResult.token
|
||||
d("Firebase", "Got App token: $token")
|
||||
config.sync.tokenApp = token
|
||||
}
|
||||
FirebaseInstanceId.getInstance(pushMobidziennikApp).instanceId.addOnSuccessListener { instanceIdResult ->
|
||||
val token = instanceIdResult.token
|
||||
d("Firebase", "Got Mobidziennik2 token: $token")
|
||||
if (token != config.sync.tokenMobidziennik) {
|
||||
config.sync.tokenMobidziennik = token
|
||||
config.sync.tokenMobidziennikList = listOf()
|
||||
@ -295,6 +382,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
}
|
||||
FirebaseInstanceId.getInstance(pushLibrusApp).instanceId.addOnSuccessListener { instanceIdResult ->
|
||||
val token = instanceIdResult.token
|
||||
d("Firebase", "Got Librus token: $token")
|
||||
if (token != config.sync.tokenLibrus) {
|
||||
config.sync.tokenLibrus = token
|
||||
config.sync.tokenLibrusList = listOf()
|
||||
@ -302,11 +390,20 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
}
|
||||
FirebaseInstanceId.getInstance(pushVulcanApp).instanceId.addOnSuccessListener { instanceIdResult ->
|
||||
val token = instanceIdResult.token
|
||||
d("Firebase", "Got Vulcan token: $token")
|
||||
if (token != config.sync.tokenVulcan) {
|
||||
config.sync.tokenVulcan = token
|
||||
config.sync.tokenVulcanList = listOf()
|
||||
}
|
||||
}
|
||||
FirebaseInstanceId.getInstance(pushVulcanHebeApp).instanceId.addOnSuccessListener { instanceIdResult ->
|
||||
val token = instanceIdResult.token
|
||||
d("Firebase", "Got VulcanHebe token: $token")
|
||||
if (token != config.sync.tokenVulcanHebe) {
|
||||
config.sync.tokenVulcanHebe = token
|
||||
config.sync.tokenVulcanHebeList = listOf()
|
||||
}
|
||||
}
|
||||
FirebaseMessaging.getInstance().subscribeToTopic(packageName)
|
||||
} catch (e: IllegalStateException) {
|
||||
e.printStackTrace()
|
||||
@ -320,10 +417,28 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
fun profileLoad(profile: Profile) {
|
||||
App.profile = profile
|
||||
App.config.lastProfileId = profile.id
|
||||
try {
|
||||
App.data = AppData.get(profile.loginStoreType)
|
||||
d("App", "Loaded AppData: ${App.data}")
|
||||
// apply newly-added config overrides, if not changed by the user yet
|
||||
for ((key, value) in App.data.configOverrides) {
|
||||
val config = App.profile.config
|
||||
if (!config.has(key))
|
||||
config.set(key, value)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("App", "Cannot load AppData", e)
|
||||
Toast.makeText(this, R.string.app_cannot_load_data, Toast.LENGTH_LONG).show()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun profileLoadById(profileId: Int): Boolean {
|
||||
db.profileDao().getByIdNow(profileId)?.also {
|
||||
App.profile = it
|
||||
App.config.lastProfileId = it.id
|
||||
profileLoad(it)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -347,10 +462,15 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
|
||||
if (!success) {
|
||||
EventBus.getDefault().post(ProfileListEmptyEvent())
|
||||
}
|
||||
else {
|
||||
onSuccess(profile)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun profileSave() = profileSave(profile)
|
||||
fun profileSave(profile: Profile) {
|
||||
if (profile.id == profileId)
|
||||
App.profile = profile
|
||||
launch(Dispatchers.Default) {
|
||||
App.db.profileDao().add(profile)
|
||||
}
|
||||
|
@ -4,8 +4,11 @@
|
||||
package pl.szczodrzynski.edziennik
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.BindingAdapter
|
||||
import pl.szczodrzynski.edziennik.ext.dp
|
||||
|
||||
object Binding {
|
||||
@JvmStatic
|
||||
@ -17,4 +20,64 @@ object Binding {
|
||||
textView.paintFlags = textView.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:isVisible")
|
||||
fun isVisible(view: View, isVisible: Boolean) {
|
||||
view.isVisible = isVisible
|
||||
}
|
||||
|
||||
private fun resizeDrawable(textView: TextView, index: Int, size: Int) {
|
||||
val drawables = textView.compoundDrawables
|
||||
drawables[index]?.setBounds(0, 0, size, size)
|
||||
textView.setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3])
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableLeftAutoSize")
|
||||
fun drawableLeftAutoSize(textView: TextView, enable: Boolean) = resizeDrawable(
|
||||
textView,
|
||||
index = 0,
|
||||
size = textView.textSize.toInt(),
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableRightAutoSize")
|
||||
fun drawableRightAutoSize(textView: TextView, enable: Boolean) = resizeDrawable(
|
||||
textView,
|
||||
index = 2,
|
||||
size = textView.textSize.toInt(),
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableLeftSize")
|
||||
fun drawableLeftSize(textView: TextView, sizeDp: Int) = resizeDrawable(
|
||||
textView,
|
||||
index = 0,
|
||||
size = sizeDp.dp,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableTopSize")
|
||||
fun drawableTopSize(textView: TextView, sizeDp: Int) = resizeDrawable(
|
||||
textView,
|
||||
index = 1,
|
||||
size = sizeDp.dp,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableRightSize")
|
||||
fun drawableRightSize(textView: TextView, sizeDp: Int) = resizeDrawable(
|
||||
textView,
|
||||
index = 2,
|
||||
size = sizeDp.dp,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("android:drawableBottomSize")
|
||||
fun drawableBottomSize(textView: TextView, sizeDp: Int) = resizeDrawable(
|
||||
textView,
|
||||
index = 3,
|
||||
size = sizeDp.dp,
|
||||
)
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user