Skip to content

Commit 2286ba1

Browse files
author
Tomasz Najda
committed
[sample] add: sample app
1 parent 156ea7b commit 2286ba1

24 files changed

+382
-1
lines changed

sample/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

sample/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 27
7+
defaultConfig {
8+
applicationId "com.tomasznajda.rxrecaptcha"
9+
minSdkVersion 14
10+
targetSdkVersion 27
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled true
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
implementation fileTree(dir: 'libs', include: ['*.jar'])
24+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
25+
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
26+
implementation "io.reactivex.rxjava2:rxkotlin:2.2.0"
27+
28+
implementation 'com.android.support:appcompat-v7:27.1.0'
29+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
30+
implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1'
31+
implementation project(':rxrecaptcha')
32+
33+
testImplementation 'junit:junit:4.12'
34+
}

sample/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

sample/src/main/AndroidManifest.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.tomasznajda.rxrecaptcha.sample">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
13+
<activity android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN"/>
16+
<category android:name="android.intent.category.LAUNCHER"/>
17+
</intent-filter>
18+
</activity>
19+
20+
</application>
21+
22+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.tomasznajda.rxrecaptcha.sample
2+
3+
import android.os.Bundle
4+
import android.support.v7.app.AppCompatActivity
5+
import android.widget.Toast
6+
import com.jakewharton.rxbinding2.view.clicks
7+
import com.tomasznajda.rxrecaptcha.ReCaptcha
8+
import kotlinx.android.synthetic.main.activity_main.*
9+
10+
const val YOUR_SITE_KEY = "enter your site key here"
11+
12+
class MainActivity : AppCompatActivity() {
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
setContentView(R.layout.activity_main)
17+
18+
btnReCaptcha
19+
.clicks()
20+
.flatMapSingle { ReCaptcha(this@MainActivity).verify(YOUR_SITE_KEY) }
21+
.doOnNext { printToken(token = it) }
22+
.doOnError { printError(error = it) }
23+
.retry()
24+
.subscribe()
25+
}
26+
27+
private fun printToken(token: String) =
28+
with(token) {
29+
println(token)
30+
toast("Token: $this")
31+
}
32+
33+
private fun printError(error: Throwable) =
34+
with(error) {
35+
printStackTrace()
36+
message?.let { toast(it) } ?: toast(toString())
37+
}
38+
39+
private fun toast(text: String) = Toast.makeText(this, text, Toast.LENGTH_LONG).show()
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0"/>
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0"/>
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1"/>
34+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:height="108dp"
5+
android:width="108dp"
6+
android:viewportHeight="108"
7+
android:viewportWidth="108">
8+
<path
9+
android:fillColor="#26A69A"
10+
android:pathData="M0,0h108v108h-108z"/>
11+
<path
12+
android:fillColor="#00000000"
13+
android:pathData="M9,0L9,108"
14+
android:strokeColor="#33FFFFFF"
15+
android:strokeWidth="0.8"/>
16+
<path
17+
android:fillColor="#00000000"
18+
android:pathData="M19,0L19,108"
19+
android:strokeColor="#33FFFFFF"
20+
android:strokeWidth="0.8"/>
21+
<path
22+
android:fillColor="#00000000"
23+
android:pathData="M29,0L29,108"
24+
android:strokeColor="#33FFFFFF"
25+
android:strokeWidth="0.8"/>
26+
<path
27+
android:fillColor="#00000000"
28+
android:pathData="M39,0L39,108"
29+
android:strokeColor="#33FFFFFF"
30+
android:strokeWidth="0.8"/>
31+
<path
32+
android:fillColor="#00000000"
33+
android:pathData="M49,0L49,108"
34+
android:strokeColor="#33FFFFFF"
35+
android:strokeWidth="0.8"/>
36+
<path
37+
android:fillColor="#00000000"
38+
android:pathData="M59,0L59,108"
39+
android:strokeColor="#33FFFFFF"
40+
android:strokeWidth="0.8"/>
41+
<path
42+
android:fillColor="#00000000"
43+
android:pathData="M69,0L69,108"
44+
android:strokeColor="#33FFFFFF"
45+
android:strokeWidth="0.8"/>
46+
<path
47+
android:fillColor="#00000000"
48+
android:pathData="M79,0L79,108"
49+
android:strokeColor="#33FFFFFF"
50+
android:strokeWidth="0.8"/>
51+
<path
52+
android:fillColor="#00000000"
53+
android:pathData="M89,0L89,108"
54+
android:strokeColor="#33FFFFFF"
55+
android:strokeWidth="0.8"/>
56+
<path
57+
android:fillColor="#00000000"
58+
android:pathData="M99,0L99,108"
59+
android:strokeColor="#33FFFFFF"
60+
android:strokeWidth="0.8"/>
61+
<path
62+
android:fillColor="#00000000"
63+
android:pathData="M0,9L108,9"
64+
android:strokeColor="#33FFFFFF"
65+
android:strokeWidth="0.8"/>
66+
<path
67+
android:fillColor="#00000000"
68+
android:pathData="M0,19L108,19"
69+
android:strokeColor="#33FFFFFF"
70+
android:strokeWidth="0.8"/>
71+
<path
72+
android:fillColor="#00000000"
73+
android:pathData="M0,29L108,29"
74+
android:strokeColor="#33FFFFFF"
75+
android:strokeWidth="0.8"/>
76+
<path
77+
android:fillColor="#00000000"
78+
android:pathData="M0,39L108,39"
79+
android:strokeColor="#33FFFFFF"
80+
android:strokeWidth="0.8"/>
81+
<path
82+
android:fillColor="#00000000"
83+
android:pathData="M0,49L108,49"
84+
android:strokeColor="#33FFFFFF"
85+
android:strokeWidth="0.8"/>
86+
<path
87+
android:fillColor="#00000000"
88+
android:pathData="M0,59L108,59"
89+
android:strokeColor="#33FFFFFF"
90+
android:strokeWidth="0.8"/>
91+
<path
92+
android:fillColor="#00000000"
93+
android:pathData="M0,69L108,69"
94+
android:strokeColor="#33FFFFFF"
95+
android:strokeWidth="0.8"/>
96+
<path
97+
android:fillColor="#00000000"
98+
android:pathData="M0,79L108,79"
99+
android:strokeColor="#33FFFFFF"
100+
android:strokeWidth="0.8"/>
101+
<path
102+
android:fillColor="#00000000"
103+
android:pathData="M0,89L108,89"
104+
android:strokeColor="#33FFFFFF"
105+
android:strokeWidth="0.8"/>
106+
<path
107+
android:fillColor="#00000000"
108+
android:pathData="M0,99L108,99"
109+
android:strokeColor="#33FFFFFF"
110+
android:strokeWidth="0.8"/>
111+
<path
112+
android:fillColor="#00000000"
113+
android:pathData="M19,29L89,29"
114+
android:strokeColor="#33FFFFFF"
115+
android:strokeWidth="0.8"/>
116+
<path
117+
android:fillColor="#00000000"
118+
android:pathData="M19,39L89,39"
119+
android:strokeColor="#33FFFFFF"
120+
android:strokeWidth="0.8"/>
121+
<path
122+
android:fillColor="#00000000"
123+
android:pathData="M19,49L89,49"
124+
android:strokeColor="#33FFFFFF"
125+
android:strokeWidth="0.8"/>
126+
<path
127+
android:fillColor="#00000000"
128+
android:pathData="M19,59L89,59"
129+
android:strokeColor="#33FFFFFF"
130+
android:strokeWidth="0.8"/>
131+
<path
132+
android:fillColor="#00000000"
133+
android:pathData="M19,69L89,69"
134+
android:strokeColor="#33FFFFFF"
135+
android:strokeWidth="0.8"/>
136+
<path
137+
android:fillColor="#00000000"
138+
android:pathData="M19,79L89,79"
139+
android:strokeColor="#33FFFFFF"
140+
android:strokeWidth="0.8"/>
141+
<path
142+
android:fillColor="#00000000"
143+
android:pathData="M29,19L29,89"
144+
android:strokeColor="#33FFFFFF"
145+
android:strokeWidth="0.8"/>
146+
<path
147+
android:fillColor="#00000000"
148+
android:pathData="M39,19L39,89"
149+
android:strokeColor="#33FFFFFF"
150+
android:strokeWidth="0.8"/>
151+
<path
152+
android:fillColor="#00000000"
153+
android:pathData="M49,19L49,89"
154+
android:strokeColor="#33FFFFFF"
155+
android:strokeWidth="0.8"/>
156+
<path
157+
android:fillColor="#00000000"
158+
android:pathData="M59,19L59,89"
159+
android:strokeColor="#33FFFFFF"
160+
android:strokeWidth="0.8"/>
161+
<path
162+
android:fillColor="#00000000"
163+
android:pathData="M69,19L69,89"
164+
android:strokeColor="#33FFFFFF"
165+
android:strokeWidth="0.8"/>
166+
<path
167+
android:fillColor="#00000000"
168+
android:pathData="M79,19L79,89"
169+
android:strokeColor="#33FFFFFF"
170+
android:strokeWidth="0.8"/>
171+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context="com.tomasznajda.rxrecaptcha.sample.MainActivity">
9+
10+
<Button
11+
android:id="@+id/btnReCaptcha"
12+
android:textAllCaps="false"
13+
android:text="reCAPTCHA"
14+
android:layout_width="wrap_content"
15+
android:layout_height="wrap_content"
16+
app:layout_constraintEnd_toEndOf="parent"
17+
android:layout_marginEnd="8dp"
18+
app:layout_constraintStart_toStartOf="parent"
19+
android:layout_marginStart="8dp"
20+
app:layout_constraintBottom_toBottomOf="parent"
21+
android:layout_marginBottom="8dp"
22+
app:layout_constraintTop_toTopOf="parent"
23+
android:layout_marginTop="8dp"/>
24+
25+
</android.support.constraint.ConstraintLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
2.98 KB
Loading
Loading
2.05 KB
Loading
Loading
4.46 KB
Loading
Loading
Loading
Loading
Loading
Loading

sample/src/main/res/values/colors.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="primary">#03A9F4</color>
4+
<color name="primaryDark">#0288D1</color>
5+
<color name="primaryLight">#B3E5FC</color>
6+
<color name="accent">#448AFF</color>
7+
<color name="primaryText">#212121</color>
8+
<color name="secondaryText">#757575</color>
9+
<color name="icons">#FFFFFF</color>
10+
<color name="divider">#BDBDBD</color>
11+
</resources>
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">rx-reCAPTCHA</string>
3+
</resources>

sample/src/main/res/values/styles.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4+
<item name="colorPrimary">@color/primary</item>
5+
<item name="colorPrimaryDark">@color/primaryDark</item>
6+
<item name="colorAccent">@color/accent</item>
7+
</style>
8+
9+
</resources>

0 commit comments

Comments
 (0)