Skip to content

Instantly share code, notes, and snippets.

View auyanik's full-sized avatar
🏠
Working from home

Ahmet Uyanık auyanik

🏠
Working from home
View GitHub Profile
@auyanik
auyanik / AppComponent.kt
Last active February 4, 2021 12:44
Add job scheduler with dagger2
// Buraya serviebuilderModul ekledik
@Singleton //Bunu unutma
@Component(modules = [AndroidSupportInjectionModule::class, AppModule::class, ViewBuilderModule::class, ServiceBuilderModule::class])
interface AppComponent : AndroidInjector<AppControl> {
@Component.Builder
abstract class Builder : AndroidInjector.Builder<AppControl>()
}
@auyanik
auyanik / KeyboardListener.kt
Created January 27, 2021 12:48
Keyboard open and close listener
private val open = KeyboardState.OPEN // change value true
private val close = KeyboardState.CLOSE // change value false
private var lastKeyboardState = close
fun listener(rootView: View?, keyboardState: (KeyboardState) -> Unit) {
rootView?.viewTreeObserver?.addOnGlobalLayoutListener {
val rect = Rect().apply { rootView.getWindowVisibleDisplayFrame(this) }
val screenHeight = rootView.height
val keypadHeight = screenHeight - rect.bottom
hideSystemUI() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
}
@auyanik
auyanik / DeviceDecorViewListener.kt
Created January 27, 2021 10:39
DeviceDecorViewListener
requireActivity().window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
Handler(Looper.getMainLooper()).postDelayed({
hideSystemUi()
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services-safetynet:17.0.0'
}
fun errors(statusCode: Int){
when(statusCode){
RECAPTCHA_INVALID_KEYTYPE -> {
Timber.d("Kopyaladığınız \"site key\" doğruluğundan emin olun" )
}
RECAPTCHA_INVALID_PACKAGE_NAME -> {
Timber.d("Yanlış paket adı.\"Packages\" kısmına doğru paket adını eklediğinizden emin olun" )
}
TIMEOUT -> {
Timber.d("Captcha zaman aşımına uğradı yeniden yükleyin" )
<string name="key_captcha_client_sc_ky" translatable="false">6LdpiycaAAAAACZj3EXVTm4tQy7JisKGih_BmaP3</string>
fun loadCaptcha() {
SafetyNet.getClient(activity)
.verifyWithRecaptcha(getString(R.string.key_captcha_client_sc_ky))
.addOnSuccessListener(activity) { response ->
if (response.tokenResult?.isNotEmpty() == true) {
val captchaToken = response.tokenResult //Token elimize ulaştı
// Bu kısımda bu aldığımız token'ı
// Server kısmında yazacağımız onaylama(token doğrulama) api linki ne yollayacağız
// callCaptchaAuth(captChaToken)