Skip to content

Commit

Permalink
Setup codestyle (#27)
Browse files Browse the repository at this point in the history
Updates deps and sets up code style
  • Loading branch information
mustafa01ali authored Nov 4, 2017
1 parent c8e34ff commit 30e0095
Show file tree
Hide file tree
Showing 15 changed files with 1,283 additions and 45 deletions.
11 changes: 10 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ jobs:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Check code style
command: ./gradlew ktlint
- run:
name: Compile & Run Tests
command: ./gradlew assemble test
- store_artifacts:
path: app/build/reports
destination: reports
- store_artifacts:
path: app/build/analysis
destination: analysis
- store_artifacts:
path: app/build/outputs/apk
destination: apks
- store_test_results:
path: app/build/test-results
path: app/build/test-results
29 changes: 29 additions & 0 deletions analysis/code-style.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repositories {
mavenCentral()
}

configurations {
ktlint
}

dependencies {
ktlint "com.github.shyiko:ktlint:0.11.1"
// additional 3rd party ruleset(s) can be specified here
// just add them to the classpath (ktlint 'groupId:artifactId:version') and
// ktlint will pick them up
}

task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt", "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/analysis/ktlint.xml"
}
check.dependsOn ktlint

task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}
27 changes: 15 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.oss.licenses.plugin'
apply from: '../analysis/code-style.gradle'

repositories {
mavenCentral()
Expand All @@ -10,12 +11,13 @@ repositories {

android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "xyz.mustafaali.devqstiles"
minSdkVersion 24

// Writing show taps setting fails on higher versions
//noinspection OldTargetApi
targetSdkVersion 22

versionCode 6
Expand All @@ -36,16 +38,17 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.google.android.gms:play-services-oss-licenses:11.4.2'
implementation 'com.jakewharton.timber:timber:4.5.1'

compile "com.android.support:appcompat-v7:$support_lib_version"
compile "com.android.support:recyclerview-v7:$support_lib_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.google.android.gms:play-services-oss-licenses:11.2.2'
compile 'com.jakewharton.timber:timber:4.5.1'
testImplementation 'junit:junit:4.12'

testCompile 'junit:junit:4.12'
}
androidTestImplementation ('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
5 changes: 2 additions & 3 deletions app/src/main/kotlin/xyz/mustafaali/devqstiles/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.mustafaali.devqstiles;
package xyz.mustafaali.devqstiles

import android.content.ActivityNotFoundException
import android.content.Intent
Expand All @@ -14,7 +14,6 @@ import timber.log.Timber
import xyz.mustafaali.devqstiles.model.Feature
import xyz.mustafaali.devqstiles.ui.FeaturesAdapter


class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -59,7 +58,7 @@ class MainActivity : AppCompatActivity() {
intent.data = Uri.parse("market://details?id=xyz.mustafaali.devqstiles")
try {
startActivity(intent)
} catch(e: ActivityNotFoundException) {
} catch (e: ActivityNotFoundException) {
Timber.e("Couldn't launch activity, maybe PlayStore is not installed")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ class ToggleAnimationService : TileService() {
tile.icon = Icon.createWithResource(applicationContext, AnimationScaler.getIcon(scale))
tile.updateTile()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ class ToggleAnimatorDurationService : TileService() {
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ class ToggleKeepScreenOnService : BaseTileService() {
}
return false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ class ToggleUsbDebuggingService : BaseTileService() {
override fun isFeatureEnabled(): Boolean {
return Settings.Global.getString(contentResolver, Settings.Global.ADB_ENABLED) == "1"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ class FeaturesAdapter(val features: List<Feature>, val listener: (Feature) -> Un
override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(features[position], listener)

override fun getItemCount(): Int = features.size

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ object AnimationScaler {
Timber.e(se, message)
false
}

}

fun getAnimationScale(contentResolver: ContentResolver?): Float {
fun getAnimationScale(contentResolver: ContentResolver?): Float {
var scale = 1f
try {
scale = maxOf(
Expand All @@ -56,5 +55,4 @@ object AnimationScaler {

return if (scale >= 1) 1.0f else 0.0f
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ object AnimatorDurationScaler {
Timber.e(se, message)
false
}

}
}
84 changes: 70 additions & 14 deletions app/src/main/res/raw/third_party_license_metadata
Original file line number Diff line number Diff line change
@@ -1,17 +1,73 @@
0:46 appcompat-v7
47:46 recyclerview-v7
94:46 kotlin-stdlib-jre7
141:46 timber
188:46 animated-vector-drawable
235:46 support-vector-drawable
282:46 support-v4
329:46 support-fragment
376:46 support-core-ui
423:46 support-media-compat
470:46 support-core-utils
517:46 support-compat
564:46 support-annotations
611:46 kotlin-stdlib
658:46 runtime
705:46 annotations
799:46 common
141:47 play-services-oss-licenses
189:46 timber
236:46 animated-vector-drawable
283:46 support-vector-drawable
330:47 play-services-basement
378:46 support-v4
425:46 support-fragment
472:46 support-core-ui
519:46 support-media-compat
566:46 support-core-utils
613:46 support-compat
660:46 support-annotations
707:46 kotlin-stdlib
754:19442 ICU4C
20197:11358 safeparcel
31556:1602 JSR 305
33159:3182 PCRE
36342:680 STL
37023:243 tz database
37267:1484 DynamicAnnotations
38752:731 UTF
39484:2500 zlib
41985:11358 CCTZ
53344:1558 RE2
54903:1732 Protobuf Nano
56636:1481 darts_clone
58118:46 runtime
59933:46 annotations
59646:46 common
58306:35 klob
58342:46 ini4j
58389:46 lint-gradle
58436:46 builder
58483:46 lint
58530:46 lint-checks
58577:46 lint-api
58624:46 manifest-merger
58671:46 sdk-common
58718:46 lint-gradle-api
58765:46 gradle-api
58812:46 builder-model
58859:46 lint-kotlin
58906:46 intellij-core
58953:46 uast
59000:46 groovy-all
59047:46 kotlin-reflect
59094:46 sdklib
59141:46 repository
59188:46 kotlin-stdlib-jre8
59235:46 builder-test-api
59282:46 ddmlib
59329:40 bcpkix-jdk15on
59370:40 bcprov-jdk15on
59411:46 tracker
59458:46 shared
59505:46 protos
59552:46 layoutlib-api
59599:46 dvlib
59693:46 apksig
59740:46 javawriter
59787:47 fastutil
59835:50 jopt-simple
59886:46 json-simple
59980:46 gson
60027:121 kxml2
60149:32 lombok-ast
60182:46 kotlin-compiler
60229:48 ecj
60278:46 jsr305
60325:46 j2objc-annotations
Loading

0 comments on commit 30e0095

Please sign in to comment.