-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CA-2108 New user should accept terms of service on first login/register
- Loading branch information
Showing
27 changed files
with
380 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/rfcx/ranger/data/remote/terms/TermsEndpoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.rfcx.ranger.data.remote.terms | ||
|
||
import io.reactivex.Single | ||
import org.rfcx.ranger.entity.terms.TermsRequest | ||
import org.rfcx.ranger.entity.terms.TermsResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface TermsEndpoint { | ||
@POST("v1/users/accept-terms") | ||
fun sendPayload(@Body body: TermsRequest): Single<TermsResponse> | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/rfcx/ranger/data/remote/terms/TermsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.rfcx.ranger.data.remote.terms | ||
|
||
import io.reactivex.Single | ||
import org.rfcx.ranger.entity.terms.TermsRequest | ||
import org.rfcx.ranger.entity.terms.TermsResponse | ||
|
||
interface TermsRepository { | ||
fun sendBodyPayload(sendBody: TermsRequest): Single<TermsResponse> | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/rfcx/ranger/data/remote/terms/TermsRepositoryImp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.rfcx.ranger.data.remote.terms | ||
|
||
import io.reactivex.Single | ||
import org.rfcx.ranger.entity.terms.TermsRequest | ||
import org.rfcx.ranger.entity.terms.TermsResponse | ||
|
||
class TermsRepositoryImp(private val termsEndpoint: TermsEndpoint) : TermsRepository { | ||
override fun sendBodyPayload(sendBody: TermsRequest): Single<TermsResponse> { | ||
return termsEndpoint.sendPayload(sendBody) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/rfcx/ranger/data/remote/terms/TermsUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.rfcx.ranger.data.remote.terms | ||
|
||
import io.reactivex.Single | ||
import org.rfcx.ranger.data.remote.domain.SingleUseCase | ||
import org.rfcx.ranger.data.remote.domain.executor.PostExecutionThread | ||
import org.rfcx.ranger.data.remote.domain.executor.ThreadExecutor | ||
import org.rfcx.ranger.entity.terms.TermsRequest | ||
import org.rfcx.ranger.entity.terms.TermsResponse | ||
|
||
class TermsUseCase(private val termsRepository: TermsRepository, | ||
threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread | ||
) : SingleUseCase<TermsRequest, TermsResponse>(threadExecutor, postExecutionThread) { | ||
override fun buildUseCaseObservable(params: TermsRequest): Single<TermsResponse> { | ||
return termsRepository.sendBodyPayload(params) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.rfcx.ranger.entity.terms | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
open class TermsRequest( | ||
val app: String | ||
) | ||
|
||
open class TermsResponse( | ||
@SerializedName("success") | ||
val success: Boolean | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/main/java/org/rfcx/ranger/view/login/TermsAndServiceFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.rfcx.ranger.view.login | ||
|
||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.lifecycle.Observer | ||
import kotlinx.android.synthetic.main.fragment_terms_and_service.* | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
import org.rfcx.ranger.R | ||
import org.rfcx.ranger.data.remote.success | ||
import org.rfcx.ranger.util.Preferences | ||
import org.rfcx.ranger.view.MainActivityNew | ||
import org.rfcx.ranger.view.base.BaseFragment | ||
|
||
class TermsAndServiceFragment : BaseFragment() { | ||
lateinit var listener: LoginListener | ||
private val termsAndServiceViewModel: TermsAndServiceViewModel by viewModel() | ||
|
||
override fun onAttach(context: Context) { | ||
super.onAttach(context) | ||
listener = (context as LoginListener) | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_terms_and_service, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
termsAndConditionsWebview.loadUrl("https://rfcx.org/terms-of-service-ranger-app-text-only") | ||
|
||
checkBox.setOnClickListener { | ||
submitButton.isEnabled = checkBox.isChecked | ||
} | ||
|
||
submitButton.setOnClickListener { | ||
val preferenceHelper = context?.let { it1 -> Preferences.getInstance(it1) } | ||
val isRanger = preferenceHelper?.getBoolean(Preferences.IS_RANGER, false) | ||
|
||
if (isRanger != null) { | ||
if(isRanger){ | ||
termsAndServiceViewModel.acceptTerms() | ||
} else { | ||
listener.openInvitationCodeFragment() | ||
} | ||
} | ||
|
||
termsAndServiceViewModel.consentGivenState.observe(this, Observer { | ||
it.success({ state -> | ||
if (state) { | ||
context?.let { it1 -> MainActivityNew.startActivity(it1, null) } | ||
} | ||
}, { | ||
termsProgressBar.visibility = View.GONE | ||
submitButton.visibility = View.VISIBLE | ||
|
||
}, { | ||
termsProgressBar.visibility = View.VISIBLE | ||
submitButton.visibility = View.INVISIBLE | ||
}) | ||
}) | ||
} | ||
} | ||
} |
Oops, something went wrong.