Skip to content
Snippets Groups Projects
Verified Commit 53567b11 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Replace dependencies with external ones

parent 77214d56
No related branches found
No related tags found
No related merge requests found
Showing
with 59 additions and 410 deletions
......@@ -18,7 +18,7 @@ android {
}
composeOptions {
val androidxComposeVersion: String by project.extra
val androidxComposeVersion: String by project
kotlinCompilerExtensionVersion = androidxComposeVersion
}
......@@ -32,27 +32,27 @@ kapt {
}
dependencies {
val androidxCoreVersion: String by project.extra
val androidxCoreVersion: String by project
implementation("androidx.core", "core-ktx", androidxCoreVersion)
val androidxAppcompatVersion: String by project.extra
val androidxAppcompatVersion: String by project
implementation("androidx.appcompat", "appcompat", androidxAppcompatVersion)
val mdcVersion: String by project.extra
val mdcVersion: String by project
implementation("com.google.android.material", "material", mdcVersion)
val androidxComposeVersion: String by project.extra
val androidxComposeVersion: String by project
implementation("androidx.compose.ui", "ui", androidxComposeVersion)
implementation("androidx.compose.material", "material", androidxComposeVersion)
implementation("androidx.compose.ui", "ui-tooling", androidxComposeVersion)
val androidxLifecycleVersion: String by project.extra
val androidxLifecycleVersion: String by project
implementation("androidx.lifecycle", "lifecycle-runtime-ktx", androidxLifecycleVersion)
val androidxMultidexVersion: String by project.extra
val androidxMultidexVersion: String by project
implementation("androidx.multidex", "multidex", androidxMultidexVersion)
val daggerHiltVersion: String by project.extra
val daggerHiltVersion: String by project
implementation("com.google.dagger", "hilt-android", daggerHiltVersion)
annotationProcessor("com.google.dagger", "hilt-android-compiler", daggerHiltVersion)
testImplementation("com.google.dagger", "hilt-android-testing", daggerHiltVersion)
......@@ -67,7 +67,7 @@ dependencies {
implementation("io.coil-kt", "coil", "1.1.1")
implementation("dev.chrisbanes.accompanist", "accompanist-coil", "0.5.0")
val junit4Version: String by project.extra
val junit4Version: String by project
testImplementation("junit", "junit", junit4Version)
androidTestImplementation("androidx.test.ext", "junit", "1.1.2")
androidTestImplementation("androidx.test.espresso", "espresso-core", "3.3.0")
......
package de.kuschku.quasseldroid
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("de.kuschku.quasseldroid", appContext.packageName)
}
}
......@@ -17,17 +17,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.ci_containers
package info.quasseldroid.app
import java.net.InetSocketAddress
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
fun providedContainer(
envVariable: String,
f: () -> ProvidedContainer
) = when {
!System.getenv(envVariable).isNullOrEmpty() -> {
val (host, port) = System.getenv(envVariable).split(":")
GitlabCiProvidedContainer(InetSocketAddress(host, port.toInt()))
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("info.quasseldroid.app", appContext.packageName)
}
else -> f()
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.kuschku.quasseldroid">
package="info.quasseldroid.app">
<uses-feature
android:name="android.hardware.type.pc"
......@@ -13,7 +13,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="de.kuschku.quasseldroid.QuasseldroidApplication"
android:name="info.quasseldroid.app.QuasseldroidApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
......@@ -22,7 +22,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.Quasseldroid">
<activity
android:name=".MainActivity"
android:name="info.quasseldroid.app.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Quasseldroid.NoActionBar">
<intent-filter>
......
package de.kuschku.quasseldroid
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package info.quasseldroid.app
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
......@@ -20,9 +39,9 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.lifecycleScope
import de.kuschku.quasseldroid.ui.theme.QuasseldroidTheme
import de.kuschku.quasseldroid.ui.theme.shapes
import de.kuschku.quasseldroid.ui.theme.typography
import info.quasseldroid.app.theme.QuasseldroidTheme
import info.quasseldroid.app.theme.shapes
import info.quasseldroid.app.theme.typography
import dev.chrisbanes.accompanist.coil.CoilImage
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
......
......@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.quasseldroid
package info.quasseldroid.app
import androidx.multidex.MultiDexApplication
import dagger.hilt.android.HiltAndroidApp
......
package de.kuschku.quasseldroid.ui.theme
package info.quasseldroid.app.theme
import androidx.compose.ui.graphics.Color
......
package de.kuschku.quasseldroid.ui.theme
package info.quasseldroid.app.theme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes
......
package de.kuschku.quasseldroid.ui.theme
package info.quasseldroid.app.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
......
package de.kuschku.quasseldroid.ui.theme
package info.quasseldroid.app.theme
import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
......
plugins {
kotlin("jvm")
id("jacoco")
id("de.kuschku.coverageconverter")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.getByName<JacocoReport>("jacocoTestReport") {
reports {
sourceDirectories.from(fileTree("src/main/kotlin"))
classDirectories.from(fileTree("build/classes"))
xml.destination = File("$buildDir/reports/jacoco/report.xml")
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
}
dependencies {
implementation(kotlin("stdlib"))
val junit5Version: String by project.extra
testImplementation("org.junit.jupiter", "junit-jupiter-api", junit5Version)
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version)
val hamcrestVersion: String by project.extra
testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion)
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
interface Flag<T> {
val value: T
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
interface Flags<T, U> where U : Flag<T>, U : Enum<U> {
val all: Set<U>
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
inline fun <reified T> Flags<*, T>.none(): EnumSet<T>
where T : Flag<*>, T : Enum<T> = EnumSet.noneOf(T::class.java)
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
inline fun <reified T> Flags<*, T>.of(vararg values: T): EnumSet<T>
where T : Flag<*>, T : Enum<T> = values.toEnumSet()
inline fun <reified T> Flags<*, T>.of(values: Collection<T>): EnumSet<T>
where T : Flag<*>, T : Enum<T> = values.toEnumSet()
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import kotlin.experimental.or
@JvmName("toByteFlag")
fun Set<Flag<Byte>>?.toBits(): Byte = this?.fold(0.toByte()) { acc, el ->
acc or el.value
} ?: 0.toByte()
@JvmName("toUByteFlag")
fun Set<Flag<UByte>>?.toBits(): UByte = this?.fold(0.toUByte()) { acc, el ->
acc or el.value
} ?: 0.toUByte()
@JvmName("toShortFlag")
fun Set<Flag<Short>>?.toBits(): Short = this?.fold(0.toShort()) { acc, el ->
acc or el.value
} ?: 0.toShort()
@JvmName("toUShortFlag")
fun Set<Flag<UShort>>?.toBits(): UShort = this?.fold(0.toUShort()) { acc, el ->
acc or el.value
} ?: 0.toUShort()
@JvmName("toIntFlag")
fun Set<Flag<Int>>?.toBits(): Int = this?.fold(0) { acc, el ->
acc or el.value
} ?: 0
@JvmName("toUIntFlag")
fun Set<Flag<UInt>>?.toBits(): UInt = this?.fold(0.toUInt()) { acc, el ->
acc or el.value
} ?: 0u
@JvmName("toLongFlag")
fun Set<Flag<Long>>?.toBits(): Long = this?.fold(0.toLong()) { acc, el ->
acc or el.value
} ?: 0L
@JvmName("toULongFlag")
fun Set<Flag<ULong>>?.toBits(): ULong = this?.fold(0.toULong()) { acc, el ->
acc or el.value
} ?: 0uL
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
inline fun <reified T : Enum<T>> Array<out T>.toEnumSet() =
EnumSet.noneOf(T::class.java).apply {
addAll(this@toEnumSet)
}
inline fun <reified T : Enum<T>> Collection<T>.toEnumSet() =
EnumSet.noneOf(T::class.java).apply {
addAll(this@toEnumSet)
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
import kotlin.experimental.and
inline fun <reified T> Flags<Byte, T>.of(value: Byte?): EnumSet<T> where T : Flag<Byte>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0.toByte() }.toEnumSet()
}
inline fun <reified T> Flags<UByte, T>.of(value: UByte?): EnumSet<T> where T : Flag<UByte>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0.toUByte() }.toEnumSet()
}
inline fun <reified T> Flags<Short, T>.of(value: Short?): EnumSet<T> where T : Flag<Short>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0.toShort() }.toEnumSet()
}
inline fun <reified T> Flags<UShort, T>.of(value: UShort?): EnumSet<T> where T : Flag<UShort>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0.toUShort() }.toEnumSet()
}
inline fun <reified T> Flags<Int, T>.of(value: Int?): EnumSet<T> where T : Flag<Int>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0 }.toEnumSet()
}
inline fun <reified T> Flags<UInt, T>.of(value: UInt?): EnumSet<T> where T : Flag<UInt>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0u }.toEnumSet()
}
inline fun <reified T> Flags<Long, T>.of(value: Long?): EnumSet<T> where T : Flag<Long>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0L }.toEnumSet()
}
inline fun <reified T> Flags<ULong, T>.of(value: ULong?): EnumSet<T> where T : Flag<ULong>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet()
return all.filter { (value and it.value) != 0uL }.toEnumSet()
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
@JvmName("validValuesUByte")
inline fun <reified T> Flags<UByte, T>.validValues(): EnumSet<T>
where T : Flag<UByte>, T : Enum<T> =
all.filter { it.value != 0.toUByte() }.toEnumSet()
@JvmName("validValuesByte")
inline fun <reified T> Flags<Byte, T>.validValues(): EnumSet<T>
where T : Flag<Byte>, T : Enum<T> =
all.filter { it.value != 0.toByte() }.toEnumSet()
@JvmName("validValuesUShort")
inline fun <reified T> Flags<UShort, T>.validValues(): EnumSet<T>
where T : Flag<UShort>, T : Enum<T> =
all.filter { it.value != 0.toUShort() }.toEnumSet()
@JvmName("validValuesShort")
inline fun <reified T> Flags<Short, T>.validValues(): EnumSet<T>
where T : Flag<Short>, T : Enum<T> =
all.filter { it.value != 0.toShort() }.toEnumSet()
@JvmName("validValuesUInt")
inline fun <reified T> Flags<UInt, T>.validValues(): EnumSet<T>
where T : Flag<UInt>, T : Enum<T> =
all.filter { it.value != 0u }.toEnumSet()
@JvmName("validValuesInt")
inline fun <reified T> Flags<Int, T>.validValues(): EnumSet<T>
where T : Flag<Int>, T : Enum<T> =
all.filter { it.value != 0 }.toEnumSet()
@JvmName("validValuesULong")
inline fun <reified T> Flags<ULong, T>.validValues(): EnumSet<T>
where T : Flag<ULong>, T : Enum<T> =
all.filter { it.value != 0uL }.toEnumSet()
@JvmName("validValuesLong")
inline fun <reified T> Flags<Long, T>.validValues(): EnumSet<T>
where T : Flag<Long>, T : Enum<T> =
all.filter { it.value != 0L }.toEnumSet()
......@@ -16,9 +16,3 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
buildscript {
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21'
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment