Skip to content

Commit 6a2409e

Browse files
authored
Merge pull request #56 from horaciocome1/set-up-markdown-support
Set up markdown support
2 parents a058607 + 6fc04cc commit 6a2409e

File tree

138 files changed

+4472
-3529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+4472
-3529
lines changed

.idea/assetWizardSettings.xml

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/navEditor.xml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ android {
3636
applicationId "io.github.horaciocome1.reaque"
3737
minSdkVersion 16
3838
targetSdkVersion 29
39-
versionCode 16
40-
versionName "1.4.2-rc-35"
39+
versionCode 17
40+
versionName "1.5.0-rc-60"
4141
vectorDrawables.useSupportLibrary = true
4242
multiDexEnabled true
4343
}
@@ -51,7 +51,7 @@ android {
5151
dataBinding {
5252
enabled = true
5353
}
54-
buildToolsVersion = '29.0.0'
54+
buildToolsVersion = '29.0.2'
5555
}
5656

5757
dependencies {
@@ -64,11 +64,11 @@ dependencies {
6464
implementation 'androidx.multidex:multidex:2.0.1'
6565

6666
// lifecycle
67-
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
67+
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
6868

6969
// ui
7070
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
71-
implementation 'androidx.appcompat:appcompat:1.0.2'
71+
implementation 'androidx.appcompat:appcompat:1.1.0'
7272
implementation 'com.google.android.material:material:1.0.0'
7373
implementation 'com.github.horaciocome1:simple-recyclerview-touch-listener:0.2.2'
7474
implementation 'com.github.bumptech.glide:glide:4.9.0'
@@ -79,14 +79,14 @@ dependencies {
7979
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
8080

8181
// firebase
82-
implementation 'com.google.firebase:firebase-core:17.0.1'
83-
implementation 'com.google.firebase:firebase-firestore:20.2.0'
84-
implementation 'com.google.firebase:firebase-storage:18.1.1'
85-
implementation 'com.google.firebase:firebase-auth:18.1.0'
86-
implementation 'com.google.firebase:firebase-perf:18.0.1'
82+
implementation 'com.google.firebase:firebase-core:17.2.0'
83+
implementation 'com.google.firebase:firebase-firestore:21.1.0'
84+
implementation 'com.google.firebase:firebase-storage:19.0.1'
85+
implementation 'com.google.firebase:firebase-auth:19.0.0'
86+
implementation 'com.google.firebase:firebase-perf:19.0.0'
8787
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
88-
implementation 'com.google.firebase:firebase-dynamic-links:18.0.0'
89-
implementation 'com.google.firebase:firebase-messaging:19.0.1'
88+
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
89+
implementation 'com.google.firebase:firebase-messaging:20.0.0'
9090

9191
// play services
9292
implementation 'com.google.android.gms:play-services-auth:17.0.0'

app/src/main/java/io/github/horaciocome1/reaque/data/bookmarks/BookmarksService.kt

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ class BookmarksService : BookmarksInterface {
5252
}
5353

5454
override fun bookmark(post: Post, onCompleteListener: (Task<Void?>?) -> Unit) {
55-
if (post.id.isNotBlank() && auth.currentUser != null) {
56-
val bookmarkRef = db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
55+
if (
56+
post.id.isNotBlank()
57+
&& auth.currentUser != null
58+
) {
59+
val bookmarkRef = db.document(
60+
"users/${auth.currentUser!!.uid}" +
61+
"/bookmarks/${post.id}"
62+
)
5763
val postRef = db.document("posts/${post.id}")
5864
val userRef = db.document("users/${auth.currentUser!!.uid}")
5965
db.runBatch {
@@ -65,8 +71,14 @@ class BookmarksService : BookmarksInterface {
6571
}
6672

6773
override fun unBookmark(post: Post, onCompleteListener: (Task<Void?>?) -> Unit) {
68-
if (post.id.isNotBlank() && auth.currentUser != null) {
69-
val bookmarkRef = db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
74+
if (
75+
post.id.isNotBlank()
76+
&& auth.currentUser != null
77+
) {
78+
val bookmarkRef = db.document(
79+
"users/${auth.currentUser!!.uid}" +
80+
"/bookmarks/${post.id}"
81+
)
7082
val postRef = db.document("posts/${post.id}")
7183
val userRef = db.document("users/${auth.currentUser!!.uid}")
7284
db.runBatch {
@@ -79,9 +91,12 @@ class BookmarksService : BookmarksInterface {
7991

8092
override fun get(): LiveData<List<Post>> {
8193
posts.value?.let { list ->
82-
if (list.isEmpty() && auth.currentUser != null)
94+
if (
95+
list.isEmpty()
96+
&& auth.currentUser != null
97+
)
8398
db.collection("users/${auth.currentUser!!.uid}/bookmarks")
84-
.orderBy("score", Query.Direction.DESCENDING)
99+
.orderBy("timestamp", Query.Direction.DESCENDING)
85100
.limit(100)
86101
.get()
87102
.addOnSuccessListener {
@@ -97,7 +112,10 @@ class BookmarksService : BookmarksInterface {
97112
if (post.id.isNotBlank() && auth.currentUser != null)
98113
db.document("users/${auth.currentUser!!.uid}/bookmarks/${post.id}")
99114
.addSnapshotListener { snapshot, exception ->
100-
isBookmarked.value = if (exception == null && snapshot != null)
115+
isBookmarked.value = if (
116+
exception == null
117+
&& snapshot != null
118+
)
101119
if (snapshot.exists())
102120
Constants.States.TRUE
103121
else
@@ -113,7 +131,11 @@ class BookmarksService : BookmarksInterface {
113131
if (auth.currentUser != null)
114132
db.document("users/${auth.currentUser!!.uid}")
115133
.addSnapshotListener { snapshot, exception ->
116-
if (exception == null && snapshot != null && snapshot.contains("bookmarks"))
134+
if (
135+
exception == null
136+
&& snapshot != null
137+
&& snapshot.contains("bookmarks")
138+
)
117139
hasBookmarks.value = snapshot["bookmarks"].toString().toInt() > 0
118140
}
119141
return hasBookmarks

app/src/main/java/io/github/horaciocome1/reaque/data/configurations/ConfigurationsService.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,25 @@ class ConfigurationsService : ConfigurationsInterface {
3838
isUpdateAvailable.value = false
3939
db.document("configurations/default")
4040
.addSnapshotListener { snapshot, exception ->
41-
if (exception == null && snapshot != null && snapshot.contains("version_code"))
42-
isUpdateAvailable.value = versionCode < snapshot["version_code"].toString().toInt()
41+
if (
42+
exception == null
43+
&& snapshot != null
44+
&& snapshot.contains("version_code")
45+
)
46+
isUpdateAvailable.value = versionCode < snapshot["version_code"].toString()
47+
.toInt()
4348
}
4449
return isUpdateAvailable
4550
}
4651

4752
override fun getLatestVersionName(): LiveData<String> {
4853
db.document("configurations/default")
4954
.addSnapshotListener { snapshot, exception ->
50-
if (exception == null && snapshot != null && snapshot.contains("version_name"))
55+
if (
56+
exception == null
57+
&& snapshot != null
58+
&& snapshot.contains("version_name")
59+
)
5160
latestVersionName.value = snapshot["version_name"].toString()
5261
}
5362
return latestVersionName

app/src/main/java/io/github/horaciocome1/reaque/data/feed/FeedService.kt

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,37 @@ class FeedService : FeedInterface {
2121
private var _posts = mutableListOf<Post>()
2222

2323
private val posts: MutableLiveData<List<Post>> by lazy {
24-
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
24+
MutableLiveData<List<Post>>().apply {
25+
value = mutableListOf()
26+
}
2527
}
2628

2729
override fun get(): LiveData<List<Post>> {
28-
if (_posts.isEmpty() && auth.currentUser != null)
29-
db.collection("users/${auth.currentUser!!.uid}/feed")
30-
.orderBy("score", Query.Direction.DESCENDING)
31-
.limit(100)
32-
.get()
33-
.addOnSuccessListener {
34-
if (it != null) {
35-
_posts = it.posts
36-
posts.value = _posts
37-
}
38-
}
30+
if (auth.currentUser == null)
31+
auth.addAuthStateListener {
32+
if (
33+
_posts.isEmpty()
34+
&& it.currentUser != null
35+
&& _posts.isEmpty()
36+
)
37+
getFeed()
38+
}
39+
else if (_posts.isEmpty())
40+
getFeed()
3941
return posts
4042
}
4143

44+
private fun getFeed() {
45+
db.collection("users/${auth.currentUser!!.uid}/feed")
46+
.orderBy("timestamp", Query.Direction.DESCENDING)
47+
.limit(100)
48+
.get()
49+
.addOnSuccessListener {
50+
if (it != null) {
51+
_posts = it.posts
52+
posts.value = _posts
53+
}
54+
}
55+
}
56+
4257
}

app/src/main/java/io/github/horaciocome1/reaque/data/posts/PostsService.kt

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,21 @@ class PostsService : PostsInterface {
3232
}
3333

3434
private val topicPosts: MutableLiveData<List<Post>> by lazy {
35-
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
35+
MutableLiveData<List<Post>>().apply {
36+
value = mutableListOf()
37+
}
3638
}
3739

3840
private val userPosts: MutableLiveData<List<Post>> by lazy {
39-
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
41+
MutableLiveData<List<Post>>().apply {
42+
value = mutableListOf()
43+
}
4044
}
4145

4246
private val top10Posts: MutableLiveData<List<Post>> by lazy {
43-
MutableLiveData<List<Post>>().apply { value = mutableListOf() }
47+
MutableLiveData<List<Post>>().apply {
48+
value = mutableListOf()
49+
}
4450
}
4551

4652
private var postId = ""
@@ -54,12 +60,24 @@ class PostsService : PostsInterface {
5460
post.user = auth.currentUser!!.user
5561
val postRef = db.collection("posts").document()
5662
post.id = postRef.id
57-
val postOnTopicRef = db.document("topics/${post.topic.id}/posts/${postRef.id}")
58-
val postOnUserRef = db.document("users/${post.user.id}/posts/${postRef.id}")
59-
val userOnTopicRef = db.document("topics/${post.topic.id}/users/${post.user.id}")
63+
val postOnTopicRef = db.document(
64+
"topics/${post.topic.id}" +
65+
"/posts/${postRef.id}"
66+
)
67+
val postOnUserRef = db.document(
68+
"users/${post.user.id}" +
69+
"/posts/${postRef.id}"
70+
)
71+
val userOnTopicRef = db.document(
72+
"topics/${post.topic.id}" +
73+
"/users/${post.user.id}"
74+
)
6075
val topicRef = db.document("topics/${post.topic.id}")
6176
val userRef = db.document("users/${post.user.id}")
62-
val myFeedRef = db.document("users/${post.user.id}/feed/${postRef.id}")
77+
val myFeedRef = db.document(
78+
"users/${post.user.id}" +
79+
"/feed/${postRef.id}"
80+
)
6381
db.runBatch {
6482
it.set(postRef, post.map)
6583
it.set(postOnTopicRef, post.mapSimple)
@@ -92,7 +110,7 @@ class PostsService : PostsInterface {
92110
if (user.id != userId && user.id.isNotBlank()) {
93111
userPosts.value = mutableListOf()
94112
db.collection("users/${user.id}/posts")
95-
.orderBy("score", Query.Direction.DESCENDING)
113+
.orderBy("timestamp", Query.Direction.DESCENDING)
96114
.limit(100)
97115
.get()
98116
.addOnSuccessListener {
@@ -108,7 +126,7 @@ class PostsService : PostsInterface {
108126
if (topic.id != topicId && topic.id.isNotBlank()) {
109127
topicPosts.value = mutableListOf()
110128
db.collection("topics/${topic.id}/posts")
111-
.orderBy("score", Query.Direction.DESCENDING)
129+
.orderBy("timestamp", Query.Direction.DESCENDING)
112130
.limit(100)
113131
.get()
114132
.addOnSuccessListener {

0 commit comments

Comments
 (0)