Skip to content

Commit

Permalink
Handle TODOs ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
aksh1618 committed Feb 23, 2019
1 parent a6b9687 commit d477dc0
Show file tree
Hide file tree
Showing 26 changed files with 62 additions and 71 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

// This leads to in.bitotsav... in autogenerated code, but as in is a keyword in Kotlin, compilation
// fails. Bug report to be filed.
// fails. Bug report created: https://issuetracker.google.com/issues/126020455.
//apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: "androidx.navigation.safeargs"

Expand Down Expand Up @@ -58,7 +58,6 @@ android {
}

ext {
// TODO: Move these to project.ext in project level build.gradle
gson_version = "2.8.5"
room_version = "2.1.0-alpha04"
coroutines_version = "1.1.0"
Expand Down
47 changes: 29 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="in.bitotsav">
xmlns:tools="http://schemas.android.com/tools"
package="in.bitotsav">

<!--TODO: Fix ignores-->
<!-- ACTION-VIEW Intent Filter is automatically generated by the nav-graph element. -->
<!-- The replace is needed to override backup behaviour specified in libraries. -->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.Launcher"
android:name=".Bitotsav19"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".HomeActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:documentLaunchMode="intoExisting">
<nav-graph android:value="@navigation/nav_bitotsav"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
android:name=".Bitotsav19"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.Launcher"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:allowBackup">

<activity
android:name=".HomeActivity"
android:documentLaunchMode="intoExisting"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">

<category android:name="android.intent.category.LAUNCHER"/>
<nav-graph android:value="@navigation/nav_bitotsav" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

<service android:name="in.bitotsav.notification.fcm.DefaultFirebaseMessagingService">
<service android:name="in.bitotsav.notification.fcm.DefaultFirebaseMessagingService"
tools:ignore="ExportedService">

<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>

</service>

</application>

</manifest>
15 changes: 9 additions & 6 deletions app/src/main/java/in/bitotsav/Bitotsav19.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ class Bitotsav19 : Application() {
}

// Global TODOs
// TODO: Move tools:context in all layout files from <layout> to root inside <layout>
// TODO: [Refactor] The magnum opus: Wire color change into the lifecycle, so every
// major interactions causes a color change!
// TODO: [WARN]: Figure out if lifecycleOwner passed to data binding should be
// viewLifecycleOwner or
// TODO: [Refactor] Inject all services as AuthenticationService is right now
// TODO [WARN]: Figure out if lifecycleOwner passed to data binding should be
// viewLifecycleOwner or fragment.this
// TODO [WARN]: Figure out if app:layout_behavior="@string/appbar_scrolling_view_behavior" can
// break in various layout files.
// TODO [Refactor]: Inject all services as AuthenticationService is right now
// TODO [Refactor]: Try removing as many observers from fragments as possible, observing should
// preferably be done by data binding view only.
// TODO [WARN]: Figure out which fragment lifecycle method should contain what code, instead of putting
// everything in onCreateView. Might lead to increased performance.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class EventDetailFragment : Fragment() {
}

binding.share.setOnClickListener {
// FIXME [WARN] : Use deep link here.
eventViewModel.currentEvent.value?.let {
val link = "bitotsav.in/event/${it.id}"
val textToShare = getString(R.string.event_format_share_text, it.name, link)
Expand All @@ -102,7 +101,7 @@ class EventDetailFragment : Fragment() {
eventViewModel.isUserAlreadyRegistered
.onTrue {
Log.d(TAG, "Deregistering...")
// FIXME [WARN]: Add Confirmation Dialog
// TODO [Refactor]: Add Confirmation Dialog
toast("Deregistering...")
eventViewModel.deregister()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class EventRegistrationFragment : Fragment() {

isUserRegistered.setObserver(viewLifecycleOwner) { registered ->
if (registered) {
// TODO: Show success in some way
this@EventRegistrationFragment.toast(
getString(
R.string.event_format_registration_message,
Expand Down Expand Up @@ -107,4 +106,4 @@ class EventRegistrationFragment : Fragment() {

}

// FIXME [WARN]: Ask for confirmation before going back from registration
// TODO [Refactor]: Ask for confirmation before going back from registration
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NightDetailFragment : Fragment() {
return binding.root
}

// TODO : Create a back button somewhere
// TODO [Refactor] : Create a back button somewhere
// private fun setClickListeners(binding: FragmentEventDetailBinding) {
//
// binding.back.setOnClickListener {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/in/bitotsav/events/ui/ScheduleFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ScheduleFragment : Fragment() {
private lateinit var binding: FragmentScheduleBinding
private val filterAdapter by lazy { ScheduleFilterAdapter(scheduleViewModel) }

// TODO: Get colors from resources
private val filterColors by lazy {
context?.resources?.getIntArray(R.array.categoryColors)
?: intArrayOf(scheduleViewModel.mColor)
Expand All @@ -49,7 +48,7 @@ class ScheduleFragment : Fragment() {
): View? {

uiUtilViewModel.showBottomNav()
// TODO: May need to account for sheet closed on swipe
// TODO [Refactor] : May need to account for sheet closed on swipe
scheduleViewModel.hideFiltersSheet()
scheduleViewModel.setupFilters()
scheduleViewModel.filterColors = filterColors
Expand All @@ -58,7 +57,6 @@ class ScheduleFragment : Fragment() {
}.data

binding = FragmentScheduleBinding.inflate(inflater, container, false)
// TODO: Putting everything from here on in onActivityCreated may increase performance.
.apply {
lifecycleOwner = this@ScheduleFragment
viewModel = scheduleViewModel
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/in/bitotsav/events/ui/ScheduleViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ScheduleViewModel(
get() = scheduleFiltersList
lateinit var filterColors: IntArray
private lateinit var allCategories: List<String>
// TODO: Use switch map with double trigger for this
// TODO [Refactor]: Use switch map with double trigger for this ?
val areFiltersActive = MutableLiveData<Boolean>()
val filterFabVisible = NonNullMutableLiveData(true)

Expand All @@ -57,7 +57,6 @@ class ScheduleViewModel(
throw IllegalStateException("Categories and/or starred are null, somehow")
when (categories) {
ALL_CATEGORIES -> eventRepository.getByDay(day, starredOnly)
// TODO: May need to be sorted by time
else -> eventRepository.getByCategoriesForDay(
day,
starredOnly,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/in/bitotsav/koin/modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import retrofit2.converter.gson.GsonConverterFactory

private const val baseUrl = "https://bitotsav.in/api/app/"

// TODO: Should modules conform to package division?
// TODO [Refactor]: Should modules conform to package division?
val repositoriesModule = module {

single {
Expand Down Expand Up @@ -67,7 +67,7 @@ val retrofitModule = module {
}
).create()
}
// TODO: Check if custom client is required
// TODO @ashank : Check if custom client is required
single {
Retrofit.Builder()
.baseUrl(baseUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import androidx.navigation.NavDeepLinkBuilder
import java.util.*

enum class Channel(val id: String, val channelName: String) {
ANNOUNCEMENT("announcement", "Announcement"), // Announcement icon
EVENT("event", "Event"), // TODO: Bitotsav logo vector
PM("pm", "Private Message"), // Priority high icon or profile icon
RESULT("result", "Result"), // Trophy icon
STARRED("starred", "Starred") // Star icon
ANNOUNCEMENT("announcement", "Announcement"),
EVENT("event", "Event"),
PM("pm", "Private Message"),
RESULT("result", "Result"),
STARRED("starred", "Starred")
}

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ fun displayNotification(

@TargetApi(26)
fun createNotificationChannels(context: Context) {
// TODO("Fix notification channel for MIUI")
// TODO [Feature]: Add a workaround for anomalous behavior of notification channels on MIUI
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class ChampionshipRegistrationFragment : Fragment() {

championshipTeamRegistered.setObserver(viewLifecycleOwner) { registered ->
if (registered) {
// TODO: Show success in some way
this@ChampionshipRegistrationFragment.toast(
getString(
R.string.profile_format_registration_message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RegistrationFragment : Fragment() {
}

override fun onSaveInstanceState(outState: Bundle) {
// TODO: Check if saving email and password is needed
// TODO [Refactor]: Figure out if saving email and password is necessary
registrationViewModel.fields.email.text.value.let {
it.isNotEmpty().onTrue { outState.putString(KEY_EMAIL, it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import com.google.android.gms.common.api.CommonStatusCodes
import com.google.android.gms.safetynet.SafetyNet
import org.koin.androidx.viewmodel.ext.sharedViewModel

// TODO: [Refactor] Try removing as many observers as possible, observing should be
// done by data binding view only, preferably.
class RegistrationStepFragment : Fragment() {

companion object {
Expand Down Expand Up @@ -98,7 +96,7 @@ class RegistrationStepFragment : Fragment() {
}
}

// TODO: Autofill this OTP if same device.
// TODO [Feature]: Autofill this OTP if same device.
private fun setStepTwoObservers() {
with(registrationViewModel) {

Expand Down Expand Up @@ -153,7 +151,7 @@ class RegistrationStepFragment : Fragment() {
.addOnFailureListener(activity as Activity) { e ->
if (e is ApiException) {
// An error occurred when communicating with the
// reCAPTCHA service. TODO: Refer to the status code to
// reCAPTCHA service. TODO [Refactor]: Refer to the status code to
// handle the error appropriately.
Log.e(
"RegistrationVM.captcha",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class RegistrationViewModel(
private val authService: AuthenticationService
) : BaseViewModel("RegVM") {

// TODO: Should this be initialized or lateinit ?
var fields = RegistrationFields()
val nextStep = NonNullMutableLiveData(1)
val registrationError = NonNullMutableLiveData("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import `in`.bitotsav.shared.utils.onTrue
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData

// TODO: [REFACTOR] Make DSL out of this
// TODO [Refactor]: Make DSL out of this
class MutableLiveDataTextWithValidation(
vararg validationErrorPairs: Pair<String.() -> Boolean, String>,
defaultText: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//// FIXME: Remove after creating proper tests.
//// TODO [Refactor]: Remove after creating proper tests.
//package `in`.bitotsav.profile.utils
//
//import `in`.bitotsav.profile.api.AuthenticationService
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/in/bitotsav/shared/ui/BaseViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ abstract class BaseViewModel(

fun toast(message: String) {
_toastMessage.value = message
// TODO: Adding this line might help avoid duplicate toasts
// TODO [Refactor]: Use SingleLiveEvent for toast instead of LiveData
// Meanwhile, adding this line might help avoid duplicate toasts
// _toastMessage.value = ""
}

private val parentJob = Job()
private val coroutineContext: CoroutineContext
get() = parentJob + Dispatchers.Main

// FIXME: Rename this to uiScope
// TODO [Refactor]: Rename this to uiScope
protected val scope = CoroutineScope(coroutineContext)

override fun onCleared() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProfileWorker(context: Context, params: WorkerParameters) : Worker(context
return Result.failure()
} catch (e: AuthException) {
Log.d(TAG, e.message ?: "Authentication exception")
// TODO: Delete token
// TODO @ashank : Delete token
return Result.failure()
} catch (e: UnknownHostException) {
Log.d(TAG, e.message ?: "Unknown Error")
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/content_event_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
tools:text="Team members will be separated and sent to various rooms where they have to solve quizzes on various topics such as gaming, etc. Rest of the topics will be disclosed during the event." />

<!-- Rules -->
<!-- TODO [Refactor]: Use spans to insert bullets ? -->
<TextView
android:id="@+id/label_rules_text_view"
android:layout_width="0dp"
Expand Down Expand Up @@ -166,7 +165,6 @@
app:layout_constraintTop_toBottomOf="@+id/category_text_view"
tools:textColor="?colorPrimary" />

<!-- FIXME: Text color on this -->
<TextView
android:id="@+id/status_text_view"
android:layout_width="0dp"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
app:tabbed="@{false}"
app:title="@{@string/feed_title}" />

<!-- FIXME: [WARN] Might break because of behavior string. -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/feed"
android:layout_width="match_parent"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
app:tabbed="@{true}"
app:title="@{@string/info_title}" />

<!-- FIXME: [WARN] Might break because of behavior string. -->
<androidx.viewpager.widget.ViewPager
android:id="@+id/infoPager"
android:layout_width="match_parent"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_leaderboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
app:tabbed="@{false}"
app:title="@{@string/leaderboard_title}" />

<!-- FIXME: [WARN] Might break because of behavior string. -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
android:layout_gravity="center"
android:orientation="vertical">

<!-- TODO: Do something about hint color on focus -->
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Bitotsav.TextInput"
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_registration_step_one.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
app:inputType="@{InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS}"
app:target="@{fields.email}" />

<!-- TODO: Indicate this will mailed and then removed -->
<!-- TODO [Refactor]: Indicate this will mailed and then removed -->
<include
android:id="@+id/password"
layout="@layout/include_edit_text"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_schedule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
app:tabbed="@{true}"
app:title="@{@string/schedule_title}" />

<!-- FIXME: [WARN] Might break because of behavior string. -->
<androidx.viewpager.widget.ViewPager
android:id="@+id/dayPager"
android:layout_width="match_parent"
Expand Down
Loading

0 comments on commit d477dc0

Please sign in to comment.