Skip to content

Commit

Permalink
Android 14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Stulnev committed Oct 8, 2023
1 parent 4924fb3 commit 8ea15e3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ allprojects {
**Step 2.** Add the dependency
```gradle
dependencies {
implementation "com.github.fraggjkee:sms-confirmation-view:1.8.0"
implementation "com.github.fraggjkee:sms-confirmation-view:1.8.1"
}
```

Expand Down Expand Up @@ -69,7 +69,7 @@ Here's the list of available XML attributes:
- `scv_symbolBorderWidth`: thickness of the stroke used to draw symbol subview's border. Default value = [2dp](https://github.com/fraggjkee/SmsConfirmationView/blob/fb2be87c0510a10a95b343f79380de72f6fe7742/library/src/main/res/values/dimens.xml#L9)
- `scv_symbolBorderCornerRadius`: corner radius for symbol subview's border. Default value = [2dp](https://github.com/fraggjkee/SmsConfirmationView/blob/fb2be87c0510a10a95b343f79380de72f6fe7742/library/src/main/res/values/dimens.xml#L5)

All of these attributes can also be changed **programatically** (XML customization is the preferred way though), check out the list of available extensions [here](https://github.com/fraggjkee/SmsConfirmationView/blob/master/library/src/main/java/com/fraggjkee/smsconfirmationview/SmsConfirmationViewExt.kt).
All of these attributes can also be changed **programmatically** (XML customization is the preferred way though), check out the list of available extensions [here](https://github.com/fraggjkee/SmsConfirmationView/blob/master/library/src/main/java/com/fraggjkee/smsconfirmationview/SmsConfirmationViewExt.kt).

# SMS Detection modes
- `app:scv_smsDetectionMode="disabled"`: Prevents the view from using SMS Consent API, i.e. this option simply disables automatic SMS detection.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ apply plugin: 'maven-publish'
android {
namespace 'com.fraggjkee.smsconfirmationview'

compileSdk = 33
buildToolsVersion = "33.0.1"
compileSdk = 34
buildToolsVersion = "34.0.0"

defaultConfig {
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -65,4 +65,4 @@ publishing {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.fraggjkee.smsconfirmationview

import android.content.BroadcastReceiver
import android.content.Context
import android.content.ContextWrapper
import android.content.IntentFilter
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.annotation.AttrRes
Expand Down Expand Up @@ -35,4 +38,28 @@ internal fun View.getActivity(): AppCompatActivity? {
context = context.baseContext
}
return null
}
}

internal fun Context.registerReceiver(
receiver: BroadcastReceiver,
intentFilter: IntentFilter,
permission: String
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
@Suppress("UnspecifiedRegisterReceiverFlag")
registerReceiver(
receiver,
intentFilter,
permission,
null
)
} else {
registerReceiver(
receiver,
intentFilter,
permission,
null,
Context.RECEIVER_EXPORTED
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ class SmsConfirmationView @JvmOverloads constructor(
context.registerReceiver(
smsBroadcastReceiver,
IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION),
SmsRetriever.SEND_PERMISSION,
null
SmsRetriever.SEND_PERMISSION
)

SmsRetriever.getClient(context).startSmsUserConsent(null)
Expand Down Expand Up @@ -363,4 +362,4 @@ class SmsConfirmationView @JvmOverloads constructor(
internal const val DEFAULT_CODE_LENGTH = 4
private const val KEYBOARD_AUTO_SHOW_DELAY = 500L
}
}
}
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ apply plugin: 'kotlin-android'
android {
namespace 'com.fraggjkee.smsconfirmationview.sample'

compileSdk = 33
buildToolsVersion = "33.0.1"
compileSdk = 34
buildToolsVersion = "34.0.0"

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand All @@ -19,7 +19,7 @@ android {
defaultConfig {
applicationId "com.fraggjkee.smsconfirmationview"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode 1
versionName "1.0"

Expand Down

0 comments on commit 8ea15e3

Please sign in to comment.