Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Mar 22, 2021
2 parents 35af097 + 2977d1e commit f62b83e
Show file tree
Hide file tree
Showing 23 changed files with 316 additions and 288 deletions.
4 changes: 0 additions & 4 deletions .codecov.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/build.yml
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
22 changes: 0 additions & 22 deletions build.gradle

This file was deleted.

43 changes: 43 additions & 0 deletions build.gradle.kts
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)
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
40 changes: 0 additions & 40 deletions sample/build.gradle

This file was deleted.

44 changes: 44 additions & 0 deletions sample/build.gradle.kts
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"))
}
4 changes: 2 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.g00fy2.versioncomparesample">
package="io.github.g00fy2.versioncomparesample">

<application
android:icon="@mipmap/ic_launcher"
android:label="Version Compare"
android:theme="@style/AppTheme">
<activity
android:name="com.g00fy2.versioncomparesample.MainActivity"
android:name="io.github.g00fy2.versioncomparesample.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down

This file was deleted.

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)
}
1 change: 0 additions & 1 deletion settings.gradle

This file was deleted.

13 changes: 13 additions & 0 deletions settings.gradle.kts
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}")
}
}
}
27 changes: 0 additions & 27 deletions versioncompare/build.gradle

This file was deleted.

Loading

0 comments on commit f62b83e

Please sign in to comment.