Compare commits

..
35 Commits
Author SHA1 Message Date
robin 107f1c3955 Merge pull request 'chore: fix workflow 2' (#26) from chore/smaller-apk into main
Reviewed-on: Schanbro/WeekFocus#26
2026-10-07 13:57:30 +00:00
robin ce1eba6b83 Merge branch 'main' into chore/smaller-apk 2026-10-07 13:57:20 +00:00
robin 4b8e2bc88d chore: fix workflow 2026-10-07 15:56:01 +02:00
robin c71851702f Merge pull request 'chore: fix workflow' (#25) from chore/smaller-apk into main
Reviewed-on: Schanbro/WeekFocus#25
2026-10-07 13:44:27 +00:00
robin 4c04a5260c Merge branch 'main' into chore/smaller-apk 2026-10-07 13:44:17 +00:00
robin 90e477cb04 chore: fix workflow 2026-10-07 15:43:51 +02:00
robin 82d4fa331b Merge pull request 'chore: apk-splits' (#24) from chore/smaller-apk into main
Reviewed-on: Schanbro/WeekFocus#24
2026-10-07 13:27:42 +00:00
robin 6206a47fc7 chore: apk-splits
chore: adjust workflow in Gitea
chore(deps): update versions
2026-10-07 15:19:22 +02:00
robin ff78c71ab5 Merge pull request 'chore: automaticly mark as prerelease if necessary' (#19) from chore into main
Reviewed-on: Schanbro/WeekFocus#19
2026-10-06 15:19:59 +00:00
robin c6d6ac359b chore: automaticly mark as prerelease if necessary 2026-10-06 15:19:44 +00:00
robin 8cacb6f582 Merge pull request 'chore(l10n): update translations' (#17) from weblate-translations into main
Reviewed-on: Schanbro/WeekFocus#17
2026-10-04 15:32:04 +00:00
robin 86882fafcb chore(l10n): update German (formal) translation
chore(l10n): update English translation

Co-authored-by: Weblate Admin <robin@schanbros.de>
Language: English
Language: German (formal)
Progress: 100.0% (7 of 7 strings)
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/de@formal/
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/en/
Translation: WeekFocus/WeekFocus
2026-10-04 15:31:23 +00:00
robin edb11b360b CHANGELOG update 2026-10-04 17:22:47 +02:00
robin 18c375979c Merge pull request 'feat: better layout' (#16) from feat/better-layout into main
Reviewed-on: Schanbro/WeekFocus#16
2026-10-04 15:18:58 +00:00
robin 2545498dc2 feat: navigation
feat: remove word
2026-10-04 17:17:23 +02:00
robin fd20b5d91e chore: debug/dev builds besides normal builds 2026-10-04 15:53:24 +02:00
robin 76cf592cd1 Merge pull request 'chore(l10n): update translations' (#14) from weblate-translations into main
Reviewed-on: Schanbro/WeekFocus#14
2026-10-04 12:58:52 +00:00
robin d134b0cd0a chore(l10n): update English translation
chore(l10n): update German (formal) translation

Co-authored-by: Weblate Admin <robin@schanbros.de>
Language: English
Language: German (formal)
Progress: 100.0% (7 of 7 strings)
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/de@formal/
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/en/
Translation: WeekFocus/WeekFocus
2026-10-04 12:54:11 +00:00
robin 4a62373992 refactor: move hardcoded texts to strings.xml 2026-10-04 14:19:38 +02:00
robin e589693c67 README.md aktualisiert 2026-10-04 10:19:26 +00:00
robin f5568cf211 README.md aktualisiert 2026-10-03 17:45:08 +00:00
robin 2ab1b230d8 CHANGELOG update 2026-10-03 19:19:54 +02:00
robin ce4a40c4f3 chore: refactor: switch from release github action 2026-10-03 19:19:22 +02:00
robin a8375c4025 README.md aktualisiert
add and reorder badges
2026-10-03 16:53:38 +00:00
robin 0d3577aa2f CHANGELOG update 2026-10-03 17:35:06 +02:00
robin 33277b25e5 Merge pull request 'chore(l10n): update translations' (#12) from weblate-translations into main
Reviewed-on: Schanbro/WeekFocus#12
2026-10-03 15:32:18 +00:00
robin e2dff7cdf6 chore(l10n): update English translation
Co-authored-by: Weblate Admin <robin@schanbros.de>
Language: English
Progress: 100.0% (5 of 5 strings)
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/en/
Translation: WeekFocus/WeekFocus
2026-10-03 15:31:55 +00:00
robin 2ea4c2dbad refactor: move hardcoded strings to strings.xml 2026-10-03 17:29:08 +02:00
robin f05184a712 Important message: heavy development 2026-10-03 15:22:43 +00:00
robin e415b49232 Added Weblate/Translation information 2026-10-03 15:20:51 +00:00
robin 642bb0c3bd Merge pull request 'chore(l10n): update translations' (#11) from weblate-translations into main
Reviewed-on: Schanbro/WeekFocus#11
2026-10-03 15:10:19 +00:00
robin bdc9208b8b chore(l10n): update English translation
Translation: WeekFocus/WeekFocus
Language: English
Progress: 100.0% (2 of 2 strings)
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/en/
2026-10-03 15:09:30 +00:00
robin 2d88c0464b chore(l10n): update German (formal) translation
Translation: WeekFocus/WeekFocus
Language: German (formal)
Progress: 100.0% (2 of 2 strings)
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/de@formal/
2026-10-03 15:09:30 +00:00
robin d9bb781135 chore(l10n): add English translation
Translation: WeekFocus/WeekFocus
Language: English
Translate-URL: https://weblate.schamagusa.de/projects/weekfocus/weekfocus/en/
2026-10-03 15:03:18 +00:00
robin c373c523a5 refactor: move hardcoded texts to strings.xml 2026-10-03 17:02:17 +02:00
13 changed files with 465 additions and 148 deletions

No files matched your search

+71 -28
View File
@@ -1,4 +1,3 @@
# .gitea/workflows/build-release.yml
name: Build & Release Android App
on:
@@ -19,6 +18,7 @@ jobs:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Code auschecken
uses: actions/checkout@v4
@@ -46,14 +46,12 @@ jobs:
rm /tmp/tools.zip
fi
# Lizenzen korrekt akzeptieren (kein "yes |", wegen pipefail/SIGPIPE)
"$SDKMANAGER" --sdk_root="$SDK_PATH" --licenses < <(yes) > /dev/null
# Benötigte Pakete direkt installieren
"$SDKMANAGER" --sdk_root="$SDK_PATH" \
"platform-tools" \
"platforms;android-37.0" \
"build-tools;36.0.0"
"platforms;android-35" \
"build-tools;35.0.0"
echo "ANDROID_HOME=$SDK_PATH" >> $GITHUB_ENV
echo "ANDROID_SDK_ROOT=$SDK_PATH" >> $GITHUB_ENV
@@ -66,38 +64,47 @@ jobs:
echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore"
echo "KEYSTORE_PATH=$RUNNER_TEMP/release.keystore" >> $GITHUB_ENV
- name: Android Release APK bauen
- name: Android Release APKs bauen
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
echo "Baue Version: $VERSION"
./gradlew assembleRelease \
--no-daemon \
-Dorg.gradle.java.home="$JAVA_HOME" \
-PversionNameOverride="$VERSION"
echo "Erzeugte APK-Dateien:"
find app/build/outputs -type f -name "*.apk" -print
APK_DIR="app/build/outputs/apk/release"
APK_SOURCE="$(find app/build/outputs/apk/release -maxdepth 1 -type f -name "*.apk" ! -name "*unsigned*" | head -n 1)"
echo "Gefundene Original-APKs in $APK_DIR:"
ls -lh "$APK_DIR"
if [ -z "$APK_SOURCE" ]; then
echo "Keine Release-APK gefunden."
exit 1
for APK in "$APK_DIR"/*.apk; do
[ -e "$APK" ] || continue
if [[ "$APK" == *"unsigned"* || "$APK" == *"WeekFocus-"* ]]; then
continue
fi
APK_DIR="app/build/outputs/apk/release"
APK_NAME="WeekFocus-${VERSION}.apk"
APK_TARGET="$APK_DIR/$APK_NAME"
FILENAME=$(basename "$APK")
VARIANT=$(echo "$FILENAME" | sed -E 's/^app-(.*)-release\.apk$/\1/')
if [ "$VARIANT" = "$FILENAME" ]; then
VARIANT="release"
fi
mv "$APK_SOURCE" "$APK_TARGET"
TARGET_NAME="WeekFocus-${VERSION}-${VARIANT}.apk"
TARGET_PATH="$APK_DIR/$TARGET_NAME"
"$ANDROID_HOME/build-tools/36.0.0/apksigner" verify --verbose "$APK_TARGET"
mv "$APK" "$TARGET_PATH"
echo "APK erstellt: $APK_TARGET"
ls -lh "$APK_DIR"
echo "Signatur prüfen für $TARGET_NAME..."
"$ANDROID_HOME/build-tools/35.0.0/apksigner" verify --verbose "$TARGET_PATH"
done
echo "Finale Release-APKs:"
ls -lh "$APK_DIR"/WeekFocus-*.apk
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
@@ -134,12 +141,48 @@ jobs:
echo "Release-Notes:"
cat "$NOTES_FILE"
- name: Release in Gitea erstellen
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: ${{ runner.temp }}/release_notes.md
files: app/build/outputs/apk/release/WeekFocus-*.apk
- name: Release in Gitea erstellen und APKs hochladen
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
run: |
set -euo pipefail
TAG="$GITHUB_REF_NAME"
VERSION="${TAG#v}"
NOTES_FILE="$RUNNER_TEMP/release_notes.md"
AUTH="Authorization: token $TOKEN"
CODE=$(curl -sS -o release.json -w '%{http_code}' -H "$AUTH" "$API/releases/tags/$TAG")
if [ "$CODE" = "404" ]; then
if [[ "$VERSION" =~ (alpha|beta|rc|dev) ]]; then
IS_PRERELEASE="true"
else
IS_PRERELEASE="false"
fi
jq -n --arg tag "$TAG" --arg name "$TAG" --rawfile body "$NOTES_FILE" \
--argjson prerelease "$IS_PRERELEASE" \
'{tag_name:$tag, name:$name, body:$body, prerelease:$prerelease}' > payload.json
curl -fsS -X POST -H "$AUTH" -H "Content-Type: application/json" \
-d @payload.json "$API/releases" -o release.json
elif [ "$CODE" != "200" ]; then
echo "Release konnte nicht abgefragt werden (HTTP $CODE)"
cat release.json
exit 1
fi
RELEASE_ID=$(jq -r .id release.json)
for APK in app/build/outputs/apk/release/WeekFocus-*.apk; do
[ -e "$APK" ] || continue
NAME=$(basename "$APK")
echo "Lade Hoch: $NAME"
for ID in $(jq -r --arg n "$NAME" '.assets[]? | select(.name==$n) | .id' release.json); do
curl -fsS -X DELETE -H "$AUTH" "$API/releases/$RELEASE_ID/assets/$ID"
done
curl -fsS -X POST -H "$AUTH" -F "attachment=@$APK" \
"$API/releases/$RELEASE_ID/assets?name=$NAME"
done
+14 -1
View File
@@ -1,6 +1,19 @@
# Changelog
## [1.1.0] - 2026-10-03
## [1.2.0] - 2026-10-04
### New
* navigation
* ability to delete words
* better layout
## [1.1.3] - 2026-10-03
### Changed
- chore: refactor: switch from release github action to bash
## [1.1.1] - 2026-10-03
### Changed
- refactor: move hardcoded text to strings.xml
## [1.1.0] - 2026-10-03
### New
- chore: auto-generate apk files #6
+55 -16
View File
@@ -1,3 +1,6 @@
> [!IMPORTANT]
> This app is under heavy development currently.
<div align="center">
# WeekFocus
@@ -8,9 +11,19 @@
<img src="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="64">
</a>
![Platform](https://img.shields.io/badge/Platform-Android-3DDC84?logo=android&logoColor=white)
[![Release](https://img.shields.io/gitea/v/release/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&label=Release)](https://git.schamagusa.de/Schanbro/WeekFocus/releases)
[![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue)](LICENSE)
[![Release](https://img.shields.io/gitea/v/release/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&style=for-the-badge&label=Release)](https://git.schamagusa.de/Schanbro/WeekFocus/releases)
[![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue?style=for-the-badge)](LICENSE)
<!--[![Translation status](https://weblate.schamagusa.de/widgets/weekfocus/-/svg-badge.svg)](https://weblate.schamagusa.de/engage/weekfocus/)-->
![Android](https://img.shields.io/badge/Android-10%2B-3DDC84?style=for-the-badge&logo=android&logoColor=white)
![Language: Kotlin](https://img.shields.io/badge/Language-Kotlin-7F52FF?style=for-the-badge&logo=kotlin&logoColor=white)
![UI: Jetpack Compose](https://img.shields.io/badge/UI-Jetpack%20Compose-4285F4?style=for-the-badge&logo=jetpackcompose&logoColor=white)
![Design: Material 3](https://img.shields.io/badge/Design-Material%203-3DDC84?style=for-the-badge)
<!--[![Stars](https://img.shields.io/gitea/stars/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&style=for-the-badge)](https://git.schamagusa.de/Schanbro/WeekFocus)
[![Forks](https://img.shields.io/gitea/forks/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&style=for-the-badge)](https://git.schamagusa.de/Schanbro/WeekFocus)-->
[![Open Issues](https://img.shields.io/gitea/issues/open/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&style=for-the-badge)](https://git.schamagusa.de/Schanbro/WeekFocus/issues)
[![Last Commit](https://img.shields.io/gitea/last-commit/Schanbro/WeekFocus?gitea_url=https://git.schamagusa.de&style=for-the-badge)](https://git.schamagusa.de/Schanbro/WeekFocus)
</div>
@@ -21,11 +34,12 @@
- [About](#about)
- [How It Works](#how-it-works)
- [Features](#features)
- [Screenshots](#screenshots)
- [Installation](#installation)
- [Building from Source](#building-from-source)
- [Releases](#releases)
- [Contributing](#contributing)
- [License](#license)
- [Translations](#translations)
## About
@@ -50,16 +64,6 @@ No streaks, no pressure, no clutter. Just a gentle daily reminder of what you wa
- 🔒 No ads, no tracking, no unnecessary permissions
- ⚡ Lightweight and battery-friendly
## Screenshots
<!-- Add screenshots here, for example:
<p align="center">
<img src="docs/screenshots/1.png" width="24%" />
<img src="docs/screenshots/2.png" width="24%" />
<img src="docs/screenshots/3.png" width="24%" />
</p>
-->
## Installation
### Recommended: Obtainium
@@ -67,8 +71,7 @@ No streaks, no pressure, no clutter. Just a gentle daily reminder of what you wa
With [Obtainium](https://github.com/ImranR98/Obtainium) you get updates directly from this repository, no app store required.
1. Install Obtainium on your Android device.
2. Tap the badge above or open this link:
[Add WeekFocus to Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.schamagusa.de/Schanbro/WeekFocus)
2. Tap the badge above.
3. Confirm and install the app.
Alternatively, tap **Add App** in Obtainium and paste this URL:
@@ -89,6 +92,7 @@ https://git.schamagusa.de/Schanbro/WeekFocus
- [Android Studio](https://developer.android.com/studio) (latest stable)
- JDK 17 or newer
- Android SDK platform 37 (`minSdk` 29, `targetSdk` 37)
**Steps**
@@ -100,6 +104,34 @@ cd WeekFocus
The resulting APK is located in `app/build/outputs/apk/debug/`.
## Releases
Releases are built automatically with Gitea Actions. Pushing a tag that starts with `v` triggers the workflow, which builds and signs the APK and publishes it as a release together with the notes from `CHANGELOG.md`.
### Starting a release build
Create a tag and push it. The tag name determines the app version (`v1.1.3` builds version `1.1.3`):
```bash
git tag v1.1.3
git push origin v1.1.3
```
You can follow the build under **Actions** in the repository. When it finishes, the signed `WeekFocus-1.1.3.apk` appears on the [Releases](https://git.schamagusa.de/Schanbro/WeekFocus/releases) page.
### Release notes
The workflow takes the notes from the section of `CHANGELOG.md` whose heading starts with the version number:
```markdown
## 1.1.3
- Added Weblate translations
- Fixed widget update at the start of a new week
```
If no matching section exists, the release gets a short placeholder text instead.
## Contributing
Contributions are welcome!
@@ -117,3 +149,10 @@ Found a bug or have an idea? Please open an [issue](https://git.schamagusa.de/Sc
This project is licensed under the [GNU General Public License v3.0](LICENSE) (GPL-3.0).
You are free to use, modify and redistribute this software under the terms of the GPLv3. Derivative works must be released under the same license.
## Translations
WeekFocus is translated via [Weblate](https://weblate.schamagusa.de/engage/weekfocus/).
Help translate the app into your language!
[![Translation status](https://weblate.schamagusa.de/widgets/weekfocus/-/multi-auto.svg)](https://weblate.schamagusa.de/engage/weekfocus/)
+16 -5
View File
@@ -5,7 +5,6 @@ plugins {
val tagVersion = (project.findProperty("versionNameOverride") as String?) ?: "0.0.0-dev"
// "1.2.3" oder "1.2.3-alpha9" -> Kern "1.2.3" für den versionCode
val core = tagVersion
.removePrefix("v")
.substringBefore("-")
@@ -16,20 +15,27 @@ val patch = parts.getOrElse(2) { 0 }
android {
namespace = "de.schanbro.weekfocus"
compileSdk {
version = release(37)
}
compileSdk = 37
defaultConfig {
applicationId = "de.schanbro.weekfocus"
minSdk = 29
targetSdk = 37
versionCode = major * 10000 + minor * 100 + patch
versionCode = (major * 10000 + minor * 100 + patch).coerceAtLeast(1)
versionName = tagVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
splits {
abi {
isEnable = true
reset()
include("arm64-v8a", "armeabi-v7a", "x86", "x86_64")
isUniversalApk = true
}
}
signingConfigs {
create("release") {
val ksPath = System.getenv("KEYSTORE_PATH")
@@ -43,6 +49,10 @@ android {
}
buildTypes {
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-dev"
}
release {
signingConfig = signingConfigs.getByName("release")
optimization {
@@ -75,4 +85,5 @@ dependencies {
androidTestImplementation(libs.androidx.junit)
debugImplementation(libs.androidx.compose.ui.test.manifest)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.material.icons.extended)
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">WeekFocus-dev</string>
</resources>
@@ -1,121 +1,138 @@
package de.schanbro.weekfocus
import android.appwidget.AppWidgetManager
import android.content.ComponentName
import android.content.Context
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.List
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.List
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import android.appwidget.AppWidgetManager
import android.content.ComponentName
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
import de.schanbro.weekfocus.screens.WordListScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
WeekFocusTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
WordListScreen(
modifier = Modifier.padding(innerPadding)
MainScreen()
}
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScreen() {
var selectedTab by remember { mutableIntStateOf(0) }
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
Scaffold(
modifier = Modifier
.fillMaxSize()
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
LargeTopAppBar(
title = {
Text(
when (selectedTab) {
0 -> stringResource(R.string.title_home)
1 -> stringResource(R.string.title_words)
2 -> stringResource(R.string.title_settings)
else -> stringResource(R.string.app_name)
}
)
},
scrollBehavior = scrollBehavior,
colors = TopAppBarDefaults.largeTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surface,
scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainer
)
)
},
bottomBar = {
NavigationBar {
NavigationBarItem(
selected = selectedTab == 0,
onClick = { selectedTab = 0 },
icon = {
Icon(
imageVector = if (selectedTab == 0) Icons.Filled.Home else Icons.Outlined.Home,
contentDescription = stringResource(R.string.title_home)
)
},
label = { Text(stringResource(R.string.title_home)) }
)
NavigationBarItem(
selected = selectedTab == 1,
onClick = { selectedTab = 1 },
icon = {
Icon(
imageVector = if (selectedTab == 1) Icons.Filled.List else Icons.Outlined.List,
contentDescription = stringResource(R.string.title_words)
)
},
label = { Text(stringResource(R.string.title_words)) }
)
NavigationBarItem(
selected = selectedTab == 2,
onClick = { selectedTab = 2 },
icon = {
Icon(
imageVector = if (selectedTab == 2) Icons.Filled.Settings else Icons.Outlined.Settings,
contentDescription = stringResource(R.string.title_settings)
)
},
label = { Text(stringResource(R.string.title_settings)) }
)
}
}
) { innerPadding ->
Surface(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding),
color = MaterialTheme.colorScheme.background
) {
when (selectedTab) {
0 -> PlaceholderScreen(title = stringResource(R.string.title_weekly_focus))
1 -> WordListScreen()
2 -> PlaceholderScreen(title = stringResource(R.string.title_settings))
}
}
}
}
@Composable
fun WordListScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val sharedPrefs = remember {
context.getSharedPreferences("WeekFocusPrefs", Context.MODE_PRIVATE)
}
// Wörter aus SharedPreferences laden und Zustand verwalten
var textInput by remember { mutableStateOf("") }
val wordList = remember {
mutableStateListOf<String>().apply {
val savedSet = sharedPrefs.getStringSet("words_key", emptySet()) ?: emptySet()
addAll(savedSet)
}
}
// Funktion zum Speichern in SharedPreferences
fun saveWords() {
sharedPrefs.edit().putStringSet("words_key", wordList.toSet()).apply()
}
Column(
modifier = modifier
.fillMaxSize()
.padding(16.dp)
fun PlaceholderScreen(title: String) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
// Eingabefeld für ein neues Wort
OutlinedTextField(
value = textInput,
onValueChange = { textInput = it },
label = { Text("Neues Wort eingeben...") },
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
Spacer(modifier = Modifier.height(8.dp))
// Button zum Hinzufügen
Button(
onClick = {
val trimmed = textInput.trim()
if (trimmed.isNotEmpty()) {
wordList.add(trimmed)
saveWords()
updateWidget(context)
textInput = ""
}
},
modifier = Modifier.fillMaxWidth()
) {
Text("Wort hinzufügen")
}
Spacer(modifier = Modifier.height(24.dp))
Text(
text = "Gespeicherte Wörter:",
style = MaterialTheme.typography.titleMedium
)
Spacer(modifier = Modifier.height(8.dp))
// Liste der Wörter
if (wordList.isEmpty()) {
Text(
text = "Noch keine Wörter vorhanden.",
style = MaterialTheme.typography.bodyMedium
)
} else {
LazyColumn {
items(wordList) { word ->
Text(
text = "• $word",
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(vertical = 4.dp)
text = title,
style = MaterialTheme.typography.headlineMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
}
}
// Hilfsfunktion zum Aktualisieren des Widgets
fun updateWidget(context: Context) {
val appWidgetManager = AppWidgetManager.getInstance(context)
val componentName = ComponentName(context, SimpleWidget::class.java)
@@ -4,6 +4,7 @@ import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.widget.RemoteViews
import androidx.compose.ui.res.stringResource
import java.util.Calendar
import java.util.Random
@@ -43,7 +44,7 @@ class SimpleWidget : AppWidgetProvider() {
val randomIndex = random.nextInt(wordList.size)
wordList[randomIndex]
} else {
"Keine Wörter"
context.getString(R.string.msg_no_words)
}
// 4. RemoteViews aktualisieren
@@ -0,0 +1,169 @@
package de.schanbro.weekfocus.screens
import android.content.Context
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.unit.dp
import de.schanbro.weekfocus.R
import de.schanbro.weekfocus.updateWidget
@Composable
fun WordListScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val focusManager = LocalFocusManager.current // FocusManager holen
val sharedPrefs = remember {
context.getSharedPreferences("WeekFocusPrefs", Context.MODE_PRIVATE)
}
var textInput by remember { mutableStateOf("") }
val wordList = remember {
mutableStateListOf<String>().apply {
val savedSet = sharedPrefs.getStringSet("words_key", emptySet()) ?: emptySet()
addAll(savedSet)
}
}
fun saveWords() {
sharedPrefs.edit().putStringSet("words_key", wordList.toSet()).apply()
}
fun addCurrentWord() {
val trimmed = textInput.trim()
if (trimmed.isNotEmpty()) {
wordList.add(0, trimmed)
saveWords()
updateWidget(context)
textInput = ""
focusManager.clearFocus() // Fokus aufheben & Tastatur schließen
}
}
Column(
modifier = modifier
.fillMaxSize()
// Auf Klicks im leeren Bereich reagieren -> Fokus aufheben
.pointerInput(Unit) {
detectTapGestures(onTap = {
focusManager.clearFocus()
})
}
.padding(horizontal = 16.dp)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
OutlinedTextField(
value = textInput,
onValueChange = { textInput = it },
label = { Text(stringResource(R.string.hint_new_word)) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
shape = MaterialTheme.shapes.medium,
// "Fertig" / "Hinzufügen" Taste auf der Tastatur konfigurieren
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = { addCurrentWord() }
)
)
Button(
onClick = { addCurrentWord() },
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
shape = MaterialTheme.shapes.medium
) {
Icon(Icons.Default.Add, contentDescription = null)
Spacer(Modifier.width(8.dp))
Text(stringResource(R.string.hint_add_word))
}
}
Spacer(modifier = Modifier.height(16.dp))
AnimatedVisibility(
visible = wordList.isEmpty(),
enter = fadeIn(),
exit = fadeOut()
) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(top = 32.dp),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(R.string.msg_no_words_yet),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
LazyColumn(
verticalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(bottom = 16.dp)
) {
itemsIndexed(wordList) { index, word ->
ElevatedCard(
modifier = Modifier.fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
colors = CardDefaults.elevatedCardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = word,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier.weight(1f)
)
IconButton(
onClick = {
wordList.removeAt(index)
saveWords()
updateWidget(context)
}
) {
Icon(
imageVector = Icons.Default.Delete,
contentDescription = "Entfernen",
tint = MaterialTheme.colorScheme.error
)
}
}
}
}
}
}
}
+2 -3
View File
@@ -11,10 +11,9 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WOCHENFOKUS"
android:text="@string/title_weekly_focus"
android:textSize="11sp"
android:letterSpacing="0.1"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textStyle="bold" />
@@ -24,7 +23,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="Hallo"
android:text="@string/msg_no_words"
android:textColor="?android:attr/textColorPrimary"
android:textSize="22sp"
android:textStyle="bold" />
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hint_new_word">Enter new Word</string>
<string name="hint_add_word">Add word</string>
<string name="msg_no_words_yet">No words yet.</string>
<string name="msg_no_words">No words</string>
<string name="title_weekly_focus">Weekly Focus</string>
<string name="title_settings">Settings</string>
<string name="title_words">Words</string>
<string name="title_home">Home</string>
</resources>
+10 -1
View File
@@ -1,3 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">WeekFocus</string>
<string name="app_name" translatable="false">WeekFocus</string>
<string name="hint_new_word">Neues Wort eingeben</string>
<string name="hint_add_word">Wort hinzufügen</string>
<string name="msg_no_words_yet">Noch keine Wörter vorhanden.</string>
<string name="msg_no_words">Keine Wörter</string>
<string name="title_weekly_focus">Wochenfokus</string>
<string name="title_settings">Einstellungen</string>
<string name="title_words">Wörter</string>
<string name="title_home">Start</string>
</resources>
+1 -1
View File
@@ -7,5 +7,5 @@
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:targetCellWidth="2"
android:targetCellHeight="2">
android:targetCellHeight="1">
</appwidget-provider>
+8 -7
View File
@@ -1,13 +1,13 @@
[versions]
agp = "9.4.1"
coreKtx = "1.10.1"
coreKtx = "1.19.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
lifecycleRuntimeKtx = "2.6.1"
activityCompose = "1.8.0"
kotlin = "2.2.10"
composeBom = "2026.02.01"
junitVersion = "1.3.0"
espressoCore = "3.7.0"
lifecycleRuntimeKtx = "2.11.0"
activityCompose = "1.13.0"
kotlin = "2.4.20"
composeBom = "2026.09.00"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -24,6 +24,7 @@ androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "u
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }