diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..252985d --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,36 @@ +name: Build & Release Android App + +on: + push: + tags: + - '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 + + # HIER IST DIE LÖSUNG: Java 25 statt 17 bereitstellen + - name: Java/JDK 25 einrichten + uses: actions/setup-java@v4 + with: + java-version: '25' + distribution: 'temurin' + + - name: Gradle einrichten + uses: gradle/actions/setup-gradle@v3 + + - name: Android Release APK bauen + # Keine fehleranfälligen Flags mehr nötig! + run: | + chmod +x gradlew + ./gradlew assembleRelease + + - name: Release in Gitea erstellen + uses: softprops/action-gh-release@v2 + with: + files: app/build/outputs/apk/release/*.apk + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 096fbdd..e3a9ded 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -27,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) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1d27472..4f2cf1a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..d028ab6 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/de/schanbro/weekfocus/MainActivity.kt b/app/src/main/java/de/schanbro/weekfocus/MainActivity.kt index 49a97ed..da71da9 100644 --- a/app/src/main/java/de/schanbro/weekfocus/MainActivity.kt +++ b/app/src/main/java/de/schanbro/weekfocus/MainActivity.kt @@ -1,16 +1,20 @@ 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.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.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.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp +import android.appwidget.AppWidgetManager +import android.content.ComponentName import de.schanbro.weekfocus.ui.theme.WeekFocusTheme class MainActivity : ComponentActivity() { @@ -20,8 +24,7 @@ class MainActivity : ComponentActivity() { setContent { WeekFocusTheme { Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> - Greeting( - name = "Android", + WordListScreen( modifier = Modifier.padding(innerPadding) ) } @@ -31,17 +34,94 @@ class MainActivity : ComponentActivity() { } @Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", +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().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) + ) { + // 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) + ) + } + } + } + } } -@Preview(showBackground = true) -@Composable -fun GreetingPreview() { - WeekFocusTheme { - Greeting("Android") +// 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) } } \ No newline at end of file diff --git a/app/src/main/java/de/schanbro/weekfocus/SimpleWidget.kt b/app/src/main/java/de/schanbro/weekfocus/SimpleWidget.kt new file mode 100644 index 0000000..891f8e7 --- /dev/null +++ b/app/src/main/java/de/schanbro/weekfocus/SimpleWidget.kt @@ -0,0 +1,56 @@ +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) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/background.xml b/app/src/main/res/drawable/background.xml new file mode 100644 index 0000000..6a96839 --- /dev/null +++ b/app/src/main/res/drawable/background.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/foreground.xml b/app/src/main/res/drawable/foreground.xml new file mode 100644 index 0000000..cb7c424 --- /dev/null +++ b/app/src/main/res/drawable/foreground.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 07d5da9..36707c2 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -4,167 +4,70 @@ android:height="108dp" android:viewportWidth="108" android:viewportHeight="108"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml index 2b068d1..da1dcd9 100644 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -4,13 +4,14 @@ android:height="108dp" android:viewportWidth="108" android:viewportHeight="108"> - + + android:strokeColor="#00000000"/> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_monochrome.xml b/app/src/main/res/drawable/ic_launcher_monochrome.xml new file mode 100644 index 0000000..c05f209 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_monochrome.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/widget_background.xml b/app/src/main/res/drawable/widget_background.xml new file mode 100644 index 0000000..276ee4d --- /dev/null +++ b/app/src/main/res/drawable/widget_background.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_main.xml b/app/src/main/res/layout/widget_main.xml new file mode 100644 index 0000000..fdef214 --- /dev/null +++ b/app/src/main/res/layout/widget_main.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6fe8a06 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6fe8a06 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/app/src/main/res/mipmap-anydpi/ic_launcher.xml deleted file mode 100644 index 6f3b755..0000000 --- a/app/src/main/res/mipmap-anydpi/ic_launcher.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml deleted file mode 100644 index 6f3b755..0000000 --- a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp index c209e78..4429b08 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp index b2dfe3d..2809977 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp index 4f0f1d6..e00ada7 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp index 62b611d..b91bc25 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp index 948a307..838fe33 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp index 1b9a695..648ddbb 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp index 28d4b77..b66b8cf 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp index 9287f50..21ca1c9 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp index aa7d642..c62ef8f 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp index 9126ae3..1759a13 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values-v31/colors.xml similarity index 100% rename from app/src/main/res/values/colors.xml rename to app/src/main/res/values-v31/colors.xml diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values-v31/strings.xml similarity index 100% rename from app/src/main/res/values/strings.xml rename to app/src/main/res/values-v31/strings.xml diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values-v31/themes.xml similarity index 100% rename from app/src/main/res/values/themes.xml rename to app/src/main/res/values-v31/themes.xml diff --git a/app/src/main/res/xml/widget_info.xml b/app/src/main/res/xml/widget_info.xml new file mode 100644 index 0000000..0cf94df --- /dev/null +++ b/app/src/main/res/xml/widget_info.xml @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index c7b1f77..d9ac6e6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,9 +11,6 @@ pluginManagement { gradlePluginPortal() } } -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" -} dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories {