diff --git a/app/build.gradle b/app/build.gradle
index ab8d097..71dcb64 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -29,8 +29,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
- implementation 'com.huawei.hms:ads-lite:13.4.56.300'
- implementation 'com.huawei.hms:ads-consent:3.4.54.300'
+ implementation 'com.huawei.hms:ads-lite:13.4.69.300'
+ implementation 'com.huawei.hms:ads-consent:3.4.69.300'
implementation 'com.huawei.hms:ads-omsdk:1.3.35'
testImplementation 'junit:junit:4.13.2'
diff --git a/app/src/main/java/com/huawei/hms/ads/sdk/NativeViewFactory.java b/app/src/main/java/com/huawei/hms/ads/sdk/NativeViewFactory.java
index cd94a7d..6bc0f96 100644
--- a/app/src/main/java/com/huawei/hms/ads/sdk/NativeViewFactory.java
+++ b/app/src/main/java/com/huawei/hms/ads/sdk/NativeViewFactory.java
@@ -7,6 +7,7 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.hms.ads.AppDownloadButton;
@@ -103,6 +104,12 @@ public static View createSmallImageAdView(NativeAd nativeAd, final ViewGroup par
nativeView.getCallToActionView()
.setVisibility(null != nativeAd.getCallToAction() ? View.VISIBLE : View.INVISIBLE);
+ LinearLayout appDetailLayout = adRootView.findViewById(R.id.ad_app_detail_layout);
+ appDetailLayout.setVisibility(nativeAd.getInteractionType() == 2 ? View.VISIBLE : View.GONE);
+ if (nativeAd.getInteractionType() == 2) {
+ setSixElements(parentView.getContext(), adRootView, nativeAd);
+ }
+
// Register a native ad object.
nativeView.setNativeAd(nativeAd);
@@ -144,12 +151,48 @@ public static View createThreeImagesAdView(NativeAd nativeAd, final ViewGroup pa
imageView3.setImageDrawable(nativeAd.getImages().get(2).getDrawable());
}
+ LinearLayout appDetailLayout = adRootView.findViewById(R.id.ad_app_detail_layout);
+ appDetailLayout.setVisibility(nativeAd.getInteractionType() == 2 ? View.VISIBLE : View.GONE);
+ if (nativeAd.getInteractionType() == 2) {
+ setSixElements(parentView.getContext(), adRootView, nativeAd);
+ }
+
// Register a native ad object.
nativeView.setNativeAd(nativeAd);
return nativeView;
}
+ private static void setSixElements(final Context context, View adRootView, final NativeAd nativeAd) {
+ TextView developerView = adRootView.findViewById(R.id.ad_app_developer);
+ TextView appVersionView = adRootView.findViewById(R.id.ad_app_version);
+ developerView.setText(nativeAd.getAppInfo().getDeveloperName());
+ appVersionView.setText(context.getResources().getString(R.string.app_version) + ":" + nativeAd.getAppInfo().getVersionName());
+
+ TextView privacyView = adRootView.findViewById(R.id.ad_privacy);
+ TextView permissionView = adRootView.findViewById(R.id.ad_permission);
+ TextView detailView = adRootView.findViewById(R.id.ad_detail);
+ permissionView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nativeAd.getAppInfo().showPermissionPage(context);
+ }
+ });
+
+ privacyView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nativeAd.getAppInfo().showPrivacyPolicy(context);
+ }
+ });
+ detailView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ nativeAd.showAppDetailPage(context);
+ }
+ });
+ }
+
public static View createAppDownloadButtonAdView(NativeAd nativeAd, final ViewGroup parentView) {
LayoutInflater inflater = LayoutInflater.from(parentView.getContext());
View adRootView = inflater.inflate(R.layout.native_ad_with_app_download_btn_template, null);
@@ -177,6 +220,13 @@ public static View createAppDownloadButtonAdView(NativeAd nativeAd, final ViewGr
((Button) nativeView.getCallToActionView()).setText(nativeAd.getCallToAction());
}
+ LinearLayout appDetailLayout = adRootView.findViewById(R.id.ad_app_detail_layout);
+ appDetailLayout.setVisibility(nativeAd.getInteractionType() == 2 ? View.VISIBLE : View.GONE);
+ if (nativeAd.getInteractionType() == 2) {
+ setSixElements(parentView.getContext(), adRootView, nativeAd);
+ }
+
+
// Register a native ad object.
nativeView.setNativeAd(nativeAd);
diff --git a/app/src/main/res/layout/native_ad_with_app_download_btn_template.xml b/app/src/main/res/layout/native_ad_with_app_download_btn_template.xml
index 21ca535..2711654 100644
--- a/app/src/main/res/layout/native_ad_with_app_download_btn_template.xml
+++ b/app/src/main/res/layout/native_ad_with_app_download_btn_template.xml
@@ -15,54 +15,119 @@
+ android:layout_height="wrap_content"/>
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:layout_marginStart="16dp"
+ android:textColor="@color/black"
+ android:textSize="16sp" />
-
+ android:layout_marginTop="10dp"
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -88,13 +154,14 @@
android:layout_width="72dp"
android:layout_height="26dp"
android:layout_alignParentEnd="true"
- android:layout_marginTop="23dp"
- android:layout_marginEnd="52dp"
- android:layout_marginBottom="23dp"
+ android:layout_marginTop="24dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="24dp"
android:background="@drawable/native_button_rounded_corners_shape"
android:textColor="#FFFFFF"
android:textSize="10sp"
android:visibility="gone"/>
+
diff --git a/app/src/main/res/layout/native_common_medium_template.xml b/app/src/main/res/layout/native_common_medium_template.xml
index 09bcc22..504c392 100644
--- a/app/src/main/res/layout/native_common_medium_template.xml
+++ b/app/src/main/res/layout/native_common_medium_template.xml
@@ -27,31 +27,30 @@
android:id="@+id/ad_title"
android:layout_width="180dp"
android:layout_height="19dp"
- android:layout_marginStart="24dp"
+ android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:alpha="1"
android:textColor="#000000"
- android:textSize="@dimen/hiad_text_13_sp" />
+ android:textSize="16sp" />
+ android:textColor="#666666"/>
diff --git a/app/src/main/res/layout/native_small_image_template.xml b/app/src/main/res/layout/native_small_image_template.xml
index 58d9c6f..a3be740 100644
--- a/app/src/main/res/layout/native_small_image_template.xml
+++ b/app/src/main/res/layout/native_small_image_template.xml
@@ -9,73 +9,163 @@
android:orientation="vertical">
+ android:layout_alignParentTop="true" >
-
+ android:layout_height="wrap_content"
+ android:textColor="@color/black"
+ android:textSize="13sp" />
-
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/ad_title"
+ android:layout_alignParentStart="true" >
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:textSize="10sp"
+ android:visibility="gone"/>
diff --git a/app/src/main/res/layout/native_three_images_template.xml b/app/src/main/res/layout/native_three_images_template.xml
index 9f56138..a47107c 100644
--- a/app/src/main/res/layout/native_three_images_template.xml
+++ b/app/src/main/res/layout/native_three_images_template.xml
@@ -11,8 +11,18 @@
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="@dimen/hiad_10_dp"
android:orientation="vertical">
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true">
+
+
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..7f2a5e1
--- /dev/null
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -0,0 +1,147 @@
+
+ HUAWEI Ads Demo
+ Banner Ad
+ Native Ad
+ Reward Ad
+ Interstitial Ad
+ Instream Ad
+ Privacy Settings
+ Consent Settings
+ Load Ad
+
+
+ testw6vs28auh3
+ SIZE_320*50
+ SIZE_320*100
+ SIZE_SMART
+ SIZE_300*250
+ SIZE_360*57
+ SIZE_360*144
+ Black
+ White
+ Red
+ Transparent
+ Size:
+ Color:
+
+
+ testu7m3hc4gvm
+ testb65czjivt9
+ testr6w14o0hqz
+ testy63txaom86
+ AD
+ Display form:
+ Large image with text.
+ Three images with text.
+ Small image with text.
+ Video with text.
+ Ad with app download button.
+ Ad loading state: being loaded.
+ Ad loading state: loaded successfully.
+ Ad loading state: loaded finish.
+ Ad loading state: failed to be loaded. Error code:
+ Video playback state: starting to be played.
+ Video playback state: being played.
+ Video playback state: playback completed.
+ Ad is closed.
+ 版本
+ 介绍
+ 隐私
+ 权限
+
+
+ testx9dtjwj8hp
+ This is rewarded ads sample.
+ Play
+ Watch Video
+
+
+ testd7c5cewoj6
+ testq6zq98hecj
+ SDK Demo
+ SDK Demo
+ Copyright 2020. XXX Technologies Co., Ltd
+ Splash Ad is dismissed.
+
+
+ This is interstitial ad sample.
+ teste9ih9j0rc3
+ testb4znbuh3n2
+ Load Ad
+ Image
+ Video
+
+
+ Your video content
+ Skip
+ Learn more
+ testy3cglm3pj0
+ Normal video is playing
+ Instream ads is playing
+ Load Ad
+ Register
+ Mute
+ UnMute
+ Play
+ Pause
+ Loading
+ Ad Loaded
+
+
+ Privacy Example of HUAWEI X
+
+ 1.Privacy description\n
+ The HuaweiAdsSdk_Demo is software providing a code demo for the HUAWEI Ads SDK. Connecting to the network, the software collects and processes information to identify devices, providing customized services or ads. If you do not agree to collect the preceding information or do not agree to call related permissions or functions of your mobile phones, the software cannot run properly. You can stop data collection and uploading by uninstalling or exiting this software.\n\n
+ 2.Demo description\n
+ This demo is for reference only. Modify the content based on the user protocol specifications. \n\n
+ 3.Advertising and marketing\n
+ We will create a user group based on your personal information, collect your device information, usage information, and ad interaction information in this app, and display more relevant personalized ads and other promotion content. In this process, we will strictly protect your privacy. You can learn more about how we collect and use your personal information in personalized ads based on Ads and Privacy.
+ If you want to restrict personalized ads, you can tap here to open the ad setting page and enable the function of restricting personalized ads. After the function is enabled, you will still receive equivalent number of ads. However, the ad relevance will be reduced.
+
+ 1033
+ 1048
+ 1104
+ 1108
+ Don\'t remind me again
+ Cancel
+ Setting
+ Agree
+ Cancel
+ Reminder
+ HMS Core of this version does not have the related function. Please install HMS Core (APK) of the latest version in AppGallery.
+ OK
+
+
+ Consent Example of HUAWEI X
+ Privacy Policy
+ Close
+ Do Not Load Ads
+ The Ads in HUAWEI X is provided in collaboration with our advertising partners. To provide this service, we need to share certain information about you with these partners, including your city-level location as well as your usage records for the news service.\n\n
+ For more information about our partners and how your data is processed, please touch here.\n\n
+ By touching AGREE, you indicate that you agree to share the above personal information with our partners so that they can provide you with personalized advertisements on behalf of their customers, based on interests and preferences identified or predicted through analysis of your personal information.
+ \n\nYou can withdraw your consent at any time by going to [app settings].
+ \n\nIf you touch SKIP, your data will not be shared with our partners and you will not receive personalized ads.
+ 347
+ 351
+ The Ads in HUAWEI X is provided in collaboration with our partners. You can find a full list of our partners for each country/region here.\n\n
+ In order to provide you with personalized advertisements, we need to share the following information with our partners:\n\n
+ • User information, including advertising ID, city of residence, country, and language.\n\n
+ • Device information, including device name and model, operating system version, screen size, and network type.\n\n
+ • Service usage information, including news ID and records of views, clicks, dislikes, shares, and comments for news content and advertisements.\n\n
+ With your consent, the above information will be shared with our partners so that they can provide you with personalized advertisements on behalf of their customers, based on interests and preferences identified or predicted through analysis of your personal information.\n\n
+ You can withdraw your consent at any time by going to app settings.\n\n
+ Without your consent, no data will be shared with our partners and you will not receive personalized ads.
+ 133
+ 137
+ You can find a full list of our partners for each country/region here:\n\n
+ Back
+ Agree
+ Skip
+ You can change this setting anytime in the app.
+ Thank you!
+ This is a Consent Example
+
+ Load Personalized Ads.
+ Load Non-Personalized Ads.
+ Do Not Load Ads.
+