Skip to content

Commit c3cbe29

Browse files
committed
Update comments
1 parent 1581cf2 commit c3cbe29

24 files changed

+138
-359
lines changed

Readme.md

+7-25
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,13 @@
22
An android app that lets you use Jira like a basic to-do app, keeping
33
all your personal and work tasks in one interface.
44

5-
# API
6-
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get
5+
# Sample Data to test app
6+
Name: Any
7+
Email: dave@davedavis.io
8+
Jira subdomain: davedavis
9+
Jira project ID: TODORA
10+
Jira API key: MpkWzHiXp3QdnrtdSZdqF38A
11+
Annex 2 - Supervisor Emails
712

8-
# API Token
9-
https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/
10-
MpkWzHiXp3QdnrtdSZdqF38A
11-
12-
# Sample API Queries
13-
14-
curl -D- \
15-
-u dave@davedavis.io:MpkWzHiXp3QdnrtdSZdqF38A \
16-
-X GET \
17-
-H "Content-Type: application/json" \
18-
https://davedavis.atlassian.net/rest/api/2/issue/createmeta
19-
20-
21-
22-
curl -D- \
23-
-u dave@davedavis.io:MpkWzHiXp3QdnrtdSZdqF38A \
24-
-X GET \
25-
-H "Content-Type: application/json" \
26-
https://davedavis.atlassian.net/rest/api/2/search?jql=project="TODORA"
27-
28-
29-
# Sample API Response
30-
sampleresponse.json
3113

3214

app/src/main/java/io/davedavis/todora/model/ParcelableIssue.kt

-21
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@ import com.squareup.moshi.Json
77
import com.squareup.moshi.JsonClass
88
import kotlinx.android.parcel.Parcelize
99

10-
//@SuppressLint("ParcelCreator")
11-
//@Parcelize
12-
//@JsonClass(generateAdapter = true)
13-
//data class ParcelableIssue(
14-
// @Json(name = "summary")
15-
// val summary: String?,
16-
// @Json(name = "description")
17-
// val description: String?,
18-
// @Json(name = "id")
19-
// val id: String?,
20-
// @Json(name = "key")
21-
// val key: String?,
22-
// @Json(name = "priority")
23-
// val priority: String?,
24-
// @Json(name = "timespent")
25-
// val timespent: Long?,
26-
// @Json(name = "self")
27-
// val self: String?
28-
//
29-
//) : Parcelable
30-
3110

3211
@SuppressLint("ParcelCreator")
3312
@Parcelize

app/src/main/java/io/davedavis/todora/ui/create/CreateFragment.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,29 @@ import timber.log.Timber
2020

2121
class CreateFragment : Fragment() {
2222

23-
23+
/**
24+
* Grab instances of our [CreateViewModel] and [viewModelFactory] so we can build the viewModel
25+
* with a factory (we're not actually using it yet in this fragment.
26+
*/
2427
private lateinit var viewModel: CreateViewModel
2528
private lateinit var viewModelFactory: CreateViewModelFactory
2629

30+
/**
31+
* Hide keyboard helper function that hides the keyboard when focus is lost on the edit text
32+
* items. Prevents keyboard from staying on screen.
33+
* @param view which the system removes input focus from.
34+
*/
2735
fun hideKeyboard(view: View) {
2836
view.apply {
2937
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
3038
imm.hideSoftInputFromWindow(view.windowToken, 0)
3139
}
3240
}
3341

42+
/**
43+
* IInflates the fragment, databinds it, sets its lifecycle owner to the OverviewFragment
44+
* to enable Data Binding to observe LiveData (for state maintenance)
45+
*/
3446
override fun onCreateView(
3547
inflater: LayoutInflater, container: ViewGroup?,
3648
savedInstanceState: Bundle?

app/src/main/java/io/davedavis/todora/ui/create/CreateViewModel.kt

+25-7
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ import androidx.lifecycle.MutableLiveData
66
import androidx.lifecycle.ViewModel
77
import androidx.lifecycle.viewModelScope
88
import io.davedavis.todora.model.*
9-
import io.davedavis.todora.network.Auth
10-
import io.davedavis.todora.network.JiraApi
9+
import io.davedavis.todora.network.*
1110
import io.davedavis.todora.utils.SharedPreferencesManager
1211
import kotlinx.coroutines.launch
1312
import retrofit2.Response
1413
import timber.log.Timber
1514

15+
/**
16+
* ViewModel class that holds all the data and logic for the create issue flow.
17+
*/
1618
class CreateViewModel : ViewModel() {
1719

20+
// Response from the API as a string as it's only in English so can't be localized.
1821
var responseMessage: String = "No response yet"
1922

20-
// The internal MutableLiveData for the selected property
23+
// The internal MutableLiveData for the selected issue
2124
private val _newIssue = MutableLiveData<NewIssue>()
2225
val newIssue: LiveData<NewIssue>
2326
get() = _newIssue
@@ -60,8 +63,11 @@ class CreateViewModel : ViewModel() {
6063

6164

6265
// Set up the edit fields on changed listeners (Bound in the XML)
63-
// Thanks https://stackoverflow.com/questions/33798426/how-to-databind-to-ontextchanged-for-an-edittext-on-android
64-
// ToDo: Move this to the Binding Adapter Class.
66+
67+
/**
68+
* When the description is changed, set the livedata of [newSummary] to the updated value
69+
* so when there's a lifecycle change, the user won't lose any input.
70+
*/
6571
fun onSummaryTextChange(newSummary: Editable?) {
6672
_newIssue.value?.fields?.summary = newSummary.toString()
6773
if (!_newIssue.value?.fields?.description?.content?.get(0)?.content?.get(0)?.actualDescriptionText.isNullOrEmpty()) {
@@ -70,6 +76,10 @@ class CreateViewModel : ViewModel() {
7076

7177
}
7278

79+
/**
80+
* When the description is changed, set the livedata of [newDescription] to the updated value
81+
* so when there's a lifecycle change, the user won't lose any input.
82+
*/
7383
fun onDescriptionTextChange(newDescription: Editable?) {
7484
_newIssue.value?.fields?.description?.content?.get(0)?.content?.get(0)?.actualDescriptionText =
7585
newDescription.toString()
@@ -79,20 +89,28 @@ class CreateViewModel : ViewModel() {
7989

8090
}
8191

92+
/**
93+
* When the issue/to-do is updated, set the [priority] [MutableLiveData]
94+
* @param updatedPriority to the updated one in the view.
95+
*/
8296
fun updatePriority(updatedPriority: Int) {
8397
_newIssue.value?.fields?.priority?.name =
8498
PriorityOptions.values()[updatedPriority].toString()
8599

86100
}
87101

88-
102+
/**
103+
* Submits new issue to the [JiraApiService] by calling [newJiraIssue] through a coroutine.
104+
* @param filter on the [JiraApiFilter]
105+
* @param [newIssue] that goes along with the post request
106+
* Returns a string response.
107+
*/
89108
fun submitNewJiraIssue() {
90109
Timber.i(">>> updateJiraIssue in ViewModel Called")
91110
viewModelScope.launch {
92111
_status.value = JiraAPIStatus.LOADING
93112
try {
94113
Timber.i(">>> Trying ...")
95-
Timber.i(newIssue.value.toString())
96114
val response: Response<Unit> = JiraApi.retrofitService.newJiraIssue(
97115
Auth.getAuthHeaders(),
98116
newIssue.value

app/src/main/java/io/davedavis/todora/ui/create/CreateViewModelFactory.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package io.davedavis.todora.ui.create
33
import androidx.lifecycle.ViewModel
44
import androidx.lifecycle.ViewModelProvider
55

6-
6+
/**
7+
* This factory isn't actually doing anything custom yet. But it will in V2.
8+
*/
79
class CreateViewModelFactory :
810
ViewModelProvider.Factory {
911
@Suppress("unchecked_cast")

app/src/main/java/io/davedavis/todora/ui/debug/DebugFragment.kt

-73
This file was deleted.

app/src/main/java/io/davedavis/todora/ui/debug/DebugViewModel.kt

-52
This file was deleted.

app/src/main/java/io/davedavis/todora/ui/debug/DebugViewModelFactory.kt

-19
This file was deleted.

0 commit comments

Comments
 (0)