diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml index 476e2ed..247e9de 100644 --- a/.github/workflows/merge_request.yml +++ b/.github/workflows/merge_request.yml @@ -7,6 +7,4 @@ on: jobs: check: - uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.merge_request.yml@v1 - with: - java_version: '8' \ No newline at end of file + uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.merge_request.yml@v1 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 734bc0a..115dce8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,8 +6,6 @@ on: jobs: publish: uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.publish.yml@v1 - with: - java_version: '8' secrets: gpg_key: ${{ secrets.GPG_KEY }} sign_ossrh_gradle_properties: ${{ secrets.SIGN_OSSRH_GRADLE_PROPERTIES }} diff --git a/build.gradle b/build.gradle index 232f488..6654ad7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { + apply from: 'gradle/versions.gradle' + repositories { google() - jcenter() + mavenCentral() } + dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath "com.android.tools.build:gradle:$androidPluginVersion" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -16,20 +18,10 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir } - -ext { - minSdk = 14 - targetSdk = 31 - - appCompatVersion = '1.4.1' - materialVersion = '1.3.0' - jUnitVersion = '4.12' - robolectricVersion = '3.1.2' -} diff --git a/changelog.md b/changelog.md index 096b1dc..8be6dec 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +## 1.5.2 + +#### Fixed +#### Changes +- bump up targetSdkVersion, compileSdkVersion 31 -> 33, update dependencies versions +#### Additions + ## 1.5.1 #### Fixed diff --git a/demo/build.gradle b/demo/build.gradle index c4b2e4b..aa8f894 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,15 +1,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion rootProject.targetSdk + compileSdkVersion rootProject.compileSdkVersion + defaultConfig { applicationId "ru.tinkoff.formattingdemo" - minSdkVersion rootProject.minSdk - targetSdkVersion rootProject.targetSdk + minSdkVersion rootProject.minSdkVersion + targetSdkVersion rootProject.targetSdkVersion versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + buildTypes { release { minifyEnabled false @@ -21,5 +23,5 @@ android { dependencies { implementation project(':library') - implementation "com.google.android.material:material:$rootProject.materialVersion" + implementation "com.google.android.material:material:$materialVersion" } diff --git a/gradle.properties b/gradle.properties index b5bcc20..74863dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,17 +18,17 @@ org.gradle.jvmargs=-Xmx1536m android.useAndroidX=true android.enableJetifier=true -VERSION_NAME=1.5.1 -VERSION_CODE=19 -GROUP=ru.tinkoff.decoro - POM_DESCRIPTION=Android library for text formatting -POM_URL=https://github.com/TinkoffCreditSystems/decoro -POM_SCM_URL=https://github.com/TinkoffCreditSystems/decoro -POM_SCM_CONNECTION=scm:git@github.com:TinkoffCreditSystems/decoro.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:TinkoffCreditSystems/decoro.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=tcs POM_DEVELOPER_NAME=Tinkoff Credit Systems +POM_URL=https://github.com/tinkoff-mobile-tech/decoro +POM_SCM_URL=https://github.com/tinkoff-mobile-tech/decoro/tree/master +POM_SCM_CONNECTION=scm:git:git://github.com/tinkoff-mobile-tech/decoro.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com:tinkoff-mobile-tech/decoro.git + +VERSION_NAME=1.5.2 +VERSION_CODE=20 +GROUP=ru.tinkoff.decoro diff --git a/gradle/publish-lib.gradle b/gradle/publish-lib.gradle index b25acac..449b468 100644 --- a/gradle/publish-lib.gradle +++ b/gradle/publish-lib.gradle @@ -14,26 +14,14 @@ * limitations under the License. */ -apply plugin: 'maven' +apply plugin: 'maven-publish' apply plugin: 'signing' -version = VERSION_NAME -group = GROUP - -def isReleaseBuild() { - return !VERSION_NAME.contains("SNAPSHOT") -} - def getReleaseRepositoryUrl() { return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" } -def getSnapshotRepositoryUrl() { - return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL - : "https://oss.sonatype.org/content/repositories/snapshots/" -} - def getRepositoryUsername() { return hasProperty('ossrhUsername') ? ossrhUsername : '' } @@ -43,176 +31,80 @@ def getRepositoryPassword() { } afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - repository(url: getReleaseRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + publishing { + publications { + release(MavenPublication) { + groupId GROUP + artifactId POM_ARTIFACT_ID + version VERSION_NAME + + from components.release + + afterEvaluate { + artifact androidSourcesJar + artifact androidJavadocsJar } - snapshotRepository(url: getSnapshotRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL + pom { + name = POM_NAME + packaging = POM_PACKAGING + description = POM_DESCRIPTION + url = POM_URL scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION + url = POM_SCM_URL + connection = POM_SCM_CONNECTION + developerConnection = POM_SCM_DEV_CONNECTION } - licenses { license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST + name = POM_LICENCE_NAME + url = POM_LICENCE_URL + distribution = POM_LICENCE_DIST } } - developers { developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME + id = POM_DEVELOPER_ID + name = POM_DEVELOPER_NAME } } } } } - } - - signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives - } - - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - task install(type: Upload, dependsOn: assemble) { - repositories.mavenInstaller { - configuration = configurations.archives - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } + repositories { + maven { + url = getReleaseRepositoryUrl() + credentials { + username = getRepositoryUsername() + password = getRepositoryPassword() } } } + } - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.source - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } - } else { - install { - repositories.mavenInstaller { - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } + task androidSourcesJar(type: Jar) { + archiveClassifier.set("sources") + from android.sourceSets.main.java.srcDirs + } - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } + task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + android.libraryVariants.all { variant -> + if (variant.name == 'release') { + owner.classpath += variant.javaCompileProvider.get().classpath } } - - task sourcesJar(type: Jar, dependsOn:classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar, dependsOn:javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } + exclude '**/R.html', '**/R.*.html', '**/index.html' } - if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + archiveClassifier.set("javadoc") + from androidJavadocs.destinationDir } - artifacts { - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - archives androidSourcesJar - archives androidJavadocsJar - } else { - archives sourcesJar - archives javadocJar - } + signing { + required { gradle.taskGraph.hasTask("publish") } + sign publishing.publications.release } } diff --git a/gradle/versions.gradle b/gradle/versions.gradle new file mode 100644 index 0000000..783e193 --- /dev/null +++ b/gradle/versions.gradle @@ -0,0 +1,17 @@ +ext { + compileSdkVersion = 33 + targetSdkVersion = 33 + minSdkVersion = 14 + + decoroVersionCode = VERSION_CODE.toInteger() + decoroVersionName = VERSION_NAME + + // android libs + appCompatVersion = '1.6.1' + materialVersion = '1.9.0' + androidPluginVersion = '7.4.2' + + // testing automation libs + jUnitVersion = '4.13.2' + robolectricVersion = '4.9.2' +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5acf6b5..774fae8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed May 27 10:04:41 MSK 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/library/build.gradle b/library/build.gradle index f611be6..63f5f03 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,15 +7,16 @@ if(new File(customGradleScript).exists()){ } android { - compileSdkVersion rootProject.targetSdk + compileSdkVersion rootProject.compileSdkVersion defaultConfig { - minSdkVersion rootProject.minSdk - targetSdkVersion rootProject.targetSdk - versionCode project.properties['VERSION_CODE'].toInteger() - versionName project.properties['VERSION_NAME'] + minSdkVersion rootProject.minSdkVersion + targetSdkVersion rootProject.targetSdkVersion + versionCode rootProject.decoroVersionCode + versionName rootProject.decoroVersionName setProperty("archivesBaseName", "decoro-${defaultConfig.versionName}") } + buildTypes { release { minifyEnabled false @@ -30,8 +31,8 @@ tasks.withType(Javadoc) { } dependencies { - compileOnly "androidx.appcompat:appcompat:$rootProject.appCompatVersion" + compileOnly "androidx.appcompat:appcompat:$appCompatVersion" - testImplementation "junit:junit:$rootProject.jUnitVersion" - testImplementation "org.robolectric:robolectric:$rootProject.robolectricVersion" + testImplementation "junit:junit:$jUnitVersion" + testImplementation "org.robolectric:robolectric:$robolectricVersion" } diff --git a/library/src/main/java/ru/tinkoff/decoro/Mask.java b/library/src/main/java/ru/tinkoff/decoro/Mask.java index ebc0087..af587f3 100644 --- a/library/src/main/java/ru/tinkoff/decoro/Mask.java +++ b/library/src/main/java/ru/tinkoff/decoro/Mask.java @@ -26,7 +26,7 @@ * Interface representing a Mask that holds slots with user input and hardcoded data. * The mask performs actual formatting of the input and able to return formatted and unformatted * string. - *

+ *

* See: {@link MaskImpl} - the main implementation of this interface. * * @author Mikhail Artemev @@ -121,7 +121,7 @@ public interface Mask extends Iterable, Parcelable { int removeBackwardsWithoutHardcoded(int position, int count); /** - * Returns current size of a mask in slots.
+ * Returns current size of a mask in slots.
* IMPORTANT: empty slots are also counted. * * @return returns current size of a mask in slots @@ -131,7 +131,7 @@ public interface Mask extends Iterable, Parcelable { /** * @return true if mask allows to display slots with no value, putting placeholder * on those positions. - *

+ *

* See: {@link #setPlaceholder(Character)} */ boolean isShowingEmptySlots(); @@ -139,7 +139,7 @@ public interface Mask extends Iterable, Parcelable { /** * Defines whether mask allows to display slots with no value, putting placeholder * on those positions. - *

+ *

* See: {@link #setPlaceholder(Character)} * * @param showingEmptySlots true if mask allows empty slots to be displayed @@ -147,18 +147,18 @@ public interface Mask extends Iterable, Parcelable { void setShowingEmptySlots(boolean showingEmptySlots); /** - * @return character that will be put on empty position when calling {@link #toString()} or + * @return character that will be put on empty position when calling {@code toString()} or * {@link #toUnformattedString()}. - *

+ *

* See: {@link #setShowingEmptySlots(boolean)} */ @NonNull Character getPlaceholder(); /** - * Sets character that will be put on empty position when calling {@link #toString()} or + * Sets character that will be put on empty position when calling {@code toString()} or * {@link #toUnformattedString()}. Placeholder should not be null! - *

+ *

* See: {@link #setShowingEmptySlots(boolean)} * * @param placeholder character that represents empty slots @@ -167,15 +167,15 @@ public interface Mask extends Iterable, Parcelable { /** * @return true if mask will hide leading hardcoded sequence of its contents. - *

+ *

* See: {@link #setHideHardcodedHead(boolean)} */ boolean isHideHardcodedHead(); /** - * Defines whether mask should hide leading hardcoded sequence when calling {@link #toString()} + * Defines whether mask should hide leading hardcoded sequence when calling {@code toString()} * or {@link #toUnformattedString()}. - *

+ *

* Example of "hardcoded head" is +7 ( in the russian cellphone number mask defined in * {@link * ru.tinkoff.decoro.slots.PredefinedSlots#RUS_PHONE_NUMBER}. @@ -187,7 +187,7 @@ public interface Mask extends Iterable, Parcelable { /** * @return true if mask won't allow to perform further input if all the slots are already filled * out. - *

+ *

* See: {@link #setForbidInputWhenFilled(boolean)} */ boolean isForbidInputWhenFilled(); @@ -196,7 +196,7 @@ public interface Mask extends Iterable, Parcelable { * Defines whether mask won't allow to perform further input if all the slots are already * filled out. If false passed - mask will shift existing input when trying to insert * text inside filled out mask ({@link #filled()} returns true). - *

+ *

* WARNING: This flag only makes sense for terminated masks. * * @param forbidInputWhenFilled flag that forbids overwriting terminated filled out masks. @@ -208,7 +208,7 @@ public interface Mask extends Iterable, Parcelable { * in a formatted string. * @param cursorPosition * @return corresponding cursor position in unformatted string - * @throws IndexOutOfBoundsException if cursorPosition < 0 or cursorPosition > size + * @throws IndexOutOfBoundsException if cursorPosition < 0 or cursorPosition > size */ int findCursorPositionInUnformattedString(int cursorPosition); } diff --git a/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java b/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java index a64cf22..b2c5f0e 100644 --- a/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java +++ b/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java @@ -89,7 +89,7 @@ public String toString() { * Returns text without decoration characters. Method works with respect to all the * mask parameters. Just as {@link #toString()} does; *

- *

Example: assume that filled mask contains "+7 999 + *

Example: assume that filled mask contains "+7 999 * 111-22-33" where spaces and dashes are decoration slots. Then this * method will return "+79991112233". * diff --git a/library/src/main/java/ru/tinkoff/decoro/watchers/FormatWatcher.java b/library/src/main/java/ru/tinkoff/decoro/watchers/FormatWatcher.java index 20be9b1..55e9237 100644 --- a/library/src/main/java/ru/tinkoff/decoro/watchers/FormatWatcher.java +++ b/library/src/main/java/ru/tinkoff/decoro/watchers/FormatWatcher.java @@ -69,7 +69,7 @@ protected FormatWatcher() { } /** - * Starts to follow text changes in the specified {@link TextView} to format any input.
+ * Starts to follow text changes in the specified {@link TextView} to format any input.
* IMPORTANT: this call will force watcher to re-create the mask * * @param textView text view to watch and format @@ -80,7 +80,7 @@ public void installOn(@NonNull final TextView textView) { /** * Starts to follow text changes in the specified {@link TextView} to format any input. - * Initial mask's value (e.g. hardcoded head) will be displayed in the view.
+ * Initial mask's value (e.g. hardcoded head) will be displayed in the view.
* IMPORTANT: this call will force watcher to re-create the mask * * @param textView text view to watch and format