Added read & agreed to general terms and privacy policy mandatory checkbox in assistant
This commit is contained in:
parent
517e95ca8c
commit
fe16aa91c0
6 changed files with 123 additions and 4 deletions
|
@ -19,8 +19,17 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.activities.assistant.fragments
|
package org.linphone.activities.assistant.fragments
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.SpannableString
|
||||||
|
import android.text.Spanned
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.text.style.ClickableSpan
|
||||||
|
import android.view.View
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.GenericFragment
|
import org.linphone.activities.GenericFragment
|
||||||
import org.linphone.activities.assistant.viewmodels.WelcomeViewModel
|
import org.linphone.activities.assistant.viewmodels.WelcomeViewModel
|
||||||
|
@ -63,5 +72,54 @@ class WelcomeFragment : GenericFragment<AssistantWelcomeFragmentBinding>() {
|
||||||
binding.setRemoteProvisioningClickListener {
|
binding.setRemoteProvisioningClickListener {
|
||||||
navigateToRemoteProvisioning()
|
navigateToRemoteProvisioning()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.termsAndPrivacyAccepted.observe(viewLifecycleOwner, {
|
||||||
|
if (it) corePreferences.readAndAgreeTermsAndPrivacy = true
|
||||||
|
})
|
||||||
|
|
||||||
|
setUpTermsAndPrivacyLinks()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpTermsAndPrivacyLinks() {
|
||||||
|
val terms = getString(R.string.assistant_general_terms)
|
||||||
|
val privacy = getString(R.string.assistant_privacy_policy)
|
||||||
|
|
||||||
|
val label = getString(
|
||||||
|
R.string.assistant_read_and_agree_terms,
|
||||||
|
terms,
|
||||||
|
privacy
|
||||||
|
)
|
||||||
|
val spannable = SpannableString(label)
|
||||||
|
|
||||||
|
val termsMatcher = Pattern.compile(terms).matcher(label)
|
||||||
|
if (termsMatcher.find()) {
|
||||||
|
val clickableSpan: ClickableSpan = object : ClickableSpan() {
|
||||||
|
override fun onClick(widget: View) {
|
||||||
|
val browserIntent = Intent(
|
||||||
|
Intent.ACTION_VIEW,
|
||||||
|
Uri.parse(getString(R.string.assistant_general_terms_link))
|
||||||
|
)
|
||||||
|
startActivity(browserIntent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spannable.setSpan(clickableSpan, termsMatcher.start(0), termsMatcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val policyMatcher = Pattern.compile(privacy).matcher(label)
|
||||||
|
if (policyMatcher.find()) {
|
||||||
|
val clickableSpan: ClickableSpan = object : ClickableSpan() {
|
||||||
|
override fun onClick(widget: View) {
|
||||||
|
val browserIntent = Intent(
|
||||||
|
Intent.ACTION_VIEW,
|
||||||
|
Uri.parse(getString(R.string.assistant_privacy_policy_link))
|
||||||
|
)
|
||||||
|
startActivity(browserIntent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spannable.setSpan(clickableSpan, policyMatcher.start(0), policyMatcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.termsAndPrivacy.text = spannable
|
||||||
|
binding.termsAndPrivacy.movementMethod = LinkMovementMethod.getInstance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.activities.assistant.viewmodels
|
package org.linphone.activities.assistant.viewmodels
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
|
|
||||||
|
@ -27,4 +28,10 @@ class WelcomeViewModel : ViewModel() {
|
||||||
val showLinphoneLogin: Boolean = corePreferences.showLinphoneLogin
|
val showLinphoneLogin: Boolean = corePreferences.showLinphoneLogin
|
||||||
val showGenericLogin: Boolean = corePreferences.showGenericLogin
|
val showGenericLogin: Boolean = corePreferences.showGenericLogin
|
||||||
val showRemoteProvisioning: Boolean = corePreferences.showRemoteProvisioning
|
val showRemoteProvisioning: Boolean = corePreferences.showRemoteProvisioning
|
||||||
|
|
||||||
|
val termsAndPrivacyAccepted = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
termsAndPrivacyAccepted.value = corePreferences.readAndAgreeTermsAndPrivacy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,12 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
config.setBool("app", "keep_service_alive", value)
|
config.setBool("app", "keep_service_alive", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var readAndAgreeTermsAndPrivacy: Boolean
|
||||||
|
get() = config.getBool("app", "read_and_agree_terms_and_privacy", false)
|
||||||
|
set(value) {
|
||||||
|
config.setBool("app", "read_and_agree_terms_and_privacy", value)
|
||||||
|
}
|
||||||
|
|
||||||
/* UI */
|
/* UI */
|
||||||
|
|
||||||
var forcePortrait: Boolean
|
var forcePortrait: Boolean
|
||||||
|
|
|
@ -66,6 +66,27 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:columnCount="2">
|
android:columnCount="2">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="fill"
|
||||||
|
android:layout_columnSpan="2"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:enabled="@{!viewModel.termsAndPrivacyAccepted}"
|
||||||
|
android:checked="@={viewModel.termsAndPrivacyAccepted}"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/terms_and_privacy"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/account_creation"
|
android:id="@+id/account_creation"
|
||||||
android:visibility="@{viewModel.showCreateAccount ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.showCreateAccount ? View.VISIBLE : View.GONE}"
|
||||||
|
|
|
@ -66,8 +66,31 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:columnCount="1">
|
android:columnCount="1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="fill"
|
||||||
|
android:layout_columnSpan="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:enabled="@{!viewModel.termsAndPrivacyAccepted}"
|
||||||
|
android:checked="@={viewModel.termsAndPrivacyAccepted}"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/terms_and_privacy"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/account_creation"
|
android:id="@+id/account_creation"
|
||||||
|
android:enabled="@{viewModel.termsAndPrivacyAccepted}"
|
||||||
android:visibility="@{viewModel.showCreateAccount ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.showCreateAccount ? View.VISIBLE : View.GONE}"
|
||||||
android:onClick="@{createAccountClickListener}"
|
android:onClick="@{createAccountClickListener}"
|
||||||
style="@style/button_font"
|
style="@style/button_font"
|
||||||
|
@ -76,7 +99,6 @@
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="fill"
|
android:layout_gravity="fill"
|
||||||
android:layout_columnWeight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/assistant_button"
|
android:background="@drawable/assistant_button"
|
||||||
android:textColor="@drawable/assistant_button_text_color"
|
android:textColor="@drawable/assistant_button_text_color"
|
||||||
|
@ -84,6 +106,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/account_connection"
|
android:id="@+id/account_connection"
|
||||||
|
android:enabled="@{viewModel.termsAndPrivacyAccepted}"
|
||||||
android:visibility="@{viewModel.showLinphoneLogin ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.showLinphoneLogin ? View.VISIBLE : View.GONE}"
|
||||||
android:onClick="@{accountLoginClickListener}"
|
android:onClick="@{accountLoginClickListener}"
|
||||||
style="@style/button_font"
|
style="@style/button_font"
|
||||||
|
@ -92,7 +115,6 @@
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="fill"
|
android:layout_gravity="fill"
|
||||||
android:layout_columnWeight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/assistant_button"
|
android:background="@drawable/assistant_button"
|
||||||
android:textColor="@drawable/assistant_button_text_color"
|
android:textColor="@drawable/assistant_button_text_color"
|
||||||
|
@ -100,6 +122,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/generic_connection"
|
android:id="@+id/generic_connection"
|
||||||
|
android:enabled="@{viewModel.termsAndPrivacyAccepted}"
|
||||||
android:visibility="@{viewModel.showGenericLogin ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.showGenericLogin ? View.VISIBLE : View.GONE}"
|
||||||
android:onClick="@{genericAccountLoginClickListener}"
|
android:onClick="@{genericAccountLoginClickListener}"
|
||||||
style="@style/button_font"
|
style="@style/button_font"
|
||||||
|
@ -108,7 +131,6 @@
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="fill"
|
android:layout_gravity="fill"
|
||||||
android:layout_columnWeight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/assistant_button"
|
android:background="@drawable/assistant_button"
|
||||||
android:textColor="@drawable/assistant_button_text_color"
|
android:textColor="@drawable/assistant_button_text_color"
|
||||||
|
@ -116,6 +138,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/remote_configuration"
|
android:id="@+id/remote_configuration"
|
||||||
|
android:enabled="@{viewModel.termsAndPrivacyAccepted}"
|
||||||
android:visibility="@{viewModel.showRemoteProvisioning ? View.VISIBLE : View.GONE}"
|
android:visibility="@{viewModel.showRemoteProvisioning ? View.VISIBLE : View.GONE}"
|
||||||
android:onClick="@{remoteProvisioningClickListener}"
|
android:onClick="@{remoteProvisioningClickListener}"
|
||||||
style="@style/button_font"
|
style="@style/button_font"
|
||||||
|
@ -124,7 +147,6 @@
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="fill"
|
android:layout_gravity="fill"
|
||||||
android:layout_columnWeight="1"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/assistant_button"
|
android:background="@drawable/assistant_button"
|
||||||
android:textColor="@drawable/assistant_button_text_color"
|
android:textColor="@drawable/assistant_button_text_color"
|
||||||
|
|
|
@ -254,6 +254,11 @@
|
||||||
<string name="assistant_phone_number_info_content">\nThanks to your phone number, your friends will find you more easily.\n\n You will see in your address book who is using &appName; and your friends will know that they can reach you on &appName; as well.\n</string>
|
<string name="assistant_phone_number_info_content">\nThanks to your phone number, your friends will find you more easily.\n\n You will see in your address book who is using &appName; and your friends will know that they can reach you on &appName; as well.\n</string>
|
||||||
<string name="assistant_phone_number_link_info_content">\nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using &appName; and your friends will know that they can reach you on &appName; as well.\n</string>
|
<string name="assistant_phone_number_link_info_content">\nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using &appName; and your friends will know that they can reach you on &appName; as well.\n</string>
|
||||||
<string name="assistant_phone_number_link_info_content_already_account">You can only use your phone number with one &appName; account.\n\nIf you had already linked your number to an other account but you prefer to use this one, simply link it now and your number will automatically be moved to this account.</string>
|
<string name="assistant_phone_number_link_info_content_already_account">You can only use your phone number with one &appName; account.\n\nIf you had already linked your number to an other account but you prefer to use this one, simply link it now and your number will automatically be moved to this account.</string>
|
||||||
|
<string name="assistant_general_terms_link" translatable="false">https://www.linphone.org/general-terms</string>
|
||||||
|
<string name="assistant_privacy_policy_link" translatable="false">https://www.linphone.org/privacy-policy</string>
|
||||||
|
<string name="assistant_general_terms">terms of use</string>
|
||||||
|
<string name="assistant_privacy_policy">privacy policy</string>
|
||||||
|
<string name="assistant_read_and_agree_terms">I accept Belledonne Communications\' %1$s and %2$s</string>
|
||||||
|
|
||||||
<!-- Assistant errors -->
|
<!-- Assistant errors -->
|
||||||
<string name="assistant_error_phone_number_invalid_characters">Only digits are expected here</string>
|
<string name="assistant_error_phone_number_invalid_characters">Only digits are expected here</string>
|
||||||
|
|
Loading…
Reference in a new issue