Compare commits

..
1 Commits
Author SHA1 Message Date
robin bd3946a638 fix workflow #8 2026-09-19 17:56:31 +02:00
15 changed files with 39 additions and 359 deletions

No files matched your search

+11 -119
View File
@@ -1,144 +1,36 @@
# .gitea/workflows/build-release.yml
name: Build & Release Android App
on:
push:
tags:
- 'v*'
- 'v*' # Startet bei Tags wie v1.0.0, v1.0.1 etc.
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Code auschecken
uses: actions/checkout@v4
- name: Java/JDK 17 einrichten
uses: actions/setup-java@v5
# HIER IST DIE LÖSUNG: Java 25 statt 17 bereitstellen
- name: Java/JDK 25 einrichten
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '25'
distribution: 'temurin'
cache: gradle
- name: Rechte für gradlew setzen
run: chmod +x gradlew
- name: Android SDK einrichten
run: |
set -euo pipefail
SDK_PATH="$HOME/android-sdk"
SDKMANAGER="$SDK_PATH/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
echo "Installiere Android cmdline-tools..."
mkdir -p "$SDK_PATH/cmdline-tools"
curl -sSL \
-o /tmp/tools.zip \
https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip -q /tmp/tools.zip -d "$SDK_PATH/cmdline-tools"
mv "$SDK_PATH/cmdline-tools/cmdline-tools" \
"$SDK_PATH/cmdline-tools/latest"
rm /tmp/tools.zip
fi
echo "Akzeptiere Android-SDK-Lizenzen..."
"$SDKMANAGER" \
--sdk_root="$SDK_PATH" \
--licenses < <(yes) > /dev/null
echo "Installiere benötigte Android-SDK-Pakete..."
"$SDKMANAGER" \
--sdk_root="$SDK_PATH" \
"platform-tools" \
"platforms;android-37.0" \
"build-tools;36.0.0"
echo "ANDROID_HOME=$SDK_PATH" >> "$GITHUB_ENV"
echo "ANDROID_SDK_ROOT=$SDK_PATH" >> "$GITHUB_ENV"
echo "sdk.dir=$SDK_PATH" > "$GITHUB_WORKSPACE/local.properties"
- name: Keystore dekodieren
run: |
set -euo pipefail
echo "${{ secrets.KEYSTORE_BASE64 }}" \
| base64 -d > "$RUNNER_TEMP/release.keystore"
echo "KEYSTORE_PATH=$RUNNER_TEMP/release.keystore" >> "$GITHUB_ENV"
- name: Gradle einrichten
uses: gradle/actions/setup-gradle@v3
- name: Android Release APK bauen
# Keine fehleranfälligen Flags mehr nötig!
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
APK_DIR="app/build/outputs/apk/release"
APK_NAME="WeekFocus-${VERSION}.apk"
./gradlew assembleRelease \
--no-daemon \
-PversionNameOverride="$VERSION"
mv "$APK_DIR/app-release.apk" "$APK_DIR/$APK_NAME"
echo "APK erstellt: $APK_DIR/$APK_NAME"
ls -lh "$APK_DIR"
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Release-Notes extrahieren
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
awk -v v="$VERSION" '
index($0, "## [" v "]") == 1 {
found=1
next
}
found && /^## \[/ {
exit
}
found {
print
}
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "Keine Release-Notes für Version $VERSION vorhanden." \
> release-notes.md
fi
chmod +x gradlew
./gradlew assembleRelease
- name: Release in Gitea erstellen
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: release-notes.md
files: app/build/outputs/apk/release/WeekFocus-*.apk
files: app/build/outputs/apk/release/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: APK-Version prüfen
run: |
VERSION="${GITHUB_REF_NAME#v}"
"$ANDROID_HOME/build-tools/36.0.0/aapt" dump badging \
"app/build/outputs/apk/release/WeekFocus-${VERSION}.apk" \
| grep -E "versionCode|versionName"
+1 -2
View File
@@ -1,14 +1,13 @@
*.iml
.gradle
.idea
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/misc.xml
.DS_Store
/build
/captures
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" project-jdk-name="jbr-25" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
-9
View File
@@ -1,9 +0,0 @@
# Changelog
## [1.0.1] - 2026-09-29
### Neu
- Erste stabile Version mit automatischen APK-Builds
- CHANGELOG.md als Release-Body
### Behoben
- VersionCode und -Name
+8 -15
View File
@@ -3,17 +3,6 @@ plugins {
alias(libs.plugins.kotlin.compose)
}
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("-")
val parts = core.split(".").map { it.toIntOrNull() ?: 0 }
val major = parts.getOrElse(0) { 0 }
val minor = parts.getOrElse(1) { 0 }
val patch = parts.getOrElse(2) { 0 }
android {
namespace = "de.schanbro.weekfocus"
compileSdk {
@@ -24,8 +13,8 @@ android {
applicationId = "de.schanbro.weekfocus"
minSdk = 29
targetSdk = 37
versionCode = major * 10000 + minor * 100 + patch
versionName = tagVersion
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@@ -38,14 +27,18 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
buildFeatures {
compose = true
}
}
kotlin {
jvmToolchain(25)
}
dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.activity.compose)
-10
View File
@@ -23,16 +23,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".SimpleWidget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
</application>
</manifest>
@@ -1,20 +1,16 @@
package de.schanbro.weekfocus
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.material3.*
import androidx.compose.runtime.*
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.tooling.preview.Preview
import de.schanbro.weekfocus.ui.theme.WeekFocusTheme
class MainActivity : ComponentActivity() {
@@ -24,7 +20,8 @@ class MainActivity : ComponentActivity() {
setContent {
WeekFocusTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
WordListScreen(
Greeting(
name = "Android",
modifier = Modifier.padding(innerPadding)
)
}
@@ -34,94 +31,17 @@ class MainActivity : ComponentActivity() {
}
@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(
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
.fillMaxSize()
.padding(16.dp)
) {
// 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)
)
}
}
}
}
)
}
// Hilfsfunktion zum Aktualisieren des Widgets
fun updateWidget(context: Context) {
val appWidgetManager = AppWidgetManager.getInstance(context)
val componentName = ComponentName(context, SimpleWidget::class.java)
val appWidgetIds = appWidgetManager.getAppWidgetIds(componentName)
for (appWidgetId in appWidgetIds) {
SimpleWidget.updateAppWidget(context, appWidgetManager, appWidgetId)
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
WeekFocusTheme {
Greeting("Android")
}
}
@@ -1,56 +0,0 @@
package de.schanbro.weekfocus
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.widget.RemoteViews
import java.util.Calendar
import java.util.Random
class SimpleWidget : AppWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray
) {
for (appWidgetId in appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId)
}
}
companion object {
fun updateAppWidget(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetId: Int
) {
// 1. SharedPreferences auslesen
val sharedPrefs = context.getSharedPreferences("WeekFocusPrefs", Context.MODE_PRIVATE)
val savedSet = sharedPrefs.getStringSet("words_key", emptySet()) ?: emptySet()
val wordList = savedSet.toList()
// 2. Aktuelle Kalenderwoche & Jahr bestimmen
val calendar = Calendar.getInstance()
val weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR)
val year = calendar.get(Calendar.YEAR)
// 3. Wort für die aktuelle Kalenderwoche auswählen
val displayText = if (wordList.isNotEmpty()) {
// Kombinierter Seed aus Jahr und Kalenderwoche
val seed = (year * 100 + weekOfYear).toLong()
val random = Random(seed)
val randomIndex = random.nextInt(wordList.size)
wordList[randomIndex]
} else {
"Keine Wörter"
}
// 4. RemoteViews aktualisieren
val views = RemoteViews(context.packageName, R.layout.widget_main)
views.setTextViewText(R.id.appwidget_text, displayText)
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="28dp" />
<solid android:color="?android:attr/colorBackgroundFloating" />
</shape>
-32
View File
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@android:style/Theme.DeviceDefault.DayNight"
android:background="@drawable/widget_background"
android:orientation="vertical"
android:padding="16dp"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WOCHENFOKUS"
android:textSize="11sp"
android:letterSpacing="0.1"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textStyle="bold" />
<TextView
android:id="@+id/appwidget_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="Hallo"
android:textColor="?android:attr/textColorPrimary"
android:textSize="22sp"
android:textStyle="bold" />
</LinearLayout>
File renamed without changes.
File renamed without changes.
File renamed without changes.
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="130dp"
android:minHeight="80dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/widget_main"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:targetCellWidth="2"
android:targetCellHeight="2">
</appwidget-provider>
+1 -1
View File
@@ -1,5 +1,5 @@
[versions]
agp = "9.4.1"
agp = "9.4.0"
coreKtx = "1.10.1"
junit = "4.13.2"
junitVersion = "1.1.5"