Skip to content

Commit

Permalink
Add: #202 - Update data sharing UI flow
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan authored and georgepadayatti committed Nov 13, 2023
1 parent 25220b6 commit a199765
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ object DataSharingUI {
* @param baseUrl
*/
fun withBaseUrl(baseUrl: String?): DataSharingUI {
this.mBaseUrl = baseUrl
if (baseUrl?.last().toString() == "/")
this.mBaseUrl = baseUrl
else
this.mBaseUrl = "$baseUrl/"
return this
}

Expand All @@ -88,7 +91,7 @@ object DataSharingUI {
* @param applicationName
* @param logoUrl
*/
fun withOtherApplication(applicationName: String?, logoUrl: String?): DataSharingUI {
fun withThirdPartyApplication(applicationName: String?, logoUrl: String?): DataSharingUI {
mDataSharingUIIntent?.putExtra(
BBConsentDataSharingActivity.TAG_EXTRA_OTHER_APPLICATION_NAME,
applicationName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class PolicyV2(
@SerializedName("dataRetentionPeriodDays") var dataRetentionPeriodDays: Int? = null,
@SerializedName("geographicRestriction") var geographicRestriction: String? = null,
@SerializedName("storageLocation") var storageLocation: String? = null,
@SerializedName("thirdPartyDataSharing") var thirdPartyDataSharing: String? = null,
@SerializedName("thirdPartyDataSharing") var thirdPartyDataSharing: Boolean? = null,
@SerializedName("id") var id: String? = null

)
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class BBConsentDataSharingActivity : BBConsentBaseActivity() {
}

private fun getIntentData() {
viewModel?.otherApplicationName = intent.getStringExtra(TAG_EXTRA_OTHER_APPLICATION_NAME)?:"Application"
viewModel?.otherApplicationName =
intent.getStringExtra(TAG_EXTRA_OTHER_APPLICATION_NAME) ?: "Application"
viewModel?.otherApplicationLogo = intent.getStringExtra(TAG_EXTRA_OTHER_APPLICATION_LOGO)
val secondaryButtonText = intent.getStringExtra(TAG_EXTRA_SECONDARY_BUTTON_TEXT)
if (secondaryButtonText != null)
Expand Down Expand Up @@ -137,55 +138,53 @@ class BBConsentDataSharingActivity : BBConsentBaseActivity() {

private fun initListeners() {
viewModel?.dataAgreement?.observe(this, Observer { newData ->
if (newData != null)
if (newData.methodOfUse != "data_source" || newData.policy?.thirdPartyDataSharing == false) {
val resultIntent = Intent()
setResult(RESULT_CANCELED, resultIntent)
finish()
} else {
binding.tvMainDesc.text = Html.fromHtml(
resources.getString(
R.string.bb_consent_data_sharing_main_desc,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.organization?.value?.name else viewModel?.otherApplicationName,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.otherApplicationName else viewModel?.organization?.value?.name,
viewModel?.dataAgreement?.value?.purpose ?: ""
)
)

binding.tvMainDesc.text = Html.fromHtml(
resources.getString(
R.string.bb_consent_data_sharing_main_desc,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.organization?.value?.name else viewModel?.otherApplicationName,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.otherApplicationName else viewModel?.organization?.value?.name,
viewModel?.dataAgreement?.value?.purpose ?: ""
)
)

BBConsentImageUtils.setImage(
binding.ivAppLogo,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.otherApplicationLogo else viewModel?.organization?.value?.logoImageURL ?: "",
R.drawable.bb_consent_default_logo
)
BBConsentImageUtils.setImage(
binding.ivAppLogo,
viewModel?.organization?.value?.logoImageURL ?: "",
R.drawable.bb_consent_default_logo
)

BBConsentImageUtils.setImage(
binding.iv3ppLogo,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.organization?.value?.logoImageURL ?: "" else viewModel?.otherApplicationLogo,
R.drawable.bb_consent_default_logo,
)
BBConsentImageUtils.setImage(
binding.iv3ppLogo,
viewModel?.otherApplicationLogo,
R.drawable.bb_consent_default_logo,
)

binding.tvMakeSureTrust.text = resources.getString(
R.string.bb_consent_data_sharing_make_sure_that_you_trust,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.organization?.value?.name else viewModel?.otherApplicationName
)
binding.tvMakeSureTrust.text = resources.getString(
R.string.bb_consent_data_sharing_make_sure_that_you_trust,
viewModel?.otherApplicationName
)

binding.tvDesc.text = resources.getString(
R.string.bb_consent_data_sharing_by_authrizing_text,
if ((viewModel?.dataAgreement?.value?.methodOfUse
?: "") == "data_using_service"
) viewModel?.organization?.value?.name else viewModel?.otherApplicationName
)
binding.tvDesc.text = resources.getString(
R.string.bb_consent_data_sharing_by_authrizing_text,
viewModel?.otherApplicationName
)

adapter = BBConsentDataSharingAttributesAdapter(
newData?.dataAttributes ?: ArrayList()
)
binding.rvDataAttributes.layoutManager = LinearLayoutManager(this)
binding.rvDataAttributes.adapter = adapter
adapter = BBConsentDataSharingAttributesAdapter(
newData?.dataAttributes ?: ArrayList()
)
binding.rvDataAttributes.layoutManager = LinearLayoutManager(this)
binding.rvDataAttributes.adapter = adapter
}
})

viewModel?.dataAgreementRecord?.observe(this, Observer { newData ->
Expand Down Expand Up @@ -282,7 +281,7 @@ class BBConsentDataSharingActivity : BBConsentBaseActivity() {
subList.add(
DataAgreementPolicyModel(
resources.getString(R.string.bb_consent_data_agreement_policy_third_party_disclosure),
dataAgreement?.policy?.thirdPartyDataSharing
dataAgreement?.policy?.thirdPartyDataSharing.toString()
)
)
subList.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BBConsentDataSharingViewModel : BBConsentBaseViewModel() {
)
)

if (result.isSuccess) {
if (result.isSuccess && result.getOrNull()?.dataAgreementRecord != null) {
withContext(Dispatchers.Main) {
isLoading.value = false
dataAgreementRecord.value = result.getOrNull()?.dataAgreementRecord
Expand Down Expand Up @@ -123,7 +123,7 @@ class BBConsentDataSharingViewModel : BBConsentBaseViewModel() {
if (result.isSuccess) {
withContext(Dispatchers.Main) {
isLoading.value = false
getDataAgreement(true, context,result.getOrNull()?.organization)
getDataAgreement(true, context, result.getOrNull()?.organization)
}
} else {
withContext(Dispatchers.Main) {
Expand Down
6 changes: 6 additions & 0 deletions PrivacyDashboard/src/main/res/drawable/ic_sync_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="24dp" android:tint="@color/bbConsentTextColor"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/bbConsentTextColor" android:pathData="M18,12l4,-4l-4,-4l0,3l-15,0l0,2l15,0z"/>
<path android:fillColor="@color/bbConsentTextColor" android:pathData="M6,12l-4,4l4,4l0,-3l15,0l0,-2l-15,0z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
android:layout_marginTop="10dp">

<androidx.cardview.widget.CardView
android:id="@+id/cvAppLogo"
android:id="@+id/cv3ppLogo"
android:layout_width="80dp"
android:layout_height="80dp"
app:cardBackgroundColor="@color/bbConsentWhite"
Expand All @@ -57,7 +57,7 @@
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/ivAppLogo"
android:id="@+id/iv3ppLogo"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/bb_consent_default_logo" />
Expand All @@ -69,15 +69,15 @@
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:src="@drawable/ic_arrow_forward"
android:src="@drawable/ic_sync_24"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/cvAppLogo"
app:layout_constraintEnd_toStartOf="@+id/cv3ppLogo"
app:layout_constraintStart_toEndOf="@+id/cvAppLogo"
app:layout_constraintTop_toTopOf="@+id/cvAppLogo" />
app:layout_constraintBottom_toBottomOf="@+id/cv3ppLogo"
app:layout_constraintEnd_toStartOf="@+id/cvAppLogo"
app:layout_constraintStart_toEndOf="@+id/cv3ppLogo"
app:layout_constraintTop_toTopOf="@+id/cv3ppLogo" />

<androidx.cardview.widget.CardView
android:id="@+id/cv3ppLogo"
android:id="@+id/cvAppLogo"
android:layout_width="80dp"
android:layout_height="80dp"
android:visibility="visible"
Expand All @@ -88,7 +88,7 @@
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/iv3ppLogo"
android:id="@+id/ivAppLogo"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/bb_consent_default_logo" />
Expand All @@ -108,7 +108,7 @@
android:textSize="@dimen/text_size_normal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cvAppLogo" />
app:layout_constraintTop_toBottomOf="@+id/cv3ppLogo" />

<TextView
android:id="@+id/tvDesc"
Expand Down

0 comments on commit a199765

Please sign in to comment.