Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ android {
minSdkVersion 16
targetSdkVersion 35

vectorDrawables.useSupportLibrary = true

// See https://developer.android.com/studio/publish/versioning
// versionCode must be integer and be incremented by one for every new update
// android system uses this to prevent downgrades
Expand Down Expand Up @@ -78,6 +80,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:4.8.1'
testImplementation 'org.skyscreamer:jsonassert:1.5.1'
testImplementation 'org.robolectric:robolectric:4.8.2'

compileOnly 'com.google.code.findbugs:annotations:3.0.1'
}
Expand Down
5 changes: 3 additions & 2 deletions sdk/src/main/res/layout/hcaptcha_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">

Expand All @@ -20,11 +21,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/ic_hcaptcha_logo"
app:srcCompat="@drawable/ic_hcaptcha_logo"
android:contentDescription="@string/logo_description" />

<ProgressBar
Expand Down
40 changes: 40 additions & 0 deletions sdk/src/test/java/com/hcaptcha/sdk/HCaptchaFragmentLayoutTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hcaptcha.sdk;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import android.app.Dialog;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.appcompat.widget.AppCompatImageView;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = Build.VERSION_CODES.S_V2)
public class HCaptchaFragmentLayoutTest {
@Test
public void layoutInflatedThroughPlainDialog_doesNotApplySrcCompat() {
final Dialog dialog = new Dialog(RuntimeEnvironment.getApplication(), R.style.HCaptchaDialogTheme);
final LayoutInflater inflater = LayoutInflater.from(RuntimeEnvironment.getApplication())
.cloneInContext(dialog.getContext());

final ImageView logo = inflateLogo(inflater);

assertEquals(AppCompatImageView.class, logo.getClass());
assertNotNull(logo.getDrawable());
}

private static ImageView inflateLogo(LayoutInflater inflater) {
final View rootView = inflater.inflate(R.layout.hcaptcha_fragment, null, false);
final LinearLayout loadingContainer = rootView.findViewById(R.id.loadingContainer);
return (ImageView) loadingContainer.getChildAt(0);
}
}
Loading