Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Tweak the CI setup and build #624

Merged
merged 11 commits into from Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/ci-scripts/install-fossa.sh

This file was deleted.

33 changes: 2 additions & 31 deletions .circleci/config.yml
Expand Up @@ -4,7 +4,7 @@ executors:
android:
working_directory: ~/squanchy
docker:
- image: circleci/android:api-28-alpha
- image: circleci/android:api-28
environment:
ANDROID_HOME: /opt/android/sdk
APPLICATION_ID: net.squanchy.example
Expand All @@ -14,13 +14,6 @@ executors:
ALGOLIA_INDICES_PREFIX: squanchy_dev

commands:
# FOSSA CLI install
install_fossa_cli:
steps:
- run:
name: Install FOSSA CLI
command: workspace/repo/.circleci/ci-scripts/install-fossa.sh

# Build Tools cache commands
restore_build_tools_cache:
steps:
Expand Down Expand Up @@ -142,7 +135,7 @@ jobs:
# See https://issuetracker.google.com/issues/62217354 for the parallelism option
- run:
name: Run static analysis
command: cd workspace/repo && ./gradlew check -Djava.util.concurrent.ForkJoinPool.common.parallelism=2
command: cd workspace/repo && ./gradlew lintRelease detekt ktlintCheck -Djava.util.concurrent.ForkJoinPool.common.parallelism=2

# Collect static analysis reports as build artifacts
- store_artifacts:
Expand All @@ -166,25 +159,6 @@ jobs:
- store_test_results:
path: workspace/repo/app/build/test-results

license_checks:
executor: android
steps:
- restore_workspace
- restore_gradle_cache
- restore_android_build_cache
- restore_build_tools_cache

- install_fossa_cli

- run:
name: Run FOSSA license check
command: fossa --no-ansi
working_directory: workspace/repo
- run:
name: Wait for FOSSA license check to complete
command: fossa test --no-ansi
working_directory: workspace/repo

workflows:
version: 2
build_and_test:
Expand All @@ -199,6 +173,3 @@ workflows:
- tests:
requires:
- prepare_for_checks
- license_checks:
requires:
- prepare_for_checks
22 changes: 0 additions & 22 deletions .fossa.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -28,8 +28,6 @@ If you wish to commit code that is failing this test for whatever reason, you ca
that if you don't address the issues before pushing, the CI will fail the build.


## License [![FOSSA Status](https://app.fossa.io/api/projects/custom%2B6635%2Fgit%40github.com%3Asquanchy-dev%2Fsquanchy-android.git.svg?type=shield)](https://app.fossa.io/projects/custom%2B6635%2Fgit%40github.com%3Asquanchy-dev%2Fsquanchy-android.git?ref=badge_shield)
## License

Squanchy Android is released under Apache 2.0 licence. See the [LICENSE](LICENSE) file.

[![FOSSA Status](https://app.fossa.io/api/projects/custom%2B6635%2Fgit%40github.com%3Asquanchy-dev%2Fsquanchy-android.git.svg?type=large)](https://app.fossa.io/projects/custom%2B6635%2Fgit%40github.com%3Asquanchy-dev%2Fsquanchy-android.git?ref=badge_large)
1 change: 1 addition & 0 deletions app/build.gradle
Expand Up @@ -121,6 +121,7 @@ detekt {
html.enabled = true
}
parallel = true
buildUponDefaultConfig = true
}

ktlint {
Expand Down
Expand Up @@ -39,6 +39,7 @@ internal class NotificationModule {

@Provides
@Named(UPCOMING_EVENT_THRESHOLD)
@Suppress("MagicNumber") // It's not a magic number in this case, this is equivalent to a constant declaration
fun provideUpcomingEventThreshold(): Duration = Duration.ofMinutes(10)

@Provides
Expand Down
Expand Up @@ -7,7 +7,6 @@ import org.threeten.bp.LocalDateTime
import org.threeten.bp.ZoneId
import org.threeten.bp.ZonedDateTime

@Suppress("LongParameterList") // This is just a big model - TODO refactor this to split it up
data class Event(
val id: String,
val numericId: Long,
Expand Down
Expand Up @@ -179,7 +179,7 @@ class FilterChipView @JvmOverloads constructor(
}
}

@Suppress("DEPRECATION", "OverridingDeprecatedMember") // We're just preventing others from messing with this, not really using it
@Suppress("deprecation") // We're just preventing others from messing with this, not really using it
override fun setBackgroundDrawable(background: Drawable?) {
allowOnlyWhileInitializing("Can't interact with a FilterChipView's background directly") {
super.setBackgroundDrawable(background)
Expand Down
34 changes: 15 additions & 19 deletions app/src/main/java/net/squanchy/search/SearchActivity.kt
Expand Up @@ -35,7 +35,6 @@ import net.squanchy.support.view.enableLightNavigationBar
import timber.log.Timber
import java.util.concurrent.TimeUnit

// Might use some refactoring later on to extract some collaborator
class SearchActivity : AppCompatActivity(), SearchRecyclerView.OnSearchResultClickListener {

private val subscriptions = CompositeDisposable()
Expand Down Expand Up @@ -228,28 +227,25 @@ class SearchActivity : AppCompatActivity(), SearchRecyclerView.OnSearchResultCli
override fun onEventClicked(event: Event) {
navigator.toEventDetails(event.id)
}
}

private class SearchTextWatcher(private val querySubject: PublishSubject<String>) : TextWatcher {

override fun beforeTextChanged(query: CharSequence, start: Int, count: Int, after: Int) {
// No-op
}

override fun onTextChanged(query: CharSequence?, start: Int, before: Int, count: Int) {
query?.let { querySubject.onNext(it.toString()) }
}
private class SearchTextWatcher(private val querySubject: PublishSubject<String>) : TextWatcher {

override fun afterTextChanged(query: Editable) {
// No-op
}
override fun beforeTextChanged(query: CharSequence, start: Int, count: Int, after: Int) {
// No-op
}

companion object {
override fun onTextChanged(query: CharSequence?, start: Int, before: Int, count: Int) {
query?.let { querySubject.onNext(it.toString()) }
}

private const val SPEECH_REQUEST_CODE = 100
private const val QUERY_DEBOUNCE_TIMEOUT = 350L
private const val MIN_QUERY_LENGTH = 2
private const val QUERY_KEY = "SearchActivity.query_key"
private const val INITIAL_QUERY = ""
override fun afterTextChanged(query: Editable) {
// No-op
}
}

private const val SPEECH_REQUEST_CODE = 100
private const val QUERY_DEBOUNCE_TIMEOUT = 350L
private const val MIN_QUERY_LENGTH = 2
private const val QUERY_KEY = "SearchActivity.query_key"
private const val INITIAL_QUERY = ""
86 changes: 51 additions & 35 deletions app/src/main/java/net/squanchy/settings/SettingsFragment.kt
Expand Up @@ -68,42 +68,12 @@ class SettingsFragment : PreferenceFragment() {
accountCategory.removePreference(accountEmailPreference)
accountSignInSignOutPreference = findPreference(getString(R.string.account_signin_signout_preference_key))

val aboutPreference = findPreference(getString(R.string.about_preference_key))
aboutPreference.setOnPreferenceClickListener {
navigator.toAboutSquanchy()
true
}

val notificationsPreference = findPreference(getString(R.string.about_to_start_notification_preference_key))
notificationsPreference.setOnPreferenceChangeListener { _, enabled ->
if (enabled as Boolean) {
analytics.trackNotificationsEnabled()
} else {
analytics.trackNotificationsDisabled()
}
true
}

val favoritesInSchedulePreference = findPreference(getString(R.string.favorites_in_schedule_preference_key))
favoritesInSchedulePreference.setOnPreferenceChangeListener { _, enabled ->
if (enabled as Boolean) {
analytics.trackFavoritesInScheduleEnabled()
} else {
analytics.trackFavoritesInScheduleDisabled()
}
true
}
setupAboutPreference()

setupAboutToStartNotificationPreference()
setupFavoritesInSchedulePreference()
setupAnalyticsOptOutPreference(activity)
setupWifiConfigPreference()

val disableAnalyticsPreferences = findPreference(getString(R.string.disable_analytics_key))
disableAnalyticsPreferences.setOnPreferenceChangeListener { _, _ ->
with(settingsFragmentComponent(activity)) {
analytics = analytics()
}
analytics.setupExceptionLogging()
true
}
}

private fun displayBuildVersion() {
Expand All @@ -119,11 +89,57 @@ class SettingsFragment : PreferenceFragment() {
preferenceScreen.removePreference(debugCategory)
}

private fun setupAboutPreference() {
findPreference(getString(R.string.about_preference_key))
.setOnPreferenceClickListener {
navigator.toAboutSquanchy()
true
}
}

private fun setupAboutToStartNotificationPreference() {
findPreference(getString(R.string.about_to_start_notification_preference_key))
.setOnPreferenceChangeListener { _, enabled ->
if (enabled as Boolean) {
analytics.trackNotificationsEnabled()
} else {
analytics.trackNotificationsDisabled()
}
true
}
}

private fun setupFavoritesInSchedulePreference() {
findPreference(getString(R.string.favorites_in_schedule_preference_key))
.setOnPreferenceChangeListener { _, enabled ->
if (enabled as Boolean) {
analytics.trackFavoritesInScheduleEnabled()
} else {
analytics.trackFavoritesInScheduleDisabled()
}
true
}
}

private fun setupAnalyticsOptOutPreference(activity: AppCompatActivity) {
findPreference(getString(R.string.disable_analytics_key))
.setOnPreferenceChangeListener { _, _ ->
with(settingsFragmentComponent(activity)) {
analytics = analytics()
}
analytics.setupExceptionLogging()
true
}
}

private fun setupWifiConfigPreference() {
val wifiPreference = findPreference(getString(R.string.auto_wifi_preference_key))

if (wifiAutoConfigEnabledNow(remoteConfig)) {
wifiPreference.setOnPreferenceClickListener { setupWifi(); true }
wifiPreference.setOnPreferenceClickListener {
setupWifi()
true
}
} else {
val settingsCategory = findPreference(getString(R.string.settings_category_key)) as PreferenceCategory
settingsCategory.removePreference(wifiPreference)
Expand Down
Expand Up @@ -2,7 +2,6 @@ package net.squanchy.speaker.domain.view

import arrow.core.Option

@Suppress("LongParameterList") // This is just a big model - TODO refactor this to split it up
data class Speaker(
val numericId: Long,
val id: String,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/net/squanchy/support/text/Html.kt
Expand Up @@ -11,7 +11,7 @@ internal fun String.parseHtml(): Spanned {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
} else {
@Suppress("DEPRECATION") // This is a "compat" method call, we only use this on pre-N
@Suppress("deprecation") // This is a "compat" method call, we only use this on pre-N
Html.fromHtml(this)
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/net/squanchy/support/view/Hotspot.kt
Expand Up @@ -3,8 +3,7 @@ package net.squanchy.support.view
import android.view.MotionEvent
import android.view.View

@Suppress("DataClassPrivateConstructor")
data class Hotspot private constructor(val x: Float, val y: Float) {
data class Hotspot constructor(val x: Float, val y: Float) {

fun offsetToParent(parent: View) = Hotspot(x + parent.x, y + parent.y)

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/net/squanchy/support/widget/ToolbarHacks.kt
@@ -1,3 +1,5 @@
@file:Suppress("MatchingDeclarationName") // See https://github.com/arturbosch/detekt/issues/1500

package net.squanchy.support.widget

import android.os.Parcel
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/net/squanchy/venue/domain/view/Venue.kt
Expand Up @@ -2,7 +2,6 @@ package net.squanchy.venue.domain.view

import org.threeten.bp.ZoneId

@Suppress("LongParameterList") // This is just a big model - TODO refactor this to split it up
data class Venue(
val name: String,
val address: String,
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -15,7 +15,7 @@ buildscript {

plugins {
id 'com.github.ben-manes.versions' version '0.20.0'
id 'io.gitlab.arturbosch.detekt' version '1.0.0-RC12'
id 'io.gitlab.arturbosch.detekt' version '1.0.0-RC14'
id 'org.jlleitschuh.gradle.ktlint' version '7.0.0'
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down