Skip to content

Commit

Permalink
Added option to agree with tos
Browse files Browse the repository at this point in the history
  • Loading branch information
gartorware committed Jan 8, 2020
1 parent 3eda470 commit b2de4b2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/components/ionic-privacy-policy-consent-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
</ion-toolbar>
</ion-header>

<ion-content padding>
<ion-content class="ion-padding">

<p class="care-text">{{careText}}</p>

<p class="message-text" [innerHtml]="alertMessageText"></p>

<p class="short-question-text" *ngIf="options.shortQuestion">{{shortQuestionText}}</p>

<p class="tos-text" [innerHtml]="tosText" *ngIf="options.tos"></p>

<p class="age-text" *ngIf="!options.explicitAgeConfirmation">{{ageText}}</p>
<ion-item class="age-check" *ngIf="options.explicitAgeConfirmation">
<ion-label class="ion-text-wrap">{{explicitAgeText}}</ion-label>
Expand All @@ -21,7 +23,7 @@

</ion-content>

<ion-footer padding>
<ion-footer class="ion-padding">
<ion-button fill="solid" expand="block" color="primary" (click)="onClickAgree()" class="agree-button">
<ion-label>{{acceptText}}</ion-label>
</ion-button>
Expand Down
4 changes: 4 additions & 0 deletions src/components/ionic-privacy-policy-consent-component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ ion-content{
}
.decline-button{
margin-top: 8px;
}
.consent-alert .alert-message.sc-ion-alert-md,
.consent-alert .alert-message.sc-ion-alert-ios {
font-size: 14px;
}
40 changes: 33 additions & 7 deletions src/components/ionic-privacy-policy-consent-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type IonicPrivacyPolicyConsentLangs = "en" | "es";
export interface IonicPrivacyPolicyConsentOptions {
language?: IonicPrivacyPolicyConsentLangs,
privacyPolicy?: string,
tos?: string,
paidVersion?: boolean, //TODO
explicitAgeConfirmation?: boolean,
shortQuestion?: boolean,
Expand Down Expand Up @@ -44,14 +45,16 @@ const HTML_TEMPLATE = `
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<p class="care-text">{{careText}}</p>
<p class="message-text" [innerHtml]="alertMessageText"></p>
<p class="short-question-text" *ngIf="options.shortQuestion">{{shortQuestionText}}</p>
<p class="tos-text" [innerHtml]="tosText" *ngIf="options.tos"></p>
<p class="age-text" *ngIf="!options.explicitAgeConfirmation">{{ageText}}</p>
<ion-item class="age-check" *ngIf="options.explicitAgeConfirmation">
<ion-label class="ion-text-wrap">{{explicitAgeText}}</ion-label>
Expand All @@ -61,7 +64,7 @@ const HTML_TEMPLATE = `
</ion-content>
<ion-footer padding>
<ion-footer class="ion-padding">
<ion-button fill="solid" expand="block" color="primary" (click)="onClickAgree()" class="agree-button">
<ion-label>{{acceptText}}</ion-label>
</ion-button>
Expand Down Expand Up @@ -97,8 +100,12 @@ ion-content{
.decline-button{
margin-top: 8px;
}
.consent-alert .alert-message.sc-ion-alert-md,
.consent-alert .alert-message.sc-ion-alert-ios {
font-size: 14px;
}
`
;
;

@Component({
selector: 'gt-privacy-policy-consent',
Expand All @@ -121,6 +128,8 @@ export class IonicPrivacyPolicyConsentComponent implements OnInit, OnDestroy {
exitText;
urlLabelText;
alertMessageText;
tosText;
tosUrlLabelText;

private defaultOpt: IonicPrivacyPolicyConsentOptions = {
language: 'en',
Expand Down Expand Up @@ -153,15 +162,25 @@ export class IonicPrivacyPolicyConsentComponent implements OnInit, OnDestroy {
this.declineText = this.translate.instant("DECLINE");
this.exitText = this.translate.instant("EXIT");
this.urlLabelText = this.translate.instant("PRIVACY_URL_LABEL");

let messageText = this.translate.instant("MESSAGE");
this.tosText = this.translate.instant("TOS_CONFIRMATION");
this.tosUrlLabelText = this.translate.instant("TOS_URL_LABEL");

// Privacy Policy text and link
const messageText = this.translate.instant("MESSAGE");
if (this.options.privacyPolicy && !this.options.privacyPolicy.startsWith("https://") && !this.options.privacyPolicy.startsWith("http://")) {
this.options.privacyPolicy = "http://" + this.options.privacyPolicy;
}
let privacyLink = this.options.privacyPolicy ? '<a target="_blank" href="' + this.options.privacyPolicy + '">' + this.urlLabelText + '</a>' : this.urlLabelText;

const privacyLink = this.options.privacyPolicy ? '<a target="_blank" href="' + this.options.privacyPolicy + '">' + this.urlLabelText + '</a>' : this.urlLabelText;
this.alertMessageText = this.sanitized.bypassSecurityTrustHtml(messageText.replace('##PRIVACY_PLACEHOLDER##', privacyLink));

// TOS text and link
if (this.options.tos && !this.options.tos.startsWith("https://") && !this.options.tos.startsWith("http://")) {
this.options.tos = "http://" + this.options.tos;
}
const tosLink = this.options.tos ? '<a target="_blank" href="' + this.options.tos + '">' + this.tosUrlLabelText + '</a>' : this.tosUrlLabelText;
this.tosText = this.sanitized.bypassSecurityTrustHtml(this.tosText.replace('##TOS_PLACEHOLDER##', tosLink));

// Back button
this.ngBackButtonSubscription = this.platform.backButton.subscribeWithPriority(1, () => {
let chooseActionMsg = this.translate.instant('CHOOSE_ACTION');
this.toastCtrl.create({ message: chooseActionMsg, duration: 2500 }).then(toast => toast.present());
Expand Down Expand Up @@ -190,10 +209,17 @@ export class IonicPrivacyPolicyConsentComponent implements OnInit, OnDestroy {
this.toastCtrl.create({ message: explicitAgeConfirmationWarningText, duration: 2500 }).then(toast => toast.present());
return;
}

this.dismiss(IonicPrivacyPolicyConsentResult.PERSONAL_CONSENT);
}

async onClickDecline() {
if (this.options.explicitAgeConfirmation && !this.explicitAgeConfirmation) {
const explicitAgeConfirmationWarningText = this.translate.instant('EXPLICIT_AGE_CONFIRMATION_WARNING');
this.toastCtrl.create({ message: explicitAgeConfirmationWarningText, duration: 2500 }).then(toast => toast.present());
return;
}

const areYouSureText = this.translate.instant("ARE_YOU_SURE");
const decline2Text = this.translate.instant("DECLINE_2");
const goBackText = this.translate.instant("GO_BACK");
Expand Down
24 changes: 14 additions & 10 deletions src/internal-providers/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,46 @@ import { Injectable } from '@angular/core';

const i18n = {
en: {
"TITLE": "Privacy policy updated",
"TITLE": "ToS & Privacy",
"CARE_TEXT": "We care about your privacy and data security",
"PAID_OR_FREE": "We maintain this app by using third party services",
"MESSAGE": "This app collects some data for its operation, including device identifiers among other data. Such data are used to offer the service, to personalise content and ads, to provide social media features and for anonymous analytics. Futhermore, some of this information (no personal data) could be shared with our advertising and analytics partners. Please, review our ##PRIVACY_PLACEHOLDER## for full details on how your data will be protected and managed.",
"SHORT_QUESTION": "Can we continue to use your data for this purposes?",
"AGE_CONFIRMATION": "By agreeing, you are confirming that you are over the age of 16.",
"AGE_CONFIRMATION": "By continuing you are confirming that you are over the age of 16.",
"EXPLICIT_AGE_CONFIRMATION": "I'm over the age of 16",
"EXPLICIT_AGE_CONFIRMATION_WARNING": "Please, confirm that you are over the age of 16",
"PRIVACY_URL_LABEL": "Privacy Policy",
"ACCEPT": "Yes, I agree. Let's go!",
"DECLINE": "Decline",
"DECLINE_2": "Yup, decline",
"DECLINE_DESCR": "I understand that I still see the same number of ads, but they may not be as relevant to my interests. On top of that, it will be much harder to find and identify bugs and problems with the app. I still confirm that I'm over the age of 16.",
"DECLINE_2": "Yes, decline",
"DECLINE_DESCR": "I understand that I still see the same number of ads, but they may not be as relevant to my interests. On top of that, it will be much harder to find and identify bugs and problems with the app. <br><br> I still agree to the Terms of Service plus I confirm that I'm over the age of 16.",
"EXIT": "I don't agree. Exit now.",
"CHOOSE_ACTION": "Please, choose an action",
"ARE_YOU_SURE": "Are you sure?",
"GO_BACK": "Go back"
"GO_BACK": "Go back",
"TOS_CONFIRMATION": "By continuing you agree to our ##TOS_PLACEHOLDER##.",
"TOS_URL_LABEL": "Terms of Service"
},
es: {
"TITLE": "Política de privacidad actualizada",
"TITLE": "TS & privacidad",
"CARE_TEXT": "Tu privacidad y la seguridad de tus datos son importantes para nosotros",
"PAID_OR_FREE": "Esta app se mantiene gracias a servicios de terceros",
"MESSAGE": "Esta aplicación recopila algunos datos para su funcionamiento, incluyendo identificadores de dispositivo entre otros. Estos datos se usan para ofrecer y monitorizar el servicio, personalizar el contenido y los anuncios, con el fin de ofrecer funciones de medios sociales y para recopilar datos estadísticos y de uso de forma anónima. Así mismo alguna de esta información (no datos personales) pueden ser compartidos con nuestros partners de publicidad y de análisis. Por favor, revisa nuestra ##PRIVACY_PLACEHOLDER## para obtener todos los detalles sobre como sus datos son tratados y protegidos",
"SHORT_QUESTION": "¿Podemos continuar usando sus datos para estos propósitos?",
"AGE_CONFIRMATION": "Al aceptar, usted confirma que es mayor de 16 años.",
"AGE_CONFIRMATION": "Al continuar usted confirma que es mayor de 16 años.",
"EXPLICIT_AGE_CONFIRMATION": "Tengo más de 16 años",
"EXPLICIT_AGE_CONFIRMATION_WARNING": "Por favor, confirme que tiene más de 16 años",
"PRIVACY_URL_LABEL": "Política de Privacidad",
"ACCEPT": "Acepto. ¡Empecemos!",
"DECLINE": "Declino",
"DECLINE_2": "Sep, declino",
"DECLINE_DESCR": "Entiendo que aún veré la misma cantidad de anuncios, pero que pueden no ser tan relevantes para mis intereses. Además, será mucho más difícil encontrar e identificar bugs y problemas con la aplicación. Aún así sigo confirmando que tengo más de 16 años.",
"DECLINE_2": ", declino",
"DECLINE_DESCR": "Entiendo que aún veré la misma cantidad de anuncios, pero que pueden no ser tan relevantes para mis intereses. Además, será mucho más difícil encontrar e identificar bugs y problemas con la aplicación. <br><br> Aún así acepto los Términos del Servicio y confirmo que tengo más de 16 años.",
"EXIT": "No acepto. Salir ahora.",
"CHOOSE_ACTION": "Por favor, escoge una opción",
"ARE_YOU_SURE": "¿Estás seguro?",
"GO_BACK": "Volver"
"GO_BACK": "Volver",
"TOS_CONFIRMATION": "Al continuar usted acepta nuestros ##TOS_PLACEHOLDER##.",
"TOS_URL_LABEL": "Términos del Servicio"
}
};

Expand Down

0 comments on commit b2de4b2

Please sign in to comment.