Localization GDPR-同意书SDK-同意书翻译

Localization GDPR-同意书SDK-同意书翻译,localization,admob,Localization,Admob,允许显示同意书,但该同意书目前仅为英文版本(SDK版本1.0.3)。SDK页面显示: 要更新谷歌提供的同意书的同意文本,请根据需要修改同意书SDK中包含的approverform.html文件 然而,ApproverForm.html是作为一种资产提供的,我看不到一种本地化它的方法,尤其是使用gradle。在这种情况下,处理本地化的最佳方法是什么?为什么当初没有这样做?欧洲不仅仅是英语。在Android Studio中选择项目文件视图,然后转到外部库>然后查找同意库,然后在classes.dex

允许显示同意书,但该同意书目前仅为英文版本(SDK版本1.0.3)。SDK页面显示:

要更新谷歌提供的同意书的同意文本,请根据需要修改同意书SDK中包含的approverform.html文件


然而,ApproverForm.html是作为一种资产提供的,我看不到一种本地化它的方法,尤其是使用gradle。在这种情况下,处理本地化的最佳方法是什么?为什么当初没有这样做?欧洲不仅仅是英语。

在Android Studio中选择项目文件视图,然后转到外部库>然后查找同意库,然后在classes.dex上单击鼠标右键并选择“在资源管理器中显示”。接下来转到上面的文件夹,搜索资产文件夹和consetform.html,该库有两个文件夹-可能是调试和发布版本?但我刚刚发现它是有效的


编辑:现在它不起作用了,由于android studio更新,这个解决方案起作用了:

由于谷歌的欧盟同意对话框不可本地化,我创建了我自己的同意对话框,你可以像往常一样用
strings.xml
翻译。它大致基于谷歌的做法。这将在没有调解的情况下使用:

您可以自由使用我的代码,但如果文本适合您,请咨询您的法律顾问。我无法提供适合您的同意书文本的法律建议。

添加到您的gradle文件:

implementation 'com.google.android.ads.consent:consent-library:1.0.3'
添加成员变量:

public boolean mShowNonPersonalizedAdRequests = false;
private AlertDialog mEuDialog;
onCreate()
调用
checkapproverstatus()

添加使用Google同意SDK的
CheckApproveStatus()
方法:

// https://developers.google.com/admob/android/eu-consent
private void checkConsentStatus(){
    ConsentInformation consentInformation = ConsentInformation.getInstance(this);
    ConsentInformation.getInstance(this).addTestDevice("YOUR-DEVICE-ID"); // enter your device id, if you need it for testing

    String[] publisherIds = {"pub-YOUR-ADMOB-PUB-ID"}; // enter your admob pub-id
    consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        @Override
        public void onConsentInfoUpdated(ConsentStatus consentStatus) {
            log("User's consent status successfully updated: " +consentStatus);

            if (ConsentInformation.getInstance(MainActivity.this).isRequestLocationInEeaOrUnknown()){
                log("User is from EU");

                /////////////////////////////
                // TESTING - reset the choice
                //ConsentInformation.getInstance(MainActivity.this).setConsentStatus(ConsentStatus.UNKNOWN);
                /////////////////////////////

                // If the returned ConsentStatus is UNKNOWN, collect user's consent.
                if (consentStatus == ConsentStatus.UNKNOWN) {
                    showMyConsentDialog(false);
                }

                // If the returned ConsentStatus is PERSONALIZED or NON_PERSONALIZED
                // the user has already provided consent. Forward consent to the Google Mobile Ads SDK.
                else if (consentStatus == ConsentStatus.NON_PERSONALIZED) {

                    mShowNonPersonalizedAdRequests = true;

                    // The default behavior of the Google Mobile Ads SDK is to serve personalized ads.
                    // If a user has consented to receive only non-personalized ads, you can configure
                    // an AdRequest object with the following code to specify that only non-personalized
                    // ads should be returned.

                }


            } else {
                log("User is NOT from EU");
                // we don't have to do anything
            }

        }

        @Override
        public void onFailedToUpdateConsentInfo(String errorDescription) {
            log("User's consent status failed to update: " +errorDescription);
        }
    });
}
添加
showmyconcentdialog()
方法:

public void showMyConsentDialog(boolean showCancel) {

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this, R.style.MyAlertDialogStyle);
    LayoutInflater inflater = getLayoutInflater();
    View eu_consent_dialog = inflater.inflate(R.layout.eu_consent, null);

    alertDialog.setView(eu_consent_dialog)
               .setCancelable(false);

    if (showCancel) alertDialog.setPositiveButton(R.string.dialog_close, null);

    mEuDialog = alertDialog.create();
    mEuDialog.show();

    Button btn_eu_consent_yes = eu_consent_dialog.findViewById(R.id.btn_eu_consent_yes);
    Button btn_eu_consent_no = eu_consent_dialog.findViewById(R.id.btn_eu_consent_no);
    Button btn_eu_consent_remove_ads = eu_consent_dialog.findViewById(R.id.btn_eu_consent_remove_ads);
    btn_eu_consent_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mEuDialog.cancel();
            toast(getString(R.string.thank_you), MainActivity.this);
            ConsentInformation.getInstance(MainActivity.this).setConsentStatus(ConsentStatus.PERSONALIZED);
            mShowNonPersonalizedAdRequests = false;
        }
    });
    btn_eu_consent_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mEuDialog.cancel();
            toast(getString(R.string.thank_you), MainActivity.this);
            ConsentInformation.getInstance(MainActivity.this).setConsentStatus(ConsentStatus.NON_PERSONALIZED);
            mShowNonPersonalizedAdRequests = true;
        }
    });
    btn_eu_consent_remove_ads.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mEuDialog.cancel();
            IAP_buyAdsFree(); // YOUR REMOVE ADS METHOD
            }
        });

    TextView tv_eu_learn_more = eu_consent_dialog.findViewById(R.id.tv_eu_learn_more);
    tv_eu_learn_more.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            euMoreInfoDialog();
        }
    });  
}
这是许可布局,保存到
eu_approve.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <LinearLayout
        android:id="@+id/ll_eu_consent"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_horizontal_margin"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_text"
            android:textSize="14sp"
            android:paddingBottom="6dp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_question"
            android:textSize="14sp"
            android:paddingBottom="6dp"
            android:textStyle="bold"
        />

        <Button
            android:id="@+id/btn_eu_consent_yes"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_yes"
            android:textSize="13sp"
            />

        <Button
            android:id="@+id/btn_eu_consent_no"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_no"
            android:textSize="13sp"
            android:layout_marginTop="6dp"
            android:layout_marginBottom="6dp"
            />

        <Button
            android:id="@+id/btn_eu_consent_remove_ads"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/action_remove_ads"
            android:textSize="13sp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_change_setting"
            android:textSize="14sp"
            android:paddingTop="6dp"
            android:paddingBottom="6dp"
            />

        <TextView
            android:id="@+id/tv_eu_learn_more"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/learn_more"
            android:textSize="14sp"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:paddingTop="6dp"
            android:paddingBottom="6dp"
            android:textColor="@color/blue"
            style="@style/SelectableItem"
            />

    </LinearLayout>

</ScrollView>
<!-- EU GDPR Consent texts -->
<string name="eu_consent_text">Dear user!\n\nWe use Google Admob to show ads. Ads support our work, and enable further development of this app. In line with the new European Data Protection Regulation (GDPR), we need your consent to serve ads tailored for you.</string>
<string name="eu_consent_question">Can your data be used to show ads tailored for you?</string>
<string name="learn_more">Learn how your data is used</string>
<string name="google_partners">Google and its partners:</string>
<string name="eu_consent_yes">Yes, continue to show relevant ads</string>
<string name="eu_consent_no">No, show ads that are irrelevant</string>
<string name="eu_consent_change_setting">You can change this setting anytime in the \"About\" window.</string>
<string name="thank_you">Thank you!</string>
在AdMob web界面中,选择要使用的广告技术提供商。我建议您不要选择超过20个(大约),因为我假设如果您选择太多的提供者,
euMoreInfoDialog()
将变得非常慢

添加到
onDestroy()
以防止屏幕旋转出现错误:

@Override
public void onDestroy(){
    // ...
    if (mEuDialog != null && mEuDialog.isShowing()) mEuDialog.cancel();
    // ...
    super.onDestroy();
}
当您发出广告请求时,请检查
mShowNonPersonalizedAdRequests
的值,并在必要时向请求中添加
“npa”

Bundle extras = new Bundle();
if (mShowNonPersonalizedAdRequests)
    extras.putString("npa", "1");

AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("YOUR-DEVICE-ID-GOES-HERE") // insert your device id
    .addNetworkExtrasBundle(AdMobAdapter.class, extras)
    .build();
最后,将所有语言的字符串添加到
strings.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <LinearLayout
        android:id="@+id/ll_eu_consent"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_horizontal_margin"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_text"
            android:textSize="14sp"
            android:paddingBottom="6dp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_question"
            android:textSize="14sp"
            android:paddingBottom="6dp"
            android:textStyle="bold"
        />

        <Button
            android:id="@+id/btn_eu_consent_yes"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_yes"
            android:textSize="13sp"
            />

        <Button
            android:id="@+id/btn_eu_consent_no"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_no"
            android:textSize="13sp"
            android:layout_marginTop="6dp"
            android:layout_marginBottom="6dp"
            />

        <Button
            android:id="@+id/btn_eu_consent_remove_ads"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/action_remove_ads"
            android:textSize="13sp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/eu_consent_change_setting"
            android:textSize="14sp"
            android:paddingTop="6dp"
            android:paddingBottom="6dp"
            />

        <TextView
            android:id="@+id/tv_eu_learn_more"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/learn_more"
            android:textSize="14sp"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:paddingTop="6dp"
            android:paddingBottom="6dp"
            android:textColor="@color/blue"
            style="@style/SelectableItem"
            />

    </LinearLayout>

</ScrollView>
<!-- EU GDPR Consent texts -->
<string name="eu_consent_text">Dear user!\n\nWe use Google Admob to show ads. Ads support our work, and enable further development of this app. In line with the new European Data Protection Regulation (GDPR), we need your consent to serve ads tailored for you.</string>
<string name="eu_consent_question">Can your data be used to show ads tailored for you?</string>
<string name="learn_more">Learn how your data is used</string>
<string name="google_partners">Google and its partners:</string>
<string name="eu_consent_yes">Yes, continue to show relevant ads</string>
<string name="eu_consent_no">No, show ads that are irrelevant</string>
<string name="eu_consent_change_setting">You can change this setting anytime in the \"About\" window.</string>
<string name="thank_you">Thank you!</string>

亲爱的用户\n\n我们使用Google Admob显示广告。广告支持我们的工作,并支持此应用程序的进一步开发。根据新的《欧洲数据保护条例》(GDPR),我们需要您的同意才能为您定制广告。
你的数据可以用来显示为你量身定做的广告吗?
了解如何使用数据
谷歌及其合作伙伴:
是的,继续播放相关广告
不,播放不相关的广告
您可以随时在“关于”窗口中更改此设置。
非常感谢。
就这样


(注意:
log()
toast()
是我的方法,用你自己的方法替换它们。
PRIVACY\u URL
是你的
字符串
URL到你的隐私政策。)

我接受了ApproverFormClasses.jar并创建了自己的MyConsentFormClasses.jar。在这个jar文件中,我使用了类'approverForm.class',并添加了一个新方法
load(stringlocale)

与原始方法
load()
不同的是WebView的调用

this.webView.loadUrl("file:///android_asset/consentform.html")
改为

this.webView.loadUrl("file:///android_asset/consentform_"+locale+".html")
字符串变量
locale
I定义为字符串资源。 在Assets文件夹中,我放置了以下文件,例如ApproverForm_en.html、ApproverForm_fr.html、ApproverForm_pl.html

正在构建新的ApproverForm.Class并创建MyConsentFormClasses.jar,在我的项目的
libs
文件夹中复制jar,并配置AndroidStudio依赖项

必须对源代码进行更改的缺点对我来说是可以忍受的。我希望谷歌能很快提供一个合适的解决方案


GGK

这是可行的,但是你最终还是只能使用一种语言。如果Google添加了指定
approverform.html
form文件的选项,那就太好了。然后您将创建多个表单,并根据用户的语言设置选择一个表单。。。顺便说一句,默认文本很糟糕。听起来好像是你在收集数据,但实际上是谷歌。你如何选择项目文件视图,我试着编辑我的,在资产>调试文件夹中,上面说这是一个生成的文件,不应该编辑,当你试图编辑它时,它会回到原来的形式。当一个应用程序没有翻译成他们的语言时,一些用户会生气,并且用另一种语言解释一个法律问题会得到很多1星级的评级。如何获得广告技术提供商的完整列表的同意?仅仅显示列表就足够了吗?注意:谷歌的欧盟用户同意政策要求,在显示个性化广告之前,您必须获得针对发布者ID配置的广告技术提供商的完整列表的同意,即使您正在使用第三方调解解决方案向谷歌发送广告请求。Amar Ilindra:如果您使用调解,您只能靠自己。上述解决方案适用于谷歌同意SDK,无需调解。从他们的文档中:
谷歌目前无法获得和处理调解网络的同意,因此您需要分别获得和处理每个广告网络的同意。
。为了避免麻烦,我禁用了调解,直到事情解决。不,据我所知,它说,如果我们播放个性化广告,我们需要获得广告技术提供商完整列表的同意。(即使我们使用第三方调解)目前,我只展示非个性化和无广告选项Amar Ilindra:这是正确的。您必须获得广告技术提供商完整列表的同意(您可以在AdMob中选择它们)。据我所知,谷歌的文档,如果你不使用中介,那也没关系。您只需使用自己的对话框。从他们的文档:
但是,您需要确定提供者列表如何