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
apply plugin: 'dagger.hilt.android.plugin' | |
// Since these are alpha dependencies and subject to change they will remain outside of the | |
// dependencies.gradle script till they reach 1.0.0 | |
implementation "com.google.dagger:hilt-android:2.28-alpha" | |
kapt "com.google.dagger:hilt-android-compiler:2.28-alpha" | |
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02' | |
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' |
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
apply plugin: 'dagger.hilt.android.plugin' | |
// Since these are alpha dependencies and subject to change they will remain outside of the | |
// dependencies.gradle script till they reach 1.0.0 | |
implementation "com.google.dagger:hilt-android:2.28-alpha" | |
kapt "com.google.dagger:hilt-android-compiler:2.28-alpha" | |
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02' | |
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' |
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
ext { | |
androidXCore="1.3.0" | |
androidXAppcompat="1.1.0" | |
constraintLayout="1.1.3" | |
kotlinVersion="1.3.72" | |
moshiVersion="1.8.0" | |
retrofit2_version = "2.9.0" | |
okhttp3_version = "3.12.0" | |
kotlinCoroutineVersion = "1.3.5" |
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
public class RecaptchaVerifyResponse { | |
private boolean success; | |
private String challenge_ts; | |
private String apk_package_name; | |
@SerializedName("error-codes") | |
private List<String> errorCodes; | |
public boolean isSuccess() { | |
return success; |
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
public class RecaptchaRepository { | |
public LiveData<RecaptchaVerifyResponse> doRecaptchaValidation(@NonNull String baseUrl, @NonNull String response, @NonNull String key) { | |
final MutableLiveData<RecaptchaVerifyResponse> data = new MutableLiveData<>(); | |
Map<String, String> params = new HashMap<>(); | |
params.put("response", response); | |
params.put("secret", key); | |
getRecaptchaValidationService(baseUrl).verifyResponse(params).enqueue(new Callback<RecaptchaVerifyResponse>() { | |
@Override |
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
public interface RecaptchaVerificationService { | |
@Headers("Content-Type: application/x-www-form-urlencoded; charset=utf-8") | |
@POST("/recaptcha/api/siteverify") | |
Call<RecaptchaVerifyResponse> verifyResponse(@QueryMap Map<String, String> params); | |
} |
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
public class SuccessListener implements OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse> { | |
@Override | |
public void onSuccess(final SafetyNetApi.RecaptchaTokenResponse recaptchaTokenResponse) { | |
String userResponseToken = recaptchaTokenResponse.getTokenResult(); | |
if (!userResponseToken.isEmpty()) { | |
RecaptchaResponseViewModel mViewModel = ViewModelProviders.of(MainActivity.this).get(RecaptchaResponseViewModel.class); | |
mViewModel.getmRecaptchaObservable("https://www.google.com", userResponseToken, **SECRET KEY GOES HERE**).observe(MainActivity.this, new Observer<RecaptchaVerifyResponse>() { |
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
public class FailureListener implements OnFailureListener { | |
@Override | |
public void onFailure(@NonNull Exception e) { | |
// Handle failure scenario | |
} | |
} |
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
package com.praszapps.mysamplenavapp | |
import android.os.Bundle | |
import android.support.v4.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import kotlinx.android.synthetic.main.fragment_destination.* |
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
package com.praszapps.mysamplenavapp | |
import android.os.Bundle | |
import android.support.v4.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.navigation.fragment.findNavController | |
import kotlinx.android.synthetic.main.fragment_main.* |
NewerOlder