Skip to content

Commit

Permalink
Merge branch 'develop' into develop-translations
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/res/values-de/strings.xml
  • Loading branch information
SapuSeven committed Nov 15, 2023
2 parents bdcba16 + c536a1f commit 935d55e
Show file tree
Hide file tree
Showing 29 changed files with 760 additions and 155 deletions.
21 changes: 10 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: 2.1
orbs:
gh: circleci/[email protected]
jq: circleci/[email protected]
android: circleci/[email protected]
filters: &release
branches:
ignore: /.*/
Expand All @@ -10,20 +11,16 @@ filters: &release
jobs:
build:
working_directory: ~/betteruntis
docker:
- image: cimg/android:2023.06.1
resource_class: large
executor:
name: android/android-machine
resource-class: large
tag: 2023.10.1
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- android/restore-gradle-cache
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Prepare signing config
command: |
Expand All @@ -34,14 +31,15 @@ jobs:
echo 'export KEY_RELEASE_PASSWORD=$(echo "$KEY_RELEASE_PASSWORD_ENCODED" | base64 --decode)' >> $BASH_ENV
- run:
name: Initial build
command: ./gradlew --no-daemon assemble bundle
command: ./gradlew --no-configuration-cache --no-daemon assemble bundle
environment:
GRADLE_OPTS: '
-Dorg.gradle.daemon=false
-Dorg.gradle.parallel=true
-Dorg.gradle.workers.max=3
-Dkotlin.incremental=false
'
- android/save-gradle-cache
- store_artifacts:
name: Upload build artifacts
path: app/build/outputs
Expand Down Expand Up @@ -163,6 +161,7 @@ jobs:
git config user.name "CircleCI"
git checkout -B release
git reset --hard HEAD~1
git merge $CIRCLE_TAG
versionCode=$(jq '.elements[0].versionCode' ./workspace/outputs/apk/gms/release/output-metadata.json)
Expand All @@ -171,7 +170,7 @@ jobs:
git add ./app/build.gradle
git commit -m "[skip ci] Update F-Droid release"
git tag fdroid-$CIRCLE_TAG
git push --set-upstream origin release
git push --force --set-upstream origin release
git push origin fdroid-$CIRCLE_TAG
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ dependencies {
implementation "androidx.compose.animation:animation:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.compose.material3:material3:1.1.0-alpha06'
implementation 'androidx.compose.material3:material3:1.1.2'
implementation 'androidx.glance:glance-appwidget:1.0.0-alpha05'
implementation 'androidx.navigation:navigation-compose:2.5.0'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ class LoginActivity : BaseComposeActivity() {

if (items.isNotEmpty()) LazyColumn(modifier) {
items(items) {
ListItem(headlineText = { Text(it.displayName) },
supportingText = { Text(it.address) },
ListItem(
headlineContent = { Text(it.displayName) },
supportingContent = { Text(it.address) },
modifier = Modifier.clickable {
val builder = Uri.Builder()
.appendQueryParameter("schoolInfo", getJSON().encodeToString(it))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.intPreferencesKey
import com.sapuseven.untis.BuildConfig
import com.sapuseven.untis.R
import com.sapuseven.untis.activities.SettingsActivity.Companion.EXTRA_STRING_PREFERENCE_HIGHLIGHT
import com.sapuseven.untis.activities.SettingsActivity.Companion.EXTRA_STRING_PREFERENCE_ROUTE
Expand Down Expand Up @@ -540,6 +541,9 @@ fun BaseComposeActivity.MainApp(state: MainAppState) {
}
},
actions = {
if (BuildConfig.DEBUG)
DebugDesclaimerAction()

ProfileSelectorAction(
users = state.userDatabase.userDao().getAll(),
currentSelectionId = state.user.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fun RoomFinderListEmpty(modifier: Modifier = Modifier) {
fun RoomFinderHourSelector(state: RoomFinderState) {
state.currentUnit?.let { unit ->
ListItem(
headlineText = {
headlineContent = {
Text(
text = stringResource(
id = R.string.roomfinder_current_hour,
Expand All @@ -256,7 +256,7 @@ fun RoomFinderHourSelector(state: RoomFinderState) {
modifier = Modifier.fillMaxWidth()
)
},
supportingText = {
supportingContent = {
Text(
text = stringResource(
id = R.string.roomfinder_current_hour_time,
Expand Down Expand Up @@ -312,8 +312,8 @@ fun RoomListItem(

// TODO: Show "Free for the rest of the day/week" (if applicable)
ListItem(
headlineText = { Text(item.name) },
supportingText = {
headlineContent = { Text(item.name) },
supportingContent = {
Text(
when {
isOccupied -> stringResource(R.string.roomfinder_item_desc_occupied)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ class SettingsActivity : BaseComposeActivity() {
}
} else {
ListItem(
headlineText = {
headlineContent = {
Text(loadingText)
},
leadingContent = {
Expand Down Expand Up @@ -1183,10 +1183,10 @@ class SettingsActivity : BaseComposeActivity() {
) {
ListItem(
modifier = Modifier.clickable(onClick = onClick),
headlineText = {
headlineContent = {
Text(githubUser.login)
},
supportingText = {
supportingContent = {
Text(
pluralStringResource(
id = R.plurals.preferences_contributors_contributions,
Expand Down
50 changes: 49 additions & 1 deletion app/src/main/java/com/sapuseven/untis/helpers/TextUtils.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
package com.sapuseven.untis.helpers

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.substring
import androidx.compose.ui.text.withStyle

object TextUtils {
fun isNullOrEmpty(obj: Any?): Boolean {
return obj?.toString()?.length ?: 0 == 0
}
}

@Composable
fun annotateUrls(
text: String,
urlColor: Color = MaterialTheme.colorScheme.primary
): AnnotatedString = buildAnnotatedString {
val urlRegex = """(?:https?:\/\/|www\.)[\w-@:%_+.~#?&/=]+""".toRegex()

var startIndex = 0
while (startIndex < text.length) {
// find the next match
val match = urlRegex.find(text, startIndex)

if (match == null) {
// no more matches - append remaining text and return
append(text.substring(startIndex))
return@buildAnnotatedString
}

if (match.range.start > startIndex) {
// matching url found with preceding text - append text first
append(text.substring(startIndex, match.range.start))
}

// append matched url
appendUrl(match.value, urlColor)

// set new start index to the end of the matched url
startIndex = match.range.endInclusive + 1
}
}

private fun AnnotatedString.Builder.appendUrl(url: String, color: Color) {
pushStringAnnotation("url", url)
withStyle(style = SpanStyle(color = color)) {
append(url)
}
pop()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import org.joda.time.LocalDateTime

@Serializable
@Serializable(UntisDateTime.Companion::class)
class UntisDateTime(
val dateTime: String
) {
@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = UntisDateTime::class)
companion object : KSerializer<UntisDateTime> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("UntisDateTime", PrimitiveKind.STRING)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun PreferenceScreen(
navController: NavController
) {
ListItem(
headlineText = title,
headlineContent = title,
leadingContent = icon,
modifier = Modifier.clickable {
navController.navigate(key)
Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/com/sapuseven/untis/ui/activities/InfoCenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ private fun MessageItem(
val textColor = MaterialTheme.colorScheme.onSurfaceVariant

ListItem(
headlineText = { Text(item.subject) },
supportingText = {
headlineContent = { Text(item.subject) },
supportingContent = {
AndroidView(
factory = { context ->
TextView(context).apply {
Expand Down Expand Up @@ -315,15 +315,15 @@ private fun EventItem(item: EventListItem) {
TimetableDatabaseInterface.Type.SUBJECT
)
ListItem(
overlineText = {
overlineContent = {
Text(
formatExamTime(
item.exam.startDateTime.toLocalDateTime(),
item.exam.endDateTime.toLocalDateTime()
)
)
},
headlineText = {
headlineContent = {
Text(
if (!item.exam.name.contains(subject)) stringResource(
R.string.infocenter_events_exam_name_long,
Expand All @@ -337,20 +337,20 @@ private fun EventItem(item: EventListItem) {

if (item.homework != null) {
ListItem(
overlineText = {
overlineContent = {
Text(
item.homework.endDate.toLocalDate().toString(DateTimeFormat.mediumDate())
)
},
headlineText = {
headlineContent = {
Text(
item.timetableDatabaseInterface.getLongName(
item.lessonsById?.get(item.homework.lessonId.toString())?.subjectId
?: 0, TimetableDatabaseInterface.Type.SUBJECT
)
)
},
supportingText = if (item.homework.text.isNotBlank()) {
supportingContent = if (item.homework.text.isNotBlank()) {
{ Text(item.homework.text) }
} else null
)
Expand All @@ -367,16 +367,16 @@ private fun OfficeHourItem(item: UntisOfficeHour) {
).filter { it?.isNotEmpty() == true }.joinToString("\n")

ListItem(
overlineText = {
overlineContent = {
Text(
formatOfficeHourTime(
item.startDateTime.toLocalDateTime(),
item.endDateTime.toLocalDateTime()
)
)
},
headlineText = { Text(item.displayNameTeacher) },
supportingText = if (body.isNotBlank()) {
headlineContent = { Text(item.displayNameTeacher) },
supportingContent = if (body.isNotBlank()) {
{ Text(body) }
} else null
)
Expand All @@ -386,15 +386,15 @@ private fun OfficeHourItem(item: UntisOfficeHour) {
@Composable
private fun AbsenceItem(item: UntisAbsence) {
ListItem(
overlineText = {
overlineContent = {
Text(
formatAbsenceTime(
item.startDateTime.toLocalDateTime(),
item.endDateTime.toLocalDateTime()
)
)
},
headlineText = {
headlineContent = {
Text(
if (item.absenceReason.isNotEmpty())
item.absenceReason.substring(0, 1)
Expand All @@ -403,7 +403,7 @@ private fun AbsenceItem(item: UntisAbsence) {
stringResource(R.string.infocenter_absence_unknown_reason)
)
},
supportingText = if (item.text.isNotBlank()) {
supportingContent = if (item.text.isNotBlank()) {
{ Text(item.text) }
} else null,
leadingContent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun ColorPicker(
onValueChange = { newColor ->
if (newColor.matches(Regex("^#[0-9a-fA-F]{0,8}$"))) {
colorHex = newColor
newColor.toUIntOrNull(16)?.let {
newColor.replace("#", "").toUIntOrNull(16)?.let {
onColorChanged(HsvColor.from(Color(it.toInt())), false)
}
}
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/com/sapuseven/untis/ui/common/ActionButtons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material.icons.outlined.Edit
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material3.Divider
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
Expand Down
Loading

0 comments on commit 935d55e

Please sign in to comment.