-
-
Notifications
You must be signed in to change notification settings - Fork 3
Integrate native ad banner into Android Studio settings screen #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
MihaiCristianCondrea
wants to merge
1
commit into
main
from
codex/create-custom-layout-with-ad-banner
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,72 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content"> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/ad_host" | ||
| <com.google.android.material.card.MaterialCardView | ||
| android:id="@+id/ad_card" | ||
| style="@style/Widget.Material3.CardView.Outlined" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| android:background="?attr/colorSurfaceContainer" | ||
| android:paddingStart="16dp" | ||
| android:paddingEnd="16dp" | ||
| android:paddingTop="12dp" | ||
| android:paddingBottom="12dp"> | ||
|
|
||
| <include layout="@layout/ad_attribution" /> | ||
| app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardView"> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:gravity="center_vertical" | ||
| android:orientation="horizontal"> | ||
| android:orientation="vertical" | ||
| android:background="?attr/colorSurfaceContainer" | ||
| android:paddingStart="16dp" | ||
| android:paddingEnd="16dp" | ||
| android:paddingTop="12dp" | ||
| android:paddingBottom="12dp"> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/ad_app_icon" | ||
| android:layout_width="32dp" | ||
| android:layout_height="32dp" | ||
| android:layout_marginEnd="12dp" /> | ||
| <include layout="@layout/ad_attribution" /> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="0dp" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_weight="1" | ||
| android:orientation="vertical"> | ||
| android:gravity="center_vertical" | ||
| android:orientation="horizontal"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/ad_headline" | ||
| android:layout_width="wrap_content" | ||
| <ImageView | ||
| android:id="@+id/ad_app_icon" | ||
| android:layout_width="32dp" | ||
| android:layout_height="32dp" | ||
| android:layout_marginEnd="12dp" /> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="0dp" | ||
| android:layout_height="wrap_content" | ||
| android:ellipsize="end" | ||
| android:maxLines="1" | ||
| android:textAppearance="@style/TextAppearance.Material3.BodyMedium" /> | ||
| android:layout_weight="1" | ||
| android:orientation="vertical"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/ad_headline" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:ellipsize="end" | ||
| android:maxLines="1" | ||
| android:textAppearance="@style/TextAppearance.Material3.BodyMedium" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/ad_body" | ||
| <TextView | ||
| android:id="@+id/ad_body" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:ellipsize="end" | ||
| android:maxLines="1" | ||
| android:textAppearance="@style/TextAppearance.Material3.BodySmall" /> | ||
| </LinearLayout> | ||
|
|
||
| <com.google.android.material.button.MaterialButton | ||
| android:id="@+id/ad_call_to_action" | ||
| style="@style/Widget.Material3.Button.TextButton" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:ellipsize="end" | ||
| android:maxLines="1" | ||
| android:textAppearance="@style/TextAppearance.Material3.BodySmall" /> | ||
| android:minWidth="88dp" | ||
| android:minHeight="40dp" | ||
| android:layout_marginStart="8dp" /> | ||
| </LinearLayout> | ||
|
|
||
| <com.google.android.material.button.MaterialButton | ||
| android:id="@+id/ad_call_to_action" | ||
| style="@style/Widget.Material3.Button.TextButton" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:minWidth="88dp" | ||
| android:minHeight="40dp" | ||
| android:layout_marginStart="8dp" /> | ||
| </LinearLayout> | ||
| </LinearLayout> | ||
| </com.google.android.material.card.MaterialCardView> | ||
| </com.google.android.gms.ads.nativead.NativeAdView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:orientation="vertical"> | ||
|
|
||
| <androidx.recyclerview.widget.RecyclerView | ||
| android:id="@android:id/list" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="0dp" | ||
| android:layout_weight="1" /> | ||
|
|
||
| <com.d4rk.androidtutorials.java.ads.views.NativeAdBannerView | ||
| android:id="@+id/native_ad_view" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| app:nativeAdLayout="@layout/bottom_app_bar_native_ad" /> | ||
| </LinearLayout> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Inflate custom layout without calling super
Overriding
onCreateViewnow inflatesfragment_android_studiodirectly and returns it without delegating toPreferenceFragmentCompat. The base implementation is responsible for creating and configuring the internalRecyclerView(layout manager, adapter, scroll listeners). Returning a raw layout means the preference list is never initialized, so the Android Studio settings screen will render empty and search filtering will have no list to operate on. The method should callsuper.onCreateView(...)and add the ad view to that hierarchy rather than replacing it.Useful? React with 👍 / 👎.