-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
316 additions
and
288 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- master | ||
pull_request: | ||
branches: | ||
- develop | ||
- master | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: ./gradlew build sonarqube |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("com.android.application") version "4.1.3" apply false | ||
kotlin("android") version "1.4.31" apply false | ||
id("org.sonarqube") version "3.1.1" | ||
} | ||
|
||
subprojects { | ||
apply(plugin = "org.sonarqube") | ||
|
||
sonarqube { | ||
if (name == "sample") { | ||
isSkipProject = true | ||
} else { | ||
properties { | ||
property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/test/jacocoTestReport.xml") | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8.toString() | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
sonarqube { | ||
properties { | ||
property("sonar.projectKey", "G00fY2_version-compare") | ||
property("sonar.organization", "g00fy2") | ||
property("sonar.host.url", "https://sonarcloud.io") | ||
} | ||
} | ||
|
||
tasks.register<Delete>("clean") { | ||
delete(buildDir) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("kotlin-android") | ||
} | ||
android { | ||
compileSdkVersion(30) | ||
defaultConfig { | ||
applicationId = "io.github.g00fy2.versioncomparesample" | ||
minSdkVersion(14) | ||
targetSdkVersion(30) | ||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
buildTypes { | ||
getByName("release") { | ||
isShrinkResources = true | ||
isMinifyEnabled = true | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
} | ||
sourceSets.getByName("main").java.srcDirs("src/main/kotlin") | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
lintOptions { | ||
disable("UnusedResources", "LockedOrientationActivity") | ||
isAbortOnError = false | ||
isIgnoreTestSources = true | ||
} | ||
} | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
implementation(project(":versioncompare")) | ||
} |
This file contains 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
63 changes: 0 additions & 63 deletions
63
sample/src/main/kotlin/com/g00fy2/versioncomparesample/MainActivity.kt
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
sample/src/main/kotlin/io/github/g00fy2/versioncomparesample/MainActivity.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.github.g00fy2.versioncomparesample | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
import io.github.g00fy2.versioncompare.Version | ||
import io.github.g00fy2.versioncomparesample.databinding.ActivityMainBinding | ||
|
||
class MainActivity : Activity() { | ||
|
||
private lateinit var binding: ActivityMainBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
binding.compareButtonTextview.setOnClickListener { compareVersions() } | ||
binding.versionBEdittext.setOnEditorActionListener { _, _, _ -> | ||
compareVersions() | ||
true | ||
} | ||
} | ||
|
||
private fun compareVersions() { | ||
val versionStringA = binding.versionAEdittext.text.toString() | ||
val versionStringB = binding.versionBEdittext.text.toString() | ||
|
||
if (versionStringA.isNotBlank() && versionStringB.isNotBlank()) { | ||
val versionA = Version(versionStringA) | ||
val versionB = Version(versionStringB) | ||
|
||
binding.isHigherCheckedtextview.isChecked = versionA.isHigherThan(versionB) | ||
binding.isLowerCheckedtextview.isChecked = versionA.isLowerThan(versionB) | ||
binding.isEqualCheckedtextview.isChecked = versionA.isEqual(versionB) | ||
|
||
setVersionDescriptionViews(versionA, versionB) | ||
} else { | ||
binding.isHigherCheckedtextview.isChecked = false | ||
binding.isLowerCheckedtextview.isChecked = false | ||
binding.isEqualCheckedtextview.isChecked = false | ||
binding.versionDescriptionLinearlayout.visibility = View.GONE | ||
} | ||
|
||
hideKeyboard() | ||
} | ||
|
||
private fun setVersionDescriptionViews(versionA: Version, versionB: Version) { | ||
binding.subversionsATextview.text = versionA.subversionNumbers.joinToString(separator = ".").ifEmpty { "invalid" } | ||
binding.majorATextview.text = versionA.major.toString() | ||
binding.minorATextview.text = versionA.minor.toString() | ||
binding.patchATextview.text = versionA.patch.toString() | ||
binding.suffixATextview.text = versionA.suffix | ||
|
||
binding.subversionsBTextview.text = versionB.subversionNumbers.joinToString(separator = ".").ifEmpty { "invalid" } | ||
binding.majorBTextview.text = versionB.major.toString() | ||
binding.minorBTextview.text = versionB.minor.toString() | ||
binding.patchBTextview.text = versionB.patch.toString() | ||
binding.suffixBTextview.text = versionB.suffix | ||
|
||
binding.versionDescriptionLinearlayout.visibility = View.VISIBLE | ||
} | ||
|
||
private fun hideKeyboard() = | ||
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(currentFocus?.windowToken, 0) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
include(":sample", ":versioncompare") | ||
|
||
pluginManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
} | ||
resolutionStrategy { | ||
eachPlugin { | ||
if (requested.id.namespace == "com.android") useModule("com.android.tools.build:gradle:${requested.version}") | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.